aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorLars Ingebrigtsen2016-02-19 16:04:11 +1100
committerLars Ingebrigtsen2016-02-19 16:04:11 +1100
commit5e8a62917ade3751a328aa90830b51bbed90e15d (patch)
tree79f6fe39aff4aebe13d22183399c98213cb17f6d /doc
parent466fc43182d1677c107856d4752ef4b6812baefe (diff)
downloademacs-5e8a62917ade3751a328aa90830b51bbed90e15d.tar.gz
emacs-5e8a62917ade3751a328aa90830b51bbed90e15d.zip
Add a library for creating and manipulating SVG images
* doc/lispref/display.texi (SVG Images): New section. * lisp/svg.el: New file.
Diffstat (limited to 'doc')
-rw-r--r--doc/lispref/display.texi126
1 files changed, 123 insertions, 3 deletions
diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi
index 26f3de40e91..17025cd1994 100644
--- a/doc/lispref/display.texi
+++ b/doc/lispref/display.texi
@@ -4761,6 +4761,7 @@ displayed (@pxref{Display Feature Testing}).
4761* XPM Images:: Special features for XPM format. 4761* XPM Images:: Special features for XPM format.
4762* PostScript Images:: Special features for PostScript format. 4762* PostScript Images:: Special features for PostScript format.
4763* ImageMagick Images:: Special features available through ImageMagick. 4763* ImageMagick Images:: Special features available through ImageMagick.
4764* SVG Images:: Creating and manipulating SVG images.
4764* Other Image Types:: Various other formats are supported. 4765* Other Image Types:: Various other formats are supported.
4765* Defining Images:: Convenient ways to define an image for later use. 4766* Defining Images:: Convenient ways to define an image for later use.
4766* Showing Images:: Convenient ways to display an image once it is defined. 4767* Showing Images:: Convenient ways to display an image once it is defined.
@@ -5220,6 +5221,128 @@ Specifies a rotation angle in degrees.
5220@xref{Multi-Frame Images}. 5221@xref{Multi-Frame Images}.
5221@end table 5222@end table
5222 5223
5224@node SVG Images
5225@subsection SVG Images
5226@cindex SVG images
5227
5228SVG (Scalable Vector Graphics) is an XML format for specifying images.
5229If you build Emacs with SVG support, you can create and manipulate
5230these images with the following commands.
5231
5232@defun svg-create width height &rest args
5233Create a new, empty SVG image with the specified dimensions.
5234@var{args} is an argument plist with you can specify following:
5235
5236@table @code
5237@item :stroke-width
5238The default width (in pixels) of any lines created.
5239
5240@item :stroke
5241The default stroke color on any lines created.
5242@end table
5243
5244This function returns an SVG structure, and all the following commands
5245work on that structure.
5246@end defun
5247
5248@defun svg-gradient svg id type stops
5249Create a gradient in @var{svg} with identifier @var{id}. @var{type}
5250specifies the gradient type, and can be either @code{linear} or
5251@code{radial}. @var{stops} is a list of percentage/color pairs.
5252
5253The following will create a linear gradient that goes from red at the
5254start, to green 25% of the way, to blue at the end:
5255
5256@lisp
5257(svg-gradient svg "gradient1" 'linear
5258 '((0 . "red") (25 . "green") (100 . "blue")))
5259@end lisp
5260
5261The gradient created (and inserted into the SVG object) can later be
5262used by all functions that create shapes.
5263@end defun
5264
5265All the following functions take an optional list of keyword
5266parameters that alter the various attributes from their default
5267values. Valid attributes include:
5268
5269@table @code
5270@item :stroke-width
5271The width (in pixels) of lines drawn, and outlines around solid
5272shapes.
5273
5274@item :stroke-color
5275The color of lines drawn, and outlines around solid shapes.
5276
5277@item :fill-color
5278The color used for solid shapes.
5279
5280@item :id
5281The identified of the shape.
5282
5283@item :gradient
5284If given, this should be the identifier of a previously defined
5285gradient object.
5286@end table
5287
5288@defun svg-rectangle svg x y width height &rest args
5289Add a rectangle to @var{svg} where the upper left corner is at
5290position @var{x}/@var{y} and is of size @var{width}/@var{height}.
5291
5292@lisp
5293(svg-rectangle svg 100 100 500 500 :gradient "gradient1")
5294@end lisp
5295@end defun
5296
5297@defun svg-circle svg x y radius &rest args
5298Add a circle to @var{svg} where the center is at @var{x}/@var{y}
5299and the radius is @var{radius}.
5300@end defun
5301
5302@defun svg-ellipse svg x y x-radius y-radius &rest args
5303Add a circle to @var{svg} where the center is at @var{x}/@var{y} and
5304the horizontal radius is @var{x-radius} and the vertical radius is
5305@var{y-radius}.
5306@end defun
5307
5308@defun svg-line svg x1 y1 x2 y2 &rest args
5309Add a line to @var{svg} that starts at @var{x1}/@var{y1} and extends
5310to @var{x2}/@var{y2}.
5311@end defun
5312
5313@defun svg-polyline svg points &rest args
5314Add a multiple segment line to @var{svg} that goes through
5315@var{points}, which is a list of X/Y position pairs.
5316
5317@lisp
5318(svg-polyline svg '((200 . 100) (500 . 450) (80 . 100))
5319 :stroke-color "green")
5320@end lisp
5321@end defun
5322
5323@defun svg-polygon svg points &rest args
5324Add a polygon to @var{svg} where @var{points} is a list of X/Y pairs
5325that describe the outer circumference of the polygon.
5326
5327@lisp
5328(svg-polygon svg '((100 . 100) (200 . 150) (150 . 90))
5329 :stroke-color "blue" :fill-color "red"")
5330@end lisp
5331@end defun
5332
5333Finally, the @code{svg-image} takes an SVG object as its parameter and
5334returns an image object suitable for use in functions like
5335@code{insert-image}. Here's a complete example that creates and
5336inserts an image with a circle:
5337
5338@lisp
5339(let ((svg (svg-create 400 400 :stroke-width 10)))
5340 (svg-gradient svg "gradient1" 'linear '((0 . "red") (100 . "blue")))
5341 (svg-circle svg 200 200 100 :gradient "gradient1" :stroke-color "green")
5342 (insert-image (svg-image svg)))
5343@end lisp
5344
5345
5223@node Other Image Types 5346@node Other Image Types
5224@subsection Other Image Types 5347@subsection Other Image Types
5225@cindex PBM 5348@cindex PBM
@@ -5256,9 +5379,6 @@ Image type @code{jpeg}.
5256@item PNG 5379@item PNG
5257Image type @code{png}. 5380Image type @code{png}.
5258 5381
5259@item SVG
5260Image type @code{svg}.
5261
5262@item TIFF 5382@item TIFF
5263Image type @code{tiff}. 5383Image type @code{tiff}.
5264Supports the @code{:index} property. @xref{Multi-Frame Images}. 5384Supports the @code{:index} property. @xref{Multi-Frame Images}.