final int NUMSQ = 10; Square[][] squares = new Square[10][10]; void setup() { size(500, 500); for (int x = 0; x < NUMSQ; x++) { for (int y = 0; y < NUMSQ; y++) { squares[x][y] = new Square(x,y); } } rectMode(CENTER); noStroke(); } void draw() { background(255,128,0); for (int x = 0; x < NUMSQ; x++) { for (int y = 0; y < NUMSQ; y++) { Square s = squares[x][y]; s.draw(); } } } class Square { float x, y; Square(int xp, int yp) { x = (xp + .5) * ( 500 / NUMSQ); y = (yp + .5)* ( 500 / NUMSQ); } void draw() { fill(128,64,0); float d = dist(x,y,mouseX,mouseY)/9; rect(x, y, d,d); } }