float delta; void setup() { size(729, 729); fill(0); background(255); noStroke(); rect(width/3, height/3, width/3, width/3); rectangles(width/3, height/3, width/3); } void rectangles(int x, int y, int s) { if (s < 1) return; int xc = x-s; int yc = y-s; for (int row = 0; row < 3; row++) { for (int col = 0; col < 3; col++) { if (!(row == 1 && col == 1)) { int xx = xc+row*s; int yy = yc+col*s; delta = s/3; rect(xx+delta, yy+delta, delta, delta); rectangles(xx+s/3, yy+s/3, s/3); } } } }