-- 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 1.5 -- | 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 drawState :: Lens' RenderState DrawState -- | Abstraction of the drawing surface details. data Surface -- | Type for a monad that writes Postscript using the commands we will -- define later. -- -- Type for a monad that writes Postscript using the commands we will -- define later. newtype PSWriter m PSWriter :: State Builder m -> PSWriter m [runPSWriter] :: PSWriter m -> State Builder 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] -- | Pure variant of renderWith renderBuilder :: Surface -> Render a -> (Builder, a) -- | Pure variant of renderPagesWith renderPagesBuilder :: Surface -> [Render a] -> (Builder, [a]) -- | Builds a surface and performs an action on that surface. withEPSSurface :: String -> Int -> Int -> (Surface -> r) -> r -- | 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 :: 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. Ignore gradients. strokeColor :: Texture n -> Render () -- | Set the color of the stroke. strokeColorCMYK :: CMYK -> Render () -- | Set the color of the fill. Ignore gradients. fillColor :: Texture n -> Render () -- | Set the color of the fill. fillColorCMYK :: CMYK -> 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 miter limit. miterLimit :: Double -> Render () -- | Set the dash style. setDash :: [Double] -> Double -> 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 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 :: Double -> Double -> Double -> Double -> CMYK [_cyan] :: CMYK -> Double [_magenta] :: CMYK -> Double [_yellow] :: CMYK -> Double [_blacK] :: CMYK -> Double cyan :: Lens' CMYK Double magenta :: Lens' CMYK Double yellow :: Lens' CMYK Double blacK :: Lens' CMYK Double instance Control.Monad.State.Class.MonadState Graphics.Rendering.Postscript.RenderState Graphics.Rendering.Postscript.Render instance GHC.Base.Monad Graphics.Rendering.Postscript.Render instance GHC.Base.Applicative Graphics.Rendering.Postscript.Render instance GHC.Base.Functor Graphics.Rendering.Postscript.Render instance Control.Monad.State.Class.MonadState Data.ByteString.Builder.Internal.Builder Graphics.Rendering.Postscript.PSWriter instance GHC.Base.Monad Graphics.Rendering.Postscript.PSWriter instance GHC.Base.Applicative Graphics.Rendering.Postscript.PSWriter instance GHC.Base.Functor Graphics.Rendering.Postscript.PSWriter instance GHC.Classes.Eq Graphics.Rendering.Postscript.DrawState instance GHC.Show.Show Graphics.Rendering.Postscript.PostscriptFont instance GHC.Classes.Eq Graphics.Rendering.Postscript.PostscriptFont instance GHC.Classes.Eq Graphics.Rendering.Postscript.FontWeight instance GHC.Show.Show Graphics.Rendering.Postscript.FontWeight instance GHC.Classes.Eq Graphics.Rendering.Postscript.FontSlant instance GHC.Show.Show Graphics.Rendering.Postscript.FontSlant instance GHC.Classes.Eq Graphics.Rendering.Postscript.CMYK instance GHC.Show.Show Graphics.Rendering.Postscript.CMYK -- | Support for CMYK color attributes in the Postscript backend. module Diagrams.Backend.Postscript.CMYK data CMYK CMYK :: Double -> Double -> Double -> Double -> CMYK [_cyan] :: CMYK -> Double [_magenta] :: CMYK -> Double [_yellow] :: CMYK -> Double [_blacK] :: CMYK -> Double -- | The color with which lines (strokes) are drawn. Note that child colors -- always override parent colors; that is, lineColorCMYK c1 . -- lineColorCMYK c2 $ d is equivalent to -- lineColorCMYK c2 $ d. More precisely, the semigroup -- structure on line color attributes is that of Last. data LineColorCMYK getLineColorCMYK :: LineColorCMYK -> CMYK mkLineColorCMYK :: CMYK -> LineColorCMYK styleLineColorCMYK :: Setter' (Style v Double) CMYK -- | Set the line (stroke) color. lineColorCMYK :: HasStyle a => CMYK -> a -> a -- | Apply a lineColorCMYK attribute. lineColorCMYKA :: HasStyle a => LineColorCMYK -> a -> a -- | A synonym for lineColorCMYK. lcCMYK :: HasStyle a => CMYK -> a -> a -- | The color with which shapes are filled. Note that child colors always -- override parent colors; that is, fillColorCMYK c1 . -- fillColorCMYK c2 $ d is equivalent to -- lineColorCMYK c2 $ d. More precisely, the semigroup -- structure on fill color attributes is that of Last. data FillColorCMYK getFillColorCMYK :: FillColorCMYK -> CMYK mkFillColorCMYK :: CMYK -> FillColorCMYK styleFillColorCMYK :: Setter' (Style v Double) CMYK -- | Set a "recommended" fill color, to be used only if no explicit calls -- to fillColor (or fc, or fcA) are used. recommendFillColorCMYK :: HasStyle a => CMYK -> a -> a -- | Set the fill color. fillColorCMYK :: HasStyle a => CMYK -> a -> a -- | A synonym for fillColorCMYK fcCMYK :: HasStyle a => CMYK -> a -> a instance GHC.Base.Semigroup Diagrams.Backend.Postscript.CMYK.FillColorCMYK instance GHC.Base.Semigroup Diagrams.Backend.Postscript.CMYK.LineColorCMYK instance Diagrams.Core.Style.AttributeClass Diagrams.Backend.Postscript.CMYK.FillColorCMYK instance Data.Default.Class.Default Diagrams.Backend.Postscript.CMYK.FillColorCMYK instance Diagrams.Core.Style.AttributeClass Diagrams.Backend.Postscript.CMYK.LineColorCMYK instance Data.Default.Class.Default Diagrams.Backend.Postscript.CMYK.LineColorCMYK -- | A Postscript rendering backend for diagrams. -- -- To build diagrams for Postscript rendering use the Postscript -- type in the diagram type construction -- --
--   d :: Diagram Postscript
--   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 type B = Postscript -- | Backend-specific rendering options. data family Options b (v :: Type -> Type) n :: Type psfileName :: Lens' (Options Postscript V2 Double) String psSizeSpec :: Lens' (Options Postscript V2 Double) (SizeSpec V2 Double) psOutputFormat :: Lens' (Options Postscript V2 Double) OutputFormat -- | 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 renderDias :: (Semigroup m, Monoid m) => Options Postscript V2 Double -> [QDiagram Postscript V2 Double m] -> IO [()] instance GHC.Show.Show (Diagrams.Core.Types.Options Diagrams.Backend.Postscript.Postscript Linear.V2.V2 GHC.Types.Double) instance Diagrams.Core.Types.Backend Diagrams.Backend.Postscript.Postscript Linear.V2.V2 GHC.Types.Double instance Data.Default.Class.Default Diagrams.Backend.Postscript.PostscriptState instance GHC.Base.Semigroup (Diagrams.Core.Types.Render Diagrams.Backend.Postscript.Postscript Linear.V2.V2 GHC.Types.Double) instance GHC.Base.Monoid (Diagrams.Core.Types.Render Diagrams.Backend.Postscript.Postscript Linear.V2.V2 GHC.Types.Double) instance Data.Hashable.Class.Hashable (Diagrams.Core.Types.Options Diagrams.Backend.Postscript.Postscript Linear.V2.V2 GHC.Types.Double) instance Diagrams.Core.Types.Renderable (Diagrams.Segment.Segment Diagrams.Segment.Closed Linear.V2.V2 GHC.Types.Double) Diagrams.Backend.Postscript.Postscript instance Diagrams.Core.Types.Renderable (Diagrams.Trail.Trail Linear.V2.V2 GHC.Types.Double) Diagrams.Backend.Postscript.Postscript instance Diagrams.Core.Types.Renderable (Diagrams.Path.Path Linear.V2.V2 GHC.Types.Double) Diagrams.Backend.Postscript.Postscript instance Diagrams.Core.Types.Renderable (Diagrams.TwoD.Text.Text GHC.Types.Double) Diagrams.Backend.Postscript.Postscript instance GHC.Generics.Generic Diagrams.Backend.Postscript.OutputFormat instance GHC.Enum.Bounded Diagrams.Backend.Postscript.OutputFormat instance GHC.Enum.Enum Diagrams.Backend.Postscript.OutputFormat instance GHC.Show.Show Diagrams.Backend.Postscript.OutputFormat instance GHC.Read.Read Diagrams.Backend.Postscript.OutputFormat instance GHC.Classes.Ord Diagrams.Backend.Postscript.OutputFormat instance GHC.Classes.Eq Diagrams.Backend.Postscript.OutputFormat instance GHC.Show.Show Diagrams.Backend.Postscript.Postscript instance GHC.Read.Read Diagrams.Backend.Postscript.Postscript instance GHC.Classes.Ord Diagrams.Backend.Postscript.Postscript instance GHC.Classes.Eq Diagrams.Backend.Postscript.Postscript instance Data.Hashable.Class.Hashable Diagrams.Backend.Postscript.OutputFormat -- | Convenient creation of command-line-driven executables for rendering -- diagrams using the Postscript backend. -- -- -- -- 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. -- -- -- -- For a tutorial on command-line diagram creation see -- http://projects.haskell.org/diagrams/doc/cmdline.html. module Diagrams.Backend.Postscript.CmdLine -- | Main entry point for command-line diagram creation. This is the method -- that users will call from their program main. For instance an -- expected user program would take the following form. -- --
--   import Diagrams.Prelude
--   import Diagrams.Backend.TheBestBackend.CmdLine
--   
--   d :: Diagram B R2
--   d = ...
--   
--   main = mainWith d
--   
-- -- Most backends should be able to use the default implementation. A -- different implementation should be used to handle more complex -- interactions with the user. mainWith :: Mainable d => d -> IO () defaultMain :: QDiagram Postscript V2 Double Any -> IO () multiMain :: [(String, QDiagram Postscript V2 Double Any)] -> IO () pagesMain :: [QDiagram Postscript V2 Double Any] -> 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 V2 Double -> IO () -- | This data declaration is simply used as a token to distinguish this -- rendering engine. data Postscript type B = Postscript instance Diagrams.Backend.CmdLine.Mainable (Diagrams.Core.Types.QDiagram Diagrams.Backend.Postscript.Postscript Linear.V2.V2 GHC.Types.Double Data.Semigroup.Internal.Any) instance Diagrams.Backend.CmdLine.Mainable [(GHC.Base.String, Diagrams.Core.Types.QDiagram Diagrams.Backend.Postscript.Postscript Linear.V2.V2 GHC.Types.Double Data.Semigroup.Internal.Any)] instance Diagrams.Backend.CmdLine.Mainable [Diagrams.Core.Types.QDiagram Diagrams.Backend.Postscript.Postscript Linear.V2.V2 GHC.Types.Double Data.Semigroup.Internal.Any] instance Diagrams.Backend.CmdLine.Mainable (Diagrams.Animation.Animation Diagrams.Backend.Postscript.Postscript Linear.V2.V2 GHC.Types.Double)