- Author:
- Max Bondar
- Twitter:
- @
- GitHub:
- Facebook:
- Google+:
- +
- Reddit:
- /r/
- Pouet:
- Website:
- Compo:
- classic
- Demo link:
- https://js1k.com/2013-spring/demo/1360
- Shortlink:
- https://js1k.com/1360
- Blog post:
- please update here!
- Bytes:
- 1017
- Chars:
- 1017
- Submission
var p=Math.PI/6;b=function(){a.beginPath()}
r=function(){a.stroke()}
c.width=c.height=500;window.onload=function(){setInterval(t,1000)}
function t(){a.clearRect(0,0,500,500);var now=new Date(),s=now.getSeconds(),m=now.getMinutes(),h=now.getHours();a.lineWidth=3;a.save();a.translate(198,272);for(var i=0;i<60;i++){if(i%5!=0){b();a.moveTo(128,0);a.lineTo(138,0);r()}else{b();a.moveTo(150,0);a.lineTo(130,0);r()}
a.rotate(p/5)}
a.lineCap="round";a.strokeStyle="black";a.rotate(-1*p*3);a.save();a.save();a.rotate(h*(p)+(p/60)*m+(p/3600)*s);k(45,16);b();a.strokeStyle="red";a.arc(0,0,30,0,p*12,false);r();a.restore();a.rotate((p/5)*m+(p/300)*s);k(75,10);a.restore();a.rotate((p/5)*s);b();a.moveTo(30,0);a.lineTo(140,0);r();a.restore();a.save();a.translate(45,120);a.lineWidth=2;a.strokeRect(0,0,305,305);b();a.moveTo(-30,0);a.lineTo(305+30,0);a.lineTo(306/2,-110);a.closePath();r();a.restore()}
function k(h,w){a.strokeRect(30,-1*w/2,h,w);b();a.moveTo(h+30,-1*w);a.lineTo(h+30,w);a.lineTo(h+50,0);a.closePath();r()}
- Description
- Simple analog clock
- Base64 encoded
dmFyIHA9TWF0aC5QSS82O2I9ZnVuY3Rpb24oKXthLmJlZ2luUGF0aCgpfQ0Kcj1mdW5jdGlvbigpe2Euc3Ryb2tlKCl9DQpjLndpZHRoPWMuaGVpZ2h0PTUwMDt3aW5kb3cub25sb2FkPWZ1bmN0aW9uKCl7c2V0SW50ZXJ2YWwodCwxMDAwKX0NCmZ1bmN0aW9uIHQoKXthLmNsZWFyUmVjdCgwLDAsN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cpO2EubGluZVRvKGgrNTAsMCk7YS5jbG9zZVBhdGgoKTtyKCl9
- Original source
var p=Math.PI/6;
window.onload = function () {
setInterval(tic, 1000)
}
function tic(){
a.clearRect(0,0,500,500);
var now = new Date(),
s = now.getSeconds(),
m = now.getMinutes(),
h = now.getHours();
a.lineWidth = 3;
a.save();
a.translate(198,272);
for (var i=0;i<60;i++){
if (i%5!=0) {
a.beginPath();
a.moveTo(128,0);
a.lineTo(138,0);
a.stroke()
} else {
a.beginPath();
a.moveTo(150,0);
a.lineTo(130,0);
a.stroke()
}
a.rotate(p/5)
}
a.lineCap = "round";
a.strokeStyle = "black";
a.rotate(-1*p*3);
a.save();
a.save();
a.rotate( h*(p) + (p/60)*m + (p/3600)*s );
arrow(45,16);
a.beginPath();
a.strokeStyle = "red";
a.arc(0, 0, 30, 0, p * 12, false);
a.stroke();
a.restore();
a.rotate( (p/5)*m + (p/300)*s );
arrow(75,10);
a.restore();
a.rotate((p/5)*s );
a.beginPath();
a.moveTo(30,0);
a.lineTo(140,0);
a.stroke();
a.restore();
a.save();
a.translate(45,120);
a.lineWidth = 2;
a.strokeRect(0,0,305,305);
a.beginPath();
a.moveTo(-30,0);
a.lineTo(305+30,0);
a.lineTo(306/2,-110);
a.closePath();
a.stroke();
a.restore()
}
function arrow(height,width){
a.strokeRect(30, -1*width/2, height, width);
a.beginPath();
a.moveTo(height+30, -1*width);
a.lineTo(height+30,width);
a.lineTo(height+50,0);
a.closePath();
a.stroke()
}