blob: 95765682d9d3524032271e13c2fdae9626f8b92d (
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
33
34
35
36
37
|
SVG.Circle = function Circle() {
this.constructor.call(this, SVG.create('circle'));
};
// inherit from SVG.Shape
SVG.Circle.prototype = new SVG.Shape();
// Add circle-specific functions
SVG.extend(SVG.Circle, {
// custom move function
move: function(x, y) {
this.attrs.x = x;
this.attrs.y = y;
this.center();
return this;
},
// custom size function
size: function(w, h) {
this.attr('r', w / 2);
this.center();
return this;
},
// private: center
center: function(cx, cy) {
var r = this.attrs.r || 0;
this.attr('cx', cx || ((this.attrs.x || 0) + r));
this.attr('cy', cy || ((this.attrs.y || 0) + r));
}
});
|