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

Copyright(c) 2010 - 2014 diagrams-canvas team (see LICENSE)
LicenseBSD-style (see LICENSE)
Safe HaskellNone



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 ->

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



data Canvas Source #

This data declaration is simply used as a token to distinguish this rendering engine.




Eq Canvas Source # 


(==) :: Canvas -> Canvas -> Bool #

(/=) :: Canvas -> Canvas -> Bool #

Ord Canvas Source # 
Read Canvas Source # 
Show Canvas Source # 
Backend Canvas V2 Double Source # 
Renderable (Text Double) Canvas Source # 
Renderable (DImage Double External) Canvas Source # 
Renderable (Path V2 Double) Canvas Source # 
Renderable (Trail V2 Double) Canvas Source # 
Monoid (Render Canvas V2 Double) Source # 
Renderable (Segment Closed V2 Double) Canvas Source # 
type V Canvas Source # 
type V Canvas = V2
type N Canvas Source # 
type N Canvas = Double
data Options Canvas V2 Double Source # 
type Result Canvas V2 Double Source # 
data Render Canvas V2 Double Source # 
data Render Canvas V2 Double = C (RenderM ())
type MainOpts [(String, QDiagram Canvas V2 Double Any)] # 
type MainOpts (QDiagram Canvas V2 Double Any) # 

type B = Canvas Source #

data family Options b (v :: * -> *) n :: * #

Backend-specific rendering options.