import java.util.*;
import java.awt.*;
import java.awt.geom.*;
public class Sample06 {
    public static void tree(ToyGraphics tg, int x, int y, int w, int h) {
	int[] xp = { x+w/2, x+w/4, x+w/3, x,       x+w,      x+w*2/3, x+w*3/4 };
	int[] yp = { y,     y+h/3, y+h/3, y+h*2/3, y+h*2/3, y+h/3, y+h/3  };
	tg.g2d.setColor(new Color(50,255,50));
	tg.g2d.fill(new Polygon(xp,yp,xp.length));

	int[] xp2 = { x+w/3,   x+w/3, x+w*2/3, x+w*2/3 };
	int[] yp2 = { y+h*2/3, y+h,   y+h,     y+h*2/3 };
	tg.g2d.setColor(new Color(200,128,50));
	tg.g2d.fill(new Polygon(xp2,yp2,xp2.length));
    }
    public static void snowman(ToyGraphics tg, int x, int y, int w, int h) {
	tg.g2d.setColor(new Color(232,232,232));
	tg.g2d.fill(new Arc2D.Double(x+w/4, y, w/2, h/2, 0, 360, Arc2D.CHORD));
	tg.g2d.fill(new Arc2D.Double(x, y+h*2/5, w, h*3/5, 0, 360, Arc2D.CHORD));

	tg.g2d.setColor(new Color(128,128,128));
	tg.g2d.fill(new Arc2D.Double(x+w*(1.0/2 - 2.0/10), y+h/8, w/10, h/8, 0, 360, Arc2D.CHORD));
	tg.g2d.fill(new Arc2D.Double(x+w*(1.0/2 + 1.0/10), y+h/8, w/10, h/8, 0, 360, Arc2D.CHORD));
    }

    public static void main(String[] args) {
	ToyGraphics tg = new ToyGraphics();

	for (int i=0; i<10; i++) {
	    for (int j=0; j<3; j++) {
		tree(tg,i*100, 50+j*200, 100+j*50, 200+j*50);
	    }
	}

	Random r = new Random(System.currentTimeMillis());
	for (int i=0; i<5; i++) {
	    int x = r.nextInt(1280/2);
	    int y = r.nextInt(720/2);
	    int w = 100 + r.nextInt(100);
	    int h = 200 + r.nextInt(200);
	    snowman(tg,x,y,w,h);
	}

	tg.repaint();
    }
}
