1
我想使用p5.js制作平滑动画的分形树。我完全不知道如何让分支一个一个地生成,而不是同时生成所有分支。使用p5.js平滑动画的分形树
这里是我的代码:
function draw() {
background(51);
strokeWeight(5);
stroke(255, 0, 0);
translate(600, height);
drawLine(300);
}
function drawLine(length) {
miliseconds = millis()/10;
if(miliseconds < length) {
line(0, 0, 0, -miliseconds);
}
else {
line(0, 0, 0, -length);
}
translate(0, -length);
if(length > 50) {
push();
rotate(PI/4);
drawLine(length * 0.67);
pop();
push();
rotate(-(PI/4));
drawLine(length * 0.67);
pop();
}
}
感谢您的建议!