|
// Generated by CoffeeScript 1.6.3 |
|
(function() { |
|
var Cursor, D2R, UnitCircle, deg2rad, extension, |
|
__hasProp = {}.hasOwnProperty, |
|
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; |
|
|
|
D2R = Math.PI / 180; |
|
|
|
deg2rad = function(d) { |
|
return d * D2R; |
|
}; |
|
|
|
Cursor = (function() { |
|
function Cursor(x, y, draw) { |
|
this.x = x; |
|
this.y = y; |
|
this.draw = draw; |
|
} |
|
|
|
Cursor.prototype.lineTo = function(x, y, color) { |
|
if (color == null) { |
|
color = "steelblue"; |
|
} |
|
this.draw.line(this.x, this.y, x, y).attr({ |
|
stroke: color |
|
}); |
|
this.x = x; |
|
this.y = y; |
|
return this; |
|
}; |
|
|
|
Cursor.prototype.moveTo = function(x, y) { |
|
return this.lineTo(x, y, "none"); |
|
}; |
|
|
|
return Cursor; |
|
|
|
})(); |
|
|
|
UnitCircle = (function(_super) { |
|
__extends(UnitCircle, _super); |
|
|
|
UnitCircle.prototype.defaultCircleStyle = { |
|
fill: "aliceblue", |
|
stroke: "steelblue", |
|
'stroke-width': 10 |
|
}; |
|
|
|
UnitCircle.prototype.defaultPointStyle = { |
|
fill: "#999", |
|
stroke: "aliceblue", |
|
'stroke-width': 2 |
|
}; |
|
|
|
function UnitCircle(cx, cy, radius, degrees, draw) { |
|
var margin; |
|
this.cx = cx; |
|
this.cy = cy; |
|
this.radius = radius != null ? radius : 100; |
|
this.degrees = degrees != null ? degrees : false; |
|
this.draw = draw; |
|
margin = this.defaultPointStyle['stroke-width']; |
|
this.diameter = this.radius * 2; |
|
this.disc = this.draw.circle(this.diameter + margin).attr(this.defaultCircleStyle).center(this.cx, this.cy); |
|
UnitCircle.__super__.constructor.call(this, this.cx, this.cy, this.draw); |
|
} |
|
|
|
UnitCircle.prototype._x = function(θ) { |
|
if (this.degrees) { |
|
θ = deg2rad(θ); |
|
} |
|
return this.cx + Math.cos(-θ) * this.radius; |
|
}; |
|
|
|
UnitCircle.prototype._y = function(θ) { |
|
if (this.degrees) { |
|
θ = deg2rad(θ); |
|
} |
|
return this.cy + Math.sin(-θ) * this.radius; |
|
}; |
|
|
|
UnitCircle.prototype.moveTo = function(θ) { |
|
this.lineTo(θ, "none"); |
|
return this; |
|
}; |
|
|
|
UnitCircle.prototype.lineTo = function(θ, color) { |
|
UnitCircle.__super__.lineTo.call(this, this._x(θ), this._y(θ), color); |
|
return this; |
|
}; |
|
|
|
UnitCircle.prototype.markPoint = function(size, style) { |
|
if (size == null) { |
|
size = 10; |
|
} |
|
style || (style = this.defaultPointStyle); |
|
this.draw.circle(size).attr(style).center(this.x, this.y); |
|
return this; |
|
}; |
|
|
|
return UnitCircle; |
|
|
|
})(Cursor); |
|
|
|
extension = { |
|
unitCircle: function(x, y, r, d) { |
|
return new UnitCircle(x, y, r, d, this); |
|
} |
|
}; |
|
|
|
SVG.extend(SVG.Doc, extension); |
|
|
|
}).call(this); |