diagrams-postscript-0.7: Postscript backend for diagrams drawing EDSL

Maintainerdiagrams-discuss@googlegroups.com
Safe HaskellNone

Graphics.Rendering.Postscript

Description

Generic tools for generating Postscript files. There is some limited support for tracking the state of the renderer when given a side-effecting (in the Postscript) command. Only drawing operations are supported, not general Postscript language generation.

In the future the tracking of rendering state could lead to optimizing output, but for now little optimization is attempted. Most systems are equiped with tools to optimize Postscript such as eps2eps.

For details on the PostScript language see the PostScript(R) Language Reference: http://www.adobe.com/products/postscript/pdfs/PLRM.pdf

Synopsis

Documentation

data Render m Source

Type of the monad that tracks the state from side-effecting commands.

data Surface Source

Abstraction of the drawing surface details.

newtype PSWriter m Source

Type for a monad that writes Postscript using the commands we will define later.

Constructors

PSWriter 

renderWith :: MonadIO m => Surface -> Render a -> m aSource

Handles opening and closing the file associated with the passed Surface and renders the commands built up in the Render argument.

renderPagesWith :: MonadIO m => Surface -> [Render a] -> m [a]Source

Renders multiple pages given as a list of Render actions to the file associated with the Surface argument.

withEPSSurface :: String -> Int -> Int -> (Surface -> IO a) -> IO aSource

Builds a surface and performs an action on that surface.

newPath :: Render ()Source

Start a new path.

moveTo :: Double -> Double -> Render ()Source

Move the current point.

lineTo :: Double -> Double -> Render ()Source

Add a line to the current path from the current point to the given point. The current point is also moved with this command.

curveTo :: Double -> Double -> Double -> Double -> Double -> Double -> Render ()Source

Add a cubic Bézier curve segment to the current path from the current point. The current point is also moved with this command.

relLineTo :: Double -> Double -> Render ()Source

Add a line segment to the current path using relative coordinates.

relCurveTo :: Double -> Double -> Double -> Double -> Double -> Double -> Render ()Source

Add a cubic Bézier curve segment to the current path from the current point using relative coordinates.

arcSource

Arguments

:: Double

x-coordinate of center.

-> Double

y-coordiante of center.

-> Double

raidus.

-> Double

start angle in radians.

-> Double

end angle in radians.

-> Render () 

Draw an arc given a center, radius, start, and end angle.

closePath :: Render ()Source

Close the current path.

stroke :: Render ()Source

Stroke the current path.

fill :: Render ()Source

Fill the current path.

fillPreserve :: Render ()Source

Fill the current path without affecting the graphics state.

transform :: Double -> Double -> Double -> Double -> Double -> Double -> Render ()Source

Apply a transform matrix to the current transform.

save :: Render ()Source

Push the current state of the renderer onto the state stack.

restore :: Render ()Source

Replace the current state by popping the state stack.

gsave :: Render ()Source

Push the current graphics state.

grestore :: Render ()Source

Pop the current graphics state.

saveMatrix :: Render ()Source

Push the current transform matrix onto the execution stack.

restoreMatrix :: Render ()Source

Set the current transform matrix to be the matrix found by popping the execution stack.

translate :: Double -> Double -> Render ()Source

Translate the current transform matrix.

scale :: Double -> Double -> Render ()Source

Scale the current transform matrix.

rotate :: Double -> Render ()Source

Rotate the current transform matrix.

strokeColor :: Color c => c -> Render ()Source

Set the color of the stroke.

fillColor :: Color c => c -> Render ()Source

Set the color of the fill.

lineWidth :: Double -> Render ()Source

Set the line width.

lineCap :: LineCap -> Render ()Source

Set the line cap style.

lineJoin :: LineJoin -> Render ()Source

Set the line join method.

setDashSource

Arguments

:: [Double]

Dash pattern (even indices are on).

-> Double

Offset.

-> Render () 

Set the dash style.

setFillRule :: FillRule -> Render ()Source

Set the fill rule.

showText :: String -> Render ()Source

Draw a string at the current point.

showTextCentered :: String -> Render ()Source

Draw a string by first measuring the width then offseting by half.

showTextAlign :: Double -> Double -> String -> Render ()Source

Draw a string with offset factors from center relative to the width and height.

showTextInBox :: (Double, Double) -> (Double, Double) -> String -> Render ()Source

Draw a string uniformally scaling to fit within a bounding box.

clip :: Render ()Source

Clip with the current path.

setFontFace :: String -> Render ()Source

Set the font face.

setFontSlant :: FontSlant -> Render ()Source

Set the font slant.

setFontWeight :: FontWeight -> Render ()Source

Set the font weight.

setFontSize :: Double -> Render ()Source

Set the font size.