xxxxxxxxxx
43
let angle = 0,
slider, magnification;
let c1, c2, c3;
function setup() {
createCanvas(windowWidth - 2, 400);
slider = createSlider(0, TWO_PI, PI / 4, 0.001);
magnification = createSlider(35, height * 0.33, 100, 0.01);
colorfill();
}
function colorfill() {
c1 = color(random(100, 255), random(255), random(255));
c2 = color(random(255), random(255), random(100, 255));
c3 = color(random(255), random(100, 255), random(100, 255));
}
function draw() {
background(0);
// colorfill();
angle = slider.value();
stroke(c1);
strokeWeight(2);
translate(width / 2, height);
branch(magnification.value());
}
function branch(len) {
line(0, 0, 0, -len);
translate(0, -len);
if (len > 3) {
push();
stroke(c2);
rotate(angle);
branch(len * 0.67);
pop();
push();
rotate(-angle);
stroke(c3);
branch(len * 0.67);
pop();
}
}