xxxxxxxxxx
32
function setup() {
createCanvas(600, 600);
}
function draw() {
background(51);
stroke(255);
translate(300, height);
branch(100, PI/4);
stroke(255, 0, 0);
translate(0, height-800);
branch(90, PI/2.2);
stroke(255, 255, 0);
translate(0, height-240);
branch(90, PI/1.5);
}
function branch(len, angle) {
line(0, 0, 0, -len);
translate(0, -len);
if (len > 4) {
push();
rotate(angle);
branch(len * 0.7, angle);
pop();
push();
rotate(-angle);
branch(len * 0.7, angle);
pop();
}
}