Last active
August 29, 2015 14:04
-
-
Save hamoid/fa415e2c0a0e7b2f69cb to your computer and use it in GitHub Desktop.
Response to code-comment on funprogramming.org (branches and leaves)
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
// http://funprogramming.org/76-Slowly-morphing-bezier-curves.html#comment-1520486548 | |
PGraphics pg; | |
void setup() { | |
size(500, 400); | |
pg = createGraphics(width, height); | |
} | |
void draw() { | |
background(255); | |
pg.clear(); | |
float t = frameCount / 40.0; | |
pg.beginDraw(); | |
for (int i = 0; i < 30; i++) { | |
float endPointX = noise(i, 3, t)*width + 100; | |
float endPointY = noise(i, 5, t) * (height - 250); | |
//BRANCHES | |
noFill(); | |
strokeWeight(2); | |
stroke(#714927); | |
bezier(width*0.2, height, 100, 50, noise(i, 2, t)*width + 100, noise(i, 4, t) * (height - 20), endPointX, endPointY); | |
//LEAVES | |
pg.strokeWeight(25); | |
pg.stroke(#5B831F); | |
pg.point(endPointX, endPointY); | |
} | |
pg.endDraw(); | |
image(pg, 0, 0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment