]> code.delx.au - gnu-emacs-elpa/blobdiff - packages/svg/svg.el
svg requires dom.el, and therefore Emacs 25
[gnu-emacs-elpa] / packages / svg / svg.el
index aa5b0764ed839040312a872b540c3c282bcbdba1..7b14ee545388ced143012b0147613ae1a76ca65d 100644 (file)
@@ -5,6 +5,7 @@
 ;; Maintainer: Lars Magne Ingebrigtsen <larsi@gnus.org>
 ;; Keywords: image
 ;; Version: 0.1
+;; Package-Requires: ((emacs "25"))
 
 ;; This program is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
 
 ;;; Commentary:
 
+;; This pacakge allows creating SVG images in Emacs.  SVG images are
+;; vector-based XML files, really, so you could create them directly
+;; as XML.  However, that's really tedious, as there are some fiddly
+;; bits.
+
+;; In addition, the `svg-insert-image' function allows inserting an
+;; SVG image into a buffer that's updated "on the fly" as you
+;; add/alter elements to the image, which is useful when composing the
+;; images.
+
+;; Here are some usage examples:
+
+;; Create the base image structure, add a gradient spec, and insert it
+;; into the buffer:
+;; (setq svg (svg-create 800 800 :stroke "orange" :stroke-width 5))
+;; (svg-gradient svg "gradient" 'linear '(0 . "red") '(100 . "blue"))
+;; (save-excursion (goto-char (point-max)) (svg-insert-image svg))
+
+;; Then add various elements to the structure:
+;; (svg-rectangle svg 100 100 500 500 :gradient "gradient" :id "rec1")
+;; (svg-circle svg 500 500 100 :id "circle1")
+;; (svg-ellipse svg 100 100 50 90 :stroke "red" :id "ellipse1")
+;; (svg-line svg 100 190 50 100 :id "line1" :stroke "yellow")
+;; (svg-polyline svg '((200 . 100) (500 . 450) (80 . 100))
+;;           :stroke "green" :id "poly1")
+;; (svg-polygon svg '((100 . 100) (200 . 150) (150 . 90))
+;;          :stroke "blue" :fill "red" :id "gon1")
+
 ;;; Code:
 
 (require 'cl-lib)
@@ -100,8 +129,8 @@ X/Y denote the center of the ellipse."
    svg
    (dom-node 'line
             `((x1 . ,x1)
-              (x2 . ,y1)
-              (y1 . ,x2)
+              (y1 . ,y1)
+              (x2 . ,x2)
               (y2 . ,y2)
               ,@(svg-arguments svg args)))))