blob: 9e032771b3dd69e03f18f9032db7d6ec8b7f10bc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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));
};
|