xxxxxxxxxx
function setup(){
w = min(windowWidth, windowHeight);
createCanvas(w, w);
strokeWeight(4);
pad = w/10;
spcX = 25;
spcY = 25;
//rectMode(CENTER)
noFill()
strokeWeight(2)
}
function draw(){
background(0)
stroke(255)
createCell(pad,pad,w-pad*2,w-pad*2,7)
noLoop()
}
function createCell(posX, posY, wid, hei, depth){
if(depth>0){
if(random()>0.5){
createCell(posX, posY, wid, hei/2, depth-1)
createCell(posX, posY+hei/2, wid, hei/2, depth-1)
}else{
createCell(posX, posY, wid/2, hei, depth-1)
createCell(posX+wid/2, posY, wid/2, hei, depth-1)
}
}else{
rect(posX, posY, wid, hei)
}
}