/** * eyes * * Move the mouse to change the direction of the eyes. * The atan2() function computes the angle from each eye * to the cursor. */ int ex1= 64, ey1=85, d1=40; int ex2 = 150, ey2 = 44, d2 =40; void setup() { size(200, 200); smooth(); noStroke(); } void draw() { background(102); lookat(ex1, ey1, d1, mouseX, mouseY); lookat(ex2, ey2, d2, mouseX, mouseY); } void lookat(int ex, int ey, int d, int mx, int my) { float angle = atan2(my-ey, mx-ex); pushMatrix(); translate(ex, ey); fill(255); ellipse(0, 0, d, d); rotate(angle); fill(153); ellipse(d/4, 0, d/2, d/2); popMatrix(); } void keyPressed() { if (key == 's') save("eyes.jpg"); }