Gtk2HsContentsIndex
Graphics.Rendering.Cairo
Portabilityportable
Stabilityexperimental
Maintainerp.martini@neuralnoise.com
Contents
Drawing
Paths
Patterns
Transformations
Text
Fonts
Font options
Surfaces
Image surfaces
PNG support
Utilities
Types
Description

The Cairo 2D graphics library.

Cairo is a 2D graphics library with support for multiple output devices. Currently supported output targets include the X Window System, win32, and image buffers. Experimental backends include OpenGL (through glitz), Quartz, XCB, PostScript and PDF file output.

Cairo is designed to produce consistent output on all output media while taking advantage of display hardware acceleration when available (eg. through the X Render Extension).

The cairo API provides operations similar to the drawing operators of PostScript and PDF. Operations in cairo including stroking and filling cubic Bezier splines, transforming and compositing translucent images, and antialiased text rendering. All drawing operations can be transformed by any affine transformation (scale, rotation, shear, etc.)

Cairo is free software and is available to be redistributed and/or modified under the terms of either the GNU Lesser General Public License (LGPL) version 2.1 or the Mozilla Public License (MPL) version 1.1.

For more information see http://cairographics.org

  • Note the Haskell bindings do not support all the possible cairo backends because it would require bindings for the associated technology (eg X11, glitz, etc) however bindings to other backends may be implemented externally. For example, Gtk2Hs provides a binding to the backend for X11 (and win32 on Windows).
Synopsis
renderWith :: MonadIO m => Surface -> Render a -> m a
save :: Render ()
restore :: Render ()
status :: Render Status
withTargetSurface :: (Surface -> Render a) -> Render a
setSourceRGB :: Double -> Double -> Double -> Render ()
setSourceRGBA :: Double -> Double -> Double -> Double -> Render ()
setSource :: Pattern -> Render ()
setSourceSurface :: Surface -> Double -> Double -> Render ()
getSource :: Render Pattern
setAntialias :: Antialias -> Render ()
setDash :: [Double] -> Double -> Render ()
setFillRule :: FillRule -> Render ()
getFillRule :: Render FillRule
setLineCap :: LineCap -> Render ()
getLineCap :: Render LineCap
setLineJoin :: LineJoin -> Render ()
getLineJoin :: Render LineJoin
setLineWidth :: Double -> Render ()
getLineWidth :: Render Double
setMiterLimit :: Double -> Render ()
getMiterLimit :: Render Double
setOperator :: Operator -> Render ()
getOperator :: Render Operator
setTolerance :: Double -> Render ()
getTolerance :: Render Double
clip :: Render ()
clipPreserve :: Render ()
resetClip :: Render ()
fill :: Render ()
fillPreserve :: Render ()
fillExtents :: Render (Double, Double, Double, Double)
inFill :: Double -> Double -> Render Bool
mask :: Pattern -> Render ()
maskSurface :: Surface -> Double -> Double -> Render ()
paint :: Render ()
paintWithAlpha :: Double -> Render ()
stroke :: Render ()
strokePreserve :: Render ()
strokeExtents :: Render (Double, Double, Double, Double)
inStroke :: Double -> Double -> Render Bool
copyPage :: Render ()
showPage :: Render ()
getCurrentPoint :: Render (Double, Double)
newPath :: Render ()
closePath :: Render ()
arc :: Double -> Double -> Double -> Double -> Double -> Render ()
arcNegative :: Double -> Double -> Double -> Double -> Double -> Render ()
curveTo :: Double -> Double -> Double -> Double -> Double -> Double -> Render ()
lineTo :: Double -> Double -> Render ()
moveTo :: Double -> Double -> Render ()
rectangle :: Double -> Double -> Double -> Double -> Render ()
textPath :: String -> Render ()
relCurveTo :: Double -> Double -> Double -> Double -> Double -> Double -> Render ()
relLineTo :: Double -> Double -> Render ()
relMoveTo :: Double -> Double -> Render ()
withRGBPattern :: Double -> Double -> Double -> (Pattern -> Render a) -> Render a
withRGBAPattern :: Double -> Double -> Double -> Double -> (Pattern -> Render a) -> Render a
withPatternForSurface :: Surface -> (Pattern -> Render a) -> Render a
withLinearPattern :: Double -> Double -> Double -> Double -> (Pattern -> Render a) -> Render a
withRadialPattern :: Double -> Double -> Double -> Double -> Double -> Double -> (Pattern -> Render a) -> Render a
patternAddColorStopRGB :: Pattern -> Double -> Double -> Double -> Double -> Render ()
patternAddColorStopRGBA :: Pattern -> Double -> Double -> Double -> Double -> Double -> Render ()
patternSetMatrix :: Pattern -> Matrix -> Render ()
patternGetMatrix :: Pattern -> Render Matrix
patternSetExtend :: Pattern -> Extend -> Render ()
patternGetExtend :: Pattern -> Render Extend
patternSetFilter :: Pattern -> Filter -> Render ()
patternGetFilter :: Pattern -> Render Filter
translate :: Double -> Double -> Render ()
scale :: Double -> Double -> Render ()
rotate :: Double -> Render ()
transform :: Matrix -> Render ()
setMatrix :: Matrix -> Render ()
getMatrix :: Render Matrix
identityMatrix :: Render ()
userToDevice :: Double -> Double -> Render (Double, Double)
userToDeviceDistance :: Double -> Double -> Render (Double, Double)
deviceToUser :: Double -> Double -> Render (Double, Double)
deviceToUserDistance :: Double -> Double -> Render (Double, Double)
selectFontFace :: String -> FontSlant -> FontWeight -> Render ()
setFontSize :: Double -> Render ()
setFontMatrix :: Matrix -> Render ()
getFontMatrix :: Render Matrix
showText :: String -> Render ()
fontExtents :: Render FontExtents
textExtents :: String -> Render TextExtents
fontOptionsCreate :: Render FontOptions
fontOptionsCopy :: FontOptions -> Render FontOptions
fontOptionsMerge :: FontOptions -> FontOptions -> Render ()
fontOptionsHash :: FontOptions -> Render Int
fontOptionsEqual :: FontOptions -> FontOptions -> Render Bool
fontOptionsSetAntialias :: FontOptions -> Antialias -> Render ()
fontOptionsGetAntialias :: FontOptions -> Render Antialias
fontOptionsSetSubpixelOrder :: FontOptions -> SubpixelOrder -> Render ()
fontOptionsGetSubpixelOrder :: FontOptions -> Render SubpixelOrder
fontOptionsSetHintStyle :: FontOptions -> HintStyle -> Render ()
fontOptionsGetHintStyle :: FontOptions -> Render HintStyle
fontOptionsSetHintMetrics :: FontOptions -> HintMetrics -> Render ()
fontOptionsGetHintMetrics :: FontOptions -> Render HintMetrics
withSimilarSurface :: Surface -> Content -> Int -> Int -> (Surface -> IO a) -> IO a
createSimilarSurface :: Surface -> Content -> Int -> Int -> IO Surface
renderWithSimilarSurface :: Content -> Int -> Int -> (Surface -> Render a) -> Render a
surfaceGetFontOptions :: Surface -> Render FontOptions
surfaceFinish :: MonadIO m => Surface -> m ()
surfaceFlush :: Surface -> Render ()
surfaceMarkDirty :: Surface -> Render ()
surfaceMarkDirtyRectangle :: Surface -> Int -> Int -> Int -> Int -> Render ()
surfaceSetDeviceOffset :: Surface -> Double -> Double -> Render ()
withImageSurface :: Format -> Int -> Int -> (Surface -> IO a) -> IO a
createImageSurface :: Format -> Int -> Int -> IO Surface
imageSurfaceGetWidth :: Surface -> Render Int
imageSurfaceGetHeight :: Surface -> Render Int
withImageSurfaceFromPNG :: FilePath -> (Surface -> IO a) -> IO a
surfaceWriteToPNG :: Surface -> FilePath -> IO ()
liftIO
version :: Int
versionString :: String
data Matrix
data Surface
data Pattern
data Status
= StatusSuccess
| StatusNoMemory
| StatusInvalidRestore
| StatusInvalidPopGroup
| StatusNoCurrentPoint
| StatusInvalidMatrix
| StatusInvalidStatus
| StatusNullPointer
| StatusInvalidString
| StatusInvalidPathData
| StatusReadError
| StatusWriteError
| StatusSurfaceFinished
| StatusSurfaceTypeMismatch
| StatusPatternTypeMismatch
| StatusInvalidContent
| StatusInvalidFormat
| StatusInvalidVisual
| StatusFileNotFound
| StatusInvalidDash
| StatusInvalidDscComment
data Operator
= OperatorClear
| OperatorSource
| OperatorOver
| OperatorIn
| OperatorOut
| OperatorAtop
| OperatorDest
| OperatorDestOver
| OperatorDestIn
| OperatorDestOut
| OperatorDestAtop
| OperatorXor
| OperatorAdd
| OperatorSaturate
data Antialias
= AntialiasDefault
| AntialiasNone
| AntialiasGray
| AntialiasSubpixel
data FillRule
= FillRuleWinding
| FillRuleEvenOdd
data LineCap
= LineCapButt
| LineCapRound
| LineCapSquare
data LineJoin
= LineJoinMiter
| LineJoinRound
| LineJoinBevel
data ScaledFont
data FontFace
data Glyph
data TextExtents = TextExtents {
textExtentsXbearing :: Double
textExtentsYbearing :: Double
textExtentsWidth :: Double
textExtentsHeight :: Double
textExtentsXadvance :: Double
textExtentsYadvance :: Double
}
data FontExtents = FontExtents {
fontExtentsAscent :: Double
fontExtentsDescent :: Double
fontExtentsHeight :: Double
fontExtentsMaxXadvance :: Double
fontExtentsMaxYadvance :: Double
}
data FontSlant
= FontSlantNormal
| FontSlantItalic
| FontSlantOblique
data FontWeight
= FontWeightNormal
| FontWeightBold
data SubpixelOrder
= SubpixelOrderDefault
| SubpixelOrderRgb
| SubpixelOrderBgr
| SubpixelOrderVrgb
| SubpixelOrderVbgr
data HintStyle
= HintStyleDefault
| HintStyleNone
| HintStyleSlight
| HintStyleMedium
| HintStyleFull
data HintMetrics
= HintMetricsDefault
| HintMetricsOff
| HintMetricsOn
data FontOptions
data Path
data Content
= ContentColor
| ContentAlpha
| ContentColorAlpha
data Format
= FormatARGB32
| FormatRGB24
| FormatA8
| FormatA1
data Extend
= ExtendNone
| ExtendRepeat
| ExtendReflect
| ExtendPad
data Filter
= FilterFast
| FilterGood
| FilterBest
| FilterNearest
| FilterBilinear
| FilterGaussian
Drawing
renderWith
:: MonadIO m
=> Surfacethe target surface for the Render context
-> Render a
-> m a
Creates a new Render context with all graphics state parameters set to default values and with the given surface as a target surface. The target surface should be constructed with a backend-specific function such as withImageSurface (or any other with<backend>Surface variant).
save :: Render ()
Makes a copy of the current state and saves it on an internal stack of saved states. When restore is called, the saved state is restored. Multiple calls to save and restore can be nested; each call to restore restores the state from the matching paired save.
restore :: Render ()
Restores to the state saved by a preceding call to save and removes that state from the stack of saved states.
status :: Render Status
Ask for the status of the current Render monad.
withTargetSurface :: (Surface -> Render a) -> Render a
Gets the target surface for the Render context as passed to renderWith.
setSourceRGB
:: Doublered component of colour
-> Doublegreen component of colour
-> Doubleblue compoment of colour
-> Render ()

Sets the source pattern within the context to an opaque color. This opaque color will then be used for any subsequent drawing operation until a new source pattern is set.

The color components are floating point numbers in the range 0 to 1. If the values passed in are outside that range, they will be clamped.

setSourceRGBA
:: Doublered component of color
-> Doublegreen component of color
-> Doubleblue component of color
-> Doublealpha component of color
-> Render ()

Sets the source pattern within the context to a translucent color. This color will then be used for any subsequent drawing operation until a new source pattern is set.

The color and alpha components are floating point numbers in the range 0 to 1. If the values passed in are outside that range, they will be clamped.

setSource
:: Patterna Pattern to be used as the source for subsequent drawing operations.
-> Render ()

Sets the source pattern within the context to source. This pattern will then be used for any subsequent drawing operation until a new source pattern is set.

Note: The pattern's transformation matrix will be locked to the user space in effect at the time of setSource. This means that further modifications of the current transformation matrix will not affect the source pattern. See setMatrix.

setSourceSurface
:: Surfacea surface to be used to set the source pattern
-> Doubleuser-space X coordinate for surface origin
-> Doubleuser-space Y coordinate for surface origin
-> Render ()

This is a convenience function for creating a pattern from surface and setting it as the source in the context with setSource.

The x and y parameters give the user-space coordinate at which the surface origin should appear. (The surface origin is its upper-left corner before any transformation has been applied.) The x and y patterns are negated and then set as translation values in the pattern matrix.

Other than the initial translation pattern matrix, as described above, all other pattern attributes, (such as its extend mode), are set to the default values as in patternCreateForSurface. The resulting pattern can be queried with getSource so that these attributes can be modified if desired, (eg. to create a repeating pattern with patternSetExtent.

getSource :: Render Pattern
Gets the current source pattern.
setAntialias
:: Antialiasthe new antialiasing mode
-> Render ()

Set the antialiasing mode of the rasterizer used for drawing shapes. This value is a hint, and a particular backend may or may not support a particular value. At the current time, no backend supports AntialiasSubpixel when drawing shapes.

Note that this option does not affect text rendering, instead see fontOptionsSetAntilias.

setDash
:: [Double]dashes a list specifying alternate lengths of on and off portions of the stroke
-> Doublean offset into the dash pattern at which the stroke should start
-> Render ()

Sets the dash pattern to be used by stroke. A dash pattern is specified by dashes, a list of positive values. Each value provides the user-space length of altenate on and off portions of the stroke. The offset specifies an offset into the pattern at which the stroke begins.

If dashes is [] then dashing is disabled.

setFillRule
:: FillRulea fill rule
-> Render ()
Set the current fill rule within the cairo context. The fill rule is used to determine which regions are inside or outside a complex (potentially self-intersecting) path. The current fill rule affects both fill and clip. See FillRule for details on the semantics of each available fill rule.
getFillRule :: Render FillRule
Gets the current fill rule, as set by setFillrule.
setLineCap
:: LineCapa line cap style
-> Render ()

Sets the current line cap style within the cairo context. See LineCap for details about how the available line cap styles are drawn.

As with the other stroke parameters, the current line cap style is examined by stroke, strokeExtents, and strokeToPath, but does not have any effect during path construction.

getLineCap :: Render LineCap
Gets the current line cap style, as set by setLineCap.
setLineJoin
:: LineJoina line joint style
-> Render ()

Sets the current line join style within the cairo context. See LineJoin for details about how the available line join styles are drawn.

As with the other stroke parameters, the current line join style is examined by stroke, strokeExtents, and strokeToPath, but does not have any effect during path construction.

getLineJoin :: Render LineJoin
Gets the current line join style, as set by setLineJoin.
setLineWidth
:: Doublea line width
-> Render ()

Sets the current line width within the cairo context. The line width specifies the diameter of a pen that is circular in user-space.

As with the other stroke parameters, the current line cap style is examined by stroke, strokeExtents, and strokeToPath, but does not have any effect during path construction.

getLineWidth :: Render Double
Gets the current line width, as set by setLineWidth.
setMiterLimit
:: Double
-> Render ()
getMiterLimit :: Render Double
Gets the current miter limit, as set by setMiterLimit.
setOperator
:: Operatora compositing operator
-> Render ()
Sets the compositing operator to be used for all drawing operations. See Operator for details on the semantics of each available compositing operator.
getOperator :: Render Operator
Gets the current compositing operator for a cairo context.
setTolerance
:: Doublethe tolerance, in device units (typically pixels)
-> Render ()
Sets the tolerance used when converting paths into trapezoids. Curved segments of the path will be subdivided until the maximum deviation between the original path and the polygonal approximation is less than tolerance. The default value is 0.1. A larger value will give better performance, a smaller value, better appearance. (Reducing the value from the default value of 0.1 is unlikely to improve appearance significantly.)
getTolerance :: Render Double
Gets the current tolerance value, as set by setTolerance.
clip :: Render ()

Establishes a new clip region by intersecting the current clip region with the current path as it would be filled by fill and according to the current fill rule (see setFillRule).

After clip, the current path will be cleared from the cairo context.

The current clip region affects all drawing operations by effectively masking out any changes to the surface that are outside the current clip region.

Calling clip can only make the clip region smaller, never larger. But the current clip is part of the graphics state, so a temporary restriction of the clip region can be achieved by calling clip within a save' pair. The only other means of increasing the size of the clip region is resetClip.

clipPreserve :: Render ()

Establishes a new clip region by intersecting the current clip region with the current path as it would be filled by fill and according to the current fill rule (see setFillRule).

Unlike clip, cairoClipPreserve preserves the path within the cairo context.

The current clip region affects all drawing operations by effectively masking out any changes to the surface that are outside the current clip region.

Calling clip can only make the clip region smaller, never larger. But the current clip is part of the graphics state, so a temporary restriction of the clip region can be achieved by calling clip within a save' pair. The only other means of increasing the size of the clip region is resetClip.

resetClip :: Render ()

Reset the current clip region to its original, unrestricted state. That is, set the clip region to an infinitely large shape containing the target surface. Equivalently, if infinity is too hard to grasp, one can imagine the clip region being reset to the exact bounds of the target surface.

Note that code meant to be reusable should not call resetClip as it will cause results unexpected by higher-level code which calls clip. Consider using save and restore around clip as a more robust means of temporarily restricting the clip region.

fill :: Render ()

A drawing operator that fills the current path according to the current fill rule, (each sub-path is implicitly closed before being filled). After fill, the current path will be cleared from the cairo context.

See setFillRule and fillPreserve.

fillPreserve :: Render ()

A drawing operator that fills the current path according to the current fill rule, (each sub-path is implicitly closed before being filled). Unlike fill, fillPreserve preserves the path within the cairo context.

See setFillRule and fill.

fillExtents :: Render (Double, Double, Double, Double)
inFill :: Double -> Double -> Render Bool
mask
:: Patterna Pattern
-> Render ()
A drawing operator that paints the current source using the alpha channel of pattern as a mask. (Opaque areas of mask are painted with the source, transparent areas are not painted.)
maskSurface
:: Surfacea Surface
-> DoubleX coordinate at which to place the origin of surface
-> DoubleY coordinate at which to place the origin of surface
-> Render ()
A drawing operator that paints the current source using the alpha channel of surface as a mask. (Opaque areas of surface are painted with the source, transparent areas are not painted.)
paint :: Render ()
A drawing operator that paints the current source everywhere within the current clip region.
paintWithAlpha
:: Doublealpha value, between 0 (transparent) and 1 (opaque)
-> Render ()
A drawing operator that paints the current source everywhere within the current clip region using a mask of constant alpha value alpha. The effect is similar to paint, but the drawing is faded out using the alpha value.
stroke :: Render ()

A drawing operator that strokes the current path according to the current line width, line join, line cap, and dash settings. After issuing stroke, the current path will be cleared from the Render monad.

See setLineWidth, setLineJoin, setLineCap, setDash, and strokePreserve.

strokePreserve :: Render ()

A drawing operator that strokes the current path according to the current line width, line join, line cap, and dash settings. Unlike stroke, strokePreserve preserves the path within the Render monad.

See setLineWidth, setLineJoin, setLineCap, setDash, and strokePreserve.

strokeExtents :: Render (Double, Double, Double, Double)
inStroke :: Double -> Double -> Render Bool
copyPage :: Render ()
showPage :: Render ()
Paths
getCurrentPoint :: Render (Double, Double)

Gets the current point of the current path, which is conceptually the final point reached by the path so far.

The current point is returned in the user-space coordinate system. If there is no defined current point then x and y will both be set to 0.0.

Most path construction functions alter the current point. See the following for details on how they affect the current point: newPath, moveTo, lineTo, curveTo, arc, relMoveTo, relLineTo, relCurveTo, arcNegative, textPath, strokeToPath.

newPath :: Render ()
Clears the current path. After this call there will be no current point.
closePath :: Render ()

Adds a line segment to the path from the current point to the beginning of the current subpath, (the most recent point passed to moveTo), and closes this subpath.

The behavior of closePath is distinct from simply calling lineTo with the equivalent coordinate in the case of stroking. When a closed subpath is stroked, there are no caps on the ends of the subpath. Instead, their is a line join connecting the final and initial segments of the subpath.

arc
:: Doublexc - X position of the center of the arc
-> Doubleyc - Y position of the center of the arc
-> Doubleradius - the radius of the arc
-> Doubleangle1 - the start angle, in radians
-> Doubleangle2 - the end angle, in radians
-> Render ()

Adds a circular arc of the given radius to the current path. The arc is centered at (xc, yc), begins at angle1 and proceeds in the direction of increasing angles to end at angle2. If angle2 is less than angle1 it will be progressively increased by 2*pi until it is greater than angle1.

If there is a current point, an initial line segment will be added to the path to connect the current point to the beginning of the arc.

Angles are measured in radians. An angle of 0 is in the direction of the positive X axis (in user-space). An angle of pi radians (90 degrees) is in the direction of the positive Y axis (in user-space). Angles increase in the direction from the positive X axis toward the positive Y axis. So with the default transformation matrix, angles increase in a clockwise direction.

(To convert from degrees to radians, use degrees * (pi / 180).)

This function gives the arc in the direction of increasing angles; see arcNegative to get the arc in the direction of decreasing angles.

The arc is circular in user-space. To achieve an elliptical arc, you can scale the current transformation matrix by different amounts in the X and Y directions. For example, to draw an ellipse in the box given by x, y, width, height:

 save
 translate (x + width / 2) (y + height / 2)
 scale (1 / (height / 2.)) (1 / (width / 2))
 arc 0 0 1 0 (2 * pi)
 restore
arcNegative
:: Doublexc - X position of the center of the arc
-> Doubleyc - Y position of the center of the arc
-> Doubleradius - the radius of the arc
-> Doubleangle1 - the start angle, in radians
-> Doubleangle2 - the end angle, in radians
-> Render ()

Adds a circular arc of the given radius to the current path. The arc is centered at (xc, yc), begins at angle1 and proceeds in the direction of decreasing angles to end at angle2. If angle2 is greater than angle1 it will be progressively decreased by 2*pi until it is greater than angle1.

See arc for more details. This function differs only in the direction of the arc between the two angles.

curveTo
:: Doublex1 - the X coordinate of the first control point
-> Doubley1 - the Y coordinate of the first control point
-> Doublex2 - the X coordinate of the second control point
-> Doubley2 - the Y coordinate of the second control point
-> Doublex3 - the X coordinate of the end of the curve
-> Doubley3 - the Y coordinate of the end of the curve
-> Render ()
Adds a cubic Bezier spline to the path from the current point to position (x3, y3) in user-space coordinates, using (x1, y1) and (x2, y2) as the control points. After this call the current point will be (x3, y3).
lineTo
:: Doublex - the X coordinate of the end of the new line
-> Doubley - the Y coordinate of the end of the new line
-> Render ()
Adds a line to the path from the current point to position (x, y) in user-space coordinates. After this call the current point will be (x, y).
moveTo
:: Doublex - the X coordinate of the new position
-> Doubley - the Y coordinate of the new position
-> Render ()
If the current subpath is not empty, begin a new subpath. After this call the current point will be (x, y).
rectangle
:: Doublex - the X coordinate of the top left corner of the rectangle
-> Doubley - the Y coordinate of the top left corner of the rectangle
-> Doublewidth - the width of the rectangle
-> Doubleheight - the height of the rectangle
-> Render ()
Adds a closed-subpath rectangle of the given size to the current path at position (x, y) in user-space coordinates.
textPath
:: String
-> Render ()

Render text at the current path.

  • See showText for why you should use Gtk functions.
relCurveTo
:: Doubledx1 - the X offset to the first control point
-> Doubledy1 - the Y offset to the first control point
-> Doubledx2 - the X offset to the second control point
-> Doubledy2 - the Y offset to the second control point
-> Doubledx3 - the X offset to the end of the curve
-> Doubledy3 - the Y offset to the end of the curve
-> Render ()

Relative-coordinate version of curveTo. All offsets are relative to the current point. Adds a cubic Bezier spline to the path from the current point to a point offset from the current point by (dx3, dy3), using points offset by (dx1, dy1) and (dx2, dy2) as the control points. After this call the current point will be offset by (dx3, dy3).

Given a current point of (x, y), relCurveTo dx1 dy1 dx2 dy2 dx3 dy3 is logically equivalent to curveTo (x + dx1) (y + dy1) (x + dx2) (y + dy2) (x + dx3) (y + dy3).

relLineTo
:: Doubledx - the X offset to the end of the new line
-> Doubledy - the Y offset to the end of the new line
-> Render ()

Relative-coordinate version of lineTo. Adds a line to the path from the current point to a point that is offset from the current point by (dx, dy) in user space. After this call the current point will be offset by (dx, dy).

Given a current point of (x, y), relLineTo dx dy is logically equivalent to lineTo (x + dx) (y + dy).

relMoveTo
:: Doubledx - the X offset
-> Doubledy - the Y offset
-> Render ()

If the current subpath is not empty, begin a new subpath. After this call the current point will offset by (x, y).

Given a current point of (x, y), relMoveTo dx dy is logically equivalent to moveTo (x + dx) (y + dy)

Patterns
withRGBPattern
:: Doublered component of the color
-> Doublegreen component of the color
-> Doubleblue component of the color
-> (Pattern -> Render a)a nested render action using the pattern
-> Render a

Creates a new Pattern corresponding to an opaque color. The color components are floating point numbers in the range 0 to 1. If the values passed in are outside that range, they will be clamped.

For example to create a solid red pattern:

 withRBGPattern 1 0 0 $ do
   ...
   ...
withRGBAPattern
:: Doublered component of color
-> Doublegreen component of color
-> Doubleblue component of color
-> Doublealpha component of color
-> (Pattern -> Render a)a nested render action using the pattern
-> Render a

Creates a new Pattern corresponding to a translucent color. The color components are floating point numbers in the range 0 to 1. If the values passed in are outside that range, they will be clamped.

For example to create a solid red pattern at 50% transparency:

 withRBGPattern 1 0 0 0.5 $ do
   ...
   ...
withPatternForSurface
:: Surface
-> (Pattern -> Render a)a nested render action using the pattern
-> Render a
Create a new Pattern for the given surface.
withLinearPattern
:: Doublex0 - x coordinate of the start point
-> Doubley0 - y coordinate of the start point
-> Doublex1 - x coordinate of the end point
-> Doubley1 - y coordinate of the end point
-> (Pattern -> Render a)a nested render action using the pattern
-> Render a

Create a new linear gradient Pattern along the line defined by (x0, y0) and (x1, y1). Before using the gradient pattern, a number of color stops should be defined using patternAddColorStopRGB and patternAddColorStopRGBA.

  • Note: The coordinates here are in pattern space. For a new pattern, pattern space is identical to user space, but the relationship between the spaces can be changed with patternSetMatrix.
withRadialPattern
:: Doublecx0 - x coordinate for the center of the start circle
-> Doublecy0 - y coordinate for the center of the start circle
-> Doubleradius0 - radius of the start cirle
-> Doublecx1 - x coordinate for the center of the end circle
-> Doublecy1 - y coordinate for the center of the end circle
-> Doubleradius1 - radius of the end circle
-> (Pattern -> Render a)a nested render action using the pattern
-> Render a

Creates a new radial gradient Pattern between the two circles defined by (x0, y0, c0) and (x1, y1, c0). Before using the gradient pattern, a number of color stops should be defined using patternAddColorStopRGB or patternAddColorStopRGBA.

  • Note: The coordinates here are in pattern space. For a new pattern, pattern space is identical to user space, but the relationship between the spaces can be changed with patternSetMatrix.
patternAddColorStopRGB
:: Patterna Pattern
-> Doublean offset in the range [0.0 .. 1.0]
-> Doublered component of color
-> Doublegreen component of color
-> Doubleblue component of color
-> Render ()

Adds an opaque color stop to a gradient pattern. The offset specifies the location along the gradient's control vector. For example, a linear gradient's control vector is from (x0,y0) to (x1,y1) while a radial gradient's control vector is from any point on the start circle to the corresponding point on the end circle.

The color is specified in the same way as in setSourceRGB.

Note: If the pattern is not a gradient pattern, (eg. a linear or radial pattern), then the pattern will be put into an error status with a status of StatusPatternTypeMismatch.

patternAddColorStopRGBA
:: Patterna Pattern
-> Doublean offset in the range [0.0 .. 1.0]
-> Doublered component of color
-> Doublegreen component of color
-> Doubleblue component of color
-> Doublealpha component of color
-> Render ()

Adds a translucent color stop to a gradient pattern. The offset specifies the location along the gradient's control vector. For example, a linear gradient's control vector is from (x0,y0) to (x1,y1) while a radial gradient's control vector is from any point on the start circle to the corresponding point on the end circle.

The color is specified in the same way as in setSourceRGBA.

Note: If the pattern is not a gradient pattern, (eg. a linear or radial pattern), then the pattern will be put into an error status with a status of StatusPatternTypeMismatch.

patternSetMatrix
:: Patterna Pattern
-> Matrixa Matrix
-> Render ()

Sets the pattern's transformation matrix to matrix. This matrix is a transformation from user space to pattern space.

When a pattern is fi