import java.awt.*; import java.applet.*; /** * Pattern1.java * * * Created: Wed Nov 10 15:43:01 1999 * * @author S. J. Ambler * @version */ public class Pattern1 extends Applet { public void paint(Graphics g) { // Colour the background white. g.setColor(Color.white); g.fillRect(0,0,600,300); // Generate a new spirograph pattern. Spiro p = new Spiro(150,100); // Initial settings p.setHole(25); p.setTooth(37); p.setCoord(150,150); // Do the following 150 times for (int x=0; x<150; x++) { // Alternate the color of the pen between green and blue if (x%2 == 0) p.setPen(Color.green); else p.setPen(Color.blue); // Draw the pattern p.drawOn(g); // Now shift to the right and rotate the starting position // by one tooth. p.shift(2,0); p.rotate(1); } } } // Pattern1