import java.awt.*;
import java.lang.Math;

public class Escherbug extends BufferedApplet {
	int wid_, hei_;
	final long T0 = System.currentTimeMillis();
	Cube cube_ = new Cube();
	Sphere sphere_ = new Sphere(14,15);
	Gear gear_ = new Gear(12,.1,.3,.5);
	Matrix3D view_ = new Matrix3D();
	Color backg_ = Color.white;
	
	public void init() {
		super.init();
		wid_ = getBounds().width;
		hei_ = getBounds().height;
		animating=true;
		view_.identity();
		cube_.setScale(.57,.61,.59);
		cube_.setRotationZ(0.08);
		sphere_.setRotationZ(0.1);
		gear_.setRotationY(0.2);
	}
	public void render(Graphics g) {
		double t = (System.currentTimeMillis()-T0) / 1000.0;
		Graphics2D g2 = (Graphics2D)g;
		g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
	    g.setColor(backg_);
     	g.fillRect(0,0,wid_,hei_);
		
		/*
		cube_.setRotationX(t/10.);
		cube_.setRotationY(t/20.);
		cube_.render(view_,wid_,hei_);
		cube_.draw(g);
		
		sphere_.setRotationY(t/9);
		sphere_.render(view_,wid_,hei_);
		sphere_.draw(g);
		*/
		
		gear_.setRotationZ(t/8.);
		gear_.render(view_,wid_,hei_);
		gear_.draw(g);
	}
}
