Copyright | (c) 2014 diagrams-rasterific 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 Rasterific, implemented natively in Haskell (making it easy to use on any platform). Can create png, tif, bmp, jpg, and animated GIFs.
To invoke the Rasterific backend, you have three options.
- You can use the Diagrams.Backend.Rasterific.CmdLine module to create standalone executables which output images when invoked.
- You can use the
renderRasterific
function provided by this module, which gives you more flexible programmatic control over when and how images are output (making it easy to, for example, write a single program that outputs multiple images, or one that outputs images dynamically based on user input, and so on). - For the most flexibility (e.g. if you want access to the
resulting Rasterific value directly in memory without writing it to
disk), you can manually invoke the
renderDia
method from theBackend
instance forRasterific
. In particular,renderDia
has the generic type
renderDia :: b -> Options b v -> QDiagram b v m -> Result b v
(omitting a few type class constraints). 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 ~ Rasterific
and v ~ R2
, we have
data Options Rasterific R2 = RasterificOptions { _rasterificSizeSpec :: SizeSpec2D -- ^ The requested size of the output , _rasterificBypassAdjust :: Bool -- ^ Should the 'adjustDia' step be bypassed during rendering? }
data family Render Rasterific R2 = 'R (RenderM ())'
type family Result Rasterific R2 = 'Image PixelRGBA8'
So the type of renderDia
resolves to
renderDia :: Rasterific -> Options Rasterific R2 -> QDiagram Rasterific R2 m -> 'Image PixelRGBA8'
which you could call like renderDia Rasterific (RasterificOptions (Width 250))
myDiagram
.
- data Rasterific = Rasterific
- type B = Rasterific
- data family Options b v
- renderRasterific :: FilePath -> SizeSpec2D -> Word8 -> Diagram Rasterific R2 -> IO ()
- size :: Lens' (Options Rasterific R2) SizeSpec2D
- writeJpeg :: Word8 -> FilePath -> Result Rasterific R2 -> IO ()
Documentation
data Rasterific
This data declaration is simply used as a token to distinguish
the Rasterific backend: (1) when calling functions where the type
inference engine would otherwise have no way to know which
backend you wanted to use, and (2) as an argument to the
Backend
and Renderable
type classes.
Eq Rasterific | |
Ord Rasterific | |
Read Rasterific | |
Show Rasterific | |
Typeable * Rasterific | |
Backend Rasterific R2 | |
Renderable Text Rasterific | |
Mainable [(String, Diagram Rasterific R2)] | |
Mainable [(Diagram Rasterific R2, GifDelay)] | |
Renderable (DImage Embedded) Rasterific | |
Renderable (Path R2) Rasterific | |
Show (Options Rasterific R2) | |
Monoid (Render Rasterific R2) | |
Mainable (Diagram Rasterific R2) | |
Mainable (Animation Rasterific R2) | |
data Options Rasterific R2 = RasterificOptions {
| |
type Result Rasterific R2 = Image PixelRGBA8 | |
data Render Rasterific R2 = R (RenderM ()) | |
type MainOpts [(String, Diagram Rasterific R2)] = (MainOpts (Diagram Rasterific R2), DiagramMultiOpts) | |
type MainOpts [(Diagram Rasterific R2, GifDelay)] = (DiagramOpts, GifOpts) | |
type MainOpts (Diagram Rasterific R2) = (DiagramOpts, DiagramLoopOpts) | |
type MainOpts (Animation Rasterific R2) = (MainOpts (Diagram Rasterific R2), DiagramAnimOpts) |
type B = Rasterific
data family Options b v
Backend-specific rendering options.
Show (Options Rasterific R2) | |
data Options NullBackend | |
data Options Rasterific R2 = RasterificOptions {
|
renderRasterific :: FilePath -> SizeSpec2D -> Word8 -> Diagram Rasterific R2 -> IO ()
size :: Lens' (Options Rasterific R2) SizeSpec2D