xxxxxxxxxx
40
var len = 100;
var theta;
var strokeW = 7;
function setup() {
createCanvas(windowWidth, windowHeight);
}
function draw() {
background(220);
theta = map(mouseX,0,width,0,PI/2);
len = height / 3;
translate(width/2, height);
stroke(0);
branch(len, strokeW);
}
function branch(len, strokeW) {
strokeWeight(strokeW);
line(0, 0, 0, -len);
translate(0, -len);
len *= 0.66;
strokeW--;
if(strokeW < 1)
strokeW = 1;
if (len > 2) {
push();
rotate(theta);
branch(len, strokeW);
pop();
push();
rotate(-theta);
branch(len, strokeW);
pop();
}
}