[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Examples of use of svg.el?

From: Tomas Hlavaty
Subject: Re: Examples of use of svg.el?
Date: Fri, 01 Apr 2022 13:11:35 +0200

On Fri 01 Apr 2022 at 04:05, Eduardo Ochs <> wrote:
> I am trying to learn how to use svg.el, and I plan to use it mainly to
> plot mathematical functions. Can you recommend me links to blog
> posts/packages/demos/snippets/whatevers that show how to use svg.el?
> My current notes are here:

There is svg.el but I do not like it because:
- it requires gui emacs
- it is not pure, it changes the cons-tree using side-effects

I prefer doing it using pure functions, something like described in

(require 'xml)
      ((xmlns . "";)
       (viewBox . "0 0 100 100"))
       ((cx . "50") (cy . "50") (r . "20"))))))
  (write-file "/tmp/a.svg"))

which you can refactor anyway you like, e.g.

(defun svg (x y w h &rest body)
     ((xmlns . "";)
      (viewBox . ,(format "%s %s %s %s" x y w h)))

(defun svg-circle (cx cy r)
    ((cx . ,(format "%s" cx)
     (cy . ,(format "%s" cy))
     (r . ,(format "%s" r))))))

   (svg 0 0 100 100 (svg-circle 50 50 20)))
  (write-file "/tmp/a.svg"))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]