// Helene Martin, Garfield High School
// 10/11/2010
// Introduction to DrawingPanel, Graphics, Color

import java.awt.*;  // to use Graphics, Color

public class GraphicsPractice {
	public static void main(String[] args) {
		DrawingPanel p = new DrawingPanel(300, 200);
		p.setBackground(Color.YELLOW);
		Graphics g = p.getGraphics();
				
		//drawFace(g);
		//stairs1(g);
		//stairs2(g);
		drawCar(g, 10, 30, 100);
		drawCar(g, 150, 10, 50);
		
		drawCars(g, 10, 130, 40, 5); 
	}
	
	// Draws a face with a rectangular mouth
	// Notice that drawn shapes "stack" (the last drawn is what shows up)
	public static void drawFace(Graphics g) {
		g.setColor(Color.YELLOW);
		g.fillOval(50, 50, 100, 100);
		
		g.setColor(Color.BLACK);
		g.fillOval(75, 80, 5, 20);
		g.fillOval(125, 80, 5, 20);
		
		g.setColor(Color.RED);
		g.drawRect(80, 120, 40, 10);	
	}
	
	// Both the width of the stairs and their starting position change
	// as we go down
	public static void stairs1(Graphics g) {
		for (int i = 0; i < 10; i++) {
    		g.drawRect(20 + 10 * i, 20 + 10 * i, 100 - 10 * i, 10);
		}
	}
	
	// The width of the stairs increases, the starting position decreases 
	public static void stairs2(Graphics g) {
		for (int i = 0; i < 10; i++) {
    		g.drawRect(110 - (10 * i), 20 + 10 * i, 10 + 10 * i, 10);
		}
	}
	
	// parameterized car method
	public static void drawCar(Graphics g, int x, int y, int size) {
        g.setColor(Color.BLACK);
        g.fillRect(x, y, size, size / 2);
        
        g.setColor(Color.RED);
        g.fillOval(x + size / 10, y + size * 2 / 5, size / 5, size / 5);
        g.fillOval(x + size * 7 / 10, y + size * 2 / 5, size / 5, size / 5);
        
        g.setColor(Color.CYAN);
        g.fillRect(x + size * 7 / 10, y + size / 10, size * 3 / 10, size / 5);
    }
	 
	 public static void drawCars(Graphics g, int x, int y, int size, int count) {
	 	for(int i = 0; i < count; i++) {
			drawCar(g, x + i * 50, y, size);
		}
	 }
}
