xxxxxxxxxx
function setup() {
createCanvas(windowWidth, windowHeight);
background(255);
}
function draw() {
var plant = new Plant(random()*width, random()*height);
plant.show();
}
function Plant(x,y) {
this.x = x;
this.y = y;
this.leafs = [];
for(var n = 0; n < 100; n++) {
this.leafs.push(new Leaf(0,0,height/2*noise(n),noise(n)*TWO_PI*4));
};
this.show = function(){
push();
translate(this.x,this.y);
this.leafs.map(l => l.show());
pop();
}
}
function Leaf(x,y,l,a){
this.x=x;
this.y=y;
this.l=l;
this.a=a;
this.o = random()*127
this.show = function(){
strokeWeight(1);
stroke(0,this.o);
fill(23,212,43,3);
push();
translate(this.x,this.y);
rotate(this.a);
beginShape();
vertex(0,0);
bezierVertex(0,-this.l/2,this.l/2,-this.l/2,0,-this.l);
vertex(0,-this.l);
bezierVertex(0,-this.l/2,-this.l/2,-this.l/2,0,0);
endShape();
pop();
}
}