soma.js
Version:
soma.js is a javascript framework created to build scalable and maintainable applications.
53 lines (44 loc) • 1.58 kB
JavaScript
// Generated by CoffeeScript 1.6.2
(function() {
(function(clock) {
"use strict"; return clock.NeedleHours = (function() {
function NeedleHours() {
this.seconds = 0;
this.minutes = 0;
this.hours = 0;
this.radius = 0;
this.center = 0;
this.size = 0;
}
NeedleHours.prototype.initialize = function(radius) {
this.radius = radius;
this.center = this.radius / 2;
return this.size = this.center * 0.4;
};
NeedleHours.prototype.update = function(hours, minutes, seconds) {
this.hours = hours;
this.minutes = minutes;
this.seconds = seconds;
};
NeedleHours.prototype.draw = function(context) {
var theta, x, y;
theta = 30 * Math.PI / 180;
x = this.center + this.size * Math.cos(((this.hours + this.minutes / 60 + this.seconds / 3600) * theta) - Math.PI / 2);
y = this.center + this.size * Math.sin(((this.hours + this.minutes / 60 + this.seconds / 3600) * theta) - Math.PI / 2);
context.save();
context.lineWidth = 5;
context.strokeStyle = '#015666';
context.lineJoin = 'round';
context.lineCap = 'round';
context.beginPath();
context.moveTo(x, y);
context.lineTo(this.center, this.center);
context.closePath();
context.stroke();
return context.restore();
};
NeedleHours.prototype.dispose = function() {};
return NeedleHours;
})();
})(window.clock = window.clock || {});
}).call(this);