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 | |
Ord Canvas | |
Read Canvas | |
Show Canvas | |
Typeable * Canvas | |
Backend Canvas V2 Double | |
Mainable [(String, QDiagram Canvas V2 Double Any)] | |
Renderable (Text Double) Canvas | |
Renderable (DImage Double External) Canvas | |
Renderable (Path V2 Double) Canvas | |
Renderable (Trail V2 Double) Canvas | |
Monoid (Render Canvas V2 Double) | |
Renderable (Segment Closed V2 Double) Canvas | |
Mainable (QDiagram Canvas V2 Double Any) | |
type V Canvas = V2 | |
type N Canvas = Double | |
data Options Canvas V2 Double = CanvasOptions {} | |
type Result Canvas V2 Double = Canvas () | |
data Render Canvas V2 Double = C (RenderM ()) | |
type MainOpts [(String, QDiagram Canvas V2 Double Any)] = (MainOpts (QDiagram Canvas V2 Double Any), DiagramMultiOpts) | |
type MainOpts (QDiagram Canvas V2 Double Any) |
data family Options b v n
Backend-specific rendering options.
data Options NullBackend | |
data Options Canvas V2 Double = CanvasOptions {} |