calgorithmgraphicsgeometry

fast algorithm for drawing filled circles?


I am using Bresenham's circle algorithm for fast circle drawing. However, I also want to (at the request of the user) draw a filled circle.

Is there a fast and efficient way of doing this? Something along the same lines of Bresenham?

The language I am using is C.


Solution

  • Having read the Wikipedia page on Bresenham's (also 'Midpoint') circle algorithm, it would appear that the easiest thing to do would be to modify its actions, such that instead of

    setPixel(x0 + x, y0 + y);
    setPixel(x0 - x, y0 + y);
    

    and similar, each time you instead do

    lineFrom(x0 - x, y0 + y, x0 + x, y0 + y);
    

    That is, for each pair of points (with the same y) that Bresenham would you have you plot, you instead connect with a line.