xxxxxxxxxx
26
function setup() {
createCanvas(400, 400);
background(0);
stroke(139, 69, 19);
translate(width / 2, height);
branch(100);
}
function branch(len) {
strokeWeight(map(len, 10, 100, 1, 4));
line(0, 0, 0, -len);
translate(0, -len);
if (len > 15) {
let branches = floor(random(1, 6));
for (let i = 0; i < branches; i++) {
push();
let angle = random(-PI / 3, PI / 3);
rotate(angle);
branch(len * random(0.6, 0.8));
pop();
}
}
}