How to make a circle on a grid?

Check out Midpoint circle algorithm.


Here is my Java implementation of Bresenham's Midpoint Circle algorithm:

private void drawCircle(final int centerX, final int centerY, final int radius) {
    int d = 3 - (2 * radius);
    int x = 0;
    int y = radius;
    Color circleColor = Color.white;

    do {
        image.setPixel(centerX + x, centerY + y, circleColor);
        image.setPixel(centerX + x, centerY - y, circleColor);
        image.setPixel(centerX - x, centerY + y, circleColor);
        image.setPixel(centerX - x, centerY - y, circleColor);
        image.setPixel(centerX + y, centerY + x, circleColor);
        image.setPixel(centerX + y, centerY - x, circleColor);
        image.setPixel(centerX - y, centerY + x, circleColor);
        image.setPixel(centerX - y, centerY - x, circleColor);
        if (d < 0) {
            d = d + (4 * x) + 6;
        } else {
            d = d + 4 * (x - y) + 10;
            y--;
        }
        x++;
    } while (x <= y);
}

The full class implementation and many other language examples can be found on the Rosetta Code site.