-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Postscript backend for diagrams drawing EDSL
--
-- This package provides a modular backend for rendering diagrams created
-- with the diagrams EDSL using Postscript.
--
--
@package diagrams-postscript
@version 0.7
-- | 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
module Graphics.Rendering.Postscript
-- | Type of the monad that tracks the state from side-effecting commands.
data Render m
data RenderState
-- | Abstraction of the drawing surface details.
data Surface
-- | Type for a monad that writes Postscript using the commands we will
-- define later.
newtype PSWriter m
PSWriter :: WriterT (DList String) IO m -> PSWriter m
runPSWriter :: PSWriter m -> WriterT (DList String) IO m
-- | Handles opening and closing the file associated with the passed
-- Surface and renders the commands built up in the Render
-- argument.
renderWith :: 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.
renderPagesWith :: MonadIO m => Surface -> [Render a] -> m [a]
-- | Builds a surface and performs an action on that surface.
withEPSSurface :: String -> Int -> Int -> (Surface -> IO a) -> IO a
-- | Start a new path.
newPath :: Render ()
-- | Move the current point.
moveTo :: 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.
lineTo :: 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.
curveTo :: Double -> Double -> Double -> Double -> Double -> Double -> Render ()
-- | Add a line segment to the current path using relative coordinates.
relLineTo :: Double -> Double -> Render ()
-- | Add a cubic Bézier curve segment to the current path from the current
-- point using relative coordinates.
relCurveTo :: Double -> Double -> Double -> Double -> Double -> Double -> Render ()
-- | Draw an arc given a center, radius, start, and end angle.
arc :: Double -> Double -> Double -> Double -> Double -> Render ()
-- | Close the current path.
closePath :: Render ()
-- | Stroke the current path.
stroke :: Render ()
-- | Fill the current path.
fill :: Render ()
-- | Fill the current path without affecting the graphics state.
fillPreserve :: Render ()
-- | Apply a transform matrix to the current transform.
transform :: Double -> Double -> Double -> Double -> Double -> Double -> Render ()
-- | Push the current state of the renderer onto the state stack.
save :: Render ()
-- | Replace the current state by popping the state stack.
restore :: Render ()
-- | Push the current graphics state.
gsave :: Render ()
-- | Pop the current graphics state.
grestore :: Render ()
-- | Push the current transform matrix onto the execution stack.
saveMatrix :: Render ()
-- | Set the current transform matrix to be the matrix found by popping the
-- execution stack.
restoreMatrix :: Render ()
-- | Translate the current transform matrix.
translate :: Double -> Double -> Render ()
-- | Scale the current transform matrix.
scale :: Double -> Double -> Render ()
-- | Rotate the current transform matrix.
rotate :: Double -> Render ()
-- | Set the color of the stroke.
strokeColor :: Color c => c -> Render ()
-- | Set the color of the fill.
fillColor :: Color c => c -> Render ()
-- | Set the line width.
lineWidth :: Double -> Render ()
-- | Set the line cap style.
lineCap :: LineCap -> Render ()
-- | Set the line join method.
lineJoin :: LineJoin -> Render ()
-- | Set the dash style.
setDash :: [Double] -> Double -> Render ()
-- | Set the fill rule.
setFillRule :: FillRule -> Render ()
-- | Draw a string at the current point.
showText :: String -> Render ()
-- | Draw a string by first measuring the width then offseting by half.
showTextCentered :: String -> Render ()
-- | Draw a string with offset factors from center relative to the width
-- and height.
showTextAlign :: Double -> Double -> String -> Render ()
-- | Draw a string uniformally scaling to fit within a bounding box.
showTextInBox :: (Double, Double) -> (Double, Double) -> String -> Render ()
-- | Clip with the current path.
clip :: Render ()
data FontSlant
FontSlantNormal :: FontSlant
FontSlantItalic :: FontSlant
FontSlantOblique :: FontSlant
FontSlant :: Double -> FontSlant
data FontWeight
FontWeightNormal :: FontWeight
FontWeightBold :: FontWeight
-- | Set the font face.
setFontFace :: String -> Render ()
-- | Set the font slant.
setFontSlant :: FontSlant -> Render ()
-- | Set the font weight.
setFontWeight :: FontWeight -> Render ()
-- | Set the font size.
setFontSize :: Double -> Render ()
instance Functor PSWriter
instance Monad PSWriter
instance MonadWriter (DList String) PSWriter
instance Show FontSlant
instance Eq FontSlant
instance Show FontWeight
instance Eq FontWeight
instance Eq PostscriptFont
instance Show PostscriptFont
instance Eq DrawState
instance Functor Render
instance Monad Render
instance MonadState RenderState Render
-- | A Postscript rendering backend for diagrams.
--
-- To build diagrams for Postscript rendering use the Postscript
-- type in the diagram type construction
--
--
-- d :: Diagram Postscript R2
-- d = ...
--
--
-- and render giving the Postscript token
--
--
-- renderDia Postscript (PostscriptOptions "file.eps" (Width 400) EPS) d
--
--
-- This IO action will write the specified file.
module Diagrams.Backend.Postscript
-- | This data declaration is simply used as a token to distinguish this
-- rendering engine.
data Postscript
Postscript :: Postscript
-- | Backend-specific rendering options.
-- | Postscript only supports EPS style output at the moment. Future
-- formats would each have their own associated properties that affect
-- the output.
data OutputFormat
-- | Encapsulated Postscript output.
EPS :: OutputFormat
instance Typeable Postscript
instance Typeable OutputFormat
instance Eq Postscript
instance Ord Postscript
instance Read Postscript
instance Show Postscript
instance Eq OutputFormat
instance Ord OutputFormat
instance Read OutputFormat
instance Show OutputFormat
instance Enum OutputFormat
instance Bounded OutputFormat
instance Show (Options Postscript R2)
instance Renderable Text Postscript
instance Renderable (Path R2) Postscript
instance Renderable (Trail R2) Postscript
instance Renderable (Segment Closed R2) Postscript
instance MultiBackend Postscript R2
instance Backend Postscript R2
instance Monoid (Render Postscript R2)
-- | Convenient creation of command-line-driven executables for rendering
-- diagrams using the Postscript backend.
--
--
-- - defaultMain creates an executable which can render a single
-- diagram at various options.
-- - multiMain is like defaultMain but allows for a list
-- of diagrams from which the user can choose one to render.
-- - pagesMain is like defaultMain but renders a list of
-- diagrams as pages in a single file.
--
--
-- If you want to generate diagrams programmatically---i.e. if you
-- want to do anything more complex than what the below functions
-- provide---you have several options.
--
--
module Diagrams.Backend.Postscript.CmdLine
-- | This is the simplest way to render diagrams, and is intended to be
-- used like so:
--
--
-- ... other definitions ...
-- myDiagram = ...
--
-- main = defaultMain myDiagram
--
--
-- Compiling a source file like the above example will result in an
-- executable which takes command-line options for setting the size,
-- output file, and so on, and renders myDiagram with the
-- specified options.
--
-- Pass --help to the generated executable to see all available
-- options. Currently it looks something like
--
--
-- Command-line diagram generation.
--
-- Foo [OPTIONS]
--
-- Common flags:
-- -w --width=INT Desired width of the output image
-- -h --height=INT Desired height of the output image
-- -o --output=FILE Output file
-- -f --fpu=FLOAT Frames per unit time (for animations)
-- -? --help Display help message
-- -V --version Print version information
--
--
-- For example, a couple common scenarios include
--
--
-- $ ghc --make MyDiagram
--
-- # output image.eps with a width of 400pt (and auto-determined height)
-- $ ./MyDiagram -o image.eps -w 400
--
defaultMain :: Diagram Postscript R2 -> IO ()
-- | multiMain is like defaultMain, except instead of a
-- single diagram it takes a list of diagrams paired with names as input.
-- The generated executable then takes a --selection option
-- specifying the name of the diagram that should be rendered. The list
-- of available diagrams may also be printed by passing the option
-- --list.
--
-- Example usage:
--
--
-- $ ghc --make MultiTest
-- [1 of 1] Compiling Main ( MultiTest.hs, MultiTest.o )
-- Linking MultiTest ...
-- $ ./MultiTest --list
-- Available diagrams:
-- foo bar
-- $ ./MultiTest --selection bar -o Bar.eps -w 200
--
multiMain :: [(String, Diagram Postscript R2)] -> IO ()
-- | pagesMain is like defaultMain, except instead of a
-- single diagram it takes a list of diagrams and each wil be rendered as
-- a page in the Postscript file.
--
-- Example usage:
--
--
-- $ ghc --make MultiPage
-- [1 of 1] Compiling Main ( MultiPage.hs, MultiPage.o )
-- Linking MultiPage ...
-- $ ./MultiPage -o Pages.ps -w 200
--
pagesMain :: [Diagram Postscript R2] -> IO ()
-- | animMain is like defaultMain, but renders an animation
-- instead of a diagram. It takes as input an animation and produces a
-- command-line program which will crudely "render" the animation by
-- rendering one image for each frame, named by extending the given
-- output file name by consecutive integers. For example if the given
-- output file name is foo/blah.eps, the frames will be saved in
-- foo/blah001.eps, foo/blah002.eps, and so on (the
-- number of padding digits used depends on the total number of frames).
-- It is up to the user to take these images and stitch them together
-- into an actual animation format (using, e.g. ffmpeg).
--
-- Of course, this is a rather crude method of rendering animations; more
-- sophisticated methods will likely be added in the future.
--
-- The --fpu option can be used to control how many frames will
-- be output for each second (unit time) of animation.
animMain :: Animation Postscript R2 -> IO ()
-- | This data declaration is simply used as a token to distinguish this
-- rendering engine.
data Postscript
instance Typeable DiagramOpts
instance Show DiagramOpts
instance Data DiagramOpts