diagrams-canvas-1.3: HTML5 canvas backend for diagrams drawing EDSL

Copyright(c) 2010 - 2014 diagrams-canvas team (see LICENSE)
LicenseBSD-style (see LICENSE)
Maintainerdiagrams-discuss@googlegroups.com
Safe HaskellNone
LanguageHaskell2010

Diagrams.Backend.Canvas

Description

A full-featured rendering backend for diagrams using Canvas. Implemented using the blank-canvas platform.

To invoke the Canvas backend, you have three options.

  • You can use the Diagrams.Backend.Canvas.CmdLine module to create standalone executables which will display the diagram in a browser using a web service.
  • You can use the renderCanvas function provided by this module, which gives you more programmatic control over when and how images are displayed (making it east to, for example, write a single program that displays multiple images, or one that diaplays images dynamically based on user input, and so on).
  • For the most flexiblity you can invoke the renderDia method from Backend instance for Canvas. In particular, renderDia has the generic type
renderDia :: b -> Options b v -> QDiagram b v m -> Result b v

(omitting a few type class contraints). b represents the backend type, v the vector space, and m the type of monoidal query annotations on the diagram. Options and Result are associated data and type families, respectively, which yield the type of option records and rendering results specific to any particular backend. For b ~ Canvas and v ~ R2, we have

data Options Canvas V2 Double = CanvasOptions
 { _size :: SizeSpec V2 -- ^^ The requested size
 }
data family Render Canvas V2 Double = C (RenderM ())
type family Result Canvas V2 Double = Canvas ()

So the type of renderDia resolves to

renderDia :: Canvas -> Options Canvas V2 Double -> QDiagram Canvas V2 Double m ->
Canvas()

which you could call like renderDia Canvas (CanvasOptions (width 250)) myDiagram

Synopsis

Documentation

type B = Canvas Source

data family Options b v n

Backend-specific rendering options.