For my abstract clock I chose to use a database of song lyrics that mention specific times of day. The clock breaks up the day into 886 equal units of time, the number of song lyrics in the data set, and displays each lyric one after another. The background color also changes with the time of day being referenced in the song. As a result the time measured by this clock is not the actual time of day, but rather the time of day represented within our popular musical cannon mapped to a real 24 hour day. Hours that are referenced more often last longer on this clock and those only mentioned a few times pass by quickly.
//Tim Nelson-Pyne
//tnelsonp@andrew.cmu.edu
//Section C
//Project-06-Abstract Clock
function preload() {
//loads a .txt file that contains a large sampling of song lyrics
//that refer to specific times of day
timeLyrics = loadStrings('https://courses.ideate.cmu.edu/15-104/f2021/wp-content/uploads/2021/10/timeLyrics.txt')
}
function setup() {
createCanvas(400, 400);
background(0);
}
function draw() {
//gets the total amount of seconds that have ellapsed that day
var s = second();
var m = minute();
var h = hour();
m = m * 60
h = h * 3600
var totalS = m + h + s;
var i = map(totalS, 0, 86400, 0, 886);
i = round(i);
//changes background color based on the time that the song lyrics are refering to
if (i < 421 || i > 780) {
//its nightime
fill(0);
}
if (i >= 421 & i < 481) {
//its 5am
fill(10, 0, 50);
}
if (i >= 481 & i < 538) {
//its 6am
fill(141, 163, 152);
}
if (i >= 538 & i < 562) {
//its 7 am
fill(217, 133, 69);
}
if (i >= 562 & i < 595) {
//its 8 am
fill(249, 192, 107);
}
if (i >= 595 & i < 628) {
//its 9 am
fill(255, 230, 190);
}
if (i >= 628 & i < 631){
//its 10 am
fill(255, 255, 200);
}
if (i >= 631 & i < 722) {
//its day
fill(255);
}
if (i >= 722 & i < 747) {
//its 5pm
fill(255, 230, 190);
}
if (i >= 747 & i < 761) {
//its 6pm
fill(238, 108, 32);
}
if (i >= 761 & i <= 780) {
//its 7pm
fill(100, 15, 36);
}
textSize(15);
noStroke();
//redraws the background
rect(0, 0, width, height);
//changes the type color based on what the background color is
if (i < 421 || i > 780) {
fill(255);
}
else {
fill(100);
}
//displays a song lyric
//each lyric gets the same amount of time on screen
//the lyrics repeat each day
textAlign(CENTER);
text(timeLyrics[i], 0, 10, width, height);
}