Module documentation for 188.8.131.52
diagrams-svg is the default out-of-the box backend that comes with the diagrams framework, and supports most features defined in diagrams-lib.
cabal update && cabal install diagrams-svg
A simple example that uses diagrams-svg to draw a square.
import Diagrams.Prelude import Diagrams.Backend.SVG.CmdLine b1 = square 20 # lw 0.002 main = mainWith (pad 1.1 b1)
Save this to file named
Square.hs and compile this program:
ghc --make Square.hs
This will generate an executable which, when run produces an SVG file. Run the
executable with the
--help option to find out more about how to call it.
$ ./Square --help ./Square Usage: ./Square [-w|--width WIDTH] [-h|--height HEIGHT] [-o|--output OUTPUT] [--loop] [-s|--src ARG] [-i|--interval INTERVAL] Command-line diagram generation. Available options: -?,--help Show this help text -w,--width WIDTH Desired WIDTH of the output image -h,--height HEIGHT Desired HEIGHT of the output image -o,--output OUTPUT OUTPUT file -l,--loop Run in a self-recompiling loop -s,--src ARG Source file to watch -i,--interval INTERVAL When running in a loop, check for changes every INTERVAL seconds.
You must pass an output file name with a
.svg extension to generate the SVG
$ ./Square -o square.svg
The command above generates the SVG file:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="22.0" height="22.0" viewBox="0 0 22 22"> <g> <g stroke="rgb(0,0,0)" stroke-opacity="1.0" fill="rgb(0,0,0)" fill-opacity="0.0" stroke-width="2.0e-3"> <path d="M 21.0,21.0 l -2.220446049250313e-15,-20.0 h -20.0 l -2.220446049250313e-15,20.0 Z" /> </g> </g> </svg>
184.108.40.206 (07 December 2014)
220.127.116.11 (17 November 2014)
18.104.22.168 (22 August 2014)
1.1 (27 May 2014)
Support for radial and linear gradients.
Support for embedded images in
Updates to work with
Substantial refactoring of
Backendinstance to support changes in
- New dependencies:
- New dependencies:
22.214.171.124 (19 March 2014)
1.0.2 (8 March 2014)
- Support for including hyperlinks.
splitFillsto properly render certain diagrams with mixed lines and filled loops. Previously, in certain situations loops that should have been filled were not. (#43)
Don’t emit last segment of a loop if it is linear.
See diagrams-cairo#38. This wasn’t actually causing any observable problems in the SVG backend output, but this seems a better/more robust way to do things in any case.
126.96.36.199 (6 February 2014)
- require diagrams-lib >= 1.0.1 (for Hashable SizeSpec2D instance)
188.8.131.52 (4 February 2014)
- Allow `blaze-markup-0.6`
184.108.40.206 (30 January 2014)
- Work around a bug in GHC 7.4.2, which chokes when deriving Generic instances for associated data types.
1.0.1 (26 January 2014)
- Add `Hashable (Options SVG R2)` instance - Remove `Show (Options SVG R2)` instance According to the PVP, these changes should require a major version bump. However, a major version bump would be quite annoying and I don't expect these instance changes to affect anyone (the changes were made for internal reasons). Please yell if it does affect you.
1.0 (24 November 2013)
- Re-implement via new backend `RTree` interface, leading to smaller output files. - Use new command-line interface from `diagrams-lib`. - Export `B` as an alias for `SVG` token
0.8.0.2 (26 October 2013)
- Documentation improvements
0.8.0.1: 11 September 2013
- require diagrams-lib-0.7.1
0.8: 10 September 2013 [BROKEN]
- Extra SVG definitions, to be inserted in the output, may be passed as an argument
- Support for new miter limit attribute
- Approximate text alignment
- Stacking multiple clip regions now works properly
0.7: 9 August 2013
- Vastly improved Haddock documentation
Options SVG R2
- Upgrade to
0.6.0.1: 14 December 2012
- Fix link to README on Hackage page
0.6: 11 December 2012
First “officially supported” release.
Features still not implemented:
- text alignment
- inline images
As of this release everything else Should Work (tm).