
void setup() {
size(400, 400);
background(000000);
smooth();
noLoop();
}
void draw() {
vine(33,17, 24);
vine(133,17, 24);
}
void vine(int x, int numLeaves, int leafSize) {
stroke(255);
line(x, 0, x, height);
noStroke();
int gap = height / numLeaves;
int direction = 1;
for (int i = 0; i < numLeaves; i++) {
int r = int(random(gap));
leaf(x, gap*i+r, leafSize, direction);
direction = -direction;
}
}
void leaf(int x, int y, int size, int dir) {
pushMatrix();
translate(x,y);
scale(size);
beginShape();
vertex(1.0*dir, -0.7);
bezierVertex(1.0*dir, -0.7, 0.4*dir, -1.0, 0.0, 0.0);
bezierVertex(0.0, 0.0, 1.0*dir, 0.4, 1.0*dir, -0.7);
endShape();
popMatrix();
}
0 comments:
Post a Comment