aboutsummaryrefslogtreecommitdiffstats
path: root/src/ellipse.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/ellipse.js')
-rw-r--r--src/ellipse.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/ellipse.js b/src/ellipse.js
new file mode 100644
index 0000000..9e03277
--- /dev/null
+++ b/src/ellipse.js
@@ -0,0 +1,30 @@
+
+SVG.Ellipse = function Ellipse() {
+ this.constructor.call(this, SVG.createElement('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();
+
+ return this;
+};
+
+// custom size function
+SVG.Ellipse.prototype.size = function(w, h) {
+ this.setAttribute('rx', w / 2);
+ this.setAttribute('ry', h / 2);
+ this._center();
+
+ return this;
+};
+
+SVG.Ellipse.prototype._center = function() {
+ this.setAttribute('cx', (this.attributes.x || 0) + (this.attributes.rx || 0));
+ this.setAttribute('cy', (this.attributes.y || 0) + (this.attributes.ry || 0));
+}; \ No newline at end of file