summaryrefslogtreecommitdiffstats
path: root/src/poly.js
diff options
context:
space:
mode:
authorwout <wout@impinc.co.uk>2013-03-24 19:19:06 +0100
committerwout <wout@impinc.co.uk>2013-03-24 19:19:06 +0100
commit67d367e0d74b3287956130da0077e42c6483dd2f (patch)
treebb2d23315e39c89b79cb8c52e7a5db54636e08ad /src/poly.js
parentff09596144c3fd6770d1dc64178a10c2432396ca (diff)
downloadsvg.js-67d367e0d74b3287956130da0077e42c6483dd2f.tar.gz
svg.js-67d367e0d74b3287956130da0077e42c6483dd2f.zip
Bumped to v0.11
- removed SVG.Wrap on SVG.Polyline, SVG.Polygon and SVG.Path - added delay on SVG.FX module - made x(), y(), cx() and cy() as getters - added SGB.get() method, to get elements by a DOM id - fixed bug in remove() method on container elements - added jasmine test suite to repo
Diffstat (limited to 'src/poly.js')
-rw-r--r--src/poly.js29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/poly.js b/src/poly.js
index ce5a70c..16a1cae 100644
--- a/src/poly.js
+++ b/src/poly.js
@@ -1,12 +1,3 @@
-SVG.Poly = {
- // Set polygon data with default zero point if no data is passed
- plot: function(points) {
- this.attr('points', points || '0,0')
-
- return this
- }
-}
-
SVG.Polyline = function() {
this.constructor.call(this, SVG.create('polyline'))
}
@@ -14,9 +5,6 @@ SVG.Polyline = function() {
// Inherit from SVG.Shape
SVG.Polyline.prototype = new SVG.Shape
-// Add polygon-specific functions
-SVG.extend(SVG.Polyline, SVG.Poly)
-
SVG.Polygon = function() {
this.constructor.call(this, SVG.create('polygon'))
}
@@ -25,4 +13,19 @@ SVG.Polygon = function() {
SVG.Polygon.prototype = new SVG.Shape
// Add polygon-specific functions
-SVG.extend(SVG.Polygon, SVG.Poly) \ No newline at end of file
+SVG.extend(SVG.Polyline, SVG.Polygon, {
+ // Private: Native plot
+ _plot: function(p) {
+ if (Array.isArray(p)) {
+ var i, l, points = []
+
+ for (i = 0, l = p.length; i < l; i++)
+ points.push(p[i].join(','))
+
+ p = points.length == 0 ? points.join(' ') : '0,0'
+ }
+
+ return this.attr('points', p || '0,0')
+ }
+
+}) \ No newline at end of file