The diagrams-html5 package

[Tags:bsd3, library]

This package provides a modular backend for rendering diagrams created with the diagrams EDSL using an HTML5 canvas.

[Skip to Readme]


Versions 1.3,,,,,,,, 1.4
Change log
Dependencies base (>=4.7 && <4.10), cmdargs (>=0.6 && <0.11), containers (>=0.3 && <0.6), data-default-class (>=0.0.1 && <0.2), diagrams-core (>=1.3 && <1.5), diagrams-lib (>=1.3 && <1.5), lens (>=4.0 && <4.16), mtl (>=2.0 && <3.0), NumInstances (>=1.0 && <1.5), optparse-applicative (>=0.10 && <0.14), split (==0.2.*), statestack (==0.2.*), static-canvas (==0.2.*), text (>=1.0 && <1.3) [details]
License BSD3
Author Jeffrey Rosenbluth
Stability Experimental
Category Graphics
Home page
Bug tracker
Source repository head: git clone
Uploaded Thu Oct 27 05:22:57 UTC 2016 by BrentYorgey
Distributions LTSHaskell:1.4, NixOS:1.4, Stackage:1.4, Tumbleweed:1.4
Downloads 792 total (17 in the last 30 days)
0 []
Status Docs available [build log]
Last success reported on 2016-10-28 [all 1 reports]




Maintainer's Corner

For package maintainers and hackage trustees

Readme for diagrams-html5

Readme for diagrams-html5-1.4


diagrams-html5 is an HTML5 Canvas backend for diagrams based on the static-canvas package.

diagrams is a powerful, flexible, declarative domain-specific language for creating vector graphics, using the Haskell programming language.


cabal update && cabal install diagrams-html5


A simple example that uses diagrams-html5 to draw a the Sierpinski triangle.


import Diagrams.Prelude
import Diagrams.Backend.Html5.CmdLine

sierpinski 1 = eqTriangle 1
sierpinski n =     s
               (s ||| s) # centerX
  where s = sierpinski (n-1)

example :: Diagram B
example = sierpinski 7 # center # lw none # fc black

main = mainWith $ example # frame 0.1

Save this to file named Sierpinski.hs and compile this program:

ghc Sierpinski.hs

This will generate an executable which, when run creates an html file containing the HTML5 Canvas code to generate the diagram.

$ ./Sierpinski -o sierpinski.html -w 400

You must pass an output file name with a .html extension.

Usage: ./Sierpinksi [-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.