all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Tomas Hlavaty <tom@logand.com>
To: Eduardo Ochs <eduardoochs@gmail.com>
Cc: help-gnu-emacs <help-gnu-emacs@gnu.org>
Subject: Re: Examples of use of svg.el?
Date: Fri, 01 Apr 2022 13:11:35 +0200	[thread overview]
Message-ID: <87bkxlm520.fsf@logand.com> (raw)
In-Reply-To: <CADs++6icdKOEN0fwxmwtM9XvNjwU8P=F+9qVjYgcwoXoq64yrQ@mail.gmail.com>

On Fri 01 Apr 2022 at 04:05, Eduardo Ochs <eduardoochs@gmail.com> 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:
>
>   http://angg.twu.net/2022eev-svg.html

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
id:87ft7zs48u.fsf@logand.com

(require 'xml)
(with-temp-buffer
  (xml-print
   '((svg
      ((xmlns . "http://www.w3.org/2000/svg")
       (viewBox . "0 0 100 100"))
      (circle
       ((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)
  `((svg
     ((xmlns . "http://www.w3.org/2000/svg")
      (viewBox . ,(format "%s %s %s %s" x y w h)))
     ,@body)))

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

(with-temp-buffer
  (xml-print
   (svg 0 0 100 100 (svg-circle 50 50 20)))
  (write-file "/tmp/a.svg"))



  reply	other threads:[~2022-04-01 11:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-01  7:05 Examples of use of svg.el? Eduardo Ochs
2022-04-01 11:11 ` Tomas Hlavaty [this message]
2022-04-01 21:47 ` Michael Heerdegen
2022-04-02  0:12   ` Eduardo Ochs
2022-04-02  1:21     ` Michael Heerdegen
2022-04-02  3:56       ` Michael Heerdegen
2022-04-02 10:46       ` Eduardo Ochs
2022-04-03  4:58         ` Michael Heerdegen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bkxlm520.fsf@logand.com \
    --to=tom@logand.com \
    --cc=eduardoochs@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.