diff options
author | wout <wout@impinc.co.uk> | 2013-01-04 19:12:16 +0100 |
---|---|---|
committer | wout <wout@impinc.co.uk> | 2013-01-04 19:12:16 +0100 |
commit | 2380c67d4ddded556617760b4b3cb38a1d7758e2 (patch) | |
tree | c0bd5ee57a4c83e5d8860becba7766188344eda3 /src/ellipse.js | |
parent | 40de19951d0a4218ee2625fa9a1a69f04e79692d (diff) | |
download | svg.js-2380c67d4ddded556617760b4b3cb38a1d7758e2.tar.gz svg.js-2380c67d4ddded556617760b4b3cb38a1d7758e2.zip |
Made code more readable and included docs
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 |