Update completed the fractal tree
This commit is contained in:
@ -3,6 +3,10 @@
|
|||||||
|
|
||||||
var angle = 0;
|
var angle = 0;
|
||||||
var seed;
|
var seed;
|
||||||
|
let r = 54;
|
||||||
|
let g = 34;
|
||||||
|
let b = 4;
|
||||||
|
//let a = 255;
|
||||||
|
|
||||||
function setup() {
|
function setup() {
|
||||||
createCanvas(400, 400);
|
createCanvas(400, 400);
|
||||||
@ -16,22 +20,36 @@ function draw() {
|
|||||||
angle = 45;
|
angle = 45;
|
||||||
stroke(255);
|
stroke(255);
|
||||||
translate(200, height);
|
translate(200, height);
|
||||||
branch(100, 3);
|
let wind = noise(frameCount/50) * 10;
|
||||||
|
branch(100, 5, 255, wind);
|
||||||
|
a = 255;
|
||||||
|
//noLoop();
|
||||||
}
|
}
|
||||||
/////////////////////////////////////////////////
|
/////////////////////////////////////////////////
|
||||||
function branch(len, thickness) {
|
function branch(len, thickness, a, w) {
|
||||||
stroke(0);
|
stroke(color(r, g, b, a));
|
||||||
|
if(a>50)
|
||||||
|
a = a-20;
|
||||||
|
|
||||||
strokeWeight(thickness);
|
strokeWeight(thickness);
|
||||||
line(0, 0, 0, -len);
|
line(0, 0, 0, -len);
|
||||||
translate(0, -len);
|
translate(0, -len);
|
||||||
if (len > 4) {
|
|
||||||
|
if (len > 4)
|
||||||
|
{
|
||||||
push();
|
push();
|
||||||
rotate(angle);
|
rotate(angle + random(-10, -35) + w);
|
||||||
branch(len * 0.67, thickness*0.8);
|
branch(len * (0.67 + random(0.0, 0.05)), thickness*0.8, a, w);
|
||||||
pop();
|
pop();
|
||||||
push();
|
push();
|
||||||
rotate(-angle);
|
rotate(-angle + random(10, 35) + w);
|
||||||
branch(len * 0.67, thickness*0.8);
|
branch(len * (0.67 + random(0.0, 0.05)), thickness*0.8, a, w);
|
||||||
pop();
|
pop();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fill(random(100, 255), 30, 20, 100);
|
||||||
|
let len = thickness * 25
|
||||||
|
ellipse(0, 0, len, len);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user