Clock Design through code. Minimalism 時間設計 — 極簡風

drawing

float h, m, s; 

void setup() {
  size(650, 650);
  smooth();
}

void draw() {
  background(200);

  pushMatrix();
  translate(width/2, height/2);

  strokeWeight(1);
  stroke(100);
  noFill();
  ellipse(0, 0, 400, 400);

  s = 6*second()*(TWO_PI)/360 - PI/2;
  m = 6*minute()*(TWO_PI)/360 - PI/2;
  h = 30*hour()*(TWO_PI)/360 - PI/2;

  fill(255);
  for (int i = 0; i <= 60; i++) {
    strokeWeight(1);
    line(cos(i*6*(TWO_PI)/360)*203, sin(i*6*(TWO_PI)/360)*203, cos(i*6*(TWO_PI)/360)*190, sin(i*6*(TWO_PI)/360)*190);
    ellipse(cos(i*6*(TWO_PI)/360)*200, sin(i*6*(TWO_PI)/360)*200, 5, 5);

    if (i % 5 == 0) {
      strokeWeight(2);
      line(cos(i*6*(TWO_PI)/360)*203, sin(i*6*(TWO_PI)/360)*203, cos(i*6*(TWO_PI)/360)*180, sin(i*6*(TWO_PI)/360)*180);
      ellipse(cos(i/5*30*(TWO_PI)/360)*200, sin(i/5*30*(TWO_PI)/360)*200, 10, 10);
    }
  }

  noStroke();
  fill(255);
  ellipse(0, 0, 10, 10);

  //ellipse(cos(s)*200, sin(s)*200, 10, 10);
  //text(s + ", "+ second(), cos(s)*200, sin(s)*200);
  ellipse(cos(m)*200, sin(m)*200, 20, 20);
  //text(m + ", "+ minute(), cos(m)*200, sin(m)*200);
  ellipse(cos(h)*200, sin(h)*200, 20, 20);

  strokeWeight(5);
  stroke(100);
  line(cos(s)*180, sin(s)*180, cos(s)*10, sin(s)*10);
  strokeWeight(8);
  line(cos(m)*150, sin(m)*150, cos(m)*10, sin(m)*10);
  strokeWeight(10);
  line(cos(h)*100, sin(h)*100, cos(h)*10, sin(h)*10);

  popMatrix();
}