diagrams-0.1: An EDSL for creating simple diagrams

Portabilityportable
Stabilityexperimental
Maintainerbyorgey@gmail.com
Safe HaskellNone

Graphics.Rendering.Diagrams.Engine

Contents

Description

The core rendering engine for Graphics.Rendering.Diagrams, an embedded domain-specific language (EDSL) for creating simple diagrams.

Synopsis

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

Arguments

:: Double

output width

-> Double

output height

-> Diagram

Diagram to render

-> Render () 

Given a target width and 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 and height.

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.

writePng :: String -> Int -> Int -> Render () -> IO ()Source

Given a rendered diagram, output it to a .png file with the given width and height.

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.