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
Digital Cat Clock
Ruka
xxxxxxxxxx
//Initialize variables for vector files (20 total)
PShape cat0A, cat0B, cat1A, cat1B, cat2A, cat2B, cat3A, cat3B, cat4A, cat4B, cat5A, cat5B, cat6A, cat6B, cat7A, cat7B, cat8A, cat8B, cat9A, cat9B;
//Initialize size and scalar variables for vector files (vector width, vector height, variable scalar)
int vw, vh, vs;
int spacing;
//Initialize variables for the 4 number slots
int h1, h2, m1, m2;
int h1prev, h2prev, m1prev, m2prev;
int h1pos, h2pos, m1pos, m2pos;
//Variables for fading from one number to another
boolean h1switch, h2switch, m1switch, m2switch;
int prevAlpha, currAlpha;
//Color variables
float r, g, b;
float prevR, prevG, prevB;
float currR, currG, currB;
void setup() {
size(818, 264); //CHANGE THIS WITH 'vs'
//Width 1650 [818 when vs = 2]
//Height 530 [264 when vs = 2]
background(0);
//Frame Rate Debug
//frameRate(60);
vs = 2; //CHANGE THIS VALUE TO "1" TO SEE FULL-SIZE IMAGE
vw = 375/vs;
vh = 500/vs;
spacing = 15/vs;
h1 = -1;
h2 = -1;
m1 = -1;
m2 = -1;
h1prev = -1;
h2prev = -1;
m1prev = -1;
m2prev = -1;
h1switch = false;
h2switch = false;
m1switch = false;
m2switch = false;
prevAlpha = 255;
currAlpha = 0;
h1pos = (spacing*1)+(vw*0);
h2pos = (spacing*2)+(vw*1);
m1pos = (width - spacing*2)-(vw*2);
m2pos = (width - spacing*1)-(vw*1);
r = random(35, 235);
g = random(35, 235);
b = random(35, 235);
prevR = r;
prevG = g;
prevB = b;
currR = random(35, 235);
currG = random(35, 235);
currB = random(35, 235);
//Load vectors
cat0A = loadShape("cat0-1.svg");
cat0B = loadShape("cat0-2.svg");
cat1A = loadShape("cat1-1.svg");
cat1B = loadShape("cat1-2.svg");
cat2A = loadShape("cat2-1.svg");
cat2B = loadShape("cat2-2.svg");
cat3A = loadShape("cat3-1.svg");
cat3B = loadShape("cat3-2.svg");
cat4A = loadShape("cat4-1.svg");
cat4B = loadShape("cat4-2.svg");
cat5A = loadShape("cat5-1.svg");
cat5B = loadShape("cat5-2.svg");
cat6A = loadShape("cat6-1.svg");
cat6B = loadShape("cat6-2.svg");
cat7A = loadShape("cat7-1.svg");
cat7B = loadShape("cat7-2.svg");
cat8A = loadShape("cat8-1.svg");
cat8B = loadShape("cat8-2.svg");
cat9A = loadShape("cat9-1.svg");
cat9B = loadShape("cat9-2.svg");
//Disable vector attributes (to be manipulated in the draw() function)
cat0A.disableStyle();
cat0B.disableStyle();
cat1A.disableStyle();
cat1B.disableStyle();
cat2A.disableStyle();
cat2B.disableStyle();
cat3A.disableStyle();
cat3B.disableStyle();
cat4A.disableStyle();
cat4B.disableStyle();
cat5A.disableStyle();
cat5B.disableStyle();
cat6A.disableStyle();
cat6B.disableStyle();
cat7A.disableStyle();
cat7B.disableStyle();
cat8A.disableStyle();
cat8B.disableStyle();
cat9A.disableStyle();
cat9B.disableStyle();
}
void draw() {
/***** VARIABLE UPDATES *****/
if (!h1switch) {
h1prev = h1;
}
if (!h2switch) {
h2prev = h2;
}
if (!m1switch) {
m1prev = m1;
}
if (!m2switch) {
m2prev = m2;
}
if (!h1switch && !h2switch && !m1switch && !m2switch) {
prevR = r;
prevG = g;
prevB = b;
currR = random(35, 235);
currG = random(35, 235);
currB = random(35, 235);
}
//Hour 1st Digit
if (((hour()>=10) && (hour()<=12)) || (hour()==22) || (hour()==23) || (hour()==0)) {
h1 = 1;
} else {
h1 = 0;
}
//Hour 2nd Digit
if ((hour()==9) || (hour()==21)) {
h2 = 9;
} else if ((hour()==8) || (hour()==20)) {
h2 = 8;
} else if ((hour()==7) || (hour()==19)) {
h2 = 7;
} else if ((hour()==6) || (hour()==18)) {
h2 = 6;
} else if ((hour()==5) || (hour()==17)) {
h2 = 5;
} else if ((hour()==4) || (hour()==16)) {
h2 = 4;
} else if ((hour()==3) || (hour()==15)) {
h2 = 3;
} else if ((hour()==0) || (hour()==2) || (hour()==12) || (hour()==14)) {
h2 = 2;
} else if ((hour()==1) || (hour()==11) || (hour()==13) || (hour()==23)) {
h2 = 1;
} else {
h2 = 0;
}
//Minute 1st Digit
if ((minute()>=0) && (minute()<=9)) {
m1 = 0;
} else if ((minute()>=10) && (minute()<=19)) {
m1 = 1;
} else if ((minute()>=20) && (minute()<=29)) {
m1 = 2;
} else if ((minute()>=30) && (minute()<=39)) {
m1 = 3;
} else if ((minute()>=40) && (minute()<=49)) {
m1 = 4;
} else {
m1 = 5;
}
//Minute 2nd Digit
m2 = minute() % 10;
//Debug print to console: println("Time [" + h1 + h2 + ":" + m1 + m2 + "]");
if ((h1prev!=-1) && (h1prev!=h1)) {
h1switch = true;
}
if ((h2prev!=-1) && (h2prev!=h2)) {
h2switch = true;
}
if ((m1prev!=-1) && (m1prev!=m1)) {
m1switch = true;
}
if ((m2prev!=-1) && (m2prev!=m2)) {
m2switch = true;
}
/***** DRAW TO SCREEN *****/
background(0);
fill(255);
noStroke();
//Changes fill of ellipses whether second() is even or odd
if (second()%2 == 0) { //even
fill(255);
} else { //odd
fill(0);
}
ellipse(width/2, 1*height/4, 30/vs, 30/vs);
ellipse(width/2, 3*height/4, 30/vs, 30/vs);
stroke(0);
if (h1switch || h2switch || m1switch || m2switch) {
prevAlpha = prevAlpha - 5;
currAlpha = currAlpha + 5;
r = map(prevAlpha, 255, 0, prevR, currR);
g = map(prevAlpha, 255, 0, prevG, currG);
b = map(prevAlpha, 255, 0, prevB, currB);
if (h1switch) {
numberSwitch(h1prev, h1pos, spacing, prevAlpha);
numberSwitch(h1, h1pos, spacing, currAlpha);
} else {
numberSwitch(h1, h1pos, spacing, 255);
}
if (h2switch) {
numberSwitch(h2prev, h2pos, spacing, prevAlpha);
numberSwitch(h2, h2pos, spacing, currAlpha);
} else {
numberSwitch(h2, h2pos, spacing, 255);
}
if (m1switch) {
numberSwitch(m1prev, m1pos, spacing, prevAlpha);
numberSwitch(m1, m1pos, spacing, currAlpha);
} else {
numberSwitch(m1, m1pos, spacing, 255);
}
if (m2switch) {
numberSwitch(m2prev, m2pos, spacing, prevAlpha);
numberSwitch(m2, m2pos, spacing, currAlpha);
} else {
numberSwitch(m2, m2pos, spacing, 255);
}
if (prevAlpha == 0) {
h1switch = false;
h2switch = false;
m1switch = false;
m2switch = false;
prevAlpha = 255;
currAlpha = 0;
}
} else {
numberSwitch(h1, h1pos, spacing, 255);
numberSwitch(h2, h2pos, spacing, 255);
numberSwitch(m1, m1pos, spacing, 255);
numberSwitch(m2, m2pos, spacing, 255);
}
//println("m2switch = " + m2switch + " || prevAlpha = " + prevAlpha + " || currAlpha = " + currAlpha);
}
void cat0(int x, int y, float r, float g, float b, int alpha) {
pushMatrix();
translate(x, y);
noStroke();
fill(255, alpha);
shape(cat0A, 0, 0, vw, vh);
stroke(0, alpha);
strokeWeight(0.5);
fill(r, g, b, alpha);
shape(cat0B, 0, 0, vw, vh);
popMatrix();
}
void cat1(int x, int y, float r, float g, float b, int alpha) {
pushMatrix();
translate(x, y);
noStroke();
fill(255, alpha);
shape(cat1A, 0, 0, vw, vh);
stroke(0, alpha);
strokeWeight(1);
fill(r, g, b, alpha);
shape(cat1B, 0, 0, vw, vh);
popMatrix();
}
void cat2(int x, int y, float r, float g, float b, int alpha) {
pushMatrix();
translate(x, y);
noStroke();
fill(255, alpha);
shape(cat2A, 0, 0, vw, vh);
stroke(0, alpha);
strokeWeight(1);
fill(r, g, b, alpha);
shape(cat2B, 0, 0, vw, vh);
popMatrix();
}
void cat3(int x, int y, float r, float g, float b, int alpha) {
pushMatrix();
translate(x, y);
noStroke();
fill(255, alpha);
shape(cat3A, 0, 0, vw, vh);
stroke(0, alpha);
strokeWeight(1);
fill(r, g, b, alpha);
shape(cat3B, 0, 0, vw, vh);
popMatrix();
}
void cat4(int x, int y, float r, float g, float b, int alpha) {
pushMatrix();
translate(x, y);
noStroke();
fill(255, alpha);
shape(cat4A, 0, 0, vw, vh);
stroke(0, alpha);
strokeWeight(1);
fill(r, g, b, alpha);
shape(cat4B, 0, 0, vw, vh);
popMatrix();
}
void cat5(int x, int y, float r, float g, float b, int alpha) {
pushMatrix();
translate(x, y);
noStroke();
fill(255, alpha);
shape(cat5A, 0, 0, vw, vh);
stroke(0, alpha);
strokeWeight(1);
fill(r, g, b, alpha);
shape(cat5B, 0, 0, vw, vh);
popMatrix();
}
void cat6(int x, int y, float r, float g, float b, int alpha) {
pushMatrix();
translate(x, y);
noStroke();
fill(255, alpha);
shape(cat6A, 0, 0, vw, vh);
stroke(0, alpha);
strokeWeight(0.5);
fill(r, g, b, alpha);
shape(cat6B, 0, 0, vw, vh);
popMatrix();
}
void cat7(int x, int y, float r, float g, float b, int alpha) {
pushMatrix();
translate(x, y);
noStroke();
fill(255, alpha);
shape(cat7A, 0, 0, vw, vh);
stroke(0, alpha);
strokeWeight(1);
fill(r, g, b, alpha);
shape(cat7B, 0, 0, vw, vh);
popMatrix();
}
void cat8(int x, int y, float r, float g, float b, int alpha) {
pushMatrix();
translate(x, y);
noStroke();
fill(255, alpha);
shape(cat8A, 0, 0, vw, vh);
stroke(0, alpha);
strokeWeight(0.5);
fill(r, g, b, alpha);
shape(cat8B, 0, 0, vw, vh);
popMatrix();
}
void cat9(int x, int y, float r, float g, float b, int alpha) {
pushMatrix();
translate(x, y);
noStroke();
fill(255, alpha);
shape(cat9A, 0, 0, vw, vh);
stroke(0, alpha);
strokeWeight(0.5);
fill(r, g, b, alpha);
shape(cat9B, 0, 0, vw, vh);
popMatrix();
}
void numberSwitch(int time, int x, int y, int alpha) {
switch(time) {
case 0:
cat0(x, y, r, g, b, alpha);
break;
case 1:
cat1(x, y, r, g, b, alpha);
break;
case 2:
cat2(x, y, r, g, b, alpha);
break;
case 3:
cat3(x, y, r, g, b, alpha);
break;
case 4:
cat4(x, y, r, g, b, alpha);
break;
case 5:
cat5(x, y, r, g, b, alpha);
break;
case 6:
cat6(x, y, r, g, b, alpha);
break;
case 7:
cat7(x, y, r, g, b, alpha);
break;
case 8:
cat8(x, y, r, g, b, alpha);
break;
case 9:
cat9(x, y, r, g, b, alpha);
break;
}
}
See More Shortcuts