diagrams-wx-0.1.1.0: Backend for rendering diagrams in wxWidgets

Safe HaskellNone
LanguageHaskell2010

Diagrams.Backend.WX

Contents

Description

An optional add-on to the diagrams-cairo package which allows rendering diagrams in wxWidgets (using wxHaskell).

wxHaskell doesn't support transparency when drawing Images, so each of these functions takes a Color to use as the background color when rendering the QDiagram.

Synopsis

Drawing to DC

drawDiagram :: (Monoid b, Semigroup b) => DC a -> QDiagram Cairo V2 Double b -> Point -> SizeSpec V2 Double -> Color -> [Prop (DC a)] -> IO () Source

Simple interface for drawing a diagram to a DC, like drawImage.

Note that this creates, renders to, draws, and then deletes a new Image instance every invocation. Particularly performance-sensitive users may want to look at using renderDiagramToImage with the same Image instance every repaint.

Drawing to uImages

withDiagramImage :: (Monoid b, Semigroup b) => QDiagram Cairo V2 Double b -> SizeSpec V2 Double -> Color -> (Image () -> IO c) -> IO c Source

Safe wrapper around renderDiagramToNewImage that ensures the Image instance is properly deleted when you're done using it.

withDiagramImage diagram size =
  bracket (renderDiagramToNewImage diagram size) imageDelete

renderDiagramToNewImage :: (Monoid b, Semigroup b) => QDiagram Cairo V2 Double b -> SizeSpec V2 Double -> Color -> IO (Image ()) Source

Create a new Image of the appropriate size and render the given QDiagram to it with Cairo.

Make sure imageDelete is called to free the Image instance! Using bracket is recommended to ensure that the Image is still freed in the case of an exception:

bracket (renderDiagramToNewImage diagram size) imageDelete doStuffWithImage

withDiagramImage provides a convenient wrapper for this.

renderDiagramToImage :: (Monoid b, Semigroup b) => QDiagram Cairo V2 Double b -> SizeSpec V2 Double -> Color -> Image i -> IO () Source

Render a QDiagram to an existing Image. Throws an ImageSizeException if the target Image is too small for the resulting rendered diagram size.

data ImageSizeException Source

Exception indicating that the target image was the wrong size (too small) for the rendered diagram size.

Constructors

ImageSizeException !(Int, Int) !(Int, Int)
ImageSizeException renderedDiagramSize targetImageSize