diff options
Diffstat (limited to 'src/ellipse.js')
-rw-r--r-- | src/ellipse.js | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/ellipse.js b/src/ellipse.js index 018cd4f..ad3e02e 100644 --- a/src/ellipse.js +++ b/src/ellipse.js @@ -1,30 +1,27 @@ - +// SVG.Ellipse = function Ellipse() { this.constructor.call(this, SVG.create('ellipse')); }; -// inherit from SVG.Shape +// Inherit from SVG.Shape SVG.Ellipse.prototype = new SVG.Shape(); -// Add ellipse-specific functions +// SVG.extend(SVG.Ellipse, { - - // custom move function + // Custom move function move: function(x, y) { this.attrs.x = x; this.attrs.y = y; return this.center(); }, - - // custom size function - size: function(w, h) { + // Custom size function + size: function(width, height) { return this. - attr({ rx: w / 2, ry: (h != null ? h : w) / 2 }). + attr({ rx: width / 2, ry: (height != null ? height : width) / 2 }). center(); }, - - // position element by its center + // Custom center function center: function(x, y) { return this.attr({ cx: x || (this.attrs.x || 0) + (this.attrs.rx || 0), @@ -33,3 +30,7 @@ SVG.extend(SVG.Ellipse, { } }); + +// Usage: + +// draw.ellipse(200, 100);
\ No newline at end of file |