Copyright | (c) 2014 Diagrams team (see LICENSE) |
---|---|
License | BSD-style (see LICENSE) |
Maintainer | diagrams-discuss@googlegroups.com |
Safe Haskell | None |
Language | Haskell2010 |
Convenient creation of command-line-driven executables for rendering diagrams using the Rasterific backend. Create png, tif, bmp, jpg or animated GIF files.
defaultMain
creates an executable which can render a single diagram at various options.multiMain
is likedefaultMain
but allows for a list of diagrams from which the user can choose one to render.animMain
is likedefaultMain
but for animations instead of diagrams.gifMain
creates an executable to generate an animated GIF.mainWith
is a generic form that does all of the above but with a slightly scarier type. See Diagrams.Backend.CmdLine. This form can also take a function type that has a suitable final result (any of arguments to the above types) andParseable
arguments.
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.
- Use a function with
mainWith
. This may require makingParseable
instances for custom argument types. - Make a new
Mainable
instance. This may require a newtype wrapper on your diagram type to avoid the existing instances. This gives you more control over argument parsing, intervening steps, and diagram creation. - Build option records and pass them along with a diagram to
mainRender
from Diagrams.Backend.CmdLine. - You can use
renderRasterific
to render a diagram to a file directly; see Diagrams.Backend.Rasterific. - A more flexible approach is to directly call
renderDia
; see Diagrams.Backend.Rasterific for more information.
For a tutorial on command-line diagram creation see http://projects.haskell.org/diagrams/doc/cmdline.html.
- mainWith :: (Mainable d, Parseable (MainOpts d)) => d -> IO ()
- defaultMain :: Diagram Rasterific -> IO ()
- multiMain :: [(String, Diagram Rasterific)] -> IO ()
- animMain :: Animation Rasterific V2 Double -> IO ()
- gifMain :: [(Diagram Rasterific, GifDelay)] -> IO ()
- data GifOpts = GifOpts {
- _dither :: Bool
- _noLooping :: Bool
- _loopRepeat :: Maybe Int
- data Rasterific
- type B = Rasterific
General form of main
mainWith :: (Mainable d, Parseable (MainOpts d)) => d -> IO () #
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.
Supported forms of main
defaultMain :: Diagram Rasterific -> IO () Source #
animMain :: Animation Rasterific V2 Double -> IO () Source #
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.png
, the frames will be saved in
foo/blah001.png
, foo/blah002.png
, 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.
GIF support
Extra options for animated GIFs.
GifOpts | |
|
Backend tokens
data Rasterific Source #
This data declaration is simply used as a token to distinguish
the Rasterific backend: (1) when calling functions where the type
inference engine would otherwise have no way to know which
backend you wanted to use, and (2) as an argument to the
Backend
and Renderable
type classes.
Eq Rasterific Source # | |
Ord Rasterific Source # | |
Read Rasterific Source # | |
Show Rasterific Source # | |
TypeableFloat n => Backend Rasterific V2 n Source # | |
TypeableFloat n => Renderable (Text n) Rasterific Source # | |
TypeableFloat n => Renderable (DImage n Embedded) Rasterific Source # | |
TypeableFloat n => Renderable (Path V2 n) Rasterific Source # | |
Show n => Show (Options Rasterific V2 n) Source # | |
Monoid (Render Rasterific V2 n) Source # | |
Hashable n => Hashable (Options Rasterific V2 n) Source # | |
type V Rasterific Source # | |
type N Rasterific Source # | |
data Options Rasterific V2 Source # | |
data Render Rasterific V2 Source # | |
type Result Rasterific V2 n Source # | |
type MainOpts [(String, QDiagram Rasterific V2 n Any)] # | |
type MainOpts [(QDiagram Rasterific V2 n Any, GifDelay)] # | |
type MainOpts (Animation Rasterific V2 n) # | |
type MainOpts (QDiagram Rasterific V2 n Any) # | |
type B = Rasterific Source #
Orphan instances
TypeableFloat n => Mainable [(String, QDiagram Rasterific V2 n Any)] Source # | |
TypeableFloat n => Mainable [(QDiagram Rasterific V2 n Any, GifDelay)] Source # | |
TypeableFloat n => Mainable (Animation Rasterific V2 n) Source # | |
TypeableFloat n => Mainable (QDiagram Rasterific V2 n Any) Source # | |