diagrams-cairo-1.3.0.5: Cairo backend for diagrams drawing EDSL

Copyright(c) 2011 Diagrams-cairo team (see LICENSE)
LicenseBSD-style (see LICENSE)
Maintainerdiagrams-discuss@googlegroups.com
Safe HaskellNone
LanguageHaskell2010

Diagrams.Backend.Cairo.Internal

Description

This module contains the internal implementation guts of the diagrams cairo backend. If you want to see how the cairo backend works under the hood, you are in the right place (try clicking on the "Source" links). (Guts under the hood, what an awful mixed metaphor.) If you know what you are doing and really want access to the internals of the implementation, you are also in the right place. Otherwise, you should have no need of this module; import Diagrams.Backend.Cairo.CmdLine or Diagrams.Backend.Cairo instead.

The one exception is that this module may have to be imported sometimes to work around an apparent bug in certain versions of GHC, which results in a "not in scope" error for CairoOptions.

The types of all the fromX functions look funny in the Haddock output, which displays them like Type -> Type. In fact they are all of the form Type -> Graphics.Rendering.Cairo.Type, i.e. they convert from a diagrams type to a cairo type of the same name.

Synopsis

Documentation

type B = Cairo Source

data OutputType Source

Output types supported by cairo, including four different file types (PNG, PS, PDF, SVG). If you want to output directly to GTK windows, see the diagrams-gtk package.

Constructors

PNG

Portable Network Graphics output.

PS

PostScript output

PDF

Portable Document Format output.

SVG

Scalable Vector Graphics output.

RenderOnly

Don't output any file; the returned IO () action will do nothing, but the Render () action can be used (e.g. to draw to a Gtk window; see the diagrams-gtk package).

data CairoState Source

Custom state tracked in the RenderM monad.

Constructors

CairoState 

Fields

_accumStyle :: Style V2 Double

The current accumulated style.

_ignoreFill :: Bool

Whether or not we saw any lines in the most recent path (as opposed to loops). If we did, we should ignore any fill attribute. diagrams-lib separates lines and loops into separate path primitives so we don't have to worry about seeing them together in the same path.

type RenderM a = StateStackT CairoState Render a Source

The custom monad in which intermediate drawing options take place; Render is cairo's own rendering monad.

save :: RenderM () Source

Push the current context onto a stack.

restore :: RenderM () Source

Restore the context from a stack.

renderC :: (Renderable a Cairo, V a ~ V2, N a ~ Double) => a -> RenderM () Source

Render an object that the cairo backend knows how to render.

getStyleAttrib :: AttributeClass a => (a -> b) -> RenderM (Maybe b) Source

Get an accumulated style attribute from the render monad state.

cairoStyle :: Style v Double -> RenderM () Source

Handle those style attributes for which we can immediately emit cairo instructions as we encounter them in the tree (clip, font size, fill rule, line width, cap, join, and dashing). Other attributes (font face, slant, weight; fill color, stroke color, opacity) must be accumulated.

cairoTransf :: T2 Double -> Render () Source

Multiply the current transformation matrix by the given 2D transformation.

if' :: Monad m => (a -> m ()) -> Maybe a -> m () Source