diagrams-svg: SVG backend for diagrams drawing EDSL.

[ bsd3, graphics, library ] [ Propose Tags ] [ Report a vulnerability ]

This package provides a modular backend for rendering diagrams created with the diagrams EDSL to SVG files. It uses svg-builder to be a native Haskell backend, making it suitable for use on any platform.

The package provides the following modules:

Additional documentation can be found in the README file distributed with the source tarball or viewable on GitHub: https://github.com/diagrams/diagrams-svg/blob/master/README.md.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.3, 0.3.1, 0.3.2, 0.3.3, 0.3.4, 0.3.5, 0.3.7, 0.6, 0.6.0.1, 0.7, 0.8, 0.8.0.1, 0.8.0.2, 1.0, 1.0.1, 1.0.1.1, 1.0.1.2, 1.0.1.3, 1.0.2, 1.0.2.1, 1.1, 1.1.0.1, 1.1.0.2, 1.1.0.3, 1.1.0.4, 1.1.0.5, 1.3, 1.3.1, 1.3.1.1, 1.3.1.2, 1.3.1.3, 1.3.1.4, 1.3.1.5, 1.3.1.6, 1.3.1.7, 1.3.1.8, 1.3.1.9, 1.3.1.10, 1.4, 1.4.0.1, 1.4.0.2, 1.4.0.3, 1.4.0.4, 1.4.1, 1.4.1.1, 1.4.2, 1.4.3, 1.4.3.1, 1.4.3.2 (info)
Change log CHANGELOG.md
Dependencies base (>=4.7 && <4.21), base64-bytestring (>=1 && <1.3), bytestring (>=0.9 && <1.0), colour (>=2.3 && <2.4), containers (>=0.3 && <0.8), diagrams-core (>=1.4 && <1.6), diagrams-lib (>=1.4.5 && <1.5), filepath (>=1.4 && <1.6), hashable (>=1.1 && <1.6), JuicyPixels (>=3.1.5 && <3.4), lens (>=4.0 && <5.4), monoid-extras (>=0.3 && <0.7), mtl (>=1 && <2.4), optparse-applicative (>=0.13 && <0.19), semigroups (>=0.13 && <0.21), split (>=0.1.2 && <0.3), svg-builder (>=0.1 && <0.2), text (>=0.11 && <2.2) [details]
Tested with ghc ==8.4.4 || ==8.6.5 || ==8.8.4 || ==8.10.7 || ==9.0.2 || ==9.2.8 || ==9.4.8 || ==9.6.5 || ==9.8.2 || ==9.10.1
License BSD-3-Clause
Author Felipe Lessa, Deepak Jois
Maintainer diagrams-discuss@googlegroups.com
Category Graphics
Home page https://diagrams.github.io/
Bug tracker http://github.com/diagrams/diagrams-svg/issues
Source repo head: git clone http://github.com/diagrams/diagrams-svg
Uploaded by BrentYorgey at 2024-08-27T12:29:43Z
Distributions Debian:1.4.3, LTSHaskell:1.4.3.2, NixOS:1.4.3.2, Stackage:1.4.3.2
Reverse Dependencies 22 direct, 33 indirect [details]
Downloads 61095 total (259 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2024-08-27 [all 1 reports]

Readme for diagrams-svg-1.4.3.2

[back to package description]

diagrams-svg Hackage Build Status)

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>