|
const spacing = 70; |
|
|
|
let angle = 0; |
|
let end1 = map(sc, 0, 60, 0, 360); |
|
// |
|
// function setup{ |
|
// angleMode(DEGREES); |
|
// |
|
// |
|
// } |
|
|
|
// Update this function to draw you own maeda clock on a 960x500 canvas |
|
function draw_clock(obj) { |
|
|
|
//fill(0); |
|
//background(100); |
|
// strokeWeight(5); |
|
// |
|
// stroke(255, 0, 0); |
|
// for(let i = -2*spacing; i <= 2*spacing; i = i+spacing) { |
|
// ellipse(width/2, height/2+i, 45, 45); |
|
// } |
|
// |
|
// strokeWeight(3); |
|
// stroke(255, 255, 0); |
|
// for(let i = -2*spacing; i <= 2*spacing; i = i+spacing) { |
|
// ellipse(width/2, height/2+i, 40, 40); |
|
// } |
|
// |
|
// stroke(0, 0, 255); |
|
// for(let i = -2*spacing; i <= 2*spacing; i = i+spacing) { |
|
// ellipse(width/2, height/2+i, 30, 30); |
|
// }// |
|
|
|
// one of 12 clock |
|
|
|
// --------- |
|
// background(100); |
|
|
|
// let hr = hour(); |
|
// let mn = minute(); |
|
// let sc = second(); |
|
// angleMode(DEGREES); |
|
|
|
// strokeWeight(9); |
|
// noFill(); |
|
// let end1 = map(sc, 0, 60, 0, 360); |
|
// let end2 = map(mn, 0, 60, 0, 360); |
|
// let end3 = map(hr % 12, 0, 12, 0, 360) |
|
|
|
// push(); |
|
// translate(350,250); |
|
// rotate(end3); |
|
// fill(255,100,50); |
|
// textSize(240); |
|
// textAlign(CENTER,CENTER); |
|
// text(hr, 0, 0); |
|
// pop(); |
|
|
|
// push(); |
|
// translate(350,250); |
|
// rotate(end2); |
|
// fill(0); |
|
// textSize(140); |
|
// textAlign(CENTER,CENTER); |
|
// text(mn, 0, 0); |
|
// pop(); |
|
|
|
// push(); |
|
// translate(350,250); |
|
// rotate(end1); |
|
// fill(0,255,0); |
|
// textSize(50); |
|
// textAlign(CENTER,CENTER); |
|
// text(sc, 0, 0); |
|
// pop(); |
|
|
|
// angle = angle + 0.1; |
|
|
|
|
|
|
|
// class note |
|
|
|
// background(0); |
|
// fill(255); |
|
// const ballWidth = 100; |
|
// let posX = map(obj.millis, 0, 1000, ballWidth/2, width-ballWidth/2); |
|
// let posY = map(80,0,100,0,height); |
|
// ellipse(posX, posY, ballWidth); |
|
|
|
|
|
// posX = map(obj.seconds, 0, 59, ballWidth/2, width-ballWidth/2); |
|
// posY = map(60,0,100,0,height); |
|
// ellipse(posX, posY,ballWidth); |
|
|
|
// posX = map(obj.minutes, 0, 59, ballWidth/2, width-ballWidth/2); |
|
// posY = map(40,0,100,0,height); |
|
// ellipse(posX, posY,ballWidth); |
|
|
|
// posX = map(obj.hours, 0, 23, ballWidth/2, width-ballWidth/2); |
|
// posY = map(20,0,100,0,height); |
|
// ellipse(posX, posY,ballWidth); |
|
|
|
|
|
// part 3 |
|
background(100); |
|
|
|
let hr = hour(); |
|
let mn = minute(); |
|
let sc = second(); |
|
angleMode(DEGREES); |
|
|
|
strokeWeight(9); |
|
noFill(); |
|
let end1 = map(sc, 0, 60, 180, 540); |
|
let end2 = map(mn, 0, 60, 180, 540); |
|
let end3 = map(hr % 12, 0, 12, 180, 540) |
|
|
|
push(); |
|
translate(500,240); |
|
rotate(end3); |
|
fill(255,100,50); |
|
textSize(40); |
|
textAlign(CENTER,CENTER); |
|
text(hr, 0,170); |
|
pop(); |
|
|
|
push(); |
|
translate(500,240); |
|
rotate(end2); |
|
fill(0); |
|
textSize(30); |
|
textAlign(CENTER,CENTER); |
|
text(mn, 0, 150); |
|
pop(); |
|
|
|
push(); |
|
translate(500,240); |
|
rotate(end1); |
|
fill(0,255,0); |
|
textSize(20); |
|
textAlign(CENTER,CENTER); |
|
text(sc, 0, 230); |
|
pop(); |
|
|
|
angle = angle + 0.1; |
|
strokeWeight(1); |
|
|
|
//ellipse(500,250,500,500) |
|
|
|
// Final |
|
|
|
|
|
} |