Skip to content

Instantly share code, notes, and snippets.

@jeesunikim
Last active January 24, 2019 02:41
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/874286fad0d03032eede55439861eb73 to your computer and use it in GitHub Desktop.
Save jeesunikim/874286fad0d03032eede55439861eb73 to your computer and use it in GitHub Desktop.
Generative Art - Sunflower
SunflowerSeedSystem SunflowerSeeds;
SunflowerPetals Petals;
float HeadMag;
void setup() {
colorMode(HSB, 360, 100, 100);
background(0);
fullScreen();
SunflowerSeeds = new SunflowerSeedSystem();
SunflowerSeeds.toCreateInnerHead();
}
void draw() {
translate(width / 2, height / 2);
// Drawing Seeds
pushMatrix();
SunflowerSeeds.toAddStyle();
SunflowerSeeds.toCreateOuterHead();
HeadMag = SunflowerSeeds.getHeadPositionMag();
popMatrix();
// Drawing Petals
Petals = new SunflowerPetals(HeadMag);
Petals.toAddStyle();
Petals.createPetals();
}
// For SAVING as an image
void keyPressed() {
if (key == 's') {
save("sunflower.png");
saveHiRes(5);
exit();
}
}
void saveHiRes(int scaleFactor) {
PGraphics hi_res = createGraphics(width*scaleFactor, height*scaleFactor, JAVA2D);
beginRecord(hi_res);
hi_res.scale(scaleFactor);
setup();
draw();
endRecord();
hi_res.save("hire_sunflower.png");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment