Clock

Screen Shot 2014-10-01 at 3.34.23 PM

I was trying to make a 12hour clock that would take a flower shape and for each hour the petal of the flower would be added to the middle part of the flower. For each minutes the orange dots would be randomly placed in the circle and for the seconds smaller brown dots would be placed in it.

I had hard time trying to make the circles be in a circular shape and trying to make the code work since it wouldn’t refresh itself every second and increase in the number of dots in the middle even though I wrote the function in the draw function.(I still couldn’t fix it) However, the shape came out as I wanted it to come out except that it isn’t working perfectly right now. I need to go back and see what the problem is.

 

void setup() {
size(400, 400);
}
void draw(){
  smooth();
  background(255);
  noStroke();
  float cx = width/2;
  float cy = height/2;
  float diameter = width*.6;
  float nbr_circles = 12;
  float lg_diam =  width * .55;                 // large circle's diameter
  float lg_rad  = lg_diam/2;                    // large circle's radius
  float lg_circ =  PI * lg_diam;                // large circumference
  float sm_diam = (lg_circ / nbr_circles);      // small circle's diameter
  float hourCount = hour();
  hourCount = hourCount%12;
  for (int i = 1; i < = nbr_circles; ++i) {
    if (hourCount > 0){
      fill(240,186,239);
      float angle = i * TWO_PI / nbr_circles;
      float x = cx + cos(angle) * lg_rad;
      float y = cy + sin(angle) * lg_rad;
      ellipse(x, y, sm_diam, sm_diam);
      println(hourCount);
      hourCount = hourCount - 1;
    }else{
      noFill();
      float angle = i * TWO_PI / nbr_circles;
      float x = cx + cos(angle) * lg_rad;
      float y = cy + sin(angle) * lg_rad;
      ellipse(x, y, sm_diam, sm_diam);
      hourCount = hourCount -1;
    }
  }

  fill(250,244,192);
  ellipse(cx, cy, lg_diam, lg_diam);

  float minuteCount = minute();
  for (int i = 1; i < = minuteCount; ++i){
    fill(245,144,77);
    ellipse(random(140,260),random(140,260),10,10);
  } noLoop();


  float secondCount = second();
  for (int i = 1; i <= secondCount; ++i){
    fill(108,81,68);
    ellipse(random(130,270),random(130,270),6,6);
  } noLoop();
}

IMG_20141001_145621 (1)

Comments are closed.