Looking for a tool to programmatically generate SVG images, I found that Emacs 26 can do it out of the box!
Example adapted from the Elisp reference manual:
(require 'svg)
(let ((svg (svg-create 400 400 :stroke-width 10)))
(svg-gradient svg "gradient1" 'linear '((0 . "red") (100 . "blue")))
(svg-circle svg 200 200 100 :gradient "gradient1" :stroke-color "green")
svg)
Now how do I save that to an SVG file?
I’m using Emacs 26.1 in the Termux terminal emulator on my phone, so no graphics.
svg
seems to contain XML structure stored as a list. It seems you'd need to just serialize it back to XML, and you'd get a svg string you could save to a file. I'm looking for a function that can do such serialization, and surprisingly,libxml
has only parsing functions. – Jul 28 '18 at 16:10