summaryrefslogtreecommitdiffstats
path: root/dist/svg.js
diff options
context:
space:
mode:
authorwout <wout@impinc.co.uk>2013-02-02 17:34:25 +0100
committerwout <wout@impinc.co.uk>2013-02-02 17:34:25 +0100
commitec56136a1a3cd83f856723d1076536e550296e31 (patch)
tree6031877fba4ada024a917947532245a0e979615c /dist/svg.js
parent1c9b6af19cd1367a74b91cb88e98ec1bef2d8234 (diff)
downloadsvg.js-ec56136a1a3cd83f856723d1076536e550296e31.tar.gz
svg.js-ec56136a1a3cd83f856723d1076536e550296e31.zip
Added SVG.Line as a native element0.5
Diffstat (limited to 'dist/svg.js')
-rw-r--r--dist/svg.js49
1 files changed, 48 insertions, 1 deletions
diff --git a/dist/svg.js b/dist/svg.js
index 5b6461c..92fd6ca 100644
--- a/dist/svg.js
+++ b/dist/svg.js
@@ -1,4 +1,4 @@
-/* svg.js v0.4-1-g7323d05 - svg element container fx event group arrange defs mask pattern gradient doc shape wrap rect ellipse poly path image text nested sugar - svgjs.com/license */
+/* svg.js v0.4-2-g1c9b6af - svg element container fx event group arrange defs mask pattern gradient doc shape wrap rect ellipse line poly path image text nested sugar - svgjs.com/license */
(function() {
this.svg = function(element) {
@@ -1180,6 +1180,53 @@
// draw.ellipse(200, 100);
+ SVG.Line = function Line() {
+ this.constructor.call(this, SVG.create('line'));
+ };
+
+ // Inherit from 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();
+
+ 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();
+
+ 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();
+
+ 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, {
+ line: function(x1, y1, x2, y2) {
+ return this.put(new SVG.Line().attr({
+ x1: x1,
+ y1: y1,
+ x2: x2,
+ y2: y2
+ }));
+ }
+ });
+
SVG.Poly = {
// Set polygon data with default zero point if no data is passed
plot: function(points) {