wonderburg7
3/11/2019 - 12:56 PM

flowers.pde

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) );
  }
}