void setup() { size(500, 500); } void draw() { rect(0,0,50,50); ellipse(80,460,60,60); } void mousePressed() { if (over_circle()){ background(255); } if (over_box()){ background(0); } } boolean over_circle() { // if you know a few things in mathematics, you'll recognize // the equation (X-X0)² + (Y-Y0)² < R² that represents all the points inside the circle // which center is the point (X0,Y0) and radius is R. return ((mouseX - 80)*(mouseX - 80) +(mouseY - 460)*(mouseY - 460) < 900 ); } boolean over_box() { return ((mouseX >= 0) && (mouseX <= 50) && (mouseY >= 0) && (mouseY <= 50)); }