[A89] Re: filling ellipses
[Prev][Next][Index][Thread]
[A89] Re: filling ellipses
Damn.. forgot to change my sending mail.
here is a new try of my mail.
has an example and the common CG name of the algorithm Andrew T talkes about.
At 22:04 2001-07-07, you wrote:
>Does anyone know a good fast way to fill an ellipse (using not only black
>and white, but xor)?
>There is a draw ellipse function, but nothing for filling it. A for loop
>decrementing the radius
>by one doesn't work; it leaves out a few pixels. You can't use a decimal
>radius, which might
>work. I was thinking along the lines of either calculating horizontal
>points on the circle then
>connecting them with a line or doing a pixel test thing, sweeping across,
>filling once it detects
>the edge of the circle. The problem is, I'm not sure if this could be
>efficient if you're drawing
>onto a background. Another idea was to create an array when you begin
>that symbolizes the
>rectangle around the ellipse, then use ones and zeros to create the filled
>circle, basically as a
>sprite in a different form, then copy it to the screen pixel by
>pixel. I'm not sure that any of
>these will be very fast, though.
Sounds like you are better off implementing the ellipse from scratch.
It isn't actually very hard, and you do not need any sinus or such.
Use a midpoint algoritm (similar thinking as in the bresenham line algorithm)
I found this code example of the algorithm, you could try that.
It is for a nonfilled ellipse, but is very simple to change into a filled
circle. just change the putpixel stuff to draw lines, preferebly horisontal
ones, since these are the fastest.
The reason it is so simple to change is that you only calculate one quarter
of the ellipse, and draw the rest based on the symmetry.
here's the code:
http://xarch.tu-graz.ac.at/home/rurban/news/comp.graphics.algorithms/ellipse_bresenham.html
(blessed be google...)
///Olle