aboutsummaryrefslogtreecommitdiffstats
path: root/src/ellipse.js
diff options
context:
space:
mode:
authorwout <wout@impinc.co.uk>2012-12-16 16:15:47 +0100
committerwout <wout@impinc.co.uk>2012-12-16 16:15:47 +0100
commitc6ac1246c271c66733366086f467e381c3fd65a8 (patch)
tree09ff273e5ffea615ba9555e38a441e5248e37190 /src/ellipse.js
parent1fc78fe531ded4bc8a1ed5e176774600b897fcb1 (diff)
downloadsvg.js-c6ac1246c271c66733366086f467e381c3fd65a8.tar.gz
svg.js-c6ac1246c271c66733366086f467e381c3fd65a8.zip
Implemented core library
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