You can make a small modification of the circle circumference algorithm to get a filled circle.
First create the coordinates:
data = new int[radius]; int f = 1 - radius, ddF_x = 1; int ddF_y = -2 * radius; int x = 0, y = radius; while (x < y) { if (f >= 0) { y--; ddF_y += 2; f += ddF_y; } x++; ddF_x += 2; f += ddF_x; data[radius - y] = x; data[radius - x] = y; }
Then go to all the internal points:
int x0 = center.X; int y0 = center.Y - Radius; int y1 = center.Y + Radius - 1; for (int y = 0; y < data.Length; y++) { for (int x = -data[y]; x < data[y]; x++) { doSomething(x + x0, y + y0); doSomething(x + x0, y1 - y); } }
This saves some operating point, which will not be in the circle, but due to a little pre-processing. It definitely will not help for small circles, but for large ones, well, to be honest, I donβt know. You would have to compare it.
harold
source share