Next: , Previous: , Up: Top   [Index]


1 cairo_t

The cairo drawing context

1.1 Overview

<cairo> is the main object used when drawing with cairo. To draw with cairo, you create a <cairo>, set the target surface, and drawing options for the <cairo>, create shapes with functions like cairo-move-to and cairo-line-to, and then draw shapes with cairo-stroke or cairo-fill.

<cairo>’s can be pushed to a stack via cairo-save. They may then safely be changed, without loosing the current state. Use cairo-restore to restore to the saved state.

1.2 Usage

Function: cairo-create (target <cairo-surface-t>) ⇒ (ret <cairo-t>)

Creates a new <cairo-t> with all graphics state parameters set to default values and with target as a target surface. The target surface should be constructed with a backend-specific function such as cairo-image-surface-create (or any other ‘cairo_<backend>_surface_create’ variant).

target

target surface for the context

ret

a newly allocated <cairo-t>.

Function: cairo-save (cr <cairo-t>)

Makes a copy of the current state of cr and saves it on an internal stack of saved states for cr. When cairo-restore is called, cr will be restored to the saved state. Multiple calls to cairo-save and cairo-restore can be nested; each call to cairo-restore restores the state from the matching paired cairo-save.

It isn’t necessary to clear all saved states before a <cairo-t> is freed. If the reference count of a <cairo-t> drops to zero in response to a call to cairo-destroy, any saved states will be freed along with the <cairo-t>.

cr

a <cairo-t>

Function: cairo-restore (cr <cairo-t>)

Restores cr to the state saved by a preceding call to cairo-save and removes that state from the stack of saved states.

cr

a <cairo-t>

Function: cairo-get-target (cr <cairo-t>) ⇒  (ret <cairo-surface-t >)

Gets the target surface for the cairo context as passed to cairo-create.

This function will always return a valid pointer, but the result can be a "nil" surface if cr is already in an error state, (ie. cairo-status!=’‘CAIRO_STATUS_SUCCESS’). A nil surface is indicated by cairo-surface-status!=’‘CAIRO_STATUS_SUCCESS’.

cr

a cairo context

ret

the target surface. This object is owned by cairo. To keep a reference to it, you must call cairo-surface-reference.

Function: cairo-push-group (cr <cairo-t>)

Temporarily redirects drawing to an intermediate surface known as a group. The redirection lasts until the group is completed by a call to cairo-pop-group or cairo-pop-group-to-source. These calls provide the result of any drawing to the group as a pattern, (either as an explicit object, or set as the source pattern).

This group functionality can be convenient for performing intermediate compositing. One common use of a group is to render objects as opaque within the group, (so that they occlude each other), and then blend the result with translucence onto the destination.

Groups can be nested arbitrarily deep by making balanced calls to cairo-push-group/cairo-pop-group. Each call pushes/pops the new target group onto/from a stack.

The cairo-push-group function calls cairo-save so that any changes to the graphics state will not be visible outside the group, (the pop_group functions call cairo-restore).

By default the intermediate group will have a content type of ‘CAIRO_CONTENT_COLOR_ALPHA’. Other content types can be chosen for the group by using cairo-push-group-with-content instead.

As an example, here is how one might fill and stroke a path with translucence, but without any portion of the fill being visible under the stroke:


cairo_push_group (cr);
cairo_set_source (cr, fill_pattern);
cairo_fill_preserve (cr);
cairo_set_source (cr, stroke_pattern);
cairo_stroke (cr);
cairo_pop_group_to_source (cr);
cairo_paint_with_alpha (cr, alpha);
cr

a cairo context

Since 1.2

Function: cairo-pop-group (cr <cairo-t>) ⇒  (ret <cairo-pattern-t >)

Terminates the redirection begun by a call to cairo-push-group or cairo-push-group-with-content and returns a new pattern containing the results of all drawing operations performed to the group.

The cairo-pop-group function calls cairo-restore, (balancing a call to cairo-save by the push_group function), so that any changes to the graphics state will not be visible outside the group.

cr

a cairo context

ret

a newly created (surface) pattern containing the results of all drawing operations performed to the group. The caller owns the returned object and should call cairo-pattern-destroy when finished with it.

Since 1.2

Function: cairo-pop-group-to-source (cr <cairo-t>)

Terminates the redirection begun by a call to cairo-push-group or cairo-push-group-with-content and installs the resulting pattern as the source pattern in the given cairo context.

The behavior of this function is equivalent to the sequence of operations:

cairo_pattern_t *group = cairo_pop_group (cr);
cairo_set_source (cr, group);
cairo_pattern_destroy (group);

but is more convenient as their is no need for a variable to store the short-lived pointer to the pattern.

The cairo-pop-group function calls cairo-restore, (balancing a call to cairo-save by the push_group function), so that any changes to the graphics state will not be visible outside the group.

cr

a cairo context

Since 1.2

Function: cairo-get-group-target (cr <cairo-t>) ⇒  (ret <cairo-surface-t >)

Gets the current destination surface for the context. This is either the original target surface as passed to cairo-create or the target surface for the current group as started by the most recent call to cairo-push-group or cairo-push-group-with-content.

This function will always return a valid pointer, but the result can be a "nil" surface if cr is already in an error state, (ie. cairo-status!=’‘CAIRO_STATUS_SUCCESS’). A nil surface is indicated by cairo-surface-status!=’‘CAIRO_STATUS_SUCCESS’.

cr

a cairo context

ret

the target surface. This object is owned by cairo. To keep a reference to it, you must call cairo-surface-reference.

Since 1.2

Function: cairo-set-source-rgb (cr <cairo-t>) (red <double>) (green <double>) (blue <double>)

Sets the source pattern within cr 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.

The default source pattern is opaque black, (that is, it is equivalent to cairo_set_source_rgb(cr, 0.0, 0.0, 0.0)).

cr

a cairo context

red

red component of color

green

green component of color

blue

blue component of color

Function: cairo-set-source-rgba (cr <cairo-t>) (red <double>) (green <double>) (blue <double>) (alpha <double>)

Sets the source pattern within cr 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.

The default source pattern is opaque black, (that is, it is equivalent to cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 1.0)).

cr

a cairo context

red

red component of color

green

green component of color

blue

blue component of color

alpha

alpha component of color

Function: cairo-set-source (cr <cairo-t>) (source <cairo-pattern-t>)

Sets the source pattern within cr 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 cairo-set-source. This means that further modifications of the current transformation matrix will not affect the source pattern. See cairo-pattern-set-matrix.

The default source pattern is a solid pattern that is opaque black, (that is, it is equivalent to cairo_set_source_rgb(cr, 0.0, 0.0, 0.0)).

cr

a cairo context

source

a <cairo-pattern-t> to be used as the source for subsequent drawing operations.

Function: cairo-set-source-surface (cr <cairo-t>) (surface <cairo-surface-t>) (x <double>) (y <double>)

This is a convenience function for creating a pattern from surface and setting it as the source in cr with cairo-set-source.

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 parameters 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 cairo-pattern-create-for-surface. The resulting pattern can be queried with cairo-get-source so that these attributes can be modified if desired, (eg. to create a repeating pattern with cairo-pattern-set-extend).

cr

a cairo context

surface

a surface to be used to set the source pattern

x

User-space X coordinate for surface origin

y

User-space Y coordinate for surface origin

Function: cairo-get-source (cr <cairo-t>) ⇒  (ret <cairo-pattern-t >)

Gets the current source pattern for cr.

cr

a cairo context

ret

the current source pattern. This object is owned by cairo. To keep a reference to it, you must call cairo-pattern-reference.

Function: cairo-set-antialias (cr <cairo-t>) (antialias <cairo-antialias-t>)

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 ‘CAIRO_ANTIALIAS_SUBPIXEL’ when drawing shapes.

Note that this option does not affect text rendering, instead see cairo-font-options-set-antialias.

cr

a <cairo-t>

antialias

the new antialiasing mode

Function: cairo-get-antialias (cr <cairo-t>) ⇒  (ret <cairo-antialias-t>)

Gets the current shape antialiasing mode, as set by cairo-set-shape-antialias.

cr

a cairo context

ret

the current shape antialiasing mode.

Function: cairo-set-dash (cr <cairo-t>) ⇒  (dashes <double>) (num-dashes <int>) (offset <double>)

Sets the dash pattern to be used by cairo-stroke. A dash pattern is specified by dashes, an array of positive values. Each value provides the length of alternate "on" and "off" portions of the stroke. The offset specifies an offset into the pattern at which the stroke begins.

Each "on" segment will have caps applied as if the segment were a separate sub-path. In particular, it is valid to use an "on" length of 0.0 with ‘CAIRO_LINE_CAP_ROUND’ or ‘CAIRO_LINE_CAP_SQUARE’ in order to distributed dots or squares along a path.

Note: The length values are in user-space units as evaluated at the time of stroking. This is not necessarily the same as the user space at the time of cairo-set-dash.

If num-dashes is 0 dashing is disabled.

If num-dashes is 1 a symmetric pattern is assumed with alternating on and off portions of the size specified by the single value in dashes.

If any value in dashes is negative, or if all values are 0, then cr will be put into an error state with a status of ‘CAIRO_STATUS_INVALID_DASH’.

cr

a cairo context

dashes

an array specifying alternate lengths of on and off stroke portions

num-dashes

the length of the dashes array

offset

an offset into the dash pattern at which the stroke should start

Function: cairo-get-dash-count (cr <cairo-t>) ⇒  (ret <int>)

This function returns the length of the dash array in cr (0 if dashing is not currently in effect).

See also cairo-set-dash and cairo-get-dash.

cr

a <cairo-t>

ret

the length of the dash array, or 0 if no dash array set.

Since 1.4

Function: cairo-set-fill-rule (cr <cairo-t>) (fill-rule <cairo-fill-rule-t>)

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 cairo-fill and cairo-clip. See <cairo-fill-rule-t> for details on the semantics of each available fill rule.

The default fill rule is ‘CAIRO_FILL_RULE_WINDING’.

cr

a <cairo-t>

fill-rule

a fill rule, specified as a <cairo-fill-rule-t>

Function: cairo-get-fill-rule (cr <cairo-t>) ⇒  (ret <cairo-fill-rule-t>)

Gets the current fill rule, as set by cairo-set-fill-rule.

cr

a cairo context

ret

the current fill rule.

Function: cairo-set-line-cap (cr <cairo-t>) (line-cap <cairo-line-cap-t>)

Sets the current line cap style within the cairo context. See <cairo-line-cap-t> 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 cairo-stroke, cairo-stroke-extents, and cairo-stroke-to-path, but does not have any effect during path construction.

The default line cap style is ‘CAIRO_LINE_CAP_BUTT’.

cr

a cairo context

line-cap

a line cap style

Function: cairo-get-line-cap (cr <cairo-t>) ⇒  (ret <cairo-line-cap-t>)

Gets the current line cap style, as set by cairo-set-line-cap.

cr

a cairo context

ret

the current line cap style.

Function: cairo-set-line-join (cr <cairo-t>) (line-join <cairo-line-join-t>)

Sets the current line join style within the cairo context. See <cairo-line-join-t> 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 cairo-stroke, cairo-stroke-extents, and cairo-stroke-to-path, but does not have any effect during path construction.

The default line join style is ‘CAIRO_LINE_JOIN_MITER’.

cr

a cairo context

line-join

a line join style

Function: cairo-get-line-join (cr <cairo-t>) ⇒  (ret <cairo-line-join-t>)

Gets the current line join style, as set by cairo-set-line-join.

cr

a cairo context

ret

the current line join style.

Function: cairo-set-line-width (cr <cairo-t>) (width <double>)

Sets the current line width within the cairo context. The line width value specifies the diameter of a pen that is circular in user space, (though device-space pen may be an ellipse in general due to scaling/shear/rotation of the CTM).

Note: When the description above refers to user space and CTM it refers to the user space and CTM in effect at the time of the stroking operation, not the user space and CTM in effect at the time of the call to cairo-set-line-width. The simplest usage makes both of these spaces identical. That is, if there is no change to the CTM between a call to cairo-set-line-width and the stroking operation, then one can just pass user-space values to cairo-set-line-width and ignore this note.

As with the other stroke parameters, the current line width is examined by cairo-stroke, cairo-stroke-extents, and cairo-stroke-to-path, but does not have any effect during path construction.

The default line width value is 2.0.

cr

a <cairo-t>

width

a line width

Function: cairo-get-line-width (cr <cairo-t>) ⇒  (ret <double>)

This function returns the current line width value exactly as set by cairo-set-line-width. Note that the value is unchanged even if the CTM has changed between the calls to cairo-set-line-width and cairo-get-line-width.

cr

a cairo context

ret

the current line width.

Function: cairo-set-miter-limit (cr <cairo-t>) (limit <double>)

Sets the current miter limit within the cairo context.

If the current line join style is set to ‘CAIRO_LINE_JOIN_MITER’ (see cairo-set-line-join), the miter limit is used to determine whether the lines should be joined with a bevel instead of a miter. Cairo divides the length of the miter by the line width. If the result is greater than the miter limit, the style is converted to a bevel.

As with the other stroke parameters, the current line miter limit is examined by cairo-stroke, cairo-stroke-extents, and cairo-stroke-to-path, but does not have any effect during path construction.

The default miter limit value is 10.0, which will convert joins with interior angles less than 11 degrees to bevels instead of miters. For reference, a miter limit of 2.0 makes the miter cutoff at 60 degrees, and a miter limit of 1.414 makes the cutoff at 90 degrees.

A miter limit for a desired angle can be computed as: miter limit = 1/sin(angle/2)

cr

a cairo context

limit

miter limit to set

Function: cairo-get-miter-limit (cr <cairo-t>) ⇒  (ret <double>)

Gets the current miter limit, as set by cairo-set-miter-limit.

cr

a cairo context

ret

the current miter limit.

Function: cairo-set-operator (cr <cairo-t>) (op <cairo-operator-t>)

Sets the compositing operator to be used for all drawing operations. See <cairo-operator-t> for details on the semantics of each available compositing operator.

The default operator is ‘CAIRO_OPERATOR_OVER’.

cr

a <cairo-t>

op

a compositing operator, specified as a <cairo-operator-t>

Function: cairo-get-operator (cr <cairo-t>) ⇒  (ret <cairo-operator-t>)

Gets the current compositing operator for a cairo context.

cr

a cairo context

ret

the current compositing operator.

Function: cairo-set-tolerance (cr <cairo-t>) (tolerance <double>)

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.) The accuracy of paths within Cairo is limited by the precision of its internal arithmetic, and the prescribed tolerance is restricted to the smallest representable internal value.

cr

a <cairo-t>

tolerance

the tolerance, in device units (typically pixels)

Function: cairo-get-tolerance (cr <cairo-t>) ⇒  (ret <double>)

Gets the current tolerance value, as set by cairo-set-tolerance.

cr

a cairo context

ret

the current tolerance value.

Function: cairo-clip (cr <cairo-t>)

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

After cairo-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 cairo-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 cairo-clip within a cairo-save/cairo-restore pair. The only other means of increasing the size of the clip region is cairo-reset-clip.

cr

a cairo context

Function: cairo-clip-preserve (cr <cairo-t>)

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

Unlike cairo-clip, cairo-clip-preserve 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 cairo-clip-preserve 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 cairo-clip-preserve within a cairo-save/cairo-restore pair. The only other means of increasing the size of the clip region is cairo-reset-clip.

cr

a cairo context

Function: cairo-clip-extents (cr <cairo-t>) ⇒  (x1 <double>) (y1 <double>) (x2 <double>) (y2 <double>)

Computes a bounding box in user coordinates covering the area inside the current clip.

cr

a cairo context

x1

left of the resulting extents

y1

top of the resulting extents

x2

right of the resulting extents

y2

bottom of the resulting extents

Since 1.4

Function: cairo-in-clip (cr <cairo-t>) (x <double>) (y <double>) ⇒  (ret <cairo-bool-t>)

Tests whether the given point is inside the area that would be visible through the current clip, i.e. the area that would be filled by a cairo-paint operation.

See cairo-clip, and cairo-clip-preserve.

cr

a cairo context

x

X coordinate of the point to test

y

Y coordinate of the point to test

ret

A non-zero value if the point is inside, or zero if outside.

Since 1.10

Function: cairo-reset-clip (cr <cairo-t>)

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 cairo-reset-clip as it will cause results unexpected by higher-level code which calls cairo-clip. Consider using cairo-save and cairo-restore around cairo-clip as a more robust means of temporarily restricting the clip region.

cr

a cairo context

Function: cairo-copy-clip-rectangle-list (cr <cairo-t>) ⇒  (ret <cairo-rectangle-list-t >)

Gets the current clip region as a list of rectangles in user coordinates. Never returns ‘#f’.

The status in the list may be ‘CAIRO_STATUS_CLIP_NOT_REPRESENTABLE’ to indicate that the clip region cannot be represented as a list of user-space rectangles. The status may have other values to indicate other errors.

cr

a cairo context

ret

the current clip region as a list of rectangles in user coordinates, which should be destroyed using cairo-rectangle-list-destroy.

Since 1.4

Function: cairo-fill (cr <cairo-t>)

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

cr

a cairo context

Function: cairo-fill-preserve (cr <cairo-t>)

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

See cairo-set-fill-rule and cairo-fill.

cr

a cairo context

Function: cairo-fill-extents (cr <cairo-t>) ⇒  (x1 <double>) (y1 <double>) (x2 <double>) (y2 <double>)

Computes a bounding box in user coordinates covering the area that would be affected, (the "inked" area), by a cairo-fill operation given the current path and fill parameters. If the current path is empty, returns an empty rectangle ((0,0), (0,0)). Surface dimensions and clipping are not taken into account.

Contrast with cairo-path-extents, which is similar, but returns non-zero extents for some paths with no inked area, (such as a simple line segment).

Note that cairo-fill-extents must necessarily do more work to compute the precise inked areas in light of the fill rule, so cairo-path-extents may be more desirable for sake of performance if the non-inked path extents are desired.

See cairo-fill, cairo-set-fill-rule and cairo-fill-preserve.

cr

a cairo context

x1

left of the resulting extents

y1

top of the resulting extents

x2

right of the resulting extents

y2

bottom of the resulting extents

Function: cairo-in-fill (cr <cairo-t>) (x <double>) (y <double>) ⇒  (ret <cairo-bool-t>)

Tests whether the given point is inside the area that would be affected by a cairo-fill operation given the current path and filling parameters. Surface dimensions and clipping are not taken into account.

See cairo-fill, cairo-set-fill-rule and cairo-fill-preserve.

cr

a cairo context

x

X coordinate of the point to test

y

Y coordinate of the point to test

ret

A non-zero value if the point is inside, or zero if outside.

Function: cairo-mask (cr <cairo-t>) (pattern <cairo-pattern-t>)

A drawing operator that paints the current source using the alpha channel of pattern as a mask. (Opaque areas of pattern are painted with the source, transparent areas are not painted.)

cr

a cairo context

pattern

a <cairo-pattern-t>

Function: cairo-mask-surface (cr <cairo-t>) (surface <cairo-surface-t>) (surface-x <double>) (surface-y <double>)

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.)

cr

a cairo context

surface

a <cairo-surface-t>

surface-x

X coordinate at which to place the origin of surface

surface-y

Y coordinate at which to place the origin of surface

Function: cairo-paint (cr <cairo-t>)

A drawing operator that paints the current source everywhere within the current clip region.

cr

a cairo context

Function: cairo-paint-with-alpha (cr <cairo-t>) (alpha <double>)

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 cairo-paint, but the drawing is faded out using the alpha value.

cr

a cairo context

alpha

alpha value, between 0 (transparent) and 1 (opaque)

Function: cairo-stroke (cr <cairo-t>)

A drawing operator that strokes the current path according to the current line width, line join, line cap, and dash settings. After cairo-stroke, the current path will be cleared from the cairo context. See cairo-set-line-width, cairo-set-line-join, cairo-set-line-cap, cairo-set-dash, and cairo-stroke-preserve.

Note: Degenerate segments and sub-paths are treated specially and provide a useful result. These can result in two different situations:

1. Zero-length "on" segments set in cairo-set-dash. If the cap style is ‘CAIRO_LINE_CAP_ROUND’ or ‘CAIRO_LINE_CAP_SQUARE’ then these segments will be drawn as circular dots or squares respectively. In the case of ‘CAIRO_LINE_CAP_SQUARE’, the orientation of the squares is determined by the direction of the underlying path.

2. A sub-path created by cairo-move-to followed by either a cairo-close-path or one or more calls to cairo-line-to to the same coordinate as the cairo-move-to. If the cap style is ‘CAIRO_LINE_CAP_ROUND’ then these sub-paths will be drawn as circular dots. Note that in the case of ‘CAIRO_LINE_CAP_SQUARE’ a degenerate sub-path will not be drawn at all, (since the correct orientation is indeterminate).

In no case will a cap style of ‘CAIRO_LINE_CAP_BUTT’ cause anything to be drawn in the case of either degenerate segments or sub-paths.

cr

a cairo context

Function: cairo-stroke-preserve (cr <cairo-t>)

A drawing operator that strokes the current path according to the current line width, line join, line cap, and dash settings. Unlike cairo-stroke, cairo-stroke-preserve preserves the path within the cairo context.

See cairo-set-line-width, cairo-set-line-join, cairo-set-line-cap, cairo-set-dash, and cairo-stroke-preserve.

cr

a cairo context

Function: cairo-stroke-extents (cr <cairo-t>) ⇒  (x1 <double>) (y1 <double>) (x2 <double>) (y2 <double>)

Computes a bounding box in user coordinates covering the area that would be affected, (the "inked" area), by a cairo-stroke operation given the current path and stroke parameters. If the current path is empty, returns an empty rectangle ((0,0), (0,0)). Surface dimensions and clipping are not taken into account.

Note that if the line width is set to exactly zero, then cairo-stroke-extents will return an empty rectangle. Contrast with cairo-path-extents which can be used to compute the non-empty bounds as the line width approaches zero.

Note that cairo-stroke-extents must necessarily do more work to compute the precise inked areas in light of the stroke parameters, so cairo-path-extents may be more desirable for sake of performance if non-inked path extents are desired.

See cairo-stroke, cairo-set-line-width, cairo-set-line-join, cairo-set-line-cap, cairo-set-dash, and cairo-stroke-preserve.

cr

a cairo context

x1

left of the resulting extents

y1

top of the resulting extents

x2

right of the resulting extents

y2

bottom of the resulting extents

Function: cairo-in-stroke (cr <cairo-t>) (x <double>) (y <double>) ⇒  (ret <cairo-bool-t>)

Tests whether the given point is inside the area that would be affected by a cairo-stroke operation given the current path and stroking parameters. Surface dimensions and clipping are not taken into account.

See cairo-stroke, cairo-set-line-width, cairo-set-line-join, cairo-set-line-cap, cairo-set-dash, and cairo-stroke-preserve.

cr

a cairo context

x

X coordinate of the point to test

y

Y coordinate of the point to test

ret

A non-zero value if the point is inside, or zero if outside.

Function: cairo-copy-page (cr <cairo-t>)

Emits the current page for backends that support multiple pages, but doesn’t clear it, so, the contents of the current page will be retained for the next page too. Use cairo-show-page if you want to get an empty page after the emission.

This is a convenience function that simply calls cairo-surface-copy-page on cr’s target.

cr

a cairo context

Function: cairo-show-page (cr <cairo-t>)

Emits and clears the current page for backends that support multiple pages. Use cairo-copy-page if you don’t want to clear the page.

This is a convenience function that simply calls cairo-surface-show-page on cr’s target.

cr

a cairo context


Next: , Previous: , Up: Top   [Index]