- Author:
- Marek
- Twitter:
- @
- GitHub:
- Facebook:
- Google+:
- +
- Reddit:
- /r/
- Pouet:
- Website:
- Compo:
- classic
- Demo link:
- https://js1k.com/2013-spring/demo/1404
- Shortlink:
- https://js1k.com/1404
- Blog post:
- please update here!
- Bytes:
- 720
- Chars:
- 720
- Submission
(function(){var e,t,n,r,i,s,o,u;s=Math.PI;i=.5*s;u=c.width;r=c.height;t=u/2;n=r/2;o=u>r?r/2:u/2;e={tick:function(){a.clearRect(0,0,u,r);this.getTime();this.update();return setTimeout(function(){return e.tick()},1e3)},getTime:function(){return this.time=new Date},update:function(){var e,r,u;u=this.time.getSeconds();if(u===0){u=60}a.strokeStyle="#cccccc";a.lineWidth=2;a.beginPath();a.arc(t,n,o-2,0-i,2*s/60*u-i);a.stroke();r=this.time.getMinutes();a.strokeStyle="#666666";a.lineWidth=4;a.beginPath();a.arc(t,n,o-9,0-i,2*s/60*r-i);a.stroke();e=this.time.getHours();if(e>12){e=e-12}if(e===0){e=12}a.strokeStyle="#000000";a.lineWidth=5;a.beginPath();a.arc(t,n,o-16,0-i,2*s/12*e-i);return a.stroke()}};e.tick()}).call(this)
- Description
- No description submitted
- Base64 encoded
KGZ1bmN0aW9uKCl7dmFyIGUsdCxuLHIsaSxzLG8sdTtzPU1hdGguUEk7aT0uNSpzO3U9Yy53aWR0aDtyPWMuaGVpZ2h0O3Q9dS8yO249ci8yO289dT5yP3IvMjp1LzI7ZT17dGljazpmdW5jdGlvbigpe2EuY2xlYXJSZWN0KDAsMCx1LHIpO3RoaXMuZ2V0VGltZSgpO3RoaXMudXBkYXRlKCk7cmV0dXJuIHNldFRpbWVvdXQoZnVuY3Rpb24oKXtyZXR1cm4gZS50aWNrKCl9LDFlMyl9LGdldFRpbWU6ZnVuY3Rpb24oKXtyZXR1cm4gdGhpcy50aW1lPW5ldyBEYXRlfSx1cGRhdGU6ZnVuY3Rpb24oKXt2YXIgZSxyLHU7dT10aGlzLnRpbWUuZ2V0U2Vjb25kcygpO2lmKHU9PT0wKXt1PTYwfWEuc3Ryb2tlU3R5bGU9IiNjY2NjY2MiO2EubGluZVdpZHRoPTI7YS5iZWdpblBhdGgoKTthLmFyYyh0LG4sby0yLDAtaSwyKnMvNjAqdS1pKTthLnN0cm9rZSgpO3I9dGhpcy50aW1lLmdldE1pbnV0ZXMoKTthLnN0cm9rZVN0eWxlPSIjNjY2NjY2IjthLmxpbmVXaWR0aD00O2EuYmVnaW5QYXRoKCk7YS5hcmModCxuLG8tOSwwLWksMipzLzYwKnItaSk7YS5zdHJva2UoKTtlPXRoaXMudGltZS5nZXRIb3VycygpO2lmKGU+MTIpe2U9ZS0xMn1pZihlPT09MCl7ZT0xMn1hLnN0cm9rZVN0eWxlPSIjMDAwMDAwIjthLmxpbmVXaWR0aD01O2EuYmVnaW5QYXRoKCk7YS5hcmModCxuLG8tMTYsMC1pLDIqcy8xMiplLWkpO3JldHVybiBhLnN0cm9rZSgpfX07ZS50aWNrKCl9KS5jYWxsKHRoaXMp
- Original source
// Generated by CoffeeScript 1.5.0
(function() {
var clock, cx, cy, h, o, pi, r, w;
pi = Math.PI;
o = .5 * pi;
w = c.width;
h = c.height;
cx = w / 2;
cy = h / 2;
r = w > h ? h / 2 : w / 2;
clock = {
tick: function() {
a.clearRect(0, 0, w, h);
this.getTime();
this.update();
return setTimeout((function() {
return clock.tick();
}), 1000);
},
getTime: function() {
return this.time = new Date();
},
update: function() {
var hours, minutes, seconds;
seconds = this.time.getSeconds();
if (seconds === 0) {
seconds = 60;
}
a.strokeStyle = "#cccccc";
a.lineWidth = 2;
a.beginPath();
a.arc(cx, cy, r - 2, 0 - o, (2 * pi / 60) * seconds - o);
a.stroke();
minutes = this.time.getMinutes();
a.strokeStyle = "#666666";
a.lineWidth = 4;
a.beginPath();
a.arc(cx, cy, r - 9, 0 - o, (2 * pi / 60) * minutes - o);
a.stroke();
hours = this.time.getHours();
if (hours > 12) {
hours = hours - 12;
}
if (hours === 0) {
hours = 12;
}
a.strokeStyle = "#000000";
a.lineWidth = 5;
a.beginPath();
a.arc(cx, cy, r - 16, 0 - o, (2 * pi / 12) * hours - o);
return a.stroke();
}
};
clock.tick();
}).call(this);