// *************************************************************** // // C - Clocks // // Design hundred clocks that indicate the passage of time using // only abstract graphic images instead of figures. // // Clock_04_01_02.pde // Subject: Circles // // 2011, December 25, 3:45 PM // Loftmatic, Henk Lamers // http://www.loftmatic.com // // *************************************************************** int clock_X, clock_Y; float secondsRadius; void setup () { size (200, 200); background (0); stroke (255); smooth (); int radius = min (width, height) / 2; secondsRadius = radius * 0.5; strokeCap (SQUARE); clock_X = width / 2; clock_Y = height / 2; } void draw () { noStroke (); fill (0, 4); rect (0, 0, width, height); fill (255); // The milli-seconds. float ml = map (millis (), 0, 60, 0, TWO_PI) - HALF_PI; stroke (255, 32); strokeWeight (2); line (width / 2, height / 2, cos (ml) * 80 + 100, sin (ml) * 80 + 100); noStroke (); // The seconds. float sc = map (second (), 0, 60, 0, TWO_PI) - HALF_PI; stroke (255); strokeWeight (1); line (width / 2, height / 2, cos (sc) * 80 + 100, sin (sc) * 80 + 100); // The minutes. float mn = map (minute (), 0, 60, 0, TWO_PI) - HALF_PI; line (width / 2, height / 2, cos (mn) * 70 + 100, sin (mn) * 70 + 100); // The hours. float hr = map (hour () + norm(minute(), 0, 60), 0, 24, 0, TWO_PI * 2) - HALF_PI; line (width / 2, height / 2, cos (hr) * 60 + 100, sin (hr) * 50 + 100); noStroke (); fill (0); ellipse (width / 2, height / 2, 100, 100); // Draw the second ticks. stroke (63, 127); strokeWeight(3); strokeCap (ROUND); beginShape(POINTS); for (int a = 0; a < 360; a+=6) { float x = clock_X + cos(radians(a)) * secondsRadius; float y = clock_Y + sin(radians(a)) * secondsRadius; //stroke (a); vertex(x, y); } endShape(); }