// mas964 ps5 import java.applet.*; import java.awt.*; import java.lang.Math; import java.lang.String; import StrokeAnimator; public class BreatheStroke extends StrokeAnimator { int frameNumber = 0; int radii[] = {8, 8, 8, 8, 9, 10, 11, 12, 12, 11, 10, 9}; // draw a bunch of circles at the mouse locations. Radii vary // over time (or frame number) - the whole effect is supposed to // look like the line is breathing. public void drawFrame(int ms) { Graphics g = imageBuffer.getGraphics(); this.clearImageBuffer(); g.setColor(this.getForeground()); if (numPoints <= 0) return; int i; int radius = radii[frameNumber % radii.length]; for (i = 0; i < numPoints; i++) centeredCircle(g, x[i], y[i], radius); frameNumber++; repaint(); } public void centeredCircle(Graphics g, int x, int y, int radius) { g.fillOval(x - radius, y - radius, radius * 2 + 1, radius * 2 + 1); } public void init() { this.setBackground(Color.white); this.setForeground(Color.black); super.init(); if (frameDelay == 0) { frameDelay = 250; } } }