From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Tomas Hlavaty Newsgroups: gmane.emacs.help Subject: Re: Examples of use of svg.el? Date: Fri, 01 Apr 2022 13:11:35 +0200 Message-ID: <87bkxlm520.fsf@logand.com> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40208"; mail-complaints-to="usenet@ciao.gmane.io" Cc: help-gnu-emacs To: Eduardo Ochs Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Fri Apr 01 13:12:47 2022 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1naFCx-000AIG-Hv for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 01 Apr 2022 13:12:47 +0200 Original-Received: from localhost ([::1]:44544 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1naFCw-0001GN-Hm for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 01 Apr 2022 07:12:46 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:50548) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1naFC4-0001F1-Rz for help-gnu-emacs@gnu.org; Fri, 01 Apr 2022 07:11:54 -0400 Original-Received: from logand.com ([37.48.87.44]:48612) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1naFC1-0000Zo-Nv for help-gnu-emacs@gnu.org; Fri, 01 Apr 2022 07:11:52 -0400 Original-Received: by logand.com (Postfix, from userid 1001) id B0C6C19FD6F; Fri, 1 Apr 2022 13:11:37 +0200 (CEST) X-Mailer: emacs 27.2 (via feedmail 11-beta-1 I) In-Reply-To: Received-SPF: pass client-ip=37.48.87.44; envelope-from=tom@logand.com; helo=logand.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:136821 Archived-At: 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: > > 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"))