tweak seconds markers
parent
293e32f9e5
commit
51888d724c
|
|
@ -3,13 +3,11 @@ g.clear();
|
||||||
var minuteDate = new Date();
|
var minuteDate = new Date();
|
||||||
var secondDate = new Date();
|
var secondDate = new Date();
|
||||||
|
|
||||||
function line(angle, r1,r2) {
|
function seconds(angle, r) {
|
||||||
var a = angle*Math.PI/180;
|
var a = angle*Math.PI/180;
|
||||||
g.drawLine(
|
var x = 120+Math.sin(a)*r;
|
||||||
120+Math.sin(a)*r1,
|
var y = 120-Math.cos(a)*r;
|
||||||
120-Math.cos(a)*r1,
|
g.fillRect(x-1,y-1,x+1,y+1);
|
||||||
120+Math.sin(a)*r2,
|
|
||||||
120-Math.cos(a)*r2);
|
|
||||||
}
|
}
|
||||||
function hand(angle, r1,r2) {
|
function hand(angle, r1,r2) {
|
||||||
var a = angle*Math.PI/180;
|
var a = angle*Math.PI/180;
|
||||||
|
|
@ -28,20 +26,20 @@ function hand(angle, r1,r2) {
|
||||||
|
|
||||||
function drawAll() {
|
function drawAll() {
|
||||||
g.clear();
|
g.clear();
|
||||||
g.setColor(0,0,0.3);
|
g.setColor(0,0,0.6);
|
||||||
for (var i=0;i<60;i++)
|
for (var i=0;i<60;i++)
|
||||||
line(360*i/60, 92, 95);
|
seconds(360*i/60, 90);
|
||||||
secondDate = minuteDate = new Date();
|
secondDate = minuteDate = new Date();
|
||||||
onSecond();
|
onSecond();
|
||||||
onMinute();
|
onMinute();
|
||||||
}
|
}
|
||||||
|
|
||||||
function onSecond() {
|
function onSecond() {
|
||||||
g.setColor(0,0,0.3);
|
g.setColor(0,0,0.6);
|
||||||
line(360*secondDate.getSeconds()/60, 92, 95);
|
seconds(360*secondDate.getSeconds()/60, 90);
|
||||||
g.setColor(1,0,0);
|
g.setColor(1,0,0);
|
||||||
secondDate = new Date();
|
secondDate = new Date();
|
||||||
line(360*secondDate.getSeconds()/60, 92, 95);
|
seconds(360*secondDate.getSeconds()/60, 90);
|
||||||
g.setColor(1,1,1);
|
g.setColor(1,1,1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -49,11 +47,11 @@ function onSecond() {
|
||||||
function onMinute() {
|
function onMinute() {
|
||||||
g.setColor(0,0,0);
|
g.setColor(0,0,0);
|
||||||
hand(360*minuteDate.getHours()/12, -10, 50);
|
hand(360*minuteDate.getHours()/12, -10, 50);
|
||||||
hand(360*minuteDate.getMinutes()/60, -10, 85);
|
hand(360*minuteDate.getMinutes()/60, -10, 82);
|
||||||
oldMinute = new Date();
|
oldMinute = new Date();
|
||||||
g.setColor(1,1,1);
|
g.setColor(1,1,1);
|
||||||
hand(360*minuteDate.getHours()/12, -10, 50);
|
hand(360*minuteDate.getHours()/12, -10, 50);
|
||||||
hand(360*minuteDate.getMinutes()/60, -10, 85);
|
hand(360*minuteDate.getMinutes()/60, -10, 82);
|
||||||
}
|
}
|
||||||
|
|
||||||
setInterval(onSecond,1000);
|
setInterval(onSecond,1000);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue