Copyright | (c) 2015 Jeffrey Rosenbluth |
---|---|
License | BSD-style (see LICENSE) |
Maintainer | diagrams-discuss@googlegroups.com |
Safe Haskell | None |
Language | Haskell2010 |
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 fromBackend
instance forHtml5
. 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 -> Html5()
which you could call like renderDia Html5 (Html5Options (width 250))
myDiagram
- data Html5 = Html5
- type B = Html5
- data family Options b (v :: * -> *) n :: *
- renderHtml5 :: FilePath -> SizeSpec V2 Double -> QDiagram Html5 V2 Double Any -> IO ()
- size :: Lens' (Options Html5 V2 Double) (SizeSpec V2 Double)
- canvasId :: Lens' (Options Html5 V2 Double) String
- standalone :: Lens' (Options Html5 V2 Double) Bool
Documentation
This data declaration is simply used as a token to distinguish this rendering engine.
Eq Html5 Source # | |
Ord Html5 Source # | |
Read Html5 Source # | |
Show Html5 Source # | |
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 N Html5 Source # | |
data Options Html5 V2 Double Source # | |
type Result Html5 V2 Double Source # | |
data Render Html5 V2 Double Source # | |
type MainOpts [(String, QDiagram Html5 V2 Double Any)] # | |
type MainOpts (QDiagram Html5 V2 Double Any) # | |