diagrams-0.2.1.3: An EDSL for creating simple diagramsSource codeContentsIndex
Graphics.Rendering.Diagrams.Engine
Portabilityportable
Stabilityexperimental
Maintainerbyorgey@gmail.com
Contents
Preprocessing
Rendering
User interface
Internals
Description
The core rendering engine for Graphics.Rendering.Diagrams, an embedded domain-specific language (EDSL) for creating simple diagrams.
Synopsis
sizeAndPos :: Diagram -> (Point, Diagram)
compose :: SizeSpec -> Diagram -> (Point, Render ())
writePNG :: String -> Point -> Render () -> IO ()
writePS :: String -> Point -> Render () -> IO ()
writePDF :: String -> Point -> Render () -> IO ()
writeSVG :: String -> Point -> Render () -> IO ()
renderWithBackend :: (String -> Point -> Render () -> IO ()) -> String -> SizeSpec -> Diagram -> IO ()
renderOverlayPNG :: FilePath -> FilePath -> Diagram -> IO ()
chooseBackend :: OutputType -> String -> Point -> Render () -> IO ()
writePagesPS :: String -> [(Point, Render ())] -> IO ()
writePagesPDF :: String -> [(Point, Render ())] -> IO ()
renderPagesWithBackend :: (String -> [(Point, Render ())] -> IO ()) -> String -> SizeSpec -> [Diagram] -> IO ()
choosePagesBackend :: OutputType -> String -> [(Point, Render ())] -> IO ()
atomic :: DiaRenderM () -> DiaRenderM ()
render :: Diagram -> DiaRenderM ()
Preprocessing
These functions take a user-generated Diagram object and preprocess it in preparation for final rendering. The preprocessing includes calculating diagram sizes and positioning diagrams by the addition of appropriate translate annotations.
sizeAndPos :: Diagram -> (Point, Diagram)Source
Given a Diagram, compute its total size, and produce a new version of the Diagram with all sub-Diagrams positioned properly.
Rendering
The rendering code takes a Diagram and turns it into actual graphics output, using the Cairo library to perform the low-level drawing operations.
User interface
composeSource
:: SizeSpecoutput width or height
-> DiagramDiagram to render
-> (Point, Render ())Output width and height, and Cairo action to render it

Given a target width or height and a user-constructed Diagram, render it using the Cairo rendering library. Note that compose takes care of all the rendering details, including preprocessing of the Diagram, and scaling/translating the final output so that it fits within the given width or height. compose also produces the size of the final diagram; the width or height will be equal to that specified in the input, and the other dimension will be determined by the aspect ratio of the diagram.

The background of the output diagram will be opaque white.

In order to produce a physical output, the output of compose must be given as input to an output adapter such as writePng. Normally, however, a user of the diagrams library should not need to call compose directly.

writePNG :: String -> Point -> Render () -> IO ()Source
Given a rendered diagram, output it to a file in PNG format with the given width and height.
writePS :: String -> Point -> Render () -> IO ()Source
Given a rendered diagram, output it to a file in PostScript format with the given width and height.
writePDF :: String -> Point -> Render () -> IO ()Source
Given a rendered diagram, output it to a file in PDF format with the given width and height.
writeSVG :: String -> Point -> Render () -> IO ()Source
Given a rendered diagram, output it to a file in SVG format with the given width and height.
renderWithBackendSource
:: String -> Point -> Render () -> IO ()backend
-> Stringfile name
-> SizeSpecoutput size specification
-> Diagramthe diagram to render
-> IO ()
Given a file name, an output size specification, and a Diagram, use a "backend" to render the Diagram to an actual physical output.
renderOverlayPNG :: FilePath -> FilePath -> Diagram -> IO ()Source
chooseBackend :: OutputType -> String -> Point -> Render () -> IO ()Source
writePagesPS :: String -> [(Point, Render ())] -> IO ()Source
Given a list of rendered diagrams with their height and width, output them as separate pages to a file in PostScript format
writePagesPDF :: String -> [(Point, Render ())] -> IO ()Source
Given a list of rendered diagrams with their height and width, output them as separate pages to a file in DFt format
renderPagesWithBackend :: (String -> [(Point, Render ())] -> IO ()) -> String -> SizeSpec -> [Diagram] -> IO ()Source
Given a file name, an output size specification, and a list of Diagrams, use a "backend" to render the Diagrams as separate pages to an actual physical output.
choosePagesBackend :: OutputType -> String -> [(Point, Render ())] -> IO ()Source
Internals
atomic :: DiaRenderM () -> DiaRenderM ()Source
Perform a rendering operation atomically, by saving the state and restoring it afterwards.
render :: Diagram -> DiaRenderM ()Source
Render a diagram.
Produced by Haddock version 2.6.0