dnam-project-06

sketch

/*
Doo Won Nam
Section B
dnam@andrew.cmu.edu
Project - 06
*/

//variables for spiral
var spiralAngle = 45;
var spiralRadius = 1;
var spiralRate = 0;

function setup() {
    createCanvas(480, 480);
    background(200, 250, 200); //background doesn't reset every frame
}

function draw() {
    noStroke();

    // Fetch the current time
  var H = hour();
  var M = minute();
  var S = second();
  var x = cos(radians(spiralAngle)) * spiralRadius; //wider
  var y = sin(radians(spiralAngle)) * spiralRadius; //taller

  fill(0 + S * 4); //gets lighter per second passed
  ellipseMode(CENTER);
  ellipse(240 + x, 240 - y, 10, 10); //the X and Y shifts along the spiral
  spiralAngle = spiralAngle + 2; //angle shifts to form spiral
  spiralRadius = spiralRadius + 0.1; //spiral radius increases
  spiralRate = spiralRate + 1; 

     if (spiralRate > 2000) { //reset once spiral goes too far
         spiralRate = 0;
         spiralRadius = 1;
         background(150, 200, 150);
}
}

I wanted to show time with just the seconds by using the formation of a spiral and the change of gradience. The code is instructed to create lighter color ellipses until a minute passes and the second resets – the ellipses in the spiral are then reset to black. The spiral also restarts if it fills up too much of the canvas. The idea was based off of Korean anti-mosquito scent candles, which look like these:

I always thought how the candle disappears in a spiral as time goes was almost hypnotising, and I wanted to create a similar effect with this candle.

Leave a Reply