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

Copyright(c) 2015 Jeffrey Rosenbluth
LicenseBSD-style (see LICENSE)
Safe HaskellNone




A full-featured rendering backend for diagrams using HTML5 Canvas. Implemented using the static-canvas package.

To invoke the Html5 backend, you have three options.

  • You can use the Diagrams.Backend.Html5.CmdLine module to create standalone executables which will display the diagram in a browser using a web service.
  • You can use the renderHtml5 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 Html5. 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 ~ Html5 and v ~ R2, we have

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

So the type of renderDia resolves to

renderDia :: Html5 -> Options Html5 V2 Double -> QDiagram Html5 V2 Double m ->

which you could call like renderDia Html5 (Html5Options (width 250)) myDiagram



data Html5 Source #

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




Eq Html5 Source # 


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

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

Ord Html5 Source # 


compare :: Html5 -> Html5 -> Ordering #

(<) :: Html5 -> Html5 -> Bool #

(<=) :: Html5 -> Html5 -> Bool #

(>) :: Html5 -> Html5 -> Bool #

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

max :: Html5 -> Html5 -> Html5 #

min :: Html5 -> Html5 -> Html5 #

Read Html5 Source # 
Show Html5 Source # 


showsPrec :: Int -> Html5 -> ShowS #

show :: Html5 -> String #

showList :: [Html5] -> ShowS #

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

type B = Html5 Source #

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

Backend-specific rendering options.


canvasId :: Lens' (Options Html5 V2 Double) String Source #

"id" for the canvas element (prepended to "StaticCanvas"). Only applies to non-standalone diagrams.

standalone :: Lens' (Options Html5 V2 Double) Bool Source #

Should the output be a standalone html file. Otherwise the output is a canvas element followed by a script calling the canvas.