“Relative Time Clock” by tesh
https://openprocessing.org/sketch/506801
License CreativeCommons Attribution ShareAlike
https://creativecommons.org/licenses/by-sa/3.0
{{filePath}}
{{width}} x {{height}}
Report Sketch
Oh, that naughty sketch! Please let us know what the issue is below.
Apply Template
Applying this template will reset your sketch and remove all your changes. Are you sure you would like to continue?
Report Sketch
Report Comment
Please confirm that you would like to report the comment below.
We will review your submission and take any actions necessary per our Community Guidelines. In addition to reporting this comment, you can also block the user to prevent any future interactions.
Please report comments only when necessary. Unnecessary or abusive use of this tool may result in your own account being suspended.
Are you sure you want to delete your sketch?
Any files uploaded will be deleted as well.
Delete Comment?
This will also delete all the replies to this comment.
Delete this tab? Any code in it will be deleted as well.
Select a collection to submit your sketch
We Need Your Support
Since 2008, OpenProcessing has provided tools for creative coders to learn, create, and share over a million open source projects in a friendly environment.
Niche websites like ours need your continued support for future development and maintenance, while keeping it an ad-free platform that respects your data and privacy!
Please consider subscribing below to show your support with a "Plus" badge on your profile and get access to many other features!
CC Attribution ShareAlike
Relative Time Clock
xxxxxxxxxx
var modMinSmall = 5;
var modMinReg = 0;
var modMinBig = 0;
var modHr = 0;
var modHrReg = 0;
var minSmallTxtRange = "";
var minBigTxtRange = "";
var minRegTxtRange = "";
var hrTxtRange = "";
var hrRegTxtRange = "";
var min1 = [];
var min5 = [];
var min10 = [];
var min30 = [];
var hr1 = [];
var hr2 = [];
var hr3 = [];
var hr4 = [];
var hr5 = [];
var hr6 = [];
var hr8 = [];
var hr12 = [];
var hr14 = [];
var hr16 = [];
var hr18 = [];
var hr24 = "You have the whole day left!";
var prevSec;
var millisRolloverTime;
var HPrev = -1;
var MPrev = -1;
//--------------------------
function setup() {
createCanvas(700, 700);
millisRolloverTime = 0;
initializeTimePhrase();
textFont('Arial Black', [25]);
textAlign(CENTER);
modMinSmall = 0;
modMinReg = 0;
modMinBig = 0;
modHr = 0;
modHrReg = 0;
}
//--------------------------
function draw() {
background(255, 255, 255); //
textAlign(CENTER);
// Fetch the current time
var H = hour();
var M = minute();
var hColor = map(hour(), 0, 23, 0, 255);
var mColor = map(minute(), 0, 60, 0, 255);
var sColor = map(second(), 0, 60, 0, 255);
background(hColor, mColor, sColor, 50); //
//which minute text is displayed?
//text("Min: " + M, width / 2, height / 2);
if (H >= 2) {
textFont('Arial Black', [28]);
text("Things you can do with the rest of your day:", width / 2, height/12);
textFont('Arial Black', [25]);
//Larger Min Range
if (60 - M > 30) {
modMinBig = 30;
if(MPrev != M &&M%modMinBig == 0){
minBigTxtRange = min30[int(random(min30.length))];
}
} else if (60 - M > 10) {
modMinBig = 10;
if(MPrev != M &&M%modMinBig == 0){
minBigTxtRange = min10[int(random(min10.length))];
}
} else if (60 - M > 5) {
modMinBig = 5;
if(MPrev != M && M%modMinBig == 0){
minBigTxtRange = min5[int(random(min5.length))];
}
}
//Smaller Min Range
if (60 - M - modMinBig > 10) {
modMinReg = 10;
if(MPrev != M && M%modMinReg == 0){
minRegTxtRange = min10[int(random(min10.length))];
}
} else if (60 - M - modMinBig > 5) {
modMinReg = 5;
if(MPrev != M && M%modMinReg == 0){
minRegTxtRange = min5[int(random(min5.length))];
}
} else if (60 - M - modMinBig > 1) {
modMinReg = 1;
if(MPrev != M && M%modMinReg == 0){
minRegTxtRange = min1[int(random(min1.length))];
}
}
if (HPrev != H) {
//Larger Hr Range
if (24 - H > 18) {
modHr = 18;
hrTxtRange = hr18[int(random(hr18.length))];
} else if (24 - H > 16) {
modHr = 16;
hrTxtRange = hr16[int(random(hr16.length))];
} else if (24 - H > 14) {
modHr = 14;
hrTxtRange = hr14[int(random(hr14.length))];
} else if (24 - H > 12) {
modHr = 12;
hrTxtRange = hr12[int(random(hr12.length))];
} else if (24 - H > 8) {
modHr = 8;
hrTxtRange = hr8[int(random(hr8.length))];
} else if (24 - H > 6) {
modHr = 6;
hrTxtRange = hr6[int(random(hr6.length))];
} else if (24 - H > 5) {
modHr = 5;
hrTxtRange = hr5[int(random(hr5.length))];
} else if (24 - H > 4) {
modHr = 4;
hrTxtRange = hr4[int(random(hr4.length))];
} else if (24 - H > 3) {
modHr = 3;
hrTxtRange = hr3[int(random(hr3.length))];
}
//Smaller Hr Range
if (24 - H - modHr > 2) {
modHrReg = 2;
hrRegTxtRange = hr2[int(random(hr2.length))];
} else if (24 - H - modHr > 1) {
modHrReg = 1;
hrRegTxtRange = hr1[int(random(hr1.length))];
}
}
if ((60 - M) % modMinBig >= 0) {
//text(min1[int(random(2))],140,22);
text(minBigTxtRange, width / 2, height/5*4);
}
if ((60 - M) % modMinReg >= 0) {
//text(min1[int(random(2))],140,42);
text(minRegTxtRange, width / 2, height/5*3);
}
if ((H) % modHr >= 0) {
//text(min1[int(random(2))],140,42);
text(hrTxtRange, width / 2, height/5*2);
}
if ((H) % modHrReg >= 0) {
//text(min1[int(random(2))],140,42);
text(hrRegTxtRange, width / 2, height/5);
}
} else if (H >= 0) {
// Midnight Case
if (H == 0 && M == 0) {
text(hr24, width / 2, height/2);
} else {
textFont('Arial Black', [28]);
text("Things you can do with the rest of your day:", width / 2, height/12);
textFont('Arial Black', [25]);
if (MPrev != M) {
//Larger Min Range
if (60 - M > 30) {
modMinBig = 30;
minBigTxtRange = min30[int(random(min30.length))];
} else if (60 - M > 10) {
modMinBig = 10;
minBigTxtRange = min10[int(random(min10.length))];
} else if (60 - M > 5) {
modMinBig = 5;
minBigTxtRange = min5[int(random(min5.length))];
}
//Smaller Min Range
if (60 - M - modMinBig > 10) {
modMinReg = 10;
minRegTxtRange = min10[int(random(min10.length))];
} else if (60 - M - modMinBig > 5) {
modMinReg = 5;
minRegTxtRange = min5[int(random(min5.length))];
} else if (60 - M - modMinBig > 1) {
modMinReg = 1;
minRegTxtRange = min1[int(random(min1.length))];
}
//Smallest Min Range
if (60 - M - modMinBig - modMinReg > 5) {
modMinSmall = 5;
minSmallTxtRange = min5[int(random(min5.length))];
} else if (60 - M - modMinBig - modMinReg > 1) {
modMinSmall = 1;
minSmallTxtRange = min1[int(random(min1.length))];
}
}
if (HPrev != H) {
//Smaller Hr Range
if (3 - H - modHr > 2) {
modHrReg = 2;
hrRegTxtRange = hr2[int(random(hr2.length))];
} else if (3 - H - modHr > 1) {
modHrReg = 1;
hrRegTxtRange = hr1[int(random(hr1.length))];
}
}
if ((60 - M) % modMinBig >= 0) {
text(minBigTxtRange, width / 2, height/5*4);
}
if ((60 - M) % modMinReg >= 0) {
text(minRegTxtRange, width / 2, height/5*3);
}
if ((60 - M) % modMinSmall >= 0) {
text(minSmallTxtRange, width / 2, height/5*2);
}
if ((H) % modHrReg >= 0) {
text(hrRegTxtRange, width / 2, height/5);
}
}
}
textAlign(LEFT);
fill(128, 100, 100);
/*text("Hour: " + H, 10, 22);
text("Minute: " + (60 - M), 10, 42);
text("Second: " + S, 10, 62);*/
MPrev = M;
HPrev = H;
}
function initializeTimePhrase() {
//minute 1
min1[0] = "Floss your teeth";
min1[1] = "Back up your computer";
min1[2] = "Replace your toilet paper";
min1[3] = "Water your plants";
min1[4] = "Take your vitamins";
min1[5] = "Refill your soap dispenser";
min1[6] = "Send an email";
min1[7] = "Shake out a mat";
min1[8] = "Give someone a hug";
min1[9] = "Make your bed";
min1[10] = "Empty your recycling bin";
min1[11] = "Blink 20 times";
min1[12] = "Start a To-Do list";
min1[13] = "Get a glass of water";
min1[14] = "Hold your breath until you can’t anymore";
min1[15] = "Unfriend someone on facebook";
min1[16] = "Have an epiphany";
min1[17] = "Microwave hot chocolate";
min1[18] = "Wipe down your phone screen";
min1[20] = "Crack all your joints";
//minute 5
min5[0] = "Take a walk around the block";
min5[1] = "Return a quick phone call";
min5[2] = "Delete those apps you don’t use";
min5[3] = "Listen to a sick beat";
min5[4] = "Make one of those Tasty recipes";
min5[5] = "Chug a smoothie";
min5[6] = "Take an online quiz";
min5[7] = "Clean your computer desktop";
min5[8] = "Think about working out but don’t";
min5[9] = "Tell a really bad joke";
min5[10] = "Think of a good name for an \ninanimate object";
min5[11] = "Move clothes into the dryer";
//minute 10
min10[0] = "Learn to whistle";
min10[1] = "Learn 5 phrases in a new language";
min10[2] = "Make fancy oatmeal";
min10[3] = "Make a sub sandwich";
min10[4] = "Eat someone else's sandwich";
min10[5] = "Read a short article";
//minute 30
min30[0] = "Bake a cake from scratch";
min30[1] = "Take a selfie you actually like"
min30[2] = "Update your LinkedIn profile \n#Networking";
min30[3] = "Work out at home";
min30[4] = "Hide your coworker's briefcase";
min30[5] = "Prank one of your friends";
min30[6] = "Have a quick shave";
//hours
hr1[0] = "Take a nap"
hr1[1] = "Watch a TV show"
hr1[2] = "Swim a few laps"
hr1[3] = "Take an indulgent bubble bath";
hr1[4] = "Go grocery shopping";
hr1[5] = "Get a haircut";
hr1[6] = "have a massage";
hr1[7] = "Clean out your refrigerator";
hr1[8] = "Rearrange your house";
hr2[0] = "Bleach and dye your hair";
hr2[1] = "Do a round of bowling";
hr2[2] = "Get your wisdom teeth removed";
hr2[3] = "Make fresh pasta from scratch";
hr2[4] = "Watch a summer blockbuster";
hr3[0] = "Play a game of Monopoly";
hr3[1] = "Watch a game of American Football";
hr3[2] = "Slowcook a meal in a crock pot";
hr4[0] = "Play a fun game of Risk";
hr4[1] = "Play Journey from start to finish";
hr4[2] = "Drive from Washington DC to a beach";
hr4[3] = "Go through almost all the exhibits \nat an art museum.";
hr5[0] = "Run a decent marathon";
hr5[1] = "Make beef stew from start to finish";
hr6[0] = "Climb Mount Fuji from its base";
hr6[1] = "Go to public school, but skip the last class";
hr8[0] = "Play a really long and terrible game of Risk";
hr8[1] = "Pick 9 bins of apples";
hr12[0] = "Watch the entirety of the \nLord of The Rings trilogy";
hr12[1] = "Work an average day on the farm";
hr14[0] = "Finish an Ironman competition";
hr14[1] = "Get really good sleep for an 13 year old";
hr16[0] = "Take a bus from NYC to Atlanta, Georgia";
hr16[1] = "Write, set up, and perform a play";
hr16[2] = "Drive from Denver Colorado to Phoenix Arizona";
hr16[3] = "Do a week's worth of work as a part-time intern";
hr18[0] = "Fly from LA to Singapore";
hr18[1] = "Take a bus though Central America";
hr18[2] = "Write a short research paper";
}
See More Shortcuts