diff options
| author | Lars Ingebrigtsen | 2016-02-19 16:04:11 +1100 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2016-02-19 16:04:11 +1100 |
| commit | 5e8a62917ade3751a328aa90830b51bbed90e15d (patch) | |
| tree | 79f6fe39aff4aebe13d22183399c98213cb17f6d /doc | |
| parent | 466fc43182d1677c107856d4752ef4b6812baefe (diff) | |
| download | emacs-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.texi | 126 |
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 | |||
| 5228 | SVG (Scalable Vector Graphics) is an XML format for specifying images. | ||
| 5229 | If you build Emacs with SVG support, you can create and manipulate | ||
| 5230 | these images with the following commands. | ||
| 5231 | |||
| 5232 | @defun svg-create width height &rest args | ||
| 5233 | Create 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 | ||
| 5238 | The default width (in pixels) of any lines created. | ||
| 5239 | |||
| 5240 | @item :stroke | ||
| 5241 | The default stroke color on any lines created. | ||
| 5242 | @end table | ||
| 5243 | |||
| 5244 | This function returns an SVG structure, and all the following commands | ||
| 5245 | work on that structure. | ||
| 5246 | @end defun | ||
| 5247 | |||
| 5248 | @defun svg-gradient svg id type stops | ||
| 5249 | Create a gradient in @var{svg} with identifier @var{id}. @var{type} | ||
| 5250 | specifies the gradient type, and can be either @code{linear} or | ||
| 5251 | @code{radial}. @var{stops} is a list of percentage/color pairs. | ||
| 5252 | |||
| 5253 | The following will create a linear gradient that goes from red at the | ||
| 5254 | start, 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 | |||
| 5261 | The gradient created (and inserted into the SVG object) can later be | ||
| 5262 | used by all functions that create shapes. | ||
| 5263 | @end defun | ||
| 5264 | |||
| 5265 | All the following functions take an optional list of keyword | ||
| 5266 | parameters that alter the various attributes from their default | ||
| 5267 | values. Valid attributes include: | ||
| 5268 | |||
| 5269 | @table @code | ||
| 5270 | @item :stroke-width | ||
| 5271 | The width (in pixels) of lines drawn, and outlines around solid | ||
| 5272 | shapes. | ||
| 5273 | |||
| 5274 | @item :stroke-color | ||
| 5275 | The color of lines drawn, and outlines around solid shapes. | ||
| 5276 | |||
| 5277 | @item :fill-color | ||
| 5278 | The color used for solid shapes. | ||
| 5279 | |||
| 5280 | @item :id | ||
| 5281 | The identified of the shape. | ||
| 5282 | |||
| 5283 | @item :gradient | ||
| 5284 | If given, this should be the identifier of a previously defined | ||
| 5285 | gradient object. | ||
| 5286 | @end table | ||
| 5287 | |||
| 5288 | @defun svg-rectangle svg x y width height &rest args | ||
| 5289 | Add a rectangle to @var{svg} where the upper left corner is at | ||
| 5290 | position @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 | ||
| 5298 | Add a circle to @var{svg} where the center is at @var{x}/@var{y} | ||
| 5299 | and the radius is @var{radius}. | ||
| 5300 | @end defun | ||
| 5301 | |||
| 5302 | @defun svg-ellipse svg x y x-radius y-radius &rest args | ||
| 5303 | Add a circle to @var{svg} where the center is at @var{x}/@var{y} and | ||
| 5304 | the 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 | ||
| 5309 | Add a line to @var{svg} that starts at @var{x1}/@var{y1} and extends | ||
| 5310 | to @var{x2}/@var{y2}. | ||
| 5311 | @end defun | ||
| 5312 | |||
| 5313 | @defun svg-polyline svg points &rest args | ||
| 5314 | Add 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 | ||
| 5324 | Add a polygon to @var{svg} where @var{points} is a list of X/Y pairs | ||
| 5325 | that 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 | |||
| 5333 | Finally, the @code{svg-image} takes an SVG object as its parameter and | ||
| 5334 | returns an image object suitable for use in functions like | ||
| 5335 | @code{insert-image}. Here's a complete example that creates and | ||
| 5336 | inserts 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 |
| 5257 | Image type @code{png}. | 5380 | Image type @code{png}. |
| 5258 | 5381 | ||
| 5259 | @item SVG | ||
| 5260 | Image type @code{svg}. | ||
| 5261 | |||
| 5262 | @item TIFF | 5382 | @item TIFF |
| 5263 | Image type @code{tiff}. | 5383 | Image type @code{tiff}. |
| 5264 | Supports the @code{:index} property. @xref{Multi-Frame Images}. | 5384 | Supports the @code{:index} property. @xref{Multi-Frame Images}. |