Last active
March 4, 2019 01:51
-
-
Save jeesunikim/c8b5ddb3cee02ce54603fab171403ba5 to your computer and use it in GitHub Desktop.
Generative Art - Sunflower - Petal
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 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