Copyright | (c) 2013 diagrams team (see LICENSE) |
---|---|
License | BSD-style (see LICENSE) |
Maintainer | diagrams-discuss@googlegroups.com |
Safe Haskell | None |
Language | Haskell2010 |
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
- data Render m
- data RenderState
- drawState :: Lens' RenderState DrawState
- data Surface
- newtype PSWriter m = PSWriter {
- runPSWriter :: WriterT (DList String) IO m
- renderWith :: MonadIO m => Surface -> Render a -> m a
- renderPagesWith :: MonadIO m => Surface -> [Render a] -> m [a]
- withEPSSurface :: String -> Int -> Int -> (Surface -> IO a) -> IO a
- newPath :: Render ()
- moveTo :: Double -> Double -> Render ()
- lineTo :: Double -> Double -> Render ()
- curveTo :: Double -> Double -> Double -> Double -> Double -> Double -> Render ()
- relLineTo :: Double -> Double -> Render ()
- relCurveTo :: Double -> Double -> Double -> Double -> Double -> Double -> Render ()
- arc :: Double -> Double -> Double -> Double -> Double -> Render ()
- closePath :: Render ()
- stroke :: Render ()
- fill :: Render ()
- fillPreserve :: Render ()
- transform :: Double -> Double -> Double -> Double -> Double -> Double -> Render ()
- save :: Render ()
- restore :: Render ()
- gsave :: Render ()
- grestore :: Render ()
- saveMatrix :: Render ()
- restoreMatrix :: Render ()
- translate :: Double -> Double -> Render ()
- scale :: Double -> Double -> Render ()
- rotate :: Double -> Render ()
- strokeColor :: Texture n -> Render ()
- strokeColorCMYK :: CMYK -> Render ()
- fillColor :: Texture n -> Render ()
- fillColorCMYK :: CMYK -> Render ()
- lineWidth :: Double -> Render ()
- lineCap :: LineCap -> Render ()
- lineJoin :: LineJoin -> Render ()
- miterLimit :: Double -> Render ()
- setDash :: [Double] -> Double -> Render ()
- showText :: String -> Render ()
- showTextCentered :: String -> Render ()
- showTextAlign :: Double -> Double -> String -> Render ()
- showTextInBox :: (Double, Double) -> (Double, Double) -> String -> Render ()
- clip :: Render ()
- data FontSlant
- data FontWeight
- 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 = CMYK {}
- cyan :: Lens' CMYK Double
- magenta :: Lens' CMYK Double
- yellow :: Lens' CMYK Double
- blacK :: Lens' CMYK Double
Documentation
Type of the monad that tracks the state from side-effecting commands.
drawState :: Lens' RenderState DrawState Source #
Type for a monad that writes Postscript using the commands we will define later.
withEPSSurface :: String -> Int -> Int -> (Surface -> IO a) -> IO a Source #
Builds a surface and performs an action on that surface.
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.
:: 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.
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.
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.
strokeColor :: Texture n -> Render () Source #
Set the color of the stroke. Ignore gradients.
strokeColorCMYK :: CMYK -> Render () Source #
Set the color of the stroke.
fillColorCMYK :: CMYK -> Render () Source #
Set the color of the fill.
miterLimit :: Double -> Render () Source #
Set the miter limit.
Set the dash style.
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.
data FontWeight Source #
weight :: Lens' PostscriptFont FontWeight Source #