36 lines
736 B
JavaScript
36 lines
736 B
JavaScript
/**
|
|
* @file ui_line.js
|
|
* @author frtk@tetalab
|
|
*/
|
|
|
|
NPGClient.Line = function(name, p1, p2, style) {
|
|
|
|
NPGClient.UIObject.call(this, name, style);
|
|
|
|
this.p1 = p1 !== undefined ? p1 : new NPGClient.Point2D();
|
|
this.p2 = p2 !== undefined ? p2 : new NPGClient.Point2D();
|
|
|
|
};
|
|
|
|
NPGClient.Line.prototype = Object.create(NPGClient.UIObject.prototype);
|
|
|
|
NPGClient.Line.prototype.constructor = NPGClient.Line;
|
|
|
|
NPGCLient.Line.prototype.draw = function(ctx) {
|
|
var self = this;
|
|
self.drawLine(ctx);
|
|
};
|
|
|
|
NPGClient.Line.prototype.drawLine = function(ctx) {
|
|
|
|
var self = this;
|
|
self.applyStyle(ctx);
|
|
|
|
ctx.beginPath();
|
|
ctx.moveTo(self.p1.x, self.p1.y);
|
|
ctx.lineTo(self.p2.x, self.p2.y);
|
|
ctx.stroke();
|
|
|
|
};
|
|
|