interactive art Homework WEEK 4

For this week we had to create something which included a for loop so first I decided to study the subject a little more and did a few practice assignments for myself before making a simple homework assignment. I wanted to create a field in which flowers would randomly appear and I used a for loop to actually make the image of the flowers and randomized the location.



My code:

float x;       
float y;


void setup() {

    frameRate(5);  //I didn't want my images/flowers to appear too fast

    background(255);
    size(500, 500); 
}

void draw() {

boolean flower=true;

  while (flower==true) {
    flower=false;
    x=random(width);
    y=random(height);           
  }

color c;
c = (color) random(#000000);
    smooth();
    noStroke();
    pushMatrix();
    translate(x, y);
    fill(c);
      for (int i = 0; i < 5; i++) {
    ellipse(0, -40, 50, 50);
    rotate(radians(72));
}
    popMatrix();

}

Comments