### ----------------------------------------------------
### -- Gnome::Gtk3
### -- Licenses: Artistic-2.0
### -- Authors: Marcel Timmerman
### -- File: docs/content-docs/reference/Cairo/Cairo.md
### ----------------------------------------------------
### -- Chunk 1 of 2
Gnome::Cairo
============

The cairo drawing context

Description
===========

**cairo_t** is the main object used when drawing with cairo. To draw with cairo, you create a **cairo_t**, set the target surface, and drawing options for the **cairo_t**, create shapes with functions like `move_to()` and `line_to()`, and then draw shapes with `stroke()` or `fill()`. **cairo_t** 's can be pushed to a stack via `save()`. They may then safely be changed, without losing the current state. Use `restore()` to restore to the saved state.

See Also
--------

**cairo_surface_t**

Synopsis
========

Declaration
-----------

    unit class Gnome::Cairo;
    also is Gnome::N::TopLevelClassSupport;

Methods
=======

new
---

### :surface

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 `Gnome::Cairo::ImageSurface.new(…)`.

This function references *$surface*, so you can immediately call `clear-object()` on it if you don't need to maintain a separate reference to it.

The object is cleared with `clear-object()` when you are done using the **cairo_t**. This function never returns `Any`. If memory cannot be allocated, a special **cairo_t** object will be returned on which `status()` returns `CAIRO_STATUS_NO_MEMORY`. If you attempt to target a surface which does not support writing (such as **cairo_mime_surface_t**) then a `CAIRO_STATUS_WRITE_ERROR` will be raised.

You can use this object normally, but no drawing will be done.

    multi method new ( cairo_surface_t :$surface! )

  * cairo_surface_t $surface;

### :native-object

Create a **Gnome::Cairo** object using a native object from elsewhere. See also **Gnome::N::TopLevelClassSupport**.

    multi method new ( N-GObject :$native-object! )

append-path
-----------

Append the *$path* onto the current path. Note that `Gnome::Cairo::Path.status()` must be `CAIRO_STATUS_SUCCESS`.

    method append-path ( cairo_path_t $path )

  * $path; path to be appended

arc
---

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*π` 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 `new-sub-path()` 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 `π/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 * (π / 180)`.) This function gives the arc in the direction of increasing angles; see `arc-negative()` 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*:

      with $cairo {
        .save;
        .translate( $x + $width / 2, $y + $height / 2);
        .scale( $width / 2, $height / 2);
        .arc( 0, 0, 1, 0, 2 * π);
        .restore;
      }

      method arc (
        Num() $xc, Num() $yc, Num() $radius, Num() $angle1, Num() $angle2
      )

  * $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

arc-negative
------------

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 * π` 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.

    method arc-negative (
      Num() $xc, Num() $yc, Num() $radius, Num() $angle1, Num() $angle2
    )

  * $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
----

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 `set-fill-rule()`).

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 `reset-clip()`.

    method clip ( )

clip-extents
------------

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

    method clip-extents ( --> List )

List holds the following values

  * Num $x1; left of the resulting extents

  * Num $y1; top of the resulting extents

  * Num $x2; right of the resulting extents

  * Num $y2; bottom of the resulting extents

clip-preserve
-------------

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 `set-fill-rule()`).

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

    method clip-preserve ( )

close-path
----------

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 `move-to()`), and closes this sub-path. After this call the current point will be at the joined endpoint of the sub-path.

The behavior of `close-path()` is distinct from simply calling `line-to()` 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 `close-path()`, this function will have no effect.

Note: As of cairo version 1.2.4 any call to `close-path()` will place an explicit MOVE_TO element into the path immediately after the CLOSE_PATH element, (which can be seen in `copy-path()` 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.

    method close-path ( )

copy-clip-rectangle-list
------------------------

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

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.

Returns: the current clip region as a list of rectangles in user coordinates

    method copy-clip-rectangle-list ( --> cairo_rectangle_list_t )

copy-page
---------

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 `show-page()` if you want to get an empty page after the emission. This is a convenience function that simply calls `Gnome::Cairo::Surface.copy-page()` on this context's target.

    method copy-page ( )

copy-path
---------

Creates a copy of the current path and returns it to the user as a **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, if either of the following conditions hold:

  * If there is insufficient memory to copy the path. In this case `$path.status` will be set to `CAIRO_STATUS_NO_MEMORY`.

  * If the context is already in an error state. In this case `$path.status` will contain the same status that would be returned by `.status()`.

Return value: the copy of the current path. The caller owns the returned object and should call `clear-object()` when finished with it.

    method copy-path ( --> cairo_path_t )

copy-path-flat
--------------

Gets a flattened copy of the current path and returns it to the user as a **cairo_path_t**. See **cairo_path_data_t** for hints on how to iterate over the returned data structure. This function is like `copy-path()` 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, if either of the following conditions hold:

  * If there is insufficient memory to copy the path. In this case `$path.status` will be set to `CAIRO_STATUS_NO_MEMORY`.

  * If the context is already in an error state. In this case `$path.status` will contain the same status that would be returned by `.status()`.

Return value: the copy of the current path. The caller owns the returned object and should call `clear-object()` when finished with it.

    method copy-path-flat ( --> cairo_path_t )

curve-to
--------

Adds a cubic Bé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 `curve-to()` this function will behave as if preceded by a call to cairo_move_to(this context, *x1*, *y1*).

    method curve-to ( Num() $x1, Num() $y1, Num() $x2, Num() $y2, Num() $x3, Num() $y3 )

  * $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

device-to-user
--------------

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

    method device-to-user ( Num() $x is rw, Num() $y is rw )

  * $x; X value of coordinate

  * $y; Y value of coordinate

device-to-user-distance
-----------------------

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

    method device-to-user-distance ( Num() $dx is rw, Num() $dy is rw )

  * $dx; y component of a distance vector

  * $dy; X component of a distance vector

fill
----

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 `set-fill-rule()` and `fill-preserve()`.

    method fill ( )

fill-extents
------------

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 `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 `fill-extents()` must necessarily do more work to compute the precise inked areas in light of the fill rule, so `path-extents()` may be more desirable for sake of performance if the non-inked path extents are desired.

See `fill()`, `set-fill-rule()` and `fill-preserve()`.

    method fill-extents ( --> List )

List returns

  * Num; left of the resulting extents

  * Num; top of the resulting extents

  * Num; right of the resulting extents

  * Num; bottom of the resulting extents

fill-preserve
-------------

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()`, `fill-preserve()` preserves the path within the cairo context. See `set-fill-rule()` and `fill()`.

    method fill-preserve ( )

get-antialias
-------------

Gets the current shape antialiasing mode, as set by `set-antialias()`. Return value: the current shape antialiasing mode.

    method get-antialias ( --> cairo_antialias_t )

get-current-point
-----------------

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 this object is not valid, *$x* and *$y* will both be set to 0.0. It is possible to check this in advance with `has-current-point()`. Most path construction functions alter the current point.

See the following for details on how they affect the current point: `new-path()`, `new-sub-path()`, `append-path()`, `close-path()`, `move-to()`, `line-to()`, `curve-to()`, `rel-move-to()`, `rel-line-to()`, `rel-curve-to()`, `arc()`, `arc-negative()`, `rectangle()`, `text-path()`, `glyph-path()`, `stroke-to-path()`.

Some functions use and alter the current point but do not otherwise change current path: `show-text()`. Some functions unset the current path and as a result, current point: `fill()`, `stroke()`.

    method get-current-point ( --> List )

The returned list has;

  * $x; X coordinate of the current point

  * $y; Y coordinate of the current point

get-dash
--------

Gets the current dash array.

    method get-dash ( --> List )

List returns;

  * Array; the dash array

  * Num; the current dash offset, or `Undefined`

get-dash-count
--------------

This function returns the length of the dash array in this context (0 if dashing is not currently in effect). See also `set-dash()` and `get-dash()`. Return value: the length of the dash array, or 0 if no dash array set.

    method get-dash-count ( --> Int )

get-fill-rule
-------------

Gets the current fill rule, as set by `set-fill-rule()`.

Return value: the current fill rule.

    method get-fill-rule ( --> cairo_fill_rule_t )

get-font-face
-------------

Gets the current font face for a **cairo_t**.

Return value: the current font face.

This function never returns an undefined font face. If memory cannot be allocated, a special "nil" **cairo_font_face_t** object will be returned on which `Gnome::Cairo::FontFace.status()` returns `CAIRO_STATUS_NO_MEMORY`. Using this nil object will cause its error state to propagate to other objects it is passed to, (for example, calling `set-font-face()` with a nil font will trigger an error that will shutdown the **cairo_t** object).

    method get-font-face ( --> Gnome::Cairo::FontFace )

get-font-matrix
---------------

Returns the current font matrix. See `set-font-matrix()`.

    method get-font-matrix ( --> Gnome::Cairo::Matrix )

get-font-options
----------------

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

    method get-font-options ( cairo_font_options_t $options --> N-GObject )

  * cairo_font_options_t $options; a **cairo_t**

get-group-target
----------------

Gets the current destination surface for the context. This is either the original target surface as passed to `new(:surface)` or the target surface for the current group as started by the most recent call to `push-group()` or `push-group-with-content()`.

This function will always return a valid pointer, but the result can be a "nil" surface if this context is already in an error state, (ie. `$context.status() ≠ CAIRO_STATUS_SUCCESS`). A nil surface is indicated by `Gnome::Cairo::Surface.status() ≠ CAIRO_STATUS_SUCCESS`.

Return value: the target surface. This object is owned by cairo. To keep a reference to it, you must call `surface-reference()`.

    method get-group-target ( --> Gnome::Cairo::Surface )

get-line-cap
------------

Gets the current line cap style, as set by `set-line-cap()`.

Return value: the current line cap style.

    method get-line-cap ( --> cairo_line_cap_t )

get-line-join
-------------

Gets the current line join style, as set by `set-line-join()`. Return value: the current line join style.

    method get-line-join ( --> cairo_line_join_t )

get-line-width
--------------

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

Return value: the current line width.

    method get-line-width ( --> Num )

get-matrix
----------

Stores the current transformation matrix (CTM) into *matrix*.

    method get-matrix ( --> Gnome::Cairo::Matrix )

get-miter-limit
---------------

Gets the current miter limit, as set by `set-miter-limit()`.

Return value: the current miter limit.

    method get-miter-limit ( --> Num )

get-operator
------------

Gets the current compositing operator for a cairo context. Return value: the current compositing operator.

    method get-operator ( --> cairo_operator_t )

get-scaled-font
---------------

Gets the current scaled font for a **cairo_t**.

Return value: the current scaled font. This object is owned by cairo.

This function never returns `Any`. If memory cannot be allocated, a special "nil" **cairo_scaled_font_t** object will be returned on which `scaled-font-status()` returns `CAIRO_STATUS_NO_MEMORY`. Using this nil object will cause its error state to propagate to other objects it is passed to, (for example, calling `set-scaled-font()` with a nil font will trigger an error that will shutdown the **cairo_t** object).

    method get-scaled-font ( --> Gnome::Cairo::ScaledFont )

get-source
----------

Gets the current source pattern for this context.

Return value: the current source pattern. This object is owned by cairo.

    method get-source ( --> Gnome::Cairo::Pattern )

get-target
----------

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 this context is already in an error state, (ie. `status()` `!=` `CAIRO_STATUS_SUCCESS`). A nil surface is indicated by `surface-status()` `!=` `CAIRO_STATUS_SUCCESS`. Return value: the target surface. This object is owned by cairo. To keep a reference to it, you must call `surface-reference()`.

    method get-target ( --> Gnome::Cairo::Surface )

get-tolerance
-------------

Gets the current tolerance value, as set by `set-tolerance()`.

Return value: the current tolerance value.

    method get-tolerance ( --> Num )

glyph-extents
-------------

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 `show-glyphs()`). Additionally, the x_advance and y_advance values indicate the amount by which the current point would be advanced by `show-glyphs()`.

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

    method glyph-extents (
      cairo_glyph_t $glyphs, Int $num_glyphs,
      cairo_text_extents_t $extents
    )

  * $glyphs; an array of **glyph-t** objects

  * $num_glyphs; the number of elements in *glyphs*

  * $extents; a **text-extents-t** object into which the results will be stored

glyph-path
----------

Adds closed paths for the glyphs to the current path. The generated path if filled, achieves an effect similar to that of `show-glyphs()`.

    method glyph-path ( cairo_glyph_t $glyphs, Int $num_glyphs )

  * $glyphs; array of glyphs to show

  * $num_glyphs; number of glyphs to show

has-current-point
-----------------

Returns whether a current point is defined on the current path. See `get-current-point()` for details on the current point.

Return value: whether a current point is defined.

    method has-current-point ( --> Bool )

identity-matrix
---------------

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.

    method identity-matrix ( )

in-clip
-------

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 `paint()` operation.

See `clip()`, and `clip-preserve()`.

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

    method in-clip ( Num() $x, Num() $y --> Bool )

  * $x; X coordinate of the point to test

  * $y; Y coordinate of the point to test

in-fill
-------

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

See `fill()`, `set-fill-rule()` and `fill-preserve()`.

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

    method in-fill ( Num() $x, Num() $y --> Bool )

  * $x; X coordinate of the point to test

  * $y; Y coordinate of the point to test

in-stroke
---------

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()`, `set-line-width()`, `set-line-join()`, `set-line-cap()`, `set-dash()`, and `stroke-preserve()`. Return value: A non-zero value if the point is inside, or zero if outside.

    method in-stroke ( Num() $x, Num() $y --> Bool )

  * $x; X coordinate of the point to test

  * $y; Y coordinate of the point to test

line-to
-------

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 `line-to()` this function will behave as cairo_move_to(this context, *x*, *y*).

    method line-to ( Num() $x, Num() $y )

  * $x; the X coordinate of the end of the new line

  * $y; the Y coordinate of the end of the new line

mask
----

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

    method mask ( cairo_pattern_t $pattern )

  * $pattern; a pattern

mask-surface
------------

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

    method mask-surface (
      cairo_surface_t $surface, Num() $surface_x, Num() $surface_y
    )

  * $surface; a surface

  * $surface_x; X coordinate at which to place the origin of *surface*

  * $surface_y; Y coordinate at which to place the origin of *surface*

move-to
-------

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

    method move-to ( Num() $x, Num() $y )

  * $x; the X coordinate of the new position

  * $y; the Y coordinate of the new position

new-path
--------

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

    method new-path ( )

new-sub-path
------------

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 `move-to()`.

A call to `new-sub-path()` 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 `move-to()`.

    method new-sub-path ( )

paint
-----

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

    method paint ( )

paint-with-alpha
----------------

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.

    method paint-with-alpha ( Num() $alpha )

  * $alpha; alpha value, between 0 (transparent) and 1 (opaque)

path-extents
------------

Computes a bounding box in user-space coordinates covering the points on the current path. If the current path is empty, returns an empty rectangle ((0,0), (0,0)). Stroke parameters, fill rule, surface dimensions and clipping are not taken into account.

Contrast with `fill-extents()` and `stroke-extents()` which return the extents of only the area that would be "inked" by the corresponding drawing operations.

The result of `path-extents()` is defined as equivalent to the limit of `stroke-extents()` with `CAIRO_LINE_CAP_ROUND` as the line width approaches 0.0, (but never reaching the empty-rectangle returned by `stroke-extents()` for a line width of 0.0).

Specifically, this means that zero-area sub-paths such as `move-to(); line-to()` segments, (even degenerate cases where the coordinates to both calls are identical), will be considered as contributing to the extents. However, a lone `move-to()` will not contribute to the results of `path-extents()`.

    method path-extents ( --> List )

List returns;

  * Num; left of the resulting extents

  * Num; top of the resulting extents

  * Num; right of the resulting extents

  * Num; bottom of the resulting extents

pop-group
---------

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

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

Return value: 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 `clear-object()` when finished with it.

    method pop-group ( --> Gnome::Cairo::Pattern )

pop-group-to-source
-------------------

Terminates the redirection begun by a call to `push-group()` or `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:

    my Gnome::Cairo::Pattern $group = $cairo.pop-group;
    $cairo.set-source($group);
    $group.clear-object;

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

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

    method pop-group-to-source ( )

push-group
----------

Temporarily redirects drawing to an intermediate surface known as a group. The redirection lasts until the group is completed by a call to `pop-group()` or `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 `push-group()`/`pop-group()`. Each call pushes/pops the new target group onto/from a stack.

The `push-group()` function calls `save()` so that any changes to the graphics state will not be visible outside the group, (the pop_group functions call `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 `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:

      my Gnome::Cairo::Pattern $fill-pattern = …
      my Gnome::Cairo::Pattern $stroke-pattern = …
      my Num() $alpha = 0.8;

      with $cairo {
        .push-group;
        .set-source($fill-pattern);
        .fill-preserve;
        .set-source($stroke-pattern);
        .stroke;
        .pop-group-to-source;
        .paint-with-alpha($alpha);
      }

      method push-group ( )

push-group-with-content
-----------------------

Temporarily redirects drawing to an intermediate surface known as a group. The redirection lasts until the group is completed by a call to `pop-group()` or `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).

The group will have a content type of *$content*. The ability to control this content type is the only distinction between this function and `push-group()` which you should see for a more detailed description of group rendering.

    method push-group-with-content ( cairo_content_t $content )

  * $content; a **content-t** indicating the type of group that will be created

rectangle
---------

Adds a closed sub-path rectangle of the given size to the current path at position (*$x*, *$y*) in user-space coordinates. This method is logically equivalent to:

      with $cairo {
        .move-to( $x, $y);
        .rel-line-to( $width, 0);
        .rel-line-to( 0, $height);
        .rel-line-to( -$width, 0);
        .close.path;
      }

      method rectangle ( Num() $x, Num() $y, Num() $width, Num() $height )

  * $x; the X coordinate of the top left corner of the rectangle

  * $y; the Y coordinate to the top left corner of the rectangle

  * $width; the width of the rectangle

  * $height; the height of the rectangle

rel-curve-to
------------

Relative-coordinate version of `curve-to()`. 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)`, then `rel-curve-to( $dx1, $dy1, $dx2, $dy2, $dx3, $dy3)` is logically equivalent to `curve-to( $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 this context to shutdown with a status of `CAIRO_STATUS_NO_CURRENT_POINT`.

    method rel-curve-to (
      Num() $dx1, Num() $dy1, Num() $dx2, Num() $dy2,
      Num() $dx3, Num() $dy3
    )

  * $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

rel-line-to
-----------

Relative-coordinate version of `line-to()`. 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)`, `rel-line-to( $dx, $dy)` is logically equivalent to `line_to( $x + $dx, $y + $dy)`.

It is an error to call this function with no current point. Doing so will cause this context to shutdown with a status of `CAIRO_STATUS_NO_CURRENT_POINT`.

    method rel-line-to ( Num() $dx, Num() $dy )

  * $dx; the X offset to the end of the new line

  * $dy; the Y offset to the end of the new line

rel-move-to
-----------

Begin a new sub-path. After this call the current point will offset by `( $x, $y)`. Given a current point of `($x, $y)`, `rel-move-to( $dx, $dy)` is logically equivalent to `move-to( $x + $dx, $y + $dy)`.

It is an error to call this function with no current point. Doing so will cause this context to shutdown with a status of `CAIRO_STATUS_NO_CURRENT_POINT`.

    method rel-move-to ( Num() $dx, Num() $dy )

  * $dx; the X offset

  * $dy; the Y offset

reset-clip
----------

Reset the current clip region to its