SVG.Circle.prototype.move = function(x, y) {
this.attributes.x = x;
this.attributes.y = y;
- this._center();
+ this.center();
return this;
};
// custom size function
SVG.Circle.prototype.size = function(w, h) {
this.setAttribute('r', w / 2);
- this._center();
+ this.center();
return this;
};
// private: center
-SVG.Circle.prototype._center = function() {
+SVG.Circle.prototype.center = function(cx, cy) {
var r = this.attributes.r || 0;
- this.setAttribute('cx', (this.attributes.x || 0) + r);
- this.setAttribute('cy', (this.attributes.y || 0) + r);
+ this.setAttribute('cx', cx || ((this.attributes.x || 0) + r));
+ this.setAttribute('cy', cy || ((this.attributes.y || 0) + r));
};
\ No newline at end of file
return this;
};
+// set svg element attribute
+SVG.Element.prototype.attr = function(v) {
+ if (typeof v == 'object')
+ for (var k in v)
+ this.setAttribute(k, v[k]);
+ else if (arguments.length == 2)
+ this.setAttribute(arguments[0], arguments[1]);
+
+ return this;
+};
+
// get bounding box
SVG.Element.prototype.getBBox = function() {
return this.svgElement.getBBox();
SVG.Ellipse.prototype.move = function(x, y) {
this.attributes.x = x;
this.attributes.y = y;
- this._center();
+ this.center();
return this;
};
SVG.Ellipse.prototype.size = function(w, h) {
this.setAttribute('rx', w / 2);
this.setAttribute('ry', h / 2);
- this._center();
+ 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));
+SVG.Ellipse.prototype.center = function(cx, cy) {
+ this.setAttribute('cx', cx || ((this.attributes.x || 0) + (this.attributes.rx || 0)));
+ this.setAttribute('cy', cy || ((this.attributes.y || 0) + (this.attributes.ry || 0)));
};
\ No newline at end of file