Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,35 @@
|
|||
import java.awt.Color;
|
||||
|
||||
public class MidPointCircle {
|
||||
private BasicBitmapStorage image;
|
||||
|
||||
public MidPointCircle(final int imageWidth, final int imageHeight) {
|
||||
this.image = new BasicBitmapStorage(imageWidth, imageHeight);
|
||||
}
|
||||
|
||||
private void drawCircle(final int centerX, final int centerY, final int radius) {
|
||||
int d = (5 - radius * 4)/4;
|
||||
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 += 2 * x + 1;
|
||||
} else {
|
||||
d += 2 * (x - y) + 1;
|
||||
y--;
|
||||
}
|
||||
x++;
|
||||
} while (x <= y);
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue