blob: f2549c76f8b4952aa1740ab028ee4c8299e32513 (
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
31
32
|
SVG.Circle = function Circle() {
this.constructor.call(this, SVG.createElement('circle'));
};
// inherit from SVG.Shape
SVG.Circle.prototype = new SVG.Shape();
// custom move function
SVG.Circle.prototype.move = function(x, y) {
this.attributes.x = x;
this.attributes.y = y;
this.center();
return this;
};
// custom size function
SVG.Circle.prototype.size = function(w, h) {
this.setAttribute('r', w / 2);
this.center();
return this;
};
// private: center
SVG.Circle.prototype.center = function(cx, cy) {
var r = this.attributes.r || 0;
this.setAttribute('cx', cx || ((this.attributes.x || 0) + r));
this.setAttribute('cy', cy || ((this.attributes.y || 0) + r));
};
|