// Zoog_3_1_translate Parson 1/30/2018 // First demo of pushMatrix(), translate(), popMatrix() // Example 3-1: Zoog as dynamic sketch // setup() runs first one time. // size() should always be first line of setup void setup() { // Set the size of the window size(480, 270); background(255); } // draw() loops continuously until you close the sketch window. void draw() { // Remember the 0,0 point in the upper left of display: pushMatrix(); // Move the 0,0 point to the middle of Zoog's head: //translate(375, 145); translate(mouseX, mouseY); // Zoog follows mouse // Draw a white background background(255); // Set CENTER mode ellipseMode(CENTER); rectMode(CENTER); // Body stroke(0); fill(150); rect(0, 30, 20, 100); // Head fill(255); ellipse(0, 0, 60, 60); // Eyes fill(0); ellipse(-19, 0, 16, 32); ellipse(19, 0, 16, 32); // Legs stroke(0); line(-10, 80, -20, 90); line(10, 80, 20, 90); // Restore the 0,0 point in the upper left of display // that was in effect at the matching pushMatrix() above: popMatrix(); }