Skip to content

Instantly share code, notes, and snippets.

@jeesunikim
Last active March 4, 2019 01:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeesunikim/c8b5ddb3cee02ce54603fab171403ba5 to your computer and use it in GitHub Desktop.
Save jeesunikim/c8b5ddb3cee02ce54603fab171403ba5 to your computer and use it in GitHub Desktop.
Generative Art - Sunflower - Petal
class SunflowerPetals {
float r;
float x;
float y;
SunflowerPetals(float headLength) {
r = headLength / 2;
}
void createPetals() {
for (float a = 0; a < TWO_PI; a += PI/13) {
x = r * cos(a);
y = r * sin(a);
drawPetal(x, y, 2.5 - PI/13 / TWO_PI, a);
drawPetal(x, y, 2.5 - PI/13 / TWO_PI, a + PI/3.75);
}
}
void drawPetal(float x, float y, float lfSize, float dir) {
pushMatrix();
// Perform transformations in TRS order
translate(x, y); // Define origin for the drawing
rotate(dir); // rotate by 'dir' radians
scale(lfSize); // scale the image
beginShape();
vertex(0, 0);
// CURVED SUNFLOWER PETALS
bezierVertex(50, -60 * noise(frameCount + 1), 100, -30 * noise(frameCount + 1), +150, -50);
bezierVertex(100, 30 * noise(frameCount + 2), 50, 30, 0, 0);
endShape();
popMatrix();
}
void toAddStyle() {
float SatRange = random(0, 5);
float BrightRange = random(60, 90);
strokeWeight(0.07);
stroke(0, SatRange, BrightRange);
noFill();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment