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

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

Instances

Monad Render Source # 

Methods

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

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

return :: a -> Render a #

fail :: String -> Render a #

Functor Render Source # 

Methods

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

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

Applicative Render Source # 

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

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 

Instances

Monad PSWriter Source # 

Methods

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

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

return :: a -> PSWriter a #

fail :: String -> PSWriter a #

Functor PSWriter Source # 

Methods

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

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

Applicative PSWriter Source # 

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

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

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

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.

arc Source #

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.

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 :: Texture n -> Render () Source #

Set the color of the stroke. Ignore gradients.

strokeColorCMYK :: CMYK -> Render () Source #

Set the color of the stroke.

fillColor :: Texture n -> Render () Source #

Set the color of the fill. Ignore gradients.

fillColorCMYK :: CMYK -> 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.

miterLimit :: Double -> Render () Source #

Set the miter limit.

setDash Source #

Arguments

:: [Double]

Dash pattern (even indices are "on").

-> Double

Offset.

-> Render () 

Set the dash style.

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.

face :: Lens' PostscriptFont String Source #

slant :: Lens' PostscriptFont FontSlant Source #

weight :: Lens' PostscriptFont FontWeight Source #

size :: Lens' PostscriptFont Double Source #

isLocal :: Lens' PostscriptFont Bool Source #

font :: Lens' DrawState PostscriptFont Source #

data CMYK Source #

Constructors

CMYK 

Instances

Eq CMYK Source # 

Methods

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

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

Show CMYK Source # 

Methods

showsPrec :: Int -> CMYK -> ShowS #

show :: CMYK -> String #

showList :: [CMYK] -> ShowS #