Importing external SVGs #10
Replies: 1 comment 6 replies
-
Hi @light-matters, thanks for opening this discussion. I have a small tools namespace which works within a Clojure context, and have a load-svg function. That function just slurps a given filename and uses a function in the utils namespace. The implementation uses clojure.data.xml to parse the SVG string into a sequence of svg elements represented as hiccup vectors. Be aware that this does not validate the SVG at all. There may be weird attrs that have no effect within the context of this library, and if any valid SVG elements break some assumptions in my library, results may appear strange. Since this is functionality I want to make more useful for people, I do want to see/hear what users struggle with so I can stabilize import behaviour. To be specific, my library 'bakes' transforms into the element's coordinates/attrs directly, but a user may import an SVG with transform attributes, which I do not (yet) re-compute into the coord attrs. As in, I don't bake transforms from the :transforms attribute. This could easily break things. As well, my path transform functions work on absolute path coords, but a user may have relative path data. This is also not handled at the moment. Basically, things should work fine if you have an SVG formatted in a way my lib (currently) expects. |
Beta Was this translation helpful? Give feedback.
-
I'm new to the "discussions" part of github, so apologies for accidentally opening a new issue, but how do you deal with importing and embedding external SVG images?
Do you use Hickory or another library to convert SVG to hiccup? Either way, do you plan on making your own convenience functions?
I (selfishly) ask because one of my upcoming projects will be heavy in arranging SVGs and I imagine it would also be of interest to those intending to make complicated images.
Beta Was this translation helpful? Give feedback.
All reactions