//Mod21_14_0 int x=30; // start of stem void setup() { size(200, 200); smooth(); noLoop(); } void draw() { vine(33, 9, 16); } void vine(int x, int numLeaves, int leafSize ) { stroke(255); line(x, 0, x, height); noStroke(); int gap = height / numLeaves; // Calculate average leaf gap int leafSizeX = leafSize; int leafSizeY = leafSize; for (int i = 0; i < numLeaves; i++) { leaf(x, i * gap + random(gap), leafSizeX, leafSizeY); leafSizeX = -leafSizeX; // Flip leaf direction } } void leaf(float x, float y, float sizeX, float sizeY) { pushMatrix(); translate(x, y); // Move to position scale(sizeX, sizeY); // Scale to size beginShape(); // Draw the shape vertex(1.0, -0.7); bezierVertex(1.0, -0.7, 0.4, -1.0, 0.0, 0.0); bezierVertex(0.0, 0.0, 1.0, 0.4, 1.0, -0.7); endShape(); popMatrix(); } void keyPressed() { if (key == 's') { save("Mod21_14_0.jpg"); } }