//Na-yeon Kim
//15-104, B section
//nayeonk1@andrew.cmu.edu
//Project-06 (Abstract clock)
var x = [];
var y = [];
function setup() {
createCanvas(400, 480);
frameRate(15);
angleMode(DEGREES);
}
function draw() {
background(20, 40, 60);
noStroke();
//variables for times
var H = hour();
var M = minute();
var S = second();
var mappedH = map(H, 0, 23, 120, 300);
var mappedS = map(S, 0, 59, 0, 30);
//small stars
fill(250);
for (var i = 0; i < x.length; i++) {
var ex = x[i];
var ey = y[i];
ellipse(ex, ey, 5, 5);
}
//wall
fill(80, 65, 30)
rect(0, 350, width, 130)
//moon
fill(250, 255, 90)
ellipse(120, 80, 100, 100);
//moon eclipse by hours
fill(10, 30, 50);
ellipse(mappedH, 80, 100, 100)
//star
fill(230, 230, 30);
var a = [250, 260, 280, 270, 270, 250, 230, 230, 217, 240];
var b = [138, 157, 163, 180, 202, 193, 202, 180, 163, 157];
var nPoints = a.length;
beginShape();
for (var i = 0; i < nPoints; i++) {
var px = a[i] + random(-1, 1);
var py = b[i] + random(-1, 1);
//star goes down by minutes
vertex(px, py + M);
}
endShape(CLOSE);
//window
push();
strokeWeight(50);
stroke(0, 115, 130);
noFill();
rect(0, -25, width, 350)
pop();
//table
fill(80, 28, 10);
arc(370, 440, 400, 150, 0, 180, CHORD);
fill(150, 78, 60);
ellipse(370, 440, 400, 100);
//ashtray shadow
push();
rotate(5);
translate(300, 420)
fill(80, 28, 10);
ellipse(0, 0, 130, 50)
pop();
//ashtray
fill(80, 100, 100)
arc(250, 430, 100, 30, 0, 180, CHORD)
rect(200, 410, 100, 20)
fill(100, 120, 120);
ellipse(250, 410, 100, 20)
fill(50, 60, 60);
ellipse(250, 410, 80, 10)
//cigarretts
push();
rotate(20);
translate(310, 300)
fill(230, 230, 230);
rect(0, 0, 50, 10);
fill(200, 200, 50);
rect(30, 0, 20, 10);
//cigarrett smoked by seconds
fill(0);
rect(0, 0, mappedS, 10)
fill(250, 20, 20);
rect(mappedS, 0, 2, 10);
pop();
//smokes come up by seconds
fill(250, 250 - 7 * S);
ellipse(170, 370 - S, mappedS + 10, mappedS + 15)
ellipse(190, 390 - S * 1.5, mappedS + 15, mappedS + 10)
ellipse(180, 375 - S, mappedS, mappedS)
ellipse(200, 380 - S * 3, mappedS + 10, mappedS)
ellipse(200, 385 - S * 2, mappedS + 10, mappedS + 10)
ellipse(190, 383 - S * 3.5, mappedS + 30, mappedS + 30)
//flower pot
fill(120, 50, 10)
quad(50, 250, 150, 250, 130, 300, 70, 300)
rect(45, 230, 110, 30)
//flower patel shows up every 5 min
push();
fill(230, 100, 100)
translate(100, 180)
var i = (M - (M % 10))/5;
for (var f = 0; f < i + 1; f++) {
ellipse(0, -20, 10, 30);
rotate(30);
}
pop();
//hours text
fill(240);
text("hour : " + H, 30, 400);
text("Minute : " + M, 30, 420);
text("Second : " + S, 30, 440);
}
//small stars show up when click
function mousePressed() {
x.push(mouseX);
y.push(mouseY);
}
My favorite time of the day is smoking at very late night while watching stars and moon. During the day, it’s too busy to feel the time. But night, every smokes from cigarett tells me of every moment of time.