unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#32359: [PATCH] Add svg-path
@ 2018-08-03 11:07 Felix E. Klee
  2018-08-03 13:05 ` Eli Zaretskii
  0 siblings, 1 reply; 27+ messages in thread
From: Felix E. Klee @ 2018-08-03 11:07 UTC (permalink / raw)
  To: 32359

[-- Attachment #1: Type: text/plain, Size: 215 bytes --]

The patch adds `svg-path'. Among other things, this function makes it
possible to add arcs to SVG images. A path is drawn using commands
defined by the SVG standard:

https://www.w3.org/TR/SVG11/paths.html#PathData

[-- Attachment #2: add-svg-path.patch --]
[-- Type: application/octet-stream, Size: 1784 bytes --]

diff --git a/ChangeLog.3 b/ChangeLog.3
index a0a4794b4e..2a9832b67b 100644
--- a/ChangeLog.3
+++ b/ChangeLog.3
@@ -1,3 +1,7 @@
+2018-08-03  Felix E. Klee  <felix.klee@inka.de>
+
+	* lisp/svg.el (svg-path): New function.
+
 2018-07-01  Paul Eggert  <eggert@cs.ucla.edu>
 
 	* etc/HISTORY: Cite Brinkhoff on early history.
diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi
index fef5188197..d45f68d95b 100644
--- a/doc/lispref/display.texi
+++ b/doc/lispref/display.texi
@@ -5541,6 +5541,19 @@ that describe the outer circumference of the polygon.
 @end lisp
 @end defun
 
+@defun svg-path svg commands &rest args
+Add the outline of a shape to @var{svg}. The @var{commands} follow the
+Scalable Vector Graphics standard. This function can be used to create
+arcs.
+
+@lisp
+(svg-path svg '((M 100 300)
+                (A 300 300 0 0 0 300 100)
+                (Z))
+          :stroke-color "blue" :fill-color "yellow")
+@end lisp
+@end defun
+
 @defun svg-text svg text &rest args
 Add a text to @var{svg}.
 
diff --git a/lisp/svg.el b/lisp/svg.el
index 1178905546..e5c4e1383a 100644
--- a/lisp/svg.el
+++ b/lisp/svg.el
@@ -138,6 +138,17 @@ POINTS is a list of x/y pairs."
 			    ", "))
       ,@(svg--arguments svg args)))))
 
+(defun svg-path (svg commands &rest args)
+  "Add the outline of a shape to SVG. The COMMANDS follow the
+Scalable Vector Graphics standard. This function can be used to
+create arcs."
+  (let ((d (mapconcat 'prin1-to-string (apply 'append commands) " ")))
+    (svg--append
+     svg
+     (dom-node 'path
+	       `((d . ,d)
+	         ,@(svg--arguments svg args))))))
+
 (defun svg-embed (svg image image-type datap &rest args)
   "Insert IMAGE into the SVG structure.
 IMAGE should be a file name if DATAP is nil, and a binary string

^ permalink raw reply related	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2019-08-02 11:57 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-03 11:07 bug#32359: [PATCH] Add svg-path Felix E. Klee
2018-08-03 13:05 ` Eli Zaretskii
2018-08-23 15:50   ` Felix E. Klee
2018-08-23 17:23     ` Eli Zaretskii
2018-08-24  9:15       ` Felix E. Klee
2019-06-23 22:15     ` Lars Ingebrigtsen
2019-06-24 14:32       ` Felix E. Klee
2019-06-24 14:39         ` Lars Ingebrigtsen
2019-07-12 14:35           ` Felix E. Klee
2019-07-12 16:02             ` Lars Ingebrigtsen
2019-07-15 13:34               ` Felix E. Klee
2019-07-15 15:12                 ` Lars Ingebrigtsen
2019-07-15 20:40                   ` Felix E. Klee
2019-07-15 20:48                     ` Noam Postavsky
2019-07-16 10:32                       ` Felix E. Klee
2019-07-15 21:13                     ` Felix E. Klee
2019-07-16  6:05                     ` Lars Ingebrigtsen
2019-07-16 10:31                       ` Felix E. Klee
2019-07-16 13:46                         ` Lars Ingebrigtsen
2019-07-24  7:49                           ` Felix E. Klee
2019-07-24 14:30                             ` Eli Zaretskii
2019-07-30 17:46                           ` Felix E. Klee
2019-07-31 20:31                             ` Lars Ingebrigtsen
2019-08-01 13:23                               ` Felix E. Klee
2019-08-02  6:40                                 ` Eli Zaretskii
2019-08-02 10:43                                   ` Felix E. Klee
2019-08-02 11:57                                     ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).