import java.awt.*; public class CircleStack extends BufferedApplet { int endx = 250, endy = 250; // Where stack is aimed (initially center, for concentric circles) public void render(Graphics g) { // WHENEVER THERE IS "DAMAGE", WE NEED TO REDRAW if (damage) { // SET COLOR TO WHITE AND CLEAR THE APPLET WINDOW g.setColor(Color.white); g.fillRect(0, 0, bounds().width, bounds().height); // Set up info for circles int numcircles = 150; double x = 100; // xy coordinates for top of double y = 100; // the first circle double d = 300; // diameter of first circle double centerx = x + (d / 2); // Center of first circle double centery = y + (d / 2); // These are how much x, y, and d change for each new circle double xoffset = (centerx - endx) / numcircles; double yoffset = (centery - endy) / numcircles; double doffset = d / numcircles; // draw first circle g.setColor(new Color(200, 255, 200)); g.fillOval((int) x, (int) y, (int) d, (int) d); g.setColor(Color.black); g.drawOval((int) x, (int) y, (int) d, (int) d); for (int i = 1; i < numcircles; i++) { // prepare next circle d -= doffset; centerx -= xoffset; centery -= yoffset; x = centerx - (d / 2); y = centery - (d / 2); // draw circle g.setColor(new Color(200, 255, 200)); g.fillOval((int) x, (int) y, (int) d, (int) d); g.setColor(Color.black); g.drawOval((int) x, (int) y, (int) d, (int) d); } } } public boolean mouseDrag(Event e, int x, int y) { this.endx = x; this.endy = y; damage = true; return true; } public boolean mouseDown(Event e, int x, int y) { this.endx = x; this.endy = y; damage = true; return true; } public boolean mouseUp(Event e, int x, int y) { this.endx = x; this.endy = y; damage = true; return true; } }