import java.awt.*;
import java.lang.Math;
public class week2 extends BufferedApplet {
	Segment rootSeg_;
	Vector3D rootPos_ = new Vector3D(0.5,.9,0),
		currPos_ = new Vector3D(200,500,0);
	int wid_, hei_;
	long T0;
	Color sky = new Color(100,120,255);
	public void init() {
		super.init();
		wid_ = bounds().width;
		hei_ = bounds().height;
		Vector3D[] points = { 
			new Vector3D(.35, 1, 0), 
			new Vector3D(.45, 0, 0), 
			new Vector3D(.55, 0, 0), 
			new Vector3D(.65, 1, 0) };
		Color brown = new Color(50,25,6);
		rootSeg_ = new Segment(rootPos_,points,100,brown);
		rootSeg_.leafOut(0,8);
		rootSeg_.place(currPos_,0,0,0);
		T0 = System.currentTimeMillis();
		animating = true;
	}
	public void render(Graphics g) {
		double t = (System.currentTimeMillis()-T0) / 1000.0,
			wind = Math.sin(t/6)/20;
	    g.setColor(sky);
     	g.fillRect(0,0,wid_,hei_);
		rootSeg_.place(currPos_,0,t,wind);
		rootSeg_.render(g);
	}
}