Circle draw algorithmΒΆ

The problem is to determine which pixels need to be colored to rasterize a circle, given its radius and centre.

The main idea is that when a curve passes between two pixels, the pixel that is closer is chosen. This is decided by the relative position of the curve with respect to the midpoint between the two pixels.

By virtue of symmetry, we can iterate through only an eigth of the circle to efficiently rasterize the circle in its entirety.

Circle symmetry Circle draw algorithm

The bresenham::figure::add_circle() method implements the same.