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