summaryrefslogtreecommitdiffstats
path: root/src/ellipse.js
diff options
context:
space:
mode:
authorwout <wout@impinc.co.uk>2012-12-17 16:55:16 +0100
committerwout <wout@impinc.co.uk>2012-12-17 16:55:16 +0100
commit6a013f19d6fa84e538d31bca5f1466c5f3479630 (patch)
tree3807acc4240bb1dbd5f25406b262a240351fa67a /src/ellipse.js
parent9ba8a780e0da4de4839df119f1d57d7f6327b1c6 (diff)
downloadsvg.js-6a013f19d6fa84e538d31bca5f1466c5f3479630.tar.gz
svg.js-6a013f19d6fa84e538d31bca5f1466c5f3479630.zip
Refactored code for readability and size
Diffstat (limited to 'src/ellipse.js')
-rw-r--r--src/ellipse.js45
1 files changed, 25 insertions, 20 deletions
diff --git a/src/ellipse.js b/src/ellipse.js
index 41443b9..1cfd0c1 100644
--- a/src/ellipse.js
+++ b/src/ellipse.js
@@ -1,30 +1,35 @@
SVG.Ellipse = function Ellipse() {
- this.constructor.call(this, SVG.createElement('ellipse'));
+ this.constructor.call(this, SVG.create('ellipse'));
};
// inherit from SVG.Shape
SVG.Ellipse.prototype = new SVG.Shape();
-// custom move function
-SVG.Ellipse.prototype.move = function(x, y) {
- this.attributes.x = x;
- this.attributes.y = y;
- this.center();
+// Add ellipse-specific functions
+SVG.Utils.merge(SVG.Ellipse, {
- return this;
-};
+ // custom move function
+ move: function(x, y) {
+ this.attrs.x = x;
+ this.attrs.y = y;
+ this.center();
-// custom size function
-SVG.Ellipse.prototype.size = function(w, h) {
- this.setAttribute('rx', w / 2);
- this.setAttribute('ry', h / 2);
- this.center();
-
- return this;
-};
+ return this;
+ },
-SVG.Ellipse.prototype.center = function(cx, cy) {
- this.setAttribute('cx', cx || ((this.attributes.x || 0) + (this.attributes.rx || 0)));
- this.setAttribute('cy', cy || ((this.attributes.y || 0) + (this.attributes.ry || 0)));
-}; \ No newline at end of file
+ // custom size function
+ size: function(w, h) {
+ this.attr('rx', w / 2);
+ this.attr('ry', h / 2);
+ this.center();
+
+ return this;
+ },
+
+ center: function(cx, cy) {
+ this.attr('cx', cx || ((this.attrs.x || 0) + (this.attrs.rx || 0)));
+ this.attr('cy', cy || ((this.attrs.y || 0) + (this.attrs.ry || 0)));
+ }
+
+});