Skip to content

Instantly share code, notes, and snippets.

@hamoid
Last active August 29, 2015 14:04
Show Gist options
  • Save hamoid/fa415e2c0a0e7b2f69cb to your computer and use it in GitHub Desktop.
Save hamoid/fa415e2c0a0e7b2f69cb to your computer and use it in GitHub Desktop.
Response to code-comment on funprogramming.org (branches and leaves)
// 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