javascript – Snap SVG: String to Element

javascript – Snap SVG: String to Element

I believe you can do it with parse (I removed the transform so the code could work in the small SO snippet window):

var s = Snap(#svg);
var string = <rect x=100 y=100 fill=#7EC242 width=230.02 height=56.723 stroke=#64bc46/>
var rect = Snap.parse(string);
s.append(rect);
<script src=http://cdn.jsdelivr.net/snap.svg/0.1.0/snap.svg-min.js></script>
<svg id=svg width=400 height=200>
</svg>

javascript – Snap SVG: String to Element

Leave a Reply

Your email address will not be published. Required fields are marked *