void setup(){ size(500,500); smooth(); background(255); frameRate(60); } float phi=0; float psi=0; float theta=0; float alpha=0; int mode=-1; float t=0; void tooth(float a,float r, float b, float w){ beginShape(); vertex(a*cos(w*-0.5),a*sin(w*-0.5)); vertex(a*cos(w*-0.28),a*sin(w*-0.28)); vertex(r*cos(w*-0.24),r*sin(w*-0.24)); vertex(b*cos(w*-0.12),b*sin(w*-0.12)); vertex(b*cos(w*+0.12),b*sin(w*+0.12)); vertex(r*cos(w*+0.24),r*sin(w*+0.24)); vertex(a*cos(w*+0.28),a*sin(w*+0.28)); vertex(a*cos(w*+0.5),a*sin(w*+0.5)); endShape();} void gear(int t, int r, int p, int h){ float w=2*PI/t; float a=r-h; float b=r+h; pushMatrix(); rotate(p*w*0.5); for(int i=0;i128*6){noLoop();}} if(mode==1){t+=1;psi=-PI*t/192;if(t>192*6){noLoop();}} if(mode==2){t+=1; if(t<=128){phi=-PI*t/256;} if(1282048){noLoop();}} } void mousePressed(){ int x=mouseX; int y=mouseY; mode=-1;theta=0;phi=0;psi=0;t=0; if(20<=x && x<=45 && 455 <=y && y <= 480){mode=0;loop();} if(70<=x && x<=95 && 455 <=y && y <= 480){mode=1;loop();} if(405<=x && x<=430 && 455 <=y && y <= 480){mode=2;loop();} if(455<=x && x<=480 && 455 <=y && y <= 480){mode=3;loop();} println("mode="+mode);}