/* hover_rect.pde Edited by Justin Hsia, Sam Wolfson (orig. Susan Evans) Change rectangle fill when mouse is hovering over it. */ int x = 100; // x-position of upper-left corner int y = 160; // y-position of upper-left corner int w = 200; // width of rectangle int h = 160; // height of rectangle void setup() { size(500,500); // set drawing canvas size noStroke(); // no shape outlines } void draw() { background(204); // clear the canvas fill(255); // white by default if ( (mouseX >= x) && (mouseX <= x+w) && (mouseY >= y) && (mouseY <= y+h) ) { fill(0); // black if mouse is hovering over } rect(x, y, w, h); // draw the rectangle }