diff options
author | wout <wout@impinc.co.uk> | 2014-02-03 15:14:47 +0100 |
---|---|---|
committer | wout <wout@impinc.co.uk> | 2014-02-03 15:14:47 +0100 |
commit | e2304534e0cfb6f6f4ab8c37ea5275ae26cd455a (patch) | |
tree | 2386e9f361d9c5fa1308387aeeaf33f00241b3c5 /src/poly.js | |
parent | 7a29817ffd764cf7ab6906250b57f234801c94e0 (diff) | |
download | svg.js-e2304534e0cfb6f6f4ab8c37ea5275ae26cd455a.tar.gz svg.js-e2304534e0cfb6f6f4ab8c37ea5275ae26cd455a.zip |
Implemented SVG.invent function and bumped to v1.0rc3
Diffstat (limited to 'src/poly.js')
-rwxr-xr-x | src/poly.js | 51 |
1 files changed, 28 insertions, 23 deletions
diff --git a/src/poly.js b/src/poly.js index 247ab8f..5a0f9b2 100755 --- a/src/poly.js +++ b/src/poly.js @@ -1,16 +1,34 @@ -SVG.Polyline = function() { - this.constructor.call(this, SVG.create('polyline')) -} +SVG.Polyline = SVG.invent({ + // Initialize node + create: 'polyline' -// Inherit from SVG.Shape -SVG.Polyline.prototype = new SVG.Shape + // Inherit from +, inherit: SVG.Shape + + // Add parent method +, construct: { + // Create a wrapped polyline element + polyline: function(p) { + return this.put(new SVG.Polyline).plot(p) + } + } +}) -SVG.Polygon = function() { - this.constructor.call(this, SVG.create('polygon')) -} +SVG.Polygon = SVG.invent({ + // Initialize node + create: 'polygon' -// Inherit from SVG.Shape -SVG.Polygon.prototype = new SVG.Shape + // Inherit from +, inherit: SVG.Shape + + // Add parent method +, construct: { + // Create a wrapped polygon element + polygon: function(p) { + return this.put(new SVG.Polygon).plot(p) + } + } +}) // Add polygon-specific functions SVG.extend(SVG.Polyline, SVG.Polygon, { @@ -51,17 +69,4 @@ SVG.extend(SVG.Polyline, SVG.Polygon, { return this.attr('points', this.array.size(p.width, p.height)) } -}) - -// -SVG.extend(SVG.Container, { - // Create a wrapped polyline element - polyline: function(p) { - return this.put(new SVG.Polyline).plot(p) - } - // Create a wrapped polygon element -, polygon: function(p) { - return this.put(new SVG.Polygon).plot(p) - } - })
\ No newline at end of file |