cairo-context: cairo_t

Description Methods and Functions Detailed Description Structures Convenient Construction Enums and Flags Author(s) References

Description

The cairo drawing context

Methods and Functions

cairoCreate(target)
cairoStatus(cr)
cairoSave(cr)
cairoRestore(cr)
cairoGetTarget(cr)
cairoPushGroup(cr)
cairoPushGroupWithContent(cr, content)
cairoPopGroup(cr)
cairoPopGroupToSource(cr)
cairoGetGroupTarget(cr)
cairoSetSourceRgb(cr, red, green, blue)
cairoSetSourceRgba(cr, red, green, blue, alpha)
cairoSetSource(cr, source)
cairoSetSourceSurface(cr, surface, x, y)
cairoGetSource(cr)
cairoSetAntialias(cr, antialias)
cairoGetAntialias(cr)
cairoSetDash(cr, dashes, offset)
cairoGetDashCount(cr)
cairoGetDash(cr)
cairoSetFillRule(cr, fill.rule)
cairoGetFillRule(cr)
cairoSetLineCap(cr, line.cap)
cairoGetLineCap(cr)
cairoSetLineJoin(cr, line.join)
cairoGetLineJoin(cr)
cairoSetLineWidth(cr, width)
cairoGetLineWidth(cr)
cairoSetMiterLimit(cr, limit)
cairoGetMiterLimit(cr)
cairoSetOperator(cr, op)
cairoGetOperator(cr)
cairoSetTolerance(cr, tolerance)
cairoGetTolerance(cr)
cairoClip(cr)
cairoClipPreserve(cr)
cairoClipExtents(cr)
cairoResetClip(cr)
cairoCopyClipRectangleList(cr)
cairoFill(cr)
cairoFillPreserve(cr)
cairoFillExtents(cr)
cairoInFill(cr, x, y)
cairoMask(cr, pattern)
cairoMaskSurface(cr, surface, surface.x, surface.y)
cairoPaint(cr)
cairoPaintWithAlpha(cr, alpha)
cairoStroke(cr)
cairoStrokePreserve(cr)
cairoStrokeExtents(cr)
cairoInStroke(cr, x, y)
cairoCopyPage(cr)
cairoShowPage(cr)
cairoSetUserData(cr, key, user.data)
cairoGetUserData(cr, key)
cairo(target)

Detailed Description

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 cairoMoveTo and cairoLineTo, and then draw shapes with cairoStroke or cairoFill. Cairo's can be pushed to a stack via cairoSave. They may then safely be changed, without loosing the current state. Use cairoRestore to restore to the saved state.

Structures

Cairo

A Cairo contains the current state of the rendering device, including coordinates of yet to be drawn shapes.

Cairo contexts, as Cairo objects are named, are central to cairo and all drawing with cairo is always done to a Cairo object.

Memory management of Cairo is done with cairoReference() and cairoDestroy().

CairoRectangle

A data structure for holding a rectangle. Since 1.4 CairoRectangle is a transparent-type.

x

[numeric] X coordinate of the left side of the rectangle

y

[numeric] Y coordinate of the the top side of the rectangle

width

[numeric] width of the rectangle

height

[numeric] height of the rectangle

CairoRectangleList

A data structure for holding a dynamically allocated array of rectangles. Since 1.4 CairoRectangleList is a transparent-type.

status

[CairoStatus] Error status of the rectangle list

rectangles

[CairoRectangle] list containing the rectangles

num_rectangles

[integer] Number of rectangles in this list

Convenient Construction

cairo is the equivalent of cairoCreate.

Enums and Flags

CairoAntialias

Specifies the type of antialiasing to do when rendering text or shapes.

default

Use the default antialiasing for the subsystem and target device

none

Use a bilevel alpha mask

gray

Perform single-color antialiasing (using shades of gray for black text on a white background, for example).

subpixel

Perform antialiasing by taking advantage of the order of subpixel elements on devices such as LCD panels

CairoFillRule

CairoFillRule is used to select how paths are filled. For both fill rules, whether or not a point is included in the fill is determined by taking a ray from that point to infinity and looking at intersections with the path. The ray can be in any direction, as long as it doesn't pass through the end point of a segment or have a tricky intersection such as intersecting tangent to the path. (Note that filling is not actually implemented in this way. This is just a description of the rule that is applied.)

The default fill rule is CAIRO_FILL_RULE_WINDING.

New entries may be added in future versions.

winding

If the path crosses the ray from left-to-right, counts +1. If the path crosses the ray from right to left, counts -1. (Left and right are determined from the perspective of looking along the ray from the starting point.) If the total count is non-zero, the point will be filled.

even-odd

Counts the total number of intersections, without regard to the orientation of the contour. If the total number of intersections is odd, the point will be filled.

CairoLineCap

Specifies how to render the endpoints of the path when stroking.

The default line cap style is CAIRO_LINE_CAP_BUTT.

butt

start(stop) the line exactly at the start(end) point

round

use a round ending, the center of the circle is the end point

square

use squared ending, the center of the square is the end point

CairoLineJoin

Specifies how to render the junction of two lines when stroking.

The default line join style is CAIRO_LINE_JOIN_MITER.

miter

use a sharp (angled) corner, see cairoSetMiterLimit

round

use a rounded join, the center of the circle is the joint point

bevel

use a cut-off join, the join is cut off at half the line width from the joint point

CairoOperator

CairoOperator is used to set the compositing operator for all cairo drawing operations.

The default operator is CAIRO_OPERATOR_OVER.

The operators marked as unbounded modify their destination even outside of the mask layer (that is, their effect is not bound by the mask layer). However, their effect can still be limited by way of clipping.

To keep things simple, the operator descriptions here document the behavior for when both source and destination are either fully transparent or fully opaque. The actual implementation works for translucent layers too. For a more detailed explanation of the effects of each operator, including the mathematical definitions, see http://cairographics.org/operators/ (http://cairographics.org/operators/).

clear

clear destination layer (bounded)

source

replace destination layer (bounded)

over

draw source layer on top of destination layer (bounded)

in

draw source where there was destination content (unbounded)

out

draw source where there was no destination content (unbounded)

atop

draw source on top of destination content and only there

dest

ignore the source

dest-over

draw destination on top of source

dest-in

leave destination only where there was source content (unbounded)

dest-out

leave destination only where there was no source content

dest-atop

leave destination on top of source content and only there (unbounded)

xor

source and destination are shown where there is only one of them

add

source and destination layers are accumulated

saturate

like over, but assuming source and dest are disjoint geometries

Author(s)

Derived by RGtkGen from GTK+ documentation

References

https://www.cairographics.org/manual/cairo-cairo-t.html


RGtk2 documentation built on Oct. 14, 2021, 5:08 p.m.

Related to cairo-context in RGtk2...