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

Copyright(c) 2013 diagrams team (see LICENSE)
LicenseBSD-style (see LICENSE)
Maintainerdiagrams-discuss@googlegroups.com
Safe HaskellNone
LanguageHaskell2010

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 #

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

Instances

Monad Render # 

Methods

(>>=) :: Render a -> (a -> Render b) -> Render b #

(>>) :: Render a -> Render b -> Render b #

return :: a -> Render a #

fail :: String -> Render a #

Functor Render # 

Methods

fmap :: (a -> b) -> Render a -> Render b #

(<$) :: a -> Render b -> Render a #

Applicative Render # 

Methods

pure :: a -> Render a #

(<*>) :: Render (a -> b) -> Render a -> Render b #

(*>) :: Render a -> Render b -> Render b #

(<*) :: Render a -> Render b -> Render a #

MonadState RenderState Render # 

data Surface #

Abstraction of the drawing surface details.

newtype PSWriter m #

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

Constructors

PSWriter 

Instances

Monad PSWriter # 

Methods

(>>=) :: PSWriter a -> (a -> PSWriter b) -> PSWriter b #

(>>) :: PSWriter a -> PSWriter b -> PSWriter b #

return :: a -> PSWriter a #

fail :: String -> PSWriter a #

Functor PSWriter # 

Methods

fmap :: (a -> b) -> PSWriter a -> PSWriter b #

(<$) :: a -> PSWriter b -> PSWriter a #

Applicative PSWriter # 

Methods

pure :: a -> PSWriter a #

(<*>) :: PSWriter (a -> b) -> PSWriter a -> PSWriter b #

(*>) :: PSWriter a -> PSWriter b -> PSWriter b #

(<*) :: PSWriter a -> PSWriter b -> PSWriter a #

MonadWriter (DList String) PSWriter # 

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

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] #

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 a #

Builds a surface and performs an action on that surface.

newPath :: Render () #

Start a new path.

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

Move the current point.

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

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 () #

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 () #

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

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

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

arc #

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 () #

Close the current path.

stroke :: Render () #

Stroke the current path.

fill :: Render () #

fillPreserve :: Render () #

Fill the current path without affecting the graphics state.

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

Apply a transform matrix to the current transform.

save :: Render () #

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

restore :: Render () #

Replace the current state by popping the state stack.

gsave :: Render () #

Push the current graphics state.

grestore :: Render () #

Pop the current graphics state.

saveMatrix :: Render () #

Push the current transform matrix onto the execution stack.

restoreMatrix :: Render () #

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

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

Translate the current transform matrix.

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

Scale the current transform matrix.

rotate :: Double -> Render () #

Rotate the current transform matrix.

strokeColor :: Texture n -> Render () #

Set the color of the stroke. Ignore gradients.

strokeColorCMYK :: CMYK -> Render () #

Set the color of the stroke.

fillColor :: Texture n -> Render () #

Set the color of the fill. Ignore gradients.

fillColorCMYK :: CMYK -> Render () #

Set the color of the fill.

lineWidth :: Double -> Render () #

Set the line width.

lineCap :: LineCap -> Render () #

Set the line cap style.

lineJoin :: LineJoin -> Render () #

Set the line join method.

miterLimit :: Double -> Render () #

Set the miter limit.

setDash #

Arguments

:: [Double]

Dash pattern (even indices are "on").

-> Double

Offset.

-> Render () 

Set the dash style.

showText :: String -> Render () #

Draw a string at the current point.

showTextCentered :: String -> Render () #

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

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

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

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

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

clip :: Render () #

Clip with the current path.

face :: Lens' PostscriptFont String #

slant :: Lens' PostscriptFont FontSlant #

weight :: Lens' PostscriptFont FontWeight #

size :: Lens' PostscriptFont Double #

isLocal :: Lens' PostscriptFont Bool #

fillRule :: Lens' DrawState FillRule #

font :: Lens' DrawState PostscriptFont #

data CMYK #

Constructors

CMYK 

Instances

Eq CMYK # 

Methods

(==) :: CMYK -> CMYK -> Bool #

(/=) :: CMYK -> CMYK -> Bool #

Show CMYK # 

Methods

showsPrec :: Int -> CMYK -> ShowS #

show :: CMYK -> String #

showList :: [CMYK] -> ShowS #