Open byorgey opened 5 years ago
That's exactly what I need! I have a complicated SVG image and I would like to turn it into an element to be manipulated in the diagram. Basically, I would like to use SVG as input (not only output) for diagrams. I guess that should be a feature in svg-builder, no? I found svg-tree but I don't think I can use it, right? Maybe if both had a general XML representation behind or provided a way to convert from/to it (like svg-tree seems to have) then it would open more possibilities for reuse/interoperability, no?
What do you suggest I do? Should I turn the SVG into a PNG?
Right, implementing this would probably require adding some features to svg-builder
, I'm not sure. svg-tree
doesn't really help. In the meantime, you might want to look into https://github.com/diagrams/diagrams-input , which has never been released to Hackage but should still work. It has a way to convert an SVG into a diagrams path, I think, which might be overkill depending on your use case but it's better than nothing.
Thank you so much! I've been using that. It's exactly what I needed. Thank you.
Right now it is possible to embed raster images (PNG, JPG, ...) but not other SVG images, although the SVG format itself supports embedded SVGs perfectly well, either via a nested
<svg>
tag or via an<image ... xlink:href="...">
tag (corresponding to the existing embedded/external distinction in diagrams).While researching the best way to support this I'm realizing that diagrams' whole system of support for images is very much biased towards raster images. The SVG backend has an instance for
DImage Embedded
which definitely represents a raster image; it also has a specialloadImageSVG
which goes viaImageNative
, but it also only supports PNG or JPEG, and ends up embedding them in a base64-encoded data URI. I think trying to shoehorn embedded SVG into this is going to be annoying.Instead, I think the simplest approach is to simply add a new kind of embedded SVG primitive, specific to the SVG backend. It would be easiest to have it work via the
xlink
approach but inlining the contents of another SVG should be possible too.