From 6c6c82ed59533f44f8754b69d47e3b11cd6dd129 Mon Sep 17 00:00:00 2001 From: wout Date: Sat, 9 Mar 2013 22:28:47 +0100 Subject: Bumped to v0.9, added better style management, text support and extended animation functionality --- src/line.js | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'src/line.js') diff --git a/src/line.js b/src/line.js index 1e783e4..0712f1e 100644 --- a/src/line.js +++ b/src/line.js @@ -12,24 +12,25 @@ SVG.extend(SVG.Line, { 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 + 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) { +, center: function(x, y) { var bbox = this.bbox() return this.move(x - bbox.width / 2, y - bbox.height / 2) - }, + } // Set line size by width and height - size: function(width, height) { +, size: function(width, height) { 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) + return this + .attr(this.attr('x1') < this.attr('x2') ? 'x2' : 'x1', bbox.x + width) + .attr(this.attr('y1') < this.attr('y2') ? 'y2' : 'y1', bbox.y + height) } }) @@ -37,10 +38,10 @@ SVG.extend(SVG.Line, { SVG.extend(SVG.Container, { line: function(x1, y1, x2, y2) { return this.put(new SVG.Line().attr({ - x1: x1, - y1: y1, - x2: x2, - y2: y2 + x1: x1 + , y1: y1 + , x2: x2 + , y2: y2 })) } }) \ No newline at end of file -- cgit v1.2.3