It seems like you are overwhelmed of the beaty of the svg.js project ;)
Jokes aside: It is really not complicated to do what you want. You have a few paths you can choose from:
- Add a
line()
method to SVG.Circle
- Invent a new Object
SVG.LinedCircle
- Extend
SVG.Parent()
with a new constructor method
Add a line()
method to SVG.Circle
SVG.extend(SVG.Circle, {
line: function() {
var r = this.radius()
, cx = this.cx()
, cy = this.cy()
this.parent().line(cx, cy, cx + r)
}
}
Usage:
draw.circle(20).line()
Invent a new Object SVG.LinedCircle
SVG.LinedCircle = SVG.invent({
create: function() { SVG.Circle.call(this) },
inherit: SVG.Circle,
line: function() {
var r = this.radius()
, cx = this.cx()
, cy = this.cy()
this.parent().line(cx, cy, cx + r)
},
construct: {
linedCircle: function(size) {
return this.put(new SVG.LinedCircle().size(size).line())
}
}
})
Usage
draw.linedCircle()
Extend SVG.Parent()
with a new constructor method
SVG.extend(SVG.Parent, {
linedCircle: function(size) {
var g = this.group()
, c = g.circle(size)
, r = c.radius()
, cx = c.cx()
, cy = c.cy()
g.line(cx, cy, cx + r
return this.put(g)
}
})
Usage:
draw.linedCircle(50)
This time I wrapped circle and line into a group. So you get back a group when calling it. Imo thats the best solution.
You can achieve what you want in multiple ways. When you read the svg.js source you wil quickly understand how things work.