diagrams-cairo- Cairo backend for diagrams drawing EDSL

Safe HaskellSafe-Infered



Convenient creation of command-line-driven executables for rendering diagrams using the cairo backend.



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

This is the simplest way to render diagrams, and is intended to be used like so:

 ... definitions ...

 main = defaultMain myDiagram

Compiling this file will result in an executable which takes various command-line options for setting the size, output file, and so on, and renders myDiagram with the specified options.

On Unix systems, the generated executable also supports a rudimentary "looped" mode, which watches the source file for changes and recompiles itself on the fly.

Pass --help to the generated executable to see all available options.

multiMain :: [(String, Diagram Cairo 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 an argument specifying the name of the diagram that should be rendered. This is a convenient way to create an executable that can render many different diagrams without modifying the source code in between each one.

animMain :: Animation Cairo R2 -> IO ()Source

animMain takes 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.

data Cairo Source

This data declaration is simply used as a token to distinguish this rendering engine.