W Wrapl, The Programming Language

Libraries:Gtk:Cairo:Cairo

Types

T

Constants

Nil : T

Functions

Create(target @ Gtk.Cairo.Surface.T) : Gtk.Cairo.Cairo.T

Creates a new 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 Gtk.Cairo.Surface.ImageSurfaceCreate (or any other cairo_backend_surface_create() variant).

This function references target, so you can immediately call cairo_surface_destroy() on it if you don't need to maintain a separate reference to it.

target target surface for the context
Returns a newly allocated T with a reference count of 1. The initial reference count should be released with Destroy when you are done using the T. This function never returns NULL. If memory cannot be allocated, a special T object will be returned on which Status returns Gtk.Cairo.Status.NoMemory. You can use this object normally, but no drawing will be done.


Methods

:"="(_ @ T, _ @ T)

:AppendPath(self @ T, path @ Gtk.Cairo.Path.T) : Std.Object.T

Append the path onto the current path. The path may be either the return value from one of CopyPath or CopyPathFlat or it may be constructed manually. See Gtk.Cairo.Path.T for details on how the path data structure should be initialized, and note that path->status must be initialized to Gtk.Cairo.Status.Success.

cr a cairo context
path path to be appended


:Arc(self @ T, xc @ Std.Real.T, yc @ Std.Real.T, radius @ Std.Real.T, angle1 @ Std.Real.T, angle2 @ Std.Real.T) : Std.Object.T

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*M_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. If this initial line is undesired, it can be avoided by calling NewSubPath before calling Arc.

Angles are measured in radians. An angle of 0.0 is in the direction of the positive X axis (in user space). An angle of M_PI/2.0 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 * (M_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:

cairo_save (cr);
cairo_translate (cr, x + width / 2., y + height / 2.);
cairo_scale (cr, width / 2., height / 2.);
cairo_arc (cr, 0., 0., 1., 0., 2 * M_PI);
cairo_restore (cr);


:ArcNegative(self @ T, xc @ Std.Real.T, yc @ Std.Real.T, radius @ Std.Real.T, angle1 @ Std.Real.T, angle2 @ Std.Real.T) : Std.Object.T

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*M_PI until it is less than angle1.

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

cr a cairo context
xc X position of the center of the arc
yc Y position of the center of the arc
radius the radius of the arc
angle1 the start angle, in radians
angle2 the end angle, in radians


:Clip(self @ T) : Std.Object.T

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/Restore pair. The only other means of increasing the size of the clip region is ResetClip.

cr a cairo context


:ClipExtents(self @ T, x1, y1, x2, y2) : Std.Object.T

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


:ClosePath(self @ T) : Std.Object.T

Adds a line segment to the path from the current point to the beginning of the current sub-path, (the most recent point passed to MoveTo), and closes this sub-path. After this call the current point will be at the joined endpoint of the sub-path.

The behavior of ClosePath is distinct from simply calling LineTo with the equivalent coordinate in the case of stroking. When a closed sub-path is stroked, there are no caps on the ends of the sub-path. Instead, there is a line join connecting the final and initial segments of the sub-path.

If there is no current point before the call to ClosePath, this function will have no effect.

Note: As of cairo version 1.2.4 any call to ClosePath will place an explicit MOVE_TO element into the path immediately after the CLOSE_PATH element, (which can be seen in CopyPath for example). This can simplify path processing in some cases as it may not be necessary to save the "last move_to point" during processing as the MOVE_TO immediately after the CLOSE_PATH will provide that point.

cr a cairo context


:CopyClipRectangleList(self @ T) : Gtk.Cairo.RectangleList.T

Gets the current clip region as a list of rectangles in user coordinates. Never returns NULL.

The status in the list may be Gtk.Cairo.Status.ClipNotRepresentable 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
Returns the current clip region as a list of rectangles in user coordinates, which should be destroyed using Gtk.Cairo.RectangleList.Destroy.


:CopyPage(self @ T) : Std.Object.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 ShowPage 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


:CopyPath(self @ T) : Gtk.Cairo.Path.T

Creates a copy of the current path and returns it to the user as a Gtk.Cairo.Path.T. See cairo_path_data_t for hints on how to iterate over the returned data structure.

This function will always return a valid pointer, but the result will have no data (data==NULL and num_data==0), if either of the following conditions hold:

  1. If there is insufficient memory to copy the path. In this case path->status will be set to Gtk.Cairo.Status.NoMemory.
  2. If cr is already in an error state. In this case path->status will contain the same status that would be returned by Status.


:CopyPathFlat(self @ T) : Gtk.Cairo.Path.T

Gets a flattened copy of the current path and returns it to the user as a Gtk.Cairo.Path.T. See cairo_path_data_t for hints on how to iterate over the returned data structure.

This function is like CopyPath except that any curves in the path will be approximated with piecewise-linear approximations, (accurate to within the current tolerance value). That is, the result is guaranteed to not have any elements of type CAIRO_PATH_CURVE_TO which will instead be replaced by a series of CAIRO_PATH_LINE_TO elements.

This function will always return a valid pointer, but the result will have no data (data==NULL and num_data==0), if either of the following conditions hold:

  1. If there is insufficient memory to copy the path. In this case path->status will be set to Gtk.Cairo.Status.NoMemory.
  2. If cr is already in an error state. In this case path->status will contain the same status that would be returned by Status.


:CurveTo(self @ T, x1 @ Std.Real.T, y1 @ Std.Real.T, x2 @ Std.Real.T, y2 @ Std.Real.T, x3 @ Std.Real.T, y3 @ Std.Real.T) : Std.Object.T

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

If there is no current point before the call to CurveTo this function will behave as if preceded by a call to cairo_move_to(cr, x1, y1).

cr a cairo context
x1 the X coordinate of the first control point
y1 the Y coordinate of the first control point
x2 the X coordinate of the second control point
y2 the Y coordinate of the second control point
x3 the X coordinate of the end of the curve
y3 the Y coordinate of the end of the curve


:Destroy(self @ T) : Std.Object.T

Decreases the reference count on cr by one. If the result is zero, then cr and all associated resources are freed. See cairo_reference().

cr a T


:DeviceToUser(self @ T, x @ Std.Real.T, y @ Std.Real.T) : Std.Object.T

Transform a coordinate from device space to user space by multiplying the given point by the inverse of the current transformation matrix (CTM).

cr a cairo
x X value of coordinate (in/out parameter)
y Y value of coordinate (in/out parameter)


:DeviceToUserDistance(self @ T, dx @ Std.Real.T, dy @ Std.Real.T) : Std.Object.T

Transform a distance vector from device space to user space. This function is similar to DeviceToUser except that the translation components of the inverse CTM will be ignored when transforming (dx,dy).

cr a cairo context
dx X component of a distance vector (in/out parameter)
dy Y component of a distance vector (in/out parameter)


:Fill(self @ T) : Std.Object.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 Fill, the current path will be cleared from the cairo context. See SetFillRule and FillPreserve.

cr a cairo context


:FillExtents(self @ T, x1, y1, x2, y2) : Std.Object.T

Computes a bounding box in user coordinates covering the area that would be affected, (the "inked" area), by a 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 FillExtents 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 Fill, SetFillRule and FillPreserve.

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


:FillPreserve(self @ T) : Std.Object.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 Fill, FillPreserve preserves the path within the cairo context.

See SetFillRule and Fill.

cr a cairo context


:FontExtents(self @ T, extents @ Gtk.Cairo.FontExtents.T) : Std.Object.T

Gets the font extents for the currently selected font.

cr a T
extents a Gtk.Cairo.FontExtents.T object into which the results will be stored.


:GetAntialias(self @ T) : Gtk.Cairo.Antialias.T

Gets the current shape antialiasing mode, as set by cairo_set_shape_antialias().

cr a cairo context
Returns the current shape antialiasing mode.


:GetCurrentPoint(self @ T, x, y) : Std.Object.T

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 or if cr is in an error status, x and y will both be set to 0.0. It is possible to check this in advance with cairo_has_current_point().

Most path construction functions alter the current point. See the following for details on how they affect the current point: NewPath, NewSubPath, AppendPath, ClosePath, MoveTo, LineTo, CurveTo, RelMoveTo, RelLineTo, RelCurveTo, Arc, ArcNegative, Rectangle, TextPath, GlyphPath, cairo_stroke_to_path().

Some functions use and alter the current point but do not otherwise change current path: ShowText.

Some functions unset the current path and as a result, current point: Fill, Stroke.

cr a cairo context
x return value for X coordinate of the current point
y return value for Y coordinate of the current point


:GetDash(self @ T, dashes @ Std.Object.T, offset @ Std.Object.T) : Std.Object.T

Gets the current dash array. If not NULL, dashes should be big enough to hold at least the number of values returned by GetDashCount.

cr a T
dashes return value for the dash array, or NULL
offset return value for the current dash offset, or NULL


:GetDashCount(self @ T) : Std.Integer.SmallT

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

See also SetDash and GetDash.

cr a T
Returns the length of the dash array, or 0 if no dash array set.


:GetFillRule(self @ T) : Gtk.Cairo.FillRule.T

Gets the current fill rule, as set by SetFillRule.

cr a cairo context
Returns the current fill rule.


:GetFontFace(self @ T) : Gtk.Cairo.FontFace.T

Gets the current font face for a T.

cr a T
Returns the current font face. This object is owned by cairo. To keep a reference to it, you must call cairo_font_face_reference(). This function never returns NULL. If memory cannot be allocated, a special "nil" Gtk.Cairo.FontFace.T object will be returned on which cairo_font_face_status() returns Gtk.Cairo.Status.NoMemory. Using this nil object will cause its error state to propagate to other objects it is passed to, (for example, calling SetFontFace with a nil font will trigger an error that will shutdown the T object).


:GetFontMatrix(self @ T, matrix @ Gtk.Cairo.Matrix.T) : Std.Object.T

Stores the current font matrix into matrix. See SetFontMatrix.

cr a T
matrix return value for the matrix


:GetFontOptions(self @ T, options @ Gtk.Cairo.FontOptions.T) : Std.Object.T

Retrieves font rendering options set via SetFontOptions. Note that the returned options do not include any options derived from the underlying surface; they are literally the options passed to SetFontOptions.

cr a T
options a Gtk.Cairo.FontOptions.T object into which to store the retrieved options. All existing values are overwritten


:GetGroupTarget(self @ T) : Gtk.Cairo.Surface.T

Gets the current destination surface for the context. This is either the original target surface as passed to 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. Status != Gtk.Cairo.Status.Success). A nil surface is indicated by cairo_surface_status() != Gtk.Cairo.Status.Success.

cr a cairo context
Returns the target surface. This object is owned by cairo. To keep a reference to it, you must call cairo_surface_reference().


:GetLineCap(self @ T) : Gtk.Cairo.LineCap.T

Gets the current line cap style, as set by SetLineCap.

cr a cairo context
Returns the current line cap style.


:GetLineJoin(self @ T) : Gtk.Cairo.LineJoin.T

Gets the current line join style, as set by SetLineJoin.

cr a cairo context
Returns the current line join style.


:GetLineWidth(self @ T) : Std.Real.T

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

cr a cairo context
Returns the current line width.


:GetMatrix(self @ T, matrix @ Gtk.Cairo.Matrix.T) : Std.Object.T

Stores the current transformation matrix (CTM) into matrix.

cr a cairo context
matrix return value for the matrix


:GetMiterLimit(self @ T) : Std.Real.T

Gets the current miter limit, as set by SetMiterLimit.

cr a cairo context
Returns the current miter limit.


:GetOperator(self @ T) : Gtk.Cairo.Operator.T

Gets the current compositing operator for a cairo context.

cr a cairo context
Returns the current compositing operator.


:GetScaledFont(self @ T) : Gtk.Cairo.ScaledFont.T

Gets the current scaled font for a T.

cr a T
Returns the current scaled font. This object is owned by cairo. To keep a reference to it, you must call cairo_scaled_font_reference(). This function never returns NULL. If memory cannot be allocated, a special "nil" Gtk.Cairo.ScaledFont.T object will be returned on which cairo_scaled_font_status() returns Gtk.Cairo.Status.NoMemory. Using this nil object will cause its error state to propagate to other objects it is passed to, (for example, calling SetScaledFont with a nil font will trigger an error that will shutdown the T object).


:GetSource(self @ T) : Gtk.Cairo.Pattern.T

Gets the current source pattern for cr.

cr a cairo context
Returns the current source pattern. This object is owned by cairo. To keep a reference to it, you must call cairo_pattern_reference().


:GetTarget(self @ T) : Gtk.Cairo.Surface.T

Gets the target surface for the cairo context as passed to 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. Status != Gtk.Cairo.Status.Success). A nil surface is indicated by cairo_surface_status() != Gtk.Cairo.Status.Success.

cr a cairo context
Returns the target surface. This object is owned by cairo. To keep a reference to it, you must call cairo_surface_reference().


:GetTolerance(self @ T) : Std.Real.T

Gets the current tolerance value, as set by SetTolerance.

cr a cairo context
Returns the current tolerance value.


:GlyphExtents(self @ T, glyphs @ Gtk.Cairo.Glyph.T, num_glyphs @ Std.Integer.SmallT, extents @ Gtk.Cairo.TextExtents.T) : Std.Object.T

Gets the extents for an array of glyphs. The extents describe a user-space rectangle that encloses the "inked" portion of the glyphs, (as they would be drawn by ShowGlyphs). Additionally, the x_advance and y_advance values indicate the amount by which the current point would be advanced by ShowGlyphs.

Note that whitespace glyphs do not contribute to the size of the rectangle (extents.width and extents.height).

cr a T
glyphs an array of Gtk.Cairo.Glyph.T objects
num_glyphs the number of elements in glyphs
extents a Gtk.Cairo.TextExtents.T object into which the results will be stored


:GlyphPath(self @ T, glyphs @ Gtk.Cairo.Glyph.T, num_glyphs @ Std.Integer.SmallT) : Std.Object.T

Adds closed paths for the glyphs to the current path. The generated path if filled, achieves an effect similar to that of ShowGlyphs.

cr a cairo context
glyphs array of glyphs to show
num_glyphs number of glyphs to show


:IdentityMatrix(self @ T) : Std.Object.T

Resets the current transformation matrix (CTM) by setting it equal to the identity matrix. That is, the user-space and device-space axes will be aligned and one user-space unit will transform to one device-space unit.

cr a cairo context


:InFill(self @ T, x @ Std.Real.T, y @ Std.Real.T) : Std.Object.T

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

See Stroke, SetLineWidth, SetLineJoin, SetLineCap, SetDash, and StrokePreserve.

cr a cairo context
x X coordinate of the point to test
y Y coordinate of the point to test
Returns A non-zero value if the point is inside, or zero if outside.


:InStroke(self @ T, x @ Std.Real.T, y @ Std.Real.T) : Std.Object.T

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

See Stroke, SetLineWidth, SetLineJoin, SetLineCap, SetDash, and StrokePreserve.

cr a cairo context
x X coordinate of the point to test
y Y coordinate of the point to test
Returns A non-zero value if the point is inside, or zero if outside.


:LineTo(self @ T, x @ Std.Real.T, y @ Std.Real.T) : Std.Object.T

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

If there is no current point before the call to LineTo this function will behave as cairo_move_to(cr, x, y).

cr a cairo context
x the X coordinate of the end of the new line
y the Y coordinate of the end of the new line


:Mask(self @ T, pattern @ Gtk.Cairo.Pattern.T) : Std.Object.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 Gtk.Cairo.Pattern.T


:MaskSurface(self @ T, surface @ Gtk.Cairo.Surface.T, surface_x @ Std.Real.T, surface_y @ Std.Real.T) : Std.Object.T

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


:MoveTo(self @ T, x @ Std.Real.T, y @ Std.Real.T) : Std.Object.T

Begin a new sub-path. After this call the current point will be (x, y).

cr a cairo context
x the X coordinate of the new position
y the Y coordinate of the new position


:NewPath(self @ T) : Std.Object.T

Clears the current path. After this call there will be no path and no current point.

cr a cairo context


:NewSubPath(self @ T) : Std.Object.T

Begin a new sub-path. Note that the existing path is not affected. After this call there will be no current point.

In many cases, this call is not needed since new sub-paths are frequently started with MoveTo.

A call to NewSubPath is particularly useful when beginning a new sub-path with one of the Arc calls. This makes things easier as it is no longer necessary to manually compute the arc's initial coordinates for a call to MoveTo.

cr a cairo context


:Paint(self @ T) : Std.Object.T

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

cr a cairo context


:PaintWithAlpha(self @ T, alpha @ Std.Real.T) : Std.Object.T

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.

cr a cairo context
alpha alpha value, between 0 (transparent) and 1 (opaque)


:Rectangle(self @ T, x @ Std.Real.T, y @ Std.Real.T, width @ Std.Real.T, height @ Std.Real.T) : Std.Object.T

Adds a closed sub-path rectangle of the given size to the current path at position (x, y) in user-space coordinates.

This function is logically equivalent to:

cairo_move_to (cr, x, y);
cairo_rel_line_to (cr, width, 0);
cairo_rel_line_to (cr, 0, height);
cairo_rel_line_to (cr, -width, 0);
cairo_close_path (cr);


:RelCurveTo(self @ T, x1 @ Std.Real.T, y1 @ Std.Real.T, x2 @ Std.Real.T, y2 @ Std.Real.T, x3 @ Std.Real.T, y3 @ Std.Real.T) : Std.Object.T

Relative-coordinate version of CurveTo. All offsets are relative to the current point. Adds a cubic Bézier 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), cairo_rel_curve_to(cr, dx1, dy1, dx2, dy2, dx3, dy3) is logically equivalent to cairo_curve_to(cr, x+dx1, y+dy1, x+dx2, y+dy2, x+dx3, y+dy3).

It is an error to call this function with no current point. Doing so will cause cr to shutdown with a status of Gtk.Cairo.Status.NoCurrentPoint.

cr a cairo context
dx1 the X offset to the first control point
dy1 the Y offset to the first control point
dx2 the X offset to the second control point
dy2 the Y offset to the second control point
dx3 the X offset to the end of the curve
dy3 the Y offset to the end of the curve


:RelLineTo(self @ T, x @ Std.Real.T, y @ Std.Real.T) : Std.Object.T

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), cairo_rel_line_to(cr, dx, dy) is logically equivalent to cairo_line_to(cr, x + dx, y + dy).

It is an error to call this function with no current point. Doing so will cause cr to shutdown with a status of Gtk.Cairo.Status.NoCurrentPoint.

cr a cairo context
dx the X offset to the end of the new line
dy the Y offset to the end of the new line


:RelMoveTo(self @ T, x @ Std.Real.T, y @ Std.Real.T) : Std.Object.T

Begin a new sub-path. After this call the current point will offset by (x, y).

Given a current point of (x, y), cairo_rel_move_to(cr, dx, dy) is logically equivalent to cairo_move_to(cr, x + dx, y + dy).

It is an error to call this function with no current point. Doing so will cause cr to shutdown with a status of Gtk.Cairo.Status.NoCurrentPoint.

cr a cairo context
dx the X offset
dy the Y offset


:ResetClip(self @ T) : Std.Object.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 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.

cr a cairo context


:Restore(self @ T) : Std.Object.T

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

cr a T


:Rotate(self @ T, angle @ Std.Real.T) : Std.Object.T

Modifies the current transformation matrix (CTM) by rotating the user-space axes by angle radians. The rotation of the axes takes places after any existing transformation of user space. The rotation direction for positive angles is from the positive X axis toward the positive Y axis.

cr a cairo context
angle angle (in radians) by which the user-space axes will be rotated


:Save(self @ T) : Std.Object.T

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

It isn't necessary to clear all saved states before a T is freed. If the reference count of a T drops to zero in response to a call to Destroy, any saved states will be freed along with the T.

cr a T


:Scale(self @ T, sx @ Std.Real.T, sy @ Std.Real.T) : Std.Object.T

Modifies the current transformation matrix (CTM) by scaling the X and Y user-space axes by sx and sy respectively. The scaling of the axes takes place after any existing transformation of user space.

cr a cairo context
sx scale factor for the X dimension
sy scale factor for the Y dimension


:SelectFontFace(self @ T, family @ Std.String.T, slant @ Gtk.Cairo.FontSlant.T, weight @ Gtk.Cairo.FontWeight.T) : Std.Object.T

Note: The SelectFontFace function call is part of what the cairo designers call the "toy" text API. It is convenient for short demos and simple programs, but it is not expected to be adequate for serious text-using applications.

Selects a family and style of font from a simplified description as a family name, slant and weight. Cairo provides no operation to list available family names on the system (this is a "toy", remember), but the standard CSS2 generic family names, ("serif", "sans-serif", "cursive", "fantasy", "monospace"), are likely to work as expected.

If family starts with the string "cairo:", or if no native font backends are compiled in, cairo will use an internal font family. The internal font family recognizes many modifiers in the family string, most notably, it recognizes the string "monospace". That is, the family name "cairo:monospace" will use the monospace version of the internal font family.

For "real" font selection, see the font-backend-specific font_face_create functions for the font backend you are using. (For example, if you are using the freetype-based cairo-ft font backend, see cairo_ft_font_face_create_for_ft_face() or cairo_ft_font_face_create_for_pattern().) The resulting font face could then be used with cairo_scaled_font_create() and SetScaledFont.

Similarly, when using the "real" font support, you can call directly into the underlying font system, (such as fontconfig or freetype), for operations such as listing available fonts, etc.

It is expected that most applications will need to use a more comprehensive font handling and text layout library, (for example, pango), in conjunction with cairo.

If text is drawn without a call to SelectFontFace, (nor SetFontFace nor SetScaledFont), the default family is platform-specific, but is essentially "sans-serif". Default slant is Gtk.Cairo.FontSlant.Normal, and default weight is Gtk.Cairo.FontWeight.Normal.

This function is equivalent to a call to cairo_toy_font_face_create() followed by SetFontFace.

cr a T
family a font family name, encoded in UTF-8
slant the slant for the font
weight the weight for the font


:SetAntialias(self @ T, antialias @ Gtk.Cairo.Antialias.T) : Std.Object.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 Gtk.Cairo.Antialias.Subpixel when drawing shapes.

Note that this option does not affect text rendering, instead see Gtk.Cairo.FontOptions.SetAntialias.

cr a T
antialias the new antialiasing mode


:SetDash(self @ T, dashes @ Std.Object.T, num_dashes @ Std.Integer.SmallT, offset @ Std.Real.T) : Std.Object.T

Sets the dash pattern to be used by 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 Gtk.Cairo.LineCap.Round or Gtk.Cairo.LineCap.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 SetDash.

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 Gtk.Cairo.Status.InvalidDash.

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


:SetFillRule(self @ T, fill_rule @ Gtk.Cairo.FillRule.T) : Std.Object.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 Fill and Clip. See Gtk.Cairo.FillRule.T for details on the semantics of each available fill rule.

The default fill rule is Gtk.Cairo.FillRule.Winding.

cr a T
fill_rule a fill rule, specified as a Gtk.Cairo.FillRule.T


:SetFontFace(self @ T, font_face @ Gtk.Cairo.FontFace.T) : Std.Object.T

Replaces the current Gtk.Cairo.FontFace.T object in the T with font_face. The replaced font face in the T will be destroyed if there are no other references to it.

cr a T
font_face a Gtk.Cairo.FontFace.T, or NULL to restore to the default font


:SetFontMatrix(self @ T, matrix @ Gtk.Cairo.Matrix.T) : Std.Object.T

Sets the current font matrix to matrix. The font matrix gives a transformation from the design space of the font (in this space, the em-square is 1 unit by 1 unit) to user space. Normally, a simple scale is used (see SetFontSize), but a more complex font matrix can be used to shear the font or stretch it unequally along the two axes

cr a T
matrix a Gtk.Cairo.Matrix.T describing a transform to be applied to the current font.


:SetFontOptions(self @ T, options @ Gtk.Cairo.FontOptions.T) : Std.Object.T

Sets a set of custom font rendering options for the T. Rendering options are derived by merging these options with the options derived from underlying surface; if the value in options has a default value (like Gtk.Cairo.Antialias.Default), then the value from the surface is used.

cr a T
options font options to use


:SetFontSize(self @ T, size @ Std.Real.T) : Std.Object.T

Sets the current font matrix to a scale by a factor of size, replacing any font matrix previously set with SetFontSize or SetFontMatrix. This results in a font size of size user space units. (More precisely, this matrix will result in the font's em-square being a size by size square in user space.)

If text is drawn without a call to SetFontSize, (nor SetFontMatrix nor SetScaledFont), the default font size is 10.0.

cr a T
size the new font size, in user space units


:SetLineCap(self @ T, line_cap @ Gtk.Cairo.LineCap.T) : Std.Object.T

Sets the current line cap style within the cairo context. See Gtk.Cairo.LineCap.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 Stroke, StrokeExtents, and cairo_stroke_to_path(), but does not have any effect during path construction.

The default line cap style is Gtk.Cairo.LineCap.Butt.

cr a cairo context
line_cap a line cap style


:SetLineJoin(self @ T, line_join @ Gtk.Cairo.LineJoin.T) : Std.Object.T

Sets the current line join style within the cairo context. See Gtk.Cairo.LineJoin.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 Stroke, StrokeExtents, and cairo_stroke_to_path(), but does not have any effect during path construction.

The default line join style is Gtk.Cairo.LineJoin.Miter.

cr a cairo context
line_join a line join style


:SetLineWidth(self @ T, width @ Std.Real.T) : Std.Object.T

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 SetLineWidth. The simplest usage makes both of these spaces identical. That is, if there is no change to the CTM between a call to SetLineWidth and the stroking operation, then one can just pass user-space values to SetLineWidth and ignore this note.

As with the other stroke parameters, the current line width is examined by Stroke, StrokeExtents, and cairo_stroke_to_path(), but does not have any effect during path construction.

The default line width value is 2.0.

cr a T
width a line width


:SetMatrix(self @ T, matrix @ Std.Object.T) : Std.Object.T

Modifies the current transformation matrix (CTM) by setting it equal to matrix.

cr a cairo context
matrix a transformation matrix from user space to device space


:SetMiterLimit(self @ T, limit @ Std.Real.T) : Std.Object.T

Sets the current miter limit within the cairo context.

If the current line join style is set to Gtk.Cairo.LineJoin.Miter (see SetLineJoin), 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 Stroke, StrokeExtents, 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


:SetOperator(self @ T, op @ Gtk.Cairo.Operator.T) : Std.Object.T

Sets the compositing operator to be used for all drawing operations. See Gtk.Cairo.Operator.T for details on the semantics of each available compositing operator.

The default operator is Gtk.Cairo.Operator.Over.

cr a T
op a compositing operator, specified as a Gtk.Cairo.Operator.T


:SetScaledFont(self @ T, font_face @ Gtk.Cairo.ScaledFont.T) : Std.Object.T

Replaces the current font face, font matrix, and font options in the T with those of the Gtk.Cairo.ScaledFont.T. Except for some translation, the current CTM of the T should be the same as that of the Gtk.Cairo.ScaledFont.T, which can be accessed using cairo_scaled_font_get_ctm().

cr a T
scaled_font a Gtk.Cairo.ScaledFont.T


:SetSource(self @ T, source @ Gtk.Cairo.Pattern.T) : Std.Object.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 SetSource. 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 Gtk.Cairo.Pattern.T to be used as the source for subsequent drawing operations.


:SetSourceRgb(self @ T, red @ Std.Real.T, green @ Std.Real.T, blue @ Std.Real.T) : Std.Object.T

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


:SetSourceRgba(self @ T, red @ Std.Real.T, green @ Std.Real.T, blue @ Std.Real.T, alpha @ Std.Real.T) : Std.Object.T

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


:SetSourceSurface(self @ T, surface @ Gtk.Cairo.Surface.T, x @ Std.Real.T, y @ Std.Real.T) : Std.Object.T

This is a convenience function for creating a pattern from surface and setting it as the source in cr 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 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 Gtk.Cairo.Pattern.CreateForSurface. The resulting pattern can be queried with GetSource 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


:SetTolerance(self @ T, tolerance @ Std.Real.T) : Std.Object.T

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 T
tolerance the tolerance, in device units (typically pixels)


:ShowGlyphs(self @ T, glyphs @ Gtk.Cairo.Glyph.T, num_glyphs @ Std.Integer.SmallT) : Std.Object.T

A drawing operator that generates the shape from an array of glyphs, rendered according to the current font face, font size (font matrix), and font options.

cr a cairo context
glyphs array of glyphs to show
num_glyphs number of glyphs to show


:ShowPage(self @ T) : Std.Object.T

Emits and clears the current page for backends that support multiple pages. Use CopyPage 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


:ShowText(self @ T, utf8 @ Std.String.T) : Std.Object.T

A drawing operator that generates the shape from a string of UTF-8 characters, rendered according to the current font_face, font_size (font_matrix), and font_options.

This function first computes a set of glyphs for the string of text. The first glyph is placed so that its origin is at the current point. The origin of each subsequent glyph is offset from that of the previous glyph by the advance values of the previous glyph.

After this call the current point is moved to the origin of where the next glyph would be placed in this same progression. That is, the current point will be at the origin of the final glyph offset by its advance values. This allows for easy display of a single logical string with multiple calls to ShowText.

Note: The ShowText function call is part of what the cairo designers call the "toy" text API. It is convenient for short demos and simple programs, but it is not expected to be adequate for serious text-using applications. See ShowGlyphs for the "real" text display API in cairo.

cr a cairo context
utf8 a NUL-terminated string of text encoded in UTF-8, or NULL


:Status(self @ T) : Gtk.Cairo.Status.T

Checks whether an error has previously occurred for this context.

cr a cairo context
Returns the current status of this context, see Gtk.Cairo.Status.T


:Stroke(self @ T) : Std.Object.T

A drawing operator that strokes the current path according to the current line width, line join, line cap, and dash settings. After Stroke, the current path will be cleared from the cairo context. See SetLineWidth, SetLineJoin, SetLineCap, SetDash, and StrokePreserve.

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 SetDash. If the cap style is Gtk.Cairo.LineCap.Round or Gtk.Cairo.LineCap.Square then these segments will be drawn as circular dots or squares respectively. In the case of Gtk.Cairo.LineCap.Square, the orientation of the squares is determined by the direction of the underlying path.

2. A sub-path created by MoveTo followed by either a ClosePath or one or more calls to LineTo to the same coordinate as the MoveTo. If the cap style is Gtk.Cairo.LineCap.Round then these sub-paths will be drawn as circular dots. Note that in the case of Gtk.Cairo.LineCap.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 Gtk.Cairo.LineCap.Butt cause anything to be drawn in the case of either degenerate segments or sub-paths.

cr a cairo context


:StrokeExtents(self @ T, x1, y1, x2, y2) : Std.Object.T

Computes a bounding box in user coordinates covering the area that would be affected, (the "inked" area), by a 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 StrokeExtents 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 StrokeExtents 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 Stroke, SetLineWidth, SetLineJoin, SetLineCap, SetDash, and StrokePreserve.

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


:StrokePreserve(self @ T) : Std.Object.T

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 cairo context.

See SetLineWidth, SetLineJoin, SetLineCap, SetDash, and StrokePreserve.

cr a cairo context


:TextExtents(self @ T, utf8 @ Std.String.T, extents @ Gtk.Cairo.TextExtents.T) : Std.Object.T

Gets the extents for a string of text. The extents describe a user-space rectangle that encloses the "inked" portion of the text, (as it would be drawn by ShowText). Additionally, the x_advance and y_advance values indicate the amount by which the current point would be advanced by ShowText.

Note that whitespace characters do not directly contribute to the size of the rectangle (extents.width and extents.height). They do contribute indirectly by changing the position of non-whitespace characters. In particular, trailing whitespace characters are likely to not affect the size of the rectangle, though they will affect the x_advance and y_advance values.

cr a T
utf8 a NUL-terminated string of text encoded in UTF-8, or NULL
extents a Gtk.Cairo.TextExtents.T object into which the results will be stored


:TextPath(self @ T, utf8 @ Std.String.T) : Std.Object.T

Adds closed paths for text to the current path. The generated path if filled, achieves an effect similar to that of ShowText.

Text conversion and positioning is done similar to ShowText.

Like ShowText, After this call the current point is moved to the origin of where the next glyph would be placed in this same progression. That is, the current point will be at the origin of the final glyph offset by its advance values. This allows for chaining multiple calls to to TextPath without having to set current point in between.

Note: The TextPath function call is part of what the cairo designers call the "toy" text API. It is convenient for short demos and simple programs, but it is not expected to be adequate for serious text-using applications. See GlyphPath for the "real" text path API in cairo.

cr a cairo context
utf8 a NUL-terminated string of text encoded in UTF-8, or NULL


:Transform(self @ T, matrix @ Std.Object.T) : Std.Object.T

Modifies the current transformation matrix (CTM) by applying matrix as an additional transformation. The new transformation of user space takes place after any existing transformation.

cr a cairo context
matrix a transformation to be applied to the user-space axes


:Translate(self @ T, tx @ Std.Real.T, ty @ Std.Real.T) : Std.Object.T

Modifies the current transformation matrix (CTM) by translating the user-space origin by (tx, ty). This offset is interpreted as a user-space coordinate according to the CTM in place before the new call to Translate. In other words, the translation of the user-space origin takes place after any existing transformation.

cr a cairo context
tx amount to translate in the X direction
ty amount to translate in the Y direction


:UserToDevice(self @ T, x @ Std.Real.T, y @ Std.Real.T) : Std.Object.T

Transform a coordinate from user space to device space by multiplying the given point by the current transformation matrix (CTM).

cr a cairo context
x X value of coordinate (in/out parameter)
y Y value of coordinate (in/out parameter)


:UserToDeviceDistance(self @ T, dx @ Std.Real.T, dy @ Std.Real.T) : Std.Object.T

Transform a distance vector from user space to device space. This function is similar to UserToDevice except that the translation components of the CTM will be ignored when transforming (dx,dy).

cr a cairo context
dx X component of a distance vector (in/out parameter)
dy Y component of a distance vector (in/out parameter)


:"~="(_ @ T, _ @ T)