Copyright | (c) 2010 - 2014 diagrams-canvas team (see LICENSE) |
---|---|
License | BSD-style (see LICENSE) |
Maintainer | diagrams-discuss@googlegroups.com |
Safe Haskell | None |
Language | Haskell2010 |
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 fromBackend
instance forCanvas
. 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
Documentation
This data declaration is simply used as a token to distinguish this rendering engine.
Eq Canvas Source # | |
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 N Canvas Source # | |
data Options Canvas V2 Double Source # | |
type Result Canvas V2 Double Source # | |
data Render Canvas V2 Double Source # | |
type MainOpts [(String, QDiagram Canvas V2 Double Any)] # | |
type MainOpts (QDiagram Canvas V2 Double Any) # | |