diagrams-cairo: Cairo backend for diagrams drawing EDSL

[ bsd3, graphics, library ] [ Propose Tags ] [ Report a vulnerability ]

A full-featured backend for rendering diagrams using the cairo rendering engine.

This ultimately depends on a C library, via Haskell's FFI, and can be difficult to install on some platforms. If you are just looking for a quick way to visualize diagrams, try the diagrams-svg backend; if you want raster output like PNG, try the diagrams-rasterific backend; if you want to embed diagrams in LaTeX documents, try diagrams-pgf.


[Skip to Readme]

Modules

[Last Documentation]

  • Diagrams
    • Backend
      • Diagrams.Backend.Cairo
        • Diagrams.Backend.Cairo.CmdLine
        • Diagrams.Backend.Cairo.Internal
        • Diagrams.Backend.Cairo.List
        • Diagrams.Backend.Cairo.Ptr
        • Diagrams.Backend.Cairo.Text

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1, 0.1.1, 0.1.2, 0.2, 0.3, 0.4, 0.5, 0.5.0.1, 0.5.0.2, 0.6, 0.7, 1.0, 1.0.1, 1.0.1.1, 1.0.1.2, 1.1, 1.1.0.1, 1.1.0.2, 1.2, 1.2.0.1, 1.2.0.2, 1.2.0.3, 1.2.0.4, 1.2.0.5, 1.2.0.6, 1.2.0.7, 1.3, 1.3.0.1, 1.3.0.2, 1.3.0.3, 1.3.0.4, 1.3.0.5, 1.3.0.6, 1.3.1, 1.3.1.1, 1.3.1.2, 1.4, 1.4.1, 1.4.1.1, 1.4.2, 1.4.2.1, 1.4.3
Change log CHANGELOG.md
Dependencies array (>=0.4.0 && <0.6), base (>=4.2 && <4.21), bytestring (>=0.9 && <0.12 || >=0.12.0 && <0.13), cairo (>=0.12.4 && <0.14), colour, containers (>=0.3 && <0.8), data-default (>=0.8 && <0.9), diagrams-core (>=1.3 && <1.6), diagrams-lib (>=1.3 && <1.5), filepath, hashable (>=1.1 && <1.6), JuicyPixels (>=3.1.3.2 && <3.4), lens (>=3.8 && <5.4), mtl (>=2.0 && <2.4), optparse-applicative (>=0.13 && <0.19), pango (>=0.12.5 && <0.14), split (>=0.1.2 && <0.3), statestack (>=0.2 && <0.4), transformers (>=0.3 && <0.7), unix (>=2.4 && <2.9), vector (>=0.10.0 && <0.14) [details]
Tested with ghc ==8.8.4 || ==8.10.7 || ==9.0.2 || ==9.2.8 || ==9.4.8 || ==9.6.5 || ==9.8.2 || ==9.10.1
License BSD-3-Clause
Author Brent Yorgey
Maintainer diagrams-discuss@googlegroups.com
Category Graphics
Home page https://diagrams.github.io
Bug tracker http://github.com/diagrams/diagrams-cairo/issues
Source repo head: git clone http://github.com/diagrams/diagrams-cairo.git
Uploaded by BrentYorgey at 2024-11-06T19:34:54Z
Distributions Debian:1.4.1.1, LTSHaskell:1.4.2.1, NixOS:1.4.2.1, Stackage:1.4.3
Reverse Dependencies 25 direct, 21 indirect [details]
Downloads 40409 total (77 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
All reported builds failed as of 2024-11-06 [all 2 reports]

Readme for diagrams-cairo-1.4.3

[back to package description]

Build Status

diagrams-cairo is a rendering backend for diagrams, a powerful, flexible, declarative domain-specific language for creating vector graphics, using the Haskell programming language.

diagrams-cairo is implemented using the cairo rendering engine and is a fully-featured, officially supported backend for diagrams.

Installation

cabal update && cabal install gtk2hs-buildtools diagrams-cairo

Basic usage

A simple example that uses diagrams-cairo to draw a blue circle:

{-# LANGUAGE NoMonomorphismRestriction #-}
{-# LANGUAGE FlexibleContexts          #-}
{-# LANGUAGE TypeFamilies              #-}

import Diagrams.Prelude
import Diagrams.Backend.Cairo.CmdLine

d :: Diagram B
d = circle 1 # fc blue

main = mainWith (pad 1.1 d)

Save this to file named Circle.hs and compile it:

ghc --make Circle.hs

This will generate an executable which, when run, outputs a blue circle to some file. Run the executable with the --help option to find out more about how to call it.

$ ./Circle --help
./Circle

Usage: ./Circle [-w|--width WIDTH] [-h|--height HEIGHT] [-o|--output OUTPUT]
                [--loop] [-s|--src ARG] [-i|--interval INTERVAL]
  Command-line diagram generation.

Available options:
  -?,--help                Show this help text
  -w,--width WIDTH         Desired WIDTH of the output image
  -h,--height HEIGHT       Desired HEIGHT of the output image
  -o,--output OUTPUT       OUTPUT file
  -l,--loop                Run in a self-recompiling loop
  -s,--src ARG             Source file to watch
  -i,--interval INTERVAL   When running in a loop, check for changes every INTERVAL seconds.
ommand-line diagram generation.

The output type will be automatically determined from the file extension. Currently PNG, PDF, PS, and SVG are supported.

$ ./Circle -o circle.png -w 400

The command above generates a PNG file with a width of 400px.

Advanced usage

Instead of just creating a standalone executable, the cairo backend can also be called from within a larger program. For more information, see the Diagram.Backend.Cairo module.