Simple Implementation
public void circleSimple(int xCenter, int yCenter, int radius, Color c)
{
int pix = c.getRGB();
int x, y, r2;
r2 = radius * radius;
for (x = -radius; x <= radius; x++) {
y = (int) (Math.sqrt(r2 - x*x) + 0.5);
raster.setPixel(pix, xCenter + x, yCenter + y);
raster.setPixel(pix, xCenter + x, yCenter - y);
}
}
And the result would look like:
As you can see the circles look fine in areas where only one pixel is
required for each column, but in areas of the circle where the local slope
is greater the one the circle appears discontinuous (where have we seen
this before?).
|