diff options
Diffstat (limited to 'src/poly.js')
-rw-r--r-- | src/poly.js | 29 |
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 |