int hot = 20; // 20x20 square as hotspot void setup() { size(400, 300); } void draw() { } // we consider a position "hot" if it is close enough to the bottom-left corner boolean isHot(int x, int y) { return (x <= hot && y >= height-hot); } void mouseMoved() { if (isHot(mouseX, mouseY) && !isHot(pmouseX, pmouseY)) { // moved into hotspot from a non-hotspot background(random(255), random(255), random(255)); } }