Copyright | (c) 2011 Diagrams-cairo team (see LICENSE) |
---|---|
License | BSD-style (see LICENSE) |
Maintainer | diagrams-discuss@googlegroups.com |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
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
- data Cairo = Cairo
- type B = Cairo
- data OutputType
- = PNG
- | PS
- | SVG
- | RenderOnly
- data CairoState = CairoState {
- _accumStyle :: Style V2 Double
- _ignoreFill :: Bool
- ignoreFill :: Lens' CairoState Bool
- accumStyle :: Lens' CairoState (Style V2 Double)
- type RenderM a = StateStackT CairoState Render a
- liftC :: Render a -> RenderM a
- runRenderM :: RenderM a -> Render a
- save :: RenderM ()
- restore :: RenderM ()
- runC :: Render Cairo V2 Double -> RenderM ()
- toRender :: RTree Cairo V2 Double a -> Render Cairo V2 Double
- cairoFileName :: Lens' (Options Cairo V2 Double) String
- cairoSizeSpec :: Lens' (Options Cairo V2 Double) (SizeSpec V2 Double)
- cairoOutputType :: Lens' (Options Cairo V2 Double) OutputType
- cairoBypassAdjust :: Lens' (Options Cairo V2 Double) Bool
- renderC :: (Renderable a Cairo, V a ~ V2, N a ~ Double) => a -> RenderM ()
- getStyleAttrib :: AttributeClass a => (a -> b) -> RenderM (Maybe b)
- cairoStyle :: Style v Double -> RenderM ()
- fromFontSlant :: FontSlant -> FontStyle
- fromFontWeight :: FontWeight -> Weight
- cairoTransf :: T2 Double -> Render ()
- fromLineCap :: LineCap -> LineCap
- fromLineJoin :: LineJoin -> LineJoin
- fromFillRule :: FillRule -> FillRule
- cairoPath :: Path V2 Double -> RenderM ()
- addStop :: MonadIO m => Pattern -> GradientStop Double -> m ()
- cairoSpreadMethod :: SpreadMethod -> Extend
- setTexture :: Maybe (Texture Double) -> RenderM ()
- toImageRGBA8 :: DynamicImage -> Image PixelRGBA8
- toARGB :: PixelRGBA8 -> Word32
- if' :: Monad m => (a -> m ()) -> Maybe a -> m ()
- layoutStyledText :: Style V2 Double -> Text Double -> Render PangoLayout
Documentation
This data declaration is simply used as a token to distinguish
the cairo backend: (1) when calling functions where the type
inference engine would otherwise have no way to know which
backend you wanted to use, and (2) as an argument to the
Backend
and Renderable
type classes.
Constructors
Cairo |
Instances
Read Cairo Source # | |
Show Cairo Source # | |
Eq Cairo Source # | |
Ord Cairo Source # | |
Defined in Diagrams.Backend.Cairo.Internal | |
Backend Cairo V2 Double Source # | |
Defined in Diagrams.Backend.Cairo.Internal Methods adjustDia :: (Additive V2, Monoid' m, Num Double) => Cairo -> Options Cairo V2 Double -> QDiagram Cairo V2 Double m -> (Options Cairo V2 Double, Transformation V2 Double, QDiagram Cairo V2 Double m) renderRTree :: Cairo -> Options Cairo V2 Double -> RTree Cairo V2 Double Annotation -> Result Cairo V2 Double | |
Mainable [(QDiagram Cairo V2 Double Any, GifDelay)] | |
Defined in Diagrams.Backend.Cairo.CmdLine Methods mainArgs :: Parseable (MainOpts [(QDiagram Cairo V2 Double Any, GifDelay)]) => proxy [(QDiagram Cairo V2 Double Any, GifDelay)] -> IO (MainOpts [(QDiagram Cairo V2 Double Any, GifDelay)]) mainRender :: MainOpts [(QDiagram Cairo V2 Double Any, GifDelay)] -> [(QDiagram Cairo V2 Double Any, GifDelay)] -> IO () mainWith :: [(QDiagram Cairo V2 Double Any, GifDelay)] -> IO () # | |
Mainable [(String, QDiagram Cairo V2 Double Any)] | |
Defined in Diagrams.Backend.Cairo.CmdLine Methods mainArgs :: Parseable (MainOpts [(String, QDiagram Cairo V2 Double Any)]) => proxy [(String, QDiagram Cairo V2 Double Any)] -> IO (MainOpts [(String, QDiagram Cairo V2 Double Any)]) mainRender :: MainOpts [(String, QDiagram Cairo V2 Double Any)] -> [(String, QDiagram Cairo V2 Double Any)] -> IO () mainWith :: [(String, QDiagram Cairo V2 Double Any)] -> IO () # | |
Renderable (Text Double) Cairo Source # | |
Renderable (Path V2 Double) Cairo Source # | |
Renderable (Trail V2 Double) Cairo Source # | |
Renderable (DImage Double Embedded) Cairo Source # | |
Renderable (DImage Double External) Cairo Source # | |
Monoid (Render Cairo V2 Double) Source # | |
Semigroup (Render Cairo V2 Double) Source # | |
Defined in Diagrams.Backend.Cairo.Internal | |
Show (Options Cairo V2 Double) Source # | |
Mainable (Animation Cairo V2 Double) | |
Defined in Diagrams.Backend.Cairo.CmdLine | |
Eq (Options Cairo V2 Double) Source # | |
Hashable (Options Cairo V2 Double) Source # | |
Defined in Diagrams.Backend.Cairo.Internal | |
Renderable (Segment Closed V2 Double) Cairo Source # | |
Mainable (QDiagram Cairo V2 Double Any) | |
type N Cairo Source # | |
Defined in Diagrams.Backend.Cairo.Internal | |
type V Cairo Source # | |
Defined in Diagrams.Backend.Cairo.Internal type V Cairo = V2 | |
data Options Cairo V2 Double Source # | |
Defined in Diagrams.Backend.Cairo.Internal data Options Cairo V2 Double = CairoOptions {
| |
data Render Cairo V2 Double Source # | |
Defined in Diagrams.Backend.Cairo.Internal | |
type Result Cairo V2 Double Source # | |
Defined in Diagrams.Backend.Cairo.Internal | |
type MainOpts [(QDiagram Cairo V2 Double Any, GifDelay)] | |
Defined in Diagrams.Backend.Cairo.CmdLine | |
type MainOpts [(String, QDiagram Cairo V2 Double Any)] | |
type MainOpts (Animation Cairo V2 Double) | |
Defined in Diagrams.Backend.Cairo.CmdLine | |
type MainOpts (QDiagram Cairo V2 Double Any) | |
Defined in Diagrams.Backend.Cairo.CmdLine |
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 |
Portable Document Format output. | |
SVG | Scalable Vector Graphics output. |
RenderOnly | Don't output any file; the returned |
Instances
data CairoState Source #
Custom state tracked in the RenderM
monad.
Constructors
CairoState | |
Fields
|
Instances
Default CairoState Source # | |
Defined in Diagrams.Backend.Cairo.Internal Methods def :: CairoState Source # |
ignoreFill :: Lens' CairoState Bool Source #
accumStyle :: Lens' CairoState (Style V2 Double) Source #
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.
runRenderM :: RenderM a -> Render a Source #
cairoOutputType :: Lens' (Options Cairo V2 Double) OutputType Source #
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.
fromFontSlant :: FontSlant -> FontStyle Source #
fromFontWeight :: FontWeight -> Weight Source #
cairoTransf :: T2 Double -> Render () Source #
Multiply the current transformation matrix by the given 2D transformation.
fromLineCap :: LineCap -> LineCap Source #
fromLineJoin :: LineJoin -> LineJoin Source #
fromFillRule :: FillRule -> FillRule Source #
cairoSpreadMethod :: SpreadMethod -> Extend Source #
toImageRGBA8 :: DynamicImage -> Image PixelRGBA8 Source #
layoutStyledText :: Style V2 Double -> Text Double -> Render PangoLayout Source #