// example of rollover testing along with custom function void setup() { size(500, 500); smooth(); background(255); frameRate(30); } //our custom function for making rectangles - note we draw the rectangles from the center void drawrect(int x, int y, float scaled){ pushMatrix(); fill(0); translate(x, y); scale(scaled); rectMode(CENTER); rect(0, 0, 5, 5); popMatrix(); } void draw() { fill(255); rect(width/2, height/2, width, height); for(int i = 10; i < width; i += 20){ for(int j = 10; j < height; j += 20){ //if(dist(mouseX, mouseY, i, j) < 15){ //this is the test method for round objects if(mouseX > i-10 && mouseX < i+10 && mouseY > j-10 && mouseY < j+10) { //this is the method for rectangular objects draw from the center drawrect(i, j, 3); //scale *3 if hit test is true } else { drawrect(i, j, 1); //scale *1 if not } } } }