import java.awt.*; import java.applet.*; import Circle; import Square; import DrawingAssistant; /** * A simple test of my various drawing mechanisms. Draws a lot of * random squares. Note that as we resize the window, the picture * gets redrawn and takes up the appropriate amount of space. * * @author Samuel A. Rebelsky * @version 1.0 of February 1999 */ public class Pixelation extends Applet { /** * Paint a picture. */ public void paint(Graphics g) { // Determine how many copies of each pixel to draw in each cycle. int pixelsPerCycle = 300; // Determine how many drawing cycles to use. We use cycles so // that we can get colors on top of colors (e.g., red on top of // blue on top of red). int cycles = 5; // Determine the size of the pixel. int pixelSize = 10; // Create something to help us draw. DrawingAssistant fred = new DrawingAssistant(); // Paint again and again for (int i = 0; i < cycles; ++i) { // Note that there's a lot more blue than anything else. fred.drawRandom(new Square(pixelSize,Color.blue), pixelsPerCycle, g); fred.drawRandom(new Square(pixelSize,Color.white), pixelsPerCycle, g); fred.drawRandom(new Square(pixelSize,Color.black), pixelsPerCycle, g); fred.drawRandom(new Square(pixelSize,Color.red), pixelsPerCycle, g); fred.drawRandom(new Square(pixelSize,Color.blue), pixelsPerCycle, g); fred.drawRandom(new Square(pixelSize,Color.green), pixelsPerCycle, g); fred.drawRandom(new Square(pixelSize,Color.yellow), pixelsPerCycle, g); fred.drawRandom(new Square(pixelSize,Color.blue), pixelsPerCycle, g); } } // paint(Graphics) } // class SimpleDrawing