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
[WIP] Cat Clock [1]
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;
int sketchWidth, sketchHeight;
//Initialize variables for the 4 number slots
int h1, h2, m1, m2;
//Currently unused int h1prev, h2prev, m1prev, m2prev;
int h1pos, h2pos, m1pos, m2pos;
void setup() {
size(818, 264); //CHANGE THIS WITH vs
background(255);
frameRate(1);
vs = 2; //CHANGE THIS VALUE TO "1" TO SEE FULL-SIZE IMAGE
vw = 375/vs;
vh = 500/vs;
spacing = 15/vs;
sketchWidth = ((spacing*10) + (vw*4)); //1650 [818 when vs = 2]
sketchHeight = (vh + (spacing*2)); //530 [264 when vs = 2]
h1 = -1;
h2 = -1;
m1 = -1;
m2 = -1;
/*Currently unused
h1prev = -1;
h2prev = -1;
m1prev = -1;
m2prev = -1; */
h1pos = (spacing*1)+(vw*0);
h2pos = (spacing*2)+(vw*1);
m1pos = (width - spacing*2)-(vw*2);
m2pos = (width - spacing*1)-(vw*1);
//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 *****/
/* Currently unused
h1prev = h1;
h2prev = h2;
m1prev = m1;
m2prev = m2; */
//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
for (int i=minute(); i>=0; i-=10) {
m2 = i;
}
//Debug print to console
//println("Time [" + h1 + h2 + ":" + m1 + m2 + "]");
/***** DRAW TO SCREEN *****/
background(255);
fill(255);
stroke(0);
ellipse(width/2, 1*height/4, 25/vs, 25/vs);
ellipse(width/2, 3*height/4, 25/vs, 25/vs);
numberSwitch(h1, h1pos, spacing);
numberSwitch(h2, h2pos, spacing);
numberSwitch(m1, m1pos, spacing);
numberSwitch(m2, m2pos, spacing);
}
void cat0(int x, int y) {
pushMatrix();
translate(x, y);
shape(cat0A, 0, 0, vw, vh);
shape(cat0B, 0, 0, vw, vh);
popMatrix();
}
void cat1(int x, int y) {
pushMatrix();
translate(x, y);
shape(cat1A, 0, 0, vw, vh);
shape(cat1B, 0, 0, vw, vh);
popMatrix();
}
void cat2(int x, int y) {
pushMatrix();
translate(x, y);
shape(cat2A, 0, 0, vw, vh);
shape(cat2B, 0, 0, vw, vh);
popMatrix();
}
void cat3(int x, int y) {
pushMatrix();
translate(x, y);
shape(cat3A, 0, 0, vw, vh);
shape(cat3B, 0, 0, vw, vh);
popMatrix();
}
void cat4(int x, int y) {
pushMatrix();
translate(x, y);
shape(cat4A, 0, 0, vw, vh);
shape(cat4B, 0, 0, vw, vh);
popMatrix();
}
void cat5(int x, int y) {
pushMatrix();
translate(x, y);
shape(cat5A, 0, 0, vw, vh);
shape(cat5B, 0, 0, vw, vh);
popMatrix();
}
void cat6(int x, int y) {
pushMatrix();
translate(x, y);
shape(cat6A, 0, 0, vw, vh);
shape(cat6B, 0, 0, vw, vh);
popMatrix();
}
void cat7(int x, int y) {
pushMatrix();
translate(x, y);
shape(cat7A, 0, 0, vw, vh);
shape(cat7B, 0, 0, vw, vh);
popMatrix();
}
void cat8(int x, int y) {
pushMatrix();
translate(x, y);
shape(cat8A, 0, 0, vw, vh);
shape(cat8B, 0, 0, vw, vh);
popMatrix();
}
void cat9(int x, int y) {
pushMatrix();
translate(x, y);
shape(cat9A, 0, 0, vw, vh);
shape(cat9B, 0, 0, vw, vh);
popMatrix();
}
void numberSwitch(int time, int x, int y) {
switch(time) {
case 0:
cat0(x, y);
break;
case 1:
cat1(x, y);
break;
case 2:
cat2(x, y);
break;
case 3:
cat3(x, y);
break;
case 4:
cat4(x, y);
break;
case 5:
cat5(x, y);
break;
case 6:
cat6(x, y);
break;
case 7:
cat7(x, y);
break;
case 8:
cat8(x, y);
break;
case 9:
cat9(x, y);
break;
}
}
See More Shortcuts