createCanvas(windowWidth, windowHeight);
prevPos = createVector(1,1);
color(153, 152, 100, 20),
color(115, 134, 107, 20),
let idx = int(random(palete.length));
let pos = createVector(mouseX,mouseY);
let angle = random(-PI,PI);
let leaf = new Leaf(mouseX,
function Leaf(x,y,l,w,a){
this.formHeights = [0, .01, .07, .12, .2, .25, .32, .35, .35, .3, .2, .1];
this.leftSideAng = this.a - HALF_PI;
this.rightSideAng = this.a + HALF_PI;
this.tipPos = createVector(this.l * cos(this.a - HALF_PI), -this.l * sin(this.a + HALF_PI));
let normVect = this.tipPos.copy().normalize();
let rightVect = normVect.copy().rotate(-HALF_PI);
let leftVect = normVect.copy().rotate(HALF_PI);
this.formHeights.forEach(h => {
this.leftVectors.push(p5.Vector.mult(leftVect, h*this.w) );
this.rightVectors.push(p5.Vector.mult(rightVect, h*this.w) );
this.stepVector = p5.Vector.div(this.tipPos,this.formHeights.length);
translate(this.x,this.y);
for (let n1 = 0; n1 < this.formHeights.length; n1++ ){
let v1 = p5.Vector.mult(this.stepVector,n1);
v1.add(this.leftVectors[n1]);
for (let n2 = 0; n2 < this.formHeights.length; n2++ ){
let v2 = p5.Vector.mult(this.stepVector,n2);
for (let n1 = 0; n1 < this.formHeights.length; n1++ ){
let v1 = p5.Vector.mult(this.stepVector,n1);
v1.add(this.rightVectors[n1]);
for (let n2 = 0; n2 < this.formHeights.length; n2++ ){
let v2 = p5.Vector.mult(this.stepVector,n2);