Skip to content

Instantly share code, notes, and snippets.

@wonderburg7
Last active March 14, 2019 22:01
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 wonderburg7/df531a30881a9e67f1bd7b99f6bace9c to your computer and use it in GitHub Desktop.
Save wonderburg7/df531a30881a9e67f1bd7b99f6bace9c to your computer and use it in GitHub Desktop.
float angle = 6;
int steps = 150;
float flowerSize = steps*3;
float stepSize = 3;
float reductionValue = 0;
void setup()
{
size( 450, 400 );
rectMode(CENTER);
ellipseMode(CENTER);
noLoop();
}
void draw()
{
background(0);
smooth();
fill(random(255), random(255), random(255));
stroke(0);
float rotationDistance = random(1.1, 1.9);
translate( width/2, height/2 );
for ( int i = 0; i < steps; i++ ) {
rotate( radians( angle*rotationDistance) );
/*
if(i <= steps/2){
rect( 0, 0, 0 + (stepSize * i), 0 + (stepSize * i) );
} else {
rect( 0, 0, flowerSize - (stepSize * i), flowerSize - (stepSize * i) );
}
*/
if (i <= steps/2) {
beginShape();
for (int deg = 0; deg < 360; deg += 120)
{
angle = deg * PI / 180;
float nextx = cos(angle*20) * (i*2);
float nexty = sin(angle*20) * (i*2);
vertex(nextx, nexty);
}
endShape(CLOSE);
} else {
beginShape();
for (int deg = 0; deg < 360; deg += 120)
{
angle = deg * PI / 180;
// I NEED TO SORT SOMETHING OUT HERE VVVV
float nextx = cos(angle*20) * ((steps/2) - reductionValue)*2;
float nexty = sin(angle*20) * ((steps/2) - reductionValue)*2;
vertex(nextx, nexty);
}
endShape(CLOSE);
reductionValue++;
}
// ellipse(0, 0, flowerSize - (stepSize * i), flowerSize - (stepSize * i) );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment