/* In this example, the canvas is painted with multiple lines going from the center of the canvas to the (moving) mouse position. Painting only occurs during a mouse drag. (i.e. with button down) A mouse click has the effect of reset the fixed point for the line. */ // GLOBAL variables float x, y; // fixed point for the line // This function is executed only once, at the very beginning void setup() { size(500, 400); background(255); x = 0.5*width; y = 0.5*height; } // We must include draw function, even though its body is empty void draw() { } // A mouse "click" only occurs when mousePress/mouseRelease coincide // (that is, without any dragging) void mouseClicked() { x = mouseX; y = mouseY; } void mouseDragged() { line(x, y, mouseX, mouseY); } void keyTyped() { background(255); }