/* built with Studio Sketchpad:
* https://sketchpad.cc
*
* observe the evolution of this sketch:
* https://studio.sketchpad.cc/sp/pad/view/ro.q3UPR1Kuk7V/rev.11
*
* authors:
* Fergus Ray Murray
* license (unless otherwise specified):
* creative commons attribution-share alike 3.0 license.
* https://creativecommons.org/licenses/by-sa/3.0/
*/
// This sketch builds on a prior work, "Chronosynclastic Curlicue Clock", created by Fergus Ray Murray
// http://studio.sketchpad.cc/sp/pad/view/ro.9PXzsGOaaeT-z/rev.41
// This sketch builds on a prior work, "Curlicue Clock 0.3", created by Fergus Ray Murray
// http://studio.sketchpad.cc/sp/pad/view/ro.9v7e1McEGqXQs/rev.207
// This sketch builds on a prior work, "Curlicue Clock", created by Fergus Ray Murray
// http://studio.sketchpad.cc/sp/pad/view/ro.9UGEP6aVRfP9j/rev.29
/* Here's a fun mating of the Curlicue fractal with a clock. The seed for the fractal is taken from the exact time of day. You can watch the build-up and wind-down that surrounds major landmarks of the day - mid-day, four thirty and so on
- and at the exact moment they pass, the form dramatically simplifies. This is because those times are relatively simple fractions of the way through the day. */
float x, y, f, stepSize=28; // Each seed value gives a different fractal.
double df=0, ddf=0, dddf=0.000000005; // dddf controls how much the fractal changes with each frame.
int i=0;
int startTime=3600*hour()+60*minute()+second(); // How many seconds since midnight?
void setup() { // 'setup' is called just once, when the program is run.
size (600, 600); // Tell Processing how big a window it should use.
colorMode (HSB, 360);
background (0);
}
void draw() { // 'draw' is called every time the program draws a frame.
// We need to reset most of the variables every frame.
strokeWeight(2);
fill(0, 6);
stroke(255);
rect(0, 0, width, height);
// Hours
ddf=TWO_PI*(startTime+millis()/1000.0)/86400.0;
curlicue (ddf*1440, 9, 32.0, 0, 30); // seconds (1 rev/minute)
curlicue (ddf*24, 60, 16.0, 80, 75); // minutes (1 rev/hour)
curlicue (ddf, 360, 8.0, 150, 90); // hours (1 rev/24 hours)
}
void curlicue(double ddf, int curlLength, float stepSize, float baseHue, float hueRange) {
f=0;
df=0;
x=width/2;
y=height/2;
strokeWeight (stepSize/2);
for (i=0; i<curlLength; i+=1) {
stroke (baseHue+((float)i/curlLength)*hueRange, 360, 360, 60);
f+=df;
df+=ddf;
x+=stepSize*sin(f);
y-=stepSize*cos(f);
point(x, y);
point(width-x, height-y);
}
}
void keyPressed() {
if (key=='s') save("Chrono-"+hour()+"-"+minute()+"-"+second()+"-"+millis()+".png");
}