float a = PI; float as = 0; void setup() { size(500, 500); noStroke(); fill(255); rectMode(CENTER); } float SPIN = .02; void draw() { if (a < - 2 * PI) a += 2 * PI; if (a > PI) a -= 2 * PI; float wantAng = 0; if (mousePressed) wantAng = -PI; if (abs(a-wantAng)> .05) { if (a < wantAng) as += SPIN ; else as -= SPIN ; } as *= .9; if (abs(as) < .01) as = 0.0; as = constrain(as, -10, 10); a += as; background(150, 150, 200); fill(255); pushMatrix(); //start bottom translate(mouseX, mouseY); ellipse(0, 0, 100, 100); pushMatrix(); //start middle rotate(a); translate(0, 50); pushMatrix();//start arms strokeWeight(2); stroke(100,100,0); rotate( a*2); line(0,0,80,0); line(60,0,70,-10); line(60,0,70,10); line(0,0,-80,0); line(-60,0,-70,-10); line(-60,0,-70,10); noStroke(); popMatrix(); //end arms ellipse(0, 0, 75, 75); fill(255); translate(0, 50); ellipse(0, 0, 50, 50); pushMatrix();//start hat rotate(a); fill(0); translate(0,-25); rect(0, 0, 60, 10); rect(0,-20,30,50); popMatrix(); //end hat popMatrix();//end head popMatrix();//end middle //popMatrix(); //end bottom }