SwiftSVG
SwiftSVG copied to clipboard
How to parse SVG node
Can this library support draw standard SVG node like <text>, <g>
。like:
<g id="doublearrow_0" event-root="true" tool-name="doublearrow" style="stroke:#FF0900;fill:none;stroke-width:7;"><defs xmlns="http://www.w3.org/2000/svg">
<marker id="da_start_0" markerWidth="140" markerHeight="120" viewBox="0 0 3200 2800" refX="100" refY="60" orient="auto">
<path d="M 0 60 l 140 -60 l -40 60 l 40 60 z" style="stroke-width: 1px; fill: rgb(255, 9, 0); stroke: rgb(255, 9, 0);"></path>
</marker>
<marker id="da_end_0" markerWidth="140" markerHeight="120" viewBox="0 0 3200 2800" refX="40" refY="60" orient="auto">
<path d="M 0 0 l 140 60 l -140 60 l 40 -60 z" style="stroke-width: 1px; fill: rgb(255, 9, 0); stroke: rgb(255, 9, 0);"></path>
</marker>
</defs><line x1="467" y1="187" x2="239" y2="620" style="fill: none;stroke-width:6;stroke:rgba(0, 0, 0, 0);"></line><line x1="466" y1="186" x2="240" y2="620" marker-end="url(#da_end_0)" marker-start="url(#da_start_0)"></line></g>
I know library can read svg file, but my whiteboard app will receive svg node from server and draw. I can't write into file and read.
Please help
I have this problem as well! Is it necessary to create a file beforehand? I guess that's not the best option in terms of permormance!
It is obviously possible to do something like this:
let svgString = "some svg content form server"
let data: Data = svgString.data(using: String.Encoding.utf8)