diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..8702015 --- /dev/null +++ b/README.txt @@ -0,0 +1 @@ +Is this sufficient ? \ No newline at end of file diff --git a/sketch_190219a/sketch_190219a.pde b/sketch_190219a/sketch_190219a.pde new file mode 100644 index 0000000..8d65c30 --- /dev/null +++ b/sketch_190219a/sketch_190219a.pde @@ -0,0 +1,42 @@ +void settings() { + size(400, 800, P2D); +} + +void setup() { + background(133, 97, 160); + noLoop(); +} + +void draw() { + plant(15, 0.4, 0.8); +} + +void leaf() { + beginShape(); + vertex(100.0, -70.0); + bezierVertex(90.0, -60.0, 40.0, -100.0, 0.0, 0.0); + bezierVertex(0.0, 0.0, 100.0, 40.0, 100.0, -70.0); + endShape(); +} + +void plant(int numLeaves, float minLeafScale, float maxLeafScale) { + line(width / 2, 0, width / 2, height); // the plant's stem + int gap = height/numLeaves; // vertical spacing between leaves + float angle = 0; + for (int i = 0; i < numLeaves; i++) { + int x = width / 2; + int y = gap * i + (int)random(gap); + float scale = random(minLeafScale, maxLeafScale); + pushMatrix(); + // Complete the code! + translate(x,y); + scale(scale); + rotate(angle); + leaf(); + rotate(-angle); + scale(1/scale); + translate(-x,-y); + popMatrix(); + angle += PI; // alternate the side for each leaf + } +}