Reputation: 1483
I don't know how to create an element in <defs>
and use
it in svg.
I try something like :
var s = Snap('#drawing');
var c1 = s.circle(ww / 2, wh / 2, 100).attr('id','c1').toDefs(); // in <defs>
and after
var cc = c1.use(); // in defs not in svg root
Upvotes: 0
Views: 1402
Reputation: 13852
That should roughly work, I've just appended as well, here is an example...
var s = Snap(800,800);
var c1 = s.circle(100,100, 100).attr('id','c1').toDefs(); // in <defs>
var cc = s.append( c1.use() );
Make sure you also have the latest snap ver 0.3.0 as I think there was a bug with defs in the older ones.
I also did a page a while back for this here for Snap which may help a little to see it in use elsewhere.
Upvotes: 4