/* In this example, the user can draw an ellipse by selecting the center and then dragging the mouse to designate a corner of the bounding box */ int cx,cy; // This function is executed only once, at the very beginning void setup() { size(500,400); background(255); fill(128, 128, 255); } // This function is repeatedly call in an implicit loop. // A single call is responsible for drawing a single frame. void draw() { } void mousePressed() { cx = mouseX; cy = mouseY; } void mouseDragged() { background(255); noFill(); int w = 2*abs(mouseX-cx); int h = 2*abs(mouseY-cy); ellipse(cx,cy,w,h); } void mouseReleased() { background(255); fill(128,128,255); int w = 2*abs(mouseX-cx); int h = 2*abs(mouseY-cy); ellipse(cx,cy,w,h); }