Created
September 30, 2014 15:52
-
-
Save dashalom/8bd524a1dba4925223c2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Leaf { | |
float currentX; | |
float currentY; | |
float startingY; | |
float currentA; | |
Leaf (float tempCurrentX, float tempCurrentY, float tempCurrentA) { | |
currentX = tempCurrentX; | |
currentY = tempCurrentY; | |
startingY = tempCurrentY; | |
currentA = tempCurrentA; | |
} | |
void display_leaf_pair() { | |
leafpair.disableStyle(); // Ignore the colors in the SVG | |
//shape(leafpair, 300, 150); | |
noStroke(); | |
for (int n = 0; n < 100; n++) { | |
float r1 = random(75-80); | |
float r2 = random(80-100); | |
fill(r1, 220, r2, currentA); | |
} | |
shape(leafpair, currentX-60, currentY, 300, 150); | |
//shape(leafpair, 300, 150); | |
} | |
} | |
ArrayList<Leaf> plants; | |
PShape soil2; | |
PShape leafpair; | |
void mouseClicked() { | |
for (int i=0; i<3; i++) { | |
plants.add(new Leaf(mouseX, (2*displayHeight)/3+i*90, -90*i)); | |
} | |
} | |
void setup() { | |
size(displayWidth, displayHeight); | |
soil2 = loadShape("soil2.svg"); | |
leafpair = loadShape("leafpair.svg"); | |
plants = new ArrayList<Leaf>(); | |
} | |
void draw() { | |
background(240, 255, 200); | |
for (int i = plants.size()-1; i >= 0; i--) { | |
Leaf leaves = plants.get(i); | |
leaves.display_leaf_pair(); | |
if (leaves.startingY - leaves.currentY < 150) { | |
leaves.currentY -= 3; | |
} | |
leaves.currentA += 3; | |
} | |
fill(100); | |
noStroke(); | |
shape(soil2, 0, 100, displayWidth, 200); | |
//shape(soil2, 0, (2*displayHeight)/3, displayWidth, displayHeight/3); | |
//rect(0, (2*displayHeight)/3, displayWidth, displayHeight/3); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment