summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorwout <wout@impinc.co.uk>2013-03-24 21:03:14 +0100
committerwout <wout@impinc.co.uk>2013-03-24 21:03:14 +0100
commit264c100153fc45cedf94a8cc8a0174fae12e1fe8 (patch)
tree690060d1ebc545fda9ec962323141d4740a3f950 /src
parenta0076d75bbac8f2c128f9b34e976bcb1ea3caa09 (diff)
downloadsvg.js-264c100153fc45cedf94a8cc8a0174fae12e1fe8.tar.gz
svg.js-264c100153fc45cedf94a8cc8a0174fae12e1fe8.zip
Added unbiased option to plotable elements
Diffstat (limited to 'src')
-rw-r--r--src/container.js12
-rw-r--r--src/path.js4
-rw-r--r--src/plotable.js12
-rw-r--r--src/poly.js8
4 files changed, 24 insertions, 12 deletions
diff --git a/src/container.js b/src/container.js
index 63822e4..08a52c8 100644
--- a/src/container.js
+++ b/src/container.js
@@ -90,16 +90,16 @@ SVG.extend(SVG.Container, {
return this.put(new SVG.Line().plot(x1, y1, x2, y2))
}
// Create a wrapped polyline element
-, polyline: function(points) {
- return this.put(new SVG.Polyline).plot(points)
+, polyline: function(points, unbiased) {
+ return this.put(new SVG.Polyline(unbiased)).plot(points)
}
// Create a wrapped polygon element
-, polygon: function(points) {
- return this.put(new SVG.Polygon).plot(points)
+, polygon: function(points, unbiased) {
+ return this.put(new SVG.Polygon(unbiased)).plot(points)
}
// Create a wrapped path element
-, path: function(data) {
- return this.put(new SVG.Path).plot(data)
+, path: function(data, unbiased) {
+ return this.put(new SVG.Path(unbiased)).plot(data)
}
// Create image element, load image and set its size
, image: function(source, width, height) {
diff --git a/src/path.js b/src/path.js
index ab5221a..b328d92 100644
--- a/src/path.js
+++ b/src/path.js
@@ -1,5 +1,7 @@
-SVG.Path = function() {
+SVG.Path = function(unbiased) {
this.constructor.call(this, SVG.create('path'))
+
+ this.unbiased = unbiased
}
// Inherit from SVG.Shape
diff --git a/src/plotable.js b/src/plotable.js
index 023d769..b4efe77 100644
--- a/src/plotable.js
+++ b/src/plotable.js
@@ -25,10 +25,16 @@ SVG.extend(SVG.Polyline, SVG.Polygon, SVG.Path, {
/* native plot */
this._plot(data)
- /* get and store the actual offset of the element */
+ /* store offset */
this._offset = this.transform({ scaleX: 1, scaleY: 1 }).bbox()
- this._offset.x -= this.trans.x
- this._offset.y -= this.trans.y
+
+ /* get and store the actual offset of the element */
+ if (this.unbiased) {
+ this._offset.x = this._offset.y = 0
+ } else {
+ this._offset.x -= this.trans.x
+ this._offset.y -= this.trans.y
+ }
return this.transform({ scaleX: x, scaleY: y })
}
diff --git a/src/poly.js b/src/poly.js
index 16a1cae..5c458f0 100644
--- a/src/poly.js
+++ b/src/poly.js
@@ -1,12 +1,16 @@
-SVG.Polyline = function() {
+SVG.Polyline = function(unbiased) {
this.constructor.call(this, SVG.create('polyline'))
+
+ this.unbiased = unbiased
}
// Inherit from SVG.Shape
SVG.Polyline.prototype = new SVG.Shape
-SVG.Polygon = function() {
+SVG.Polygon = function(unbiased) {
this.constructor.call(this, SVG.create('polygon'))
+
+ this.unbiased = unbiased
}
// Inherit from SVG.Shape