diff options
Diffstat (limited to 'src/line.js')
-rw-r--r-- | src/line.js | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/line.js b/src/line.js index b5dd2ef..1e783e4 100644 --- a/src/line.js +++ b/src/line.js @@ -1,37 +1,37 @@ -SVG.Line = function Line() { - this.constructor.call(this, SVG.create('line')); -}; +SVG.Line = function() { + this.constructor.call(this, SVG.create('line')) +} // Inherit from SVG.Shape -SVG.Line.prototype = new SVG.Shape(); +SVG.Line.prototype = new SVG.Shape() // Add required methods SVG.extend(SVG.Line, { // Move line move: function(x, y) { - var bbox = this.bbox(); + var bbox = this.bbox() return this.attr({ x1: this.attr('x1') - bbox.x + x, y1: this.attr('y1') - bbox.y + y, x2: this.attr('x2') - bbox.x + x, y2: this.attr('y2') - bbox.y + y - }); + }) }, // Move element by its center center: function(x, y) { - var bbox = this.bbox(); + var bbox = this.bbox() - return this.move(x - bbox.width / 2, y - bbox.height / 2); + return this.move(x - bbox.width / 2, y - bbox.height / 2) }, // Set line size by width and height size: function(width, height) { - var bbox = this.bbox(); + var bbox = this.bbox() - this.attr(this.attr('x1') < this.attr('x2') ? 'x2' : 'x1', bbox.x + width); - return this.attr(this.attr('y1') < this.attr('y2') ? 'y2' : 'y1', bbox.y + height); + this.attr(this.attr('x1') < this.attr('x2') ? 'x2' : 'x1', bbox.x + width) + return this.attr(this.attr('y1') < this.attr('y2') ? 'y2' : 'y1', bbox.y + height) } -}); +}) // Extend all container modules SVG.extend(SVG.Container, { @@ -41,6 +41,6 @@ SVG.extend(SVG.Container, { y1: y1, x2: x2, y2: y2 - })); + })) } -});
\ No newline at end of file +})
\ No newline at end of file |