Bressenham’s Circle Algorithm

$\require{color}$

Decision-points for the plotting of neighbouring pixels

We use the radius error $RE(x_i,y_i) = x_i^2+y_i^2-r^2$​​.

The decision parameters are the sum of the two $RE$s.

We can simplify this even further:

Using the Bresenham Circle Algorithm, we have the following:

d = 3 - 2 * radius;

for (x = 0; x < y; x++) {
	write_pixel(cx + x, cy + y, color); // top right
	write_pixel(cx + x, cy - y, color); // bottom right
	write_pixel(cx - x, cy + y, color); // top left
	write_pixel(cx - x, cy - y, color); // bottom left
	
	write_pixel(cx + y, cy + x, color); // right
	write_pixel(cx + y, cy - x, color); // right
	write_pixel(cx - y, cy + x, color); // left
	write_pixel(cx - y, cy - x, color); // left
	if (d <= 0)
		d = d + 4*x + 6;
	else {
		d = d + 4*(x-y) + 10
		y--;
	}
}