Its spooky season so I decided to make a jack-o-lantern clock. With this clock the idea is that the stem counts down the seconds, every minute the knife on the table moves right and at 60 minutes the knife is far right off the screen as if someone picked it up. Every hour a line is carved into the pumpkin so it is like someone picked up the knife and made a cut the n the knife goes back to the left side of the table as if it was put back down. Every 12 hours the jack-o-lantern is fully carved! The background represents AM or PM.
pumpkinclockDownloadvar knifeX;var stemY;var H;
function setup() {
createCanvas(480, 480);
background(220);
}
function draw() {
H = hour();
knifeX = minute() * 8; stemY = -220 + second();
strokeWeight(1);
noStroke();
if(H < 12){ background(107, 144, 255);
fill(237, 214, 100);
circle(0, 0, 250);
} else { background(28, 37, 74);
fill(177, 179, 186);
circle(100, 55, 100);
fill(28, 37, 74);
circle(125, 55, 100);
}
fill(255);
ellipse(400, 150, 200, 30);
circle(400, 130, 50);
circle(350, 125, 75);
circle(430, 140, 25);
ellipse(100, 250, 200, 30);
circle(100, 230, 50);
circle(150, 225, 75);
circle(70, 240, 25);
fill(125, 90, 29);
rect(0, 350, width, height - 130);
push();
translate(240, 240); stem()
pumpkin();
face()
pop();
knife();
}
function pumpkin(){
stroke(214, 129, 58);
fill(245, 147, 66); ellipse(0,0, 300, 250); noFill();
strokeWeight(5)
ellipse(0, 0, 100, 250);
ellipse(0, 0, 200, 250);
}
function stem(){
noStroke();
fill(18, 102, 13);
triangle(-20, -125, 20, -125, 0, -150);
rect(-15, stemY, 30, 250)
}
function knife(){
noStroke();
fill(10);
rect(knifeX, 410, 6, 50); fill(100);
rect(knifeX, 370, 6, 40);
arc(knifeX, 390, 20, 40, PI/2, (PI/2)*3)
}
function face(){
H = hour()
stroke(0);
strokeWeight(5);
if (H == 1 || H == 13){ line(-100, 0, -75, -50); } else if (H == 2 || H == 14){
line(-100, 0, -75, -50) line(-75, -50, -50, 0); } else if (H == 3 || H == 15){
fill(0);
triangle(-100, 0, -50, 0, -75, -50); } else if (H == 4 || H == 16){
fill(0);
triangle(-100, 0, -50, 0, -75, -50); line(100, 0, 75, -50) } else if (H == 5 || H == 17){
fill(0);
triangle(-100, 0, -50, 0, -75, -50); line(100, 0, 75, -50) line(75, -50, 50, 0); } else if (H == 6 || H == 18){
fill(0);
triangle(-100, 0, -50, 0, -75, -50); triangle(100, 0, 50, 0, 75, -50); } else if (H == 7 || H == 19){
fill(0);
triangle(-100, 0, -50, 0, -75, -50); triangle(100, 0, 50, 0, 75, -50); line(-120, 30, -75 , 30); } else if (H == 8 || H == 20){
fill(0);
triangle(-100, 0, -50, 0, -75, -50); triangle(100, 0, 50, 0, 75, -50); line(-120, 30, -75 , 30); line(-75 , 30, -75 , 50);
line(-75, 50, -25, 50);
line(-25, 30, -25, 50);
} else if (H == 9 || H == 21){
fill(0);
triangle(-100, 0, -50, 0, -75, -50); triangle(100, 0, 50, 0, 75, -50); line(-120, 30, -75 , 30); line(-75 , 30, -75 , 50);
line(-75, 50, -25, 50);
line(-25, 30, -25, 50);
line(-25, 30, 25, 30);
} else if (H == 10 || H == 22){
fill(0);
triangle(-100, 0, -50, 0, -75, -50); triangle(100, 0, 50, 0, 75, -50); line(-120, 30, -75 , 30); line(-75 , 30, -75 , 50);
line(-75, 50, -25, 50);
line(-25, 30, -25, 50);
line(-25, 30, 25, 30);
line(75 , 30, 75 , 50);
line(75, 50, 25, 50);
line(25, 30, 25, 50);
} else if (H == 11 || H == 23){
fill(0);
triangle(-100, 0, -50, 0, -75, -50); triangle(100, 0, 50, 0, 75, -50); line(-120, 30, -75 , 30); line(-75 , 30, -75 , 50);
line(-75, 50, -25, 50);
line(-25, 30, -25, 50);
line(-25, 30, 25, 30);
line(75 , 30, 75 , 50);
line(75, 50, 25, 50);
line(25, 30, 25, 50);
line(120, 30, 75 , 30);
}else{
fill(0);
triangle(-100, 0, -50, 0, -75, -50); triangle(100, 0, 50, 0, 75, -50); line(-120, 30, -75 , 30); line(-75 , 30, -75 , 50);
line(-75, 50, -25, 50);
line(-25, 30, -25, 50);
line(-25, 30, 25, 30);
line(75 , 30, 75 , 50);
line(75, 50, 25, 50);
line(25, 30, 25, 50);
line(120, 30, 75 , 30);
arc(0, 30, 240, 120, 2 * PI, PI);
fill(245, 147, 66)
noStroke();
rect(-75 , 25, 50, 20);
rect(25, 25, 50, 20);
}
}