void setup(){
noLoop();
size(600, 600);
noStroke();
rectMode(CENTER);
fill(0);
}
void draw(){
background(255);
carpet(width/2, height/2, width/3, 5);
}
void carpet(float x, float y, float s, int d){
rect(x, y, s, s);
if(d > 0 && s > 3){
carpet(x, y-s, s/3, d-1);
carpet(x+s, y-s, s/3, d-1);
carpet(x+s, y, s/3, d-1);
carpet(x+s, y+s, s/3, d-1);
carpet(x, y+s, s/3, d-1);
carpet(x-s, y+s, s/3, d-1);
carpet(x-s, y, s/3, d-1);
carpet(x-s, y-s, s/3, d-1);
}
}