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

Maintainerdiagrams-discuss@googlegroups.com
Safe HaskellNone

Diagrams.Backend.Postscript.CmdLine

Description

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.

Synopsis

Documentation

defaultMain :: Diagram Postscript R2 -> IO ()Source

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
   -? --help              Display help message
   -V --version           Print version information

For example, a couple common scenarios include

 $ ghc --make MyDiagram

# output image.png with a width of 400pt (and auto-determined height)
 $ ./MyDiagram -o image.eps -w 400

multiMain :: [(String, Diagram Postscript R2)] -> IO ()Source

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

pagesMain :: [Diagram Postscript R2] -> IO ()Source

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