diagrams-cairo
Cairo backend for diagrams drawing EDSL
Version on this page: | 1.4.2.1@rev:3 |
LTS Haskell 23.1: | 1.4.2.1@rev:3 |
Stackage Nightly 2024-12-27: | 1.4.3 |
Latest on Hackage: | 1.4.3 |
diagrams-cairo-1.4.2.1@sha256:04c30395165bcea5ab6cf8dcfa00cd555fdff8bc45cb9a8d07872ff3cb3cbde1,3846
Module documentation for 1.4.2.1
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.
Changes
v1.4.2.1 (2023-07-10)
- Allow
base-4.18
,mtl-2.3
,optparse-applicative-0.18
,unix-2.8
- Test with GHC 9.4 and 9.6
v1.4.2 (2022-01-26)
-
Test with GHC 9.0 (requires
--allow-newer
) -
Allow
base-4.15
,lens-5.1
,bytestring-0.11
,transformers-0.6
,hashable-1.4
-
Add
Eq Options
instance required forHashable
-
r1 (6 Feb 2022): allow
optparse-applicative-0.17
-
r2 (19 Aug 2022): allow
vector-0.13
-
r3 (4 Jan 2023): allow
lens-5.2
, test with GHC 9.2, drop official support for GHC < 8.8
v1.4.1.1 (2019-01-11)
-
Drop GHC 7.10 and 8.0 support
-
Test with GHC 8.6 and 8.8
-
r1: allow
lens-4.19
andlinear-1.21
-
r2: allow
base-4.14
,diagrams-core-1.5
,lens-5.0
,optparse-applicative-0.16
v1.4.1 (2018-05-17)
- Allow
base-4.11
andlens-4.16
- Add
Semigroup
instance forRender Cairo V2 Double
- Drop GHC 7.8 support
v1.4 (2016-10-26)
-
No significant changes, just bumping version for diagrams 1.4 release
-
Allow
vector-0.12
(Hackage revision 1) -
Allow
base-4.10
andoptparse-applicative-0.14
(Hackage rev 2)
v1.3.1.2 (2016-08-22)
- Require
optparse-applicative-0.13
and fix compilation error
v1.3.1.1 (2016-08-16)
- Allow
optparse-applicative-0.13
v1.3.1 (2016-06-16)
-
Bump upper bounds to allow:
base-4.9
data-default-class-0.1
transformers-0.5.x
-
New module
Diagrams.Backend.Cairo.Text
with better text support (based onpango
)
v1.3.0.6 (2016-05-01)
- allow
lens-4.14
- New module
Diagrams.Backend.Cairo.Text
(should have been minor version bump; if you want to depend on this module please usediagrams-cairo-1.3.1
or later).
v1.3.0.5 (2015-09-29)
- Allow
optparse-applicative-0.12
v1.3.0.4 (2015-09-17)
- Allow
lens-4.13
v1.3.0.3 (2015-07-19)
v1.3.0.2 (2015-05-26)
v1.3.0.1(2015-04-25)
Fixed bug:
- Reflection should be included in transformation returned by adjustDia #63
v1.3(2015-04-19)
- allow
lens-4.9
- update for
diagrams-1.3
v1.2.0.7 (2015-04-04)
Fixed bugs:
- loop when rendering text #59
Merged pull requests:
[v1.2.0.6] () (2015-01-12)
- allow
lens-4.7
v1.2.0.5 (2014-12-25)
v1.2.0.4 (2014-11-17)
Closed issues:
- expose gifRender #55
Merged pull requests:
-
Bump lens upper version bounds #58 (RyanGlScott)
-
Diagram B #56 (jeffreyrosenbluth)
v1.2.0.3 (2014-10-08)
Fixed bugs:
- –loop disables generating multiple files #50
Merged pull requests:
v1.2.0.2-1 (2014-09-08)
v1.2.0.2 (2014-09-07)
v1.2.0.1 (2014-08-22)
Closed issues:
- Problems with yellow color in gif animation #51
v1.2 (2014-06-02)
New features
-
Much improved text support using the
pango
library instead of cairo’s “toy” text API. -
Support for linear and radial gradients on strokes and fills.
Fixed bugs:
- textLineBoundedIO sometimes produces incorrect envelopes #19
Closed issues:
- Mac OS X/XQuartz: Can’t render single letter #43
Merged pull requests:
-
DImage implemented #47 (jeffreyrosenbluth)
-
Units #46 (jeffreyrosenbluth)
-
Gradient #37 (jeffreyrosenbluth)
v1.1.0.1 (2014-03-19)
v1.1 (2014-03-09)
New features
- It is now possible to directly output animated GIFs, using the
gifMain
function
Closed issues:
- Color conversions have huge impact on performance #44
Merged pull requests:
v1.0.1.2 (2014-02-06)
Closed issues:
- Build failure for GHC 7.4 #42
v1.0.1.1 (2014-01-30)
v1.0.1 (2014-01-26)
Merged pull requests:
-
Making animated GIFs directly from diagrams using Cairo. #40 (jeffreyrosenbluth)
v1.0 (2013-11-25)
New Features
-
Re-implement via new backend
RTree
interface. -
Use new command-line interface from
diagrams-lib
. -
Export
B
as an alias forCairo
token.
Fixed bugs:
- opacity does not affect text #15
Merged pull requests:
-
Lens #35 (jeffreyrosenbluth)
v0.7 (2013-08-09)
New features
-
New
renderCairo
function for more convenient use of the cairo backend. -
Lots of Haddock documentation improvements.
Fixed bugs:
- Lines should not be filled #32
Merged pull requests:
v0.6 (2012-12-12)
New features
-
New
--list
option formultiMain
to list all available diagrams -
Major documentation improvements
-
New modules:
-
Diagrams.Backend.Cairo.Ptr
, for rendering directly to buffers in memory -
Diagrams.Backend.Cairo.List
, for rendering to a list of lists of pixels.
-
API changes
-
Removal of
StyleParam
fromDiagrams.Backend.Cairo.Text
, change functions in that module to acceptStyle R2
. Usage can be fixed by applying these style functions tomempty
. -
GTK rendering has been split out into a new package, diagrams-gtk.
-
The
Diagrams.Backend.Cairo.Gtk
module is nowDiagrams.Backend.Gtk
in thediagrams-gtk
package. -
The
CairoOptions
record has a new booleancairoBypassAdjust
option; when set, the backend should bypass callingadjustDia2D
. -
The GTK output type is gone.
-
There is a new
RenderOnly
output type, for when you don’t care about theIO
action but only want the cairoRender
action.
Fixed bugs:
-
old-time and 7.6 #21
-
Use of deprecated ‘try’ function in Diagrams.Backend.Cairo.Internal #12
-
Better error message when image file does not exist #11
-
Path doesn’t get resized correctly when no transformations are applied to it #6
-
Make Cairo backend smarter about missing attributes #4
-
Attribute transformations are not handled correctly when rendering #3
Closed issues:
-
vector-space-0.8.5 breaks compilation #27
-
‘cairoBypassAdjust’ undocumented #23
-
Improve diagrams-cairo documentation #10
Merged pull requests:
-
Additional rendering functions, for Ptr Word8 and [[Colour a]] #25 (haasn)
-
split out gtk rendering into a separate package #20 (byorgey)
-
use requiredScaleT in place of deprecated adjustSize #17 (byorgey)
-
call setDefault2DAttributes even when bypassing size adjustments #16 (byorgey)
v0.5.0.2 (13 May 2012)
- Allow building under
mtl
2.1.*
v0.5.0.1 (9 March 2012)
- Remove statement in package description that a development version
of
gtk2hs
must be used with GHC 7.4; this is no longer true as of the 0.12.3 release ofgtk2hs
.
v0.5 (March 2012)
New features
-
New
Diagrams.Backend.Cairo.Text
module by Michael Sloan, with functions for creating appropriately sized text objects by querying cairo for the size, and related supporting functions. -
Basic support for animation with
animMain
function, by generating frames sampled at regular intervals. -
Proper vertical alignment of default text based on font parameters (Michael Sloan).
-
Requesting just a width or height now causes the other to be computed appropriately.
API changes
- Move
Diagrams.Backend.Cairo
toDiagrams.Backend.Cairo.Internal
and export everything.Diagrams.Backend.Cairo
now just re-exports selected functions fromInternal
. This allows anyone who wants access to the helper/utility functions to importInternal
.
Dependency/version changes
-
relax
cmdargs
upper bound -
GHC 7.4.1 compatibility: update
base
,filepath
, andold-time
upper bounds
Bug fixes
- #54: Generate warning for missing image files (Ian Ross).
v0.4 (22 October 2011)
-
New features:
-
Support for drawing directly to Gtk widgets
- Support for path fill rule attribute
-
-
New/improved examples
-
Improved documentation
-
Bug fixes:
- Warning for unsupported image types (#41)
v0.3 (18 June 2011)
-
Some new/improved examples
-
New features:
-
simple text support
-
simple support for external PNG images
-
v0.2 (3 June 2011)
-
add
Typeable
and other instances forCairo
type -
generalize
Result
type to(IO (), Render ())
, so programs that don’t want to generate a file but just want aRender
operation (e.g. to use to paint a gtk window) can use the second component. -
add support for opacity attribute and path clipping
v0.1.2 (18 May 2011)
- link to new website
v0.1.1 (18 May 2011)
- fix tic-tac-toe example
v0.1 (17 May 2011)
- initial preview release
* This Change Log was automatically generated by (and hand edited) github_changelog_generator