/*6.914, Example 1.6 working with the mouse II: mousePressed, etc. We have a boolean, mousePressed, which can be accessed from any method, including draw(). We can use mousePressed as a predicate, since it will evaluate as either true or false at any point (depending on whether the mouse is pressed at that time.) mousePressed() can also be used as its own method. The code inside the method will be executed whenever mousePressed evaluates to true. There are a number of other methods we can use to get input on mouse behavior: mouseDragged() -- mouse is moving while pressed mouseMoved() -- mouse is moving while not pressed mouseReleased() -- mouse is released */ void setup(){ size(500, 500); background(255); strokeWeight(5); } void draw(){ // we don't really need this } void mousePressed(){ stroke(0, 0, 255); strokeWeight(20); point(mouseX, mouseY); strokeWeight(5); } void mouseReleased(){ stroke(0, 0, 100); strokeWeight(20); point(mouseX, mouseY); strokeWeight(5); } void mouseMoved(){ stroke(255, 0, 0); line(pmouseX, pmouseY, mouseX, mouseY); } void mouseDragged(){ stroke(100, 0, 0); line(pmouseX, pmouseY, mouseX, mouseY); }