diagrams-svg
SVG backend for diagrams drawing EDSL.
Version on this page: | 1.4.3.1@rev:5 |
LTS Haskell 22.40: | 1.4.3.2 |
Stackage Nightly 2024-11-08: | 1.4.3.2 |
Latest on Hackage: | 1.4.3.2 |
diagrams-svg-1.4.3.1@sha256:de76d7ffc218d2f4e5106541ebec92042abe0a814fbc04d4a1b13866d3de1202,3139
Module documentation for 1.4.3.1
- Diagrams
- Diagrams.Backend
diagrams-svg
diagrams-svg is a an SVG backend for diagrams. Diagrams is a powerful, flexible, declarative domain-specific language for creating vector graphics, using the Haskell programming language.
diagrams-svg is the default out-of-the box backend that comes with the diagrams framework, and supports most features defined in diagrams-lib.
Installation
cabal update && cabal install diagrams-svg
Usage
A simple example that uses diagrams-svg to draw a square.
import Diagrams.Prelude
import Diagrams.Backend.SVG.CmdLine
b1 :: Diagram B
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.
-p,--pretty Pretty print the SVG output
You must pass an output file name with a .svg
extension to generate the SVG
file.
$ ./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>
Changes
v1.4.3.1 (2021-12-28)
- Dependency upper bounds updates to allow:
base-4.16
(GHC 9.2)lens-5.1
hashable-1.4
semigroups-0.20
- Add
Eq
instance forOptions SVG
and (orphan)Eq
instance forElement
v1.4.3-r3 (2021-06-08)
Dependency upper bounds updates, to allow:
base-4.15
(GHC 9.0)base64-bytestring-1.2
diagrams-core-1.5
monoid-extras-0.6
lens-5.0
optparse-applicative-0.16
v1.4.3 (2019-12-10)
- Allow
base-4.13
(GHC 8.8),lens-4.18
,semigroups-0.19
,hashable-1.3
,optparse-applicative-0.15
- Stop rounding the coordinates of the viewbox (#109)
- New
svgClass
,svgId
, andsvgTitle
functions for setting SVG attributes via annotations
v1.4.2 (2018-05-09)
- Allow
base-4.11
(GHC 8.4) andlens-4.16
- Add
Semigroup (Render SVG V2 n)
instance
v1.4.1.1 (2017-08-23)
- Allow
base-4.10
andoptparse-applicative-0.14
- Fix gradients applied to text (#98)
v1.4.1 (2016-10-26)
- Handle wider range of font weight specifications
- allow
lens-4.15
v1.4.0.4 (2016-08-22)
- Require
optparse-applicative-0.13
, and fix compilation error
v1.4.0.3 (2016-08-16)
- Allow
optparse-applicative-0.13
v1.4.0.2 (2016-06-06)
- allow
base-4.9
- test with GHC 8.0
- minor documentation updates
v1.4.0.1 (2016-05-01)
- allow
lens-4.14
v1.4 (2016-02-14)
– Changes for svg-builder
– Deprecate svgId
and svgClass
v1.3.1.8 (2015-11-14)
- allow
lucid-svg-0.6
v1.3.1.7 (2015-11-10)
- allow
semigroups-0.18
v1.3.1.6 (2015-09-29)
- allow
optparse-applicative-0.12
v1.3.1.5 (2015-09-19)
- allow
lens-4.13
andsemigroups-0.17
v1.3.1.4 (2015-07-19)
v1.3.1.3 (2015-07-09)
- Changes to allow
lucid-svg-0.5
v1.3.1.2 (2015-05-26)
v1.3.1.1 (2015-05-06)
Bug Fix: handle empty dashing array properly (#80)
v1.3.1 (2015-04-30)
API Changes
- Type of
SVGOptions
changed._svgDefinitions :: Maybe SvgM
Internal Changes
- Use
ReaderT
for styles
v1.3 (2015-04-19)
New features
-
User settable ID prefixes
-
Support opacity group
-
Fix clipping bug (Issue #70)
Internal Changes
-
Switch rendering engine from
blaze-svg
tolucid-svg
-
Use
fsnotify
for looping -
Add defs tags for clips and gradients
Implemented enhancements:
- Put
clip path
,gradients
, etc in defs tag. #73
Fixed bugs:
Merged pull requests:
-
Allow user to set ID prefixes #71 (mightybyte)
-
Lucid #69 (jeffreyrosenbluth)
v1.1.0.5 (2015-04-03)
-
allow
lens-4.9
-
allow
vector-space-0.10
-
allow
blaze-markup-0.7
v1.1.0.4 (2015-01-13)
v1.1.0.3 (2014-12-07)
v1.1.0.2 (2014-11-17)
Fixed bugs:
- Font scaling uses “em” units. #30
Merged pull requests:
-
Bump lens upper version bounds #65 (RyanGlScott)
-
Allows us to write
Diagram B
instead ofDiagram B V2 Double/Float/Whatever
in diagrams programs #62 (jeffreyrosenbluth)
v1.1.0.1 (2014-08-22)
Closed issues:
- Embedding JPEG images without repacking #57
Merged pull requests:
-
Add loadImageSVG to support JPEG-images without repacking via Native DImages #58 (taruti)
-
Allow svg output file to be pretty printed #56 (jeffreyrosenbluth)
v1.1 (2014-06-02)
New features
-
Support for radial and linear gradients.
-
Support for embedded images in
.png
format.
New instances
Renderable
instances forDImage Embedded
.
API changes
-
Updates to work with
Measure
units. -
Substantial refactoring of
Backend
instance to support changes inDiagrams.Core
.
Dependency/version changes
-
New dependencies:
base64-bytestring
andJuicyPixels
. -
Allow
lens-4.2
-
Allow
mtl-2.2
Closed issues:
-
Support hyperlinks #48
-
Line width not handled properly by some browsers #33
-
implement image embedding #11
Merged pull requests:
-
Embedded images - png working #54 (jeffreyrosenbluth)
-
Preliminary implementation of Measure #46 (jeffreyrosenbluth)
-
Gradient #41 (jeffreyrosenbluth)
v1.0.2.1 (2014-03-19)
v1.0.2 (2014-03-09)
New features
- Support for including hyperlinks.
Dependency/version changes
-
Allow
diagrams-core-1.1
anddiagrams-lib-1.1
-
Allow
lens-4.0
Bug fixes
-
Use
splitFills
to 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.
Closed issues:
- SVG backend doesn’t fill loops if they occur in the same subtree as a line #43
Merged pull requests:
v1.0.1.3 (2014-02-06)
v1.0.1.2 (2014-02-04)
v1.0.1.1 (2014-01-30)
v1.0.1 (2014-01-26)
Merged pull requests:
v1.0 (2013-11-25)
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.
Fixed bugs:
- SVG backend fills lines again #42
v0.8.0.2 (2013-10-26)
Closed issues:
Merged pull requests:
-
Lens #40 (jeffreyrosenbluth)
v0.8.0.1 (2013-09-11)
v0.8 (2013-09-10)
New features
-
Extra SVG definitions, to be inserted in the output, may be passed as an argument
-
Support for new miter limit attribute
-
Approximate text alignment
Bug fixes
- Stacking multiple clip regions now works properly
Merged pull requests:
v0.7 (2013-08-09)
New features
-
New
renderToSVG
convenience function -
Vastly improved Haddock documentation
New instances
Show
instance forOptions SVG R2
Dependency/version changes
-
allow
base-4.7
andunix-2.7
-
Upgrade to
monoid-extras-0.3
Implemented enhancements:
- Improve Haddock documentation #27
Fixed bugs:
- Lines should not be filled #35
Closed issues:
-
diagrams-svg.cabal out of sync with core and lib #34
-
Add function of type FilePath -> SizeSpec2D -> Diagram -> IO () #28
Merged pull requests:
v0.6.0.1 (2012-12-14)
v0.6 (2012-12-12)
First “officially supported” release.
Features still not implemented:
-
text alignment
-
inline images
As of this release everything else Should Work (tm).
Closed issues:
-
Line width does not follow specification? #24
-
diagrams-svg doesn’t build under directory-1.2 (and hence GHC-7.6) #20
-
Freezing does not appear to work with the SVG backend #19
-
Font family support #18
-
Fill color needs to be explicitly specified for text nodes #15
-
Implement clipping #14
-
Add README, documentation and generate documentation on Hackage #13
-
implement text attributes #10
-
implement text rendering #9
-
implement line cap #8
-
implement line dashing #7
-
Implement line join attribute #6
-
Implement opacity #5
-
Implement fill rule #4
-
Switch to using blaze-svg combinators #2
-
Create a new branch for using blaze-svg #1
Merged pull requests:
* This Change Log was automatically generated by (and hand edited) github_changelog_generator