### ----------------------------------------------------
### -- Gnome::Cairo
### -- Licenses: Artistic-2.0
### -- Authors: Marcel Timmerman
### -- File: lib/Gnome/Cairo.rakumod
### ----------------------------------------------------
### -- Chunk 1 of 4
#TL:1:Gnome::Cairo:

use v6;
#-------------------------------------------------------------------------------
=begin pod

=head1 Gnome::Cairo

The cairo drawing context

=comment ![](images/X.png)

=head1 Description

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


=head2 See Also

B<cairo_surface_t>

=head1 Synopsis
=head2 Declaration

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

=comment head2 Example

=end pod
#-------------------------------------------------------------------------------
use NativeCall;

use Gnome::N::X:api<1>;
use Gnome::N::N-GObject:api<1>;
use Gnome::N::NativeLib:api<1>;
use Gnome::N::TopLevelClassSupport:api<1>;
use Gnome::N::GlibToRakuTypes:api<1>;

use Gnome::Cairo::Types:api<1>;
use Gnome::Cairo::Enums:api<1>;
#use Gnome::Cairo::Matrix:api<1>;

#-------------------------------------------------------------------------------
unit class Gnome::Cairo:auth<github:MARTIMM>:api<1>;
also is Gnome::N::TopLevelClassSupport;

#-------------------------------------------------------------------------------
=begin pod
=head1 Methods
=head2 new

=head3 :surface

Creates a new B<cairo_t> with all graphics state parameters set to default values and with I<target> as a target surface. The target surface should be constructed with a backend-specific function such as C<Gnome::Cairo::ImageSurface.new(…)>.

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

The object is cleared with C<clear-object()> when you are done using the B<cairo_t>. This function never returns C<Any>. If memory cannot be allocated, a special B<cairo_t> object will be returned on which C<status()> returns C<CAIRO_STATUS_NO_MEMORY>. If you attempt to target a surface which does not support writing (such as B<cairo_mime_surface_t>) then a C<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! )

=item cairo_surface_t $surface;


=head3 :native-object

Create a B<Gnome::Cairo> object using a native object from elsewhere. See also B<Gnome::N::TopLevelClassSupport>.

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

=end pod

#TM:1:new(:surface):
#TM:4:new(:native-object):Gnome::N::TopLevelClassSupport
submethod BUILD ( *%options ) {

#note "o: ", self.^name, ', ', %options;
  # prevent creating wrong native-objects
  if self.^name eq 'Gnome::Cairo' #`{{ or %options<Cairo> }} {

    # check if native object is set by a parent class
    if self.is-valid { }

    # process all options

    # check if common options are handled by some parent
    elsif %options<native-object>:exists { }

    else {
      my $no;
      if %options<surface>:exists {
        $no = %options<surface>;
        $no .= _get-native-object-no-reffing unless $no ~~ cairo_surface_t;
        $no = _cairo_create($no);
      }

#      #`{{ use this when the module is not made inheritable
      # check if there are unknown options
      elsif %options.elems {
        die X::Gnome.new(
          :message(
            'Unsupported, undefined, incomplete or wrongly typed options for ' ~
            self.^name ~ ': ' ~ %options.keys.join(', ')
          )
        );
      }
#      }}

#      #`{{ when there are no defaults use this
      # check if there are any options
      elsif %options.elems == 0 {
        die X::Gnome.new(:message('No options specified ' ~ self.^name));
      }
#      }}

      #`{{ when there are defaults use this instead
      # create default object
      else {
        $no = cairo_new();
      }
      }}

      self._set-native-object($no);
    }

#    self._set-class-info('Cairo');
  }
}

#-------------------------------------------------------------------------------
# no pod. user does not have to know about it.
method _fallback ( $native-sub is copy --> Callable ) {

  my Callable $s;
  try { $s = &::("cairo_$native-sub"); };
  try { $s = &::("cairo_$native-sub"); } unless ?$s;
  try { $s = &::($native-sub); } if !$s and $native-sub ~~ m/^ 'cairo_' /;

#  self._set-class-name-of-sub('Cairo');
  $s = callsame unless ?$s;

  $s;
}

#-------------------------------------------------------------------------------
method native-object-ref ( $no ) {
  _cairo_reference($no);
}

#-------------------------------------------------------------------------------
method native-object-unref ( $no ) {
  _cairo_destroy($no) if _cairo_get_reference_count($no) > 0;
}








#-------------------------------------------------------------------------------
#TM:1:append-path:
=begin pod
=head2 append-path

Append the I<$path> onto the current path. Note that C<Gnome::Cairo::Path.status()> must be C<CAIRO_STATUS_SUCCESS>.

  method append-path ( cairo_path_t $path )

=item $path; path to be appended
=end pod

method append-path ( $path is copy ) {
  $path .= get-native-object-no-reffing unless $path ~~ cairo_path_t;
  cairo_append_path( self._get-native-object-no-reffing, $path);
}

sub cairo_append_path (
  cairo_t $cr, cairo_path_t $path
) is native(&cairo-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:1:arc:
=begin pod
=head2 arc

Adds a circular arc of the given I<$radius> to the current path. The arc is centered at (I<$xc>, I<$yc>), begins at I<$angle1> and proceeds in the direction of increasing angles to end at I<$angle2>. If I<$angle2> is less than I<$angle1> it will be progressively increased by C<2*π> until it is greater than I<$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 C<new-sub-path()> before calling C<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 C<π/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 C<degrees * (π / 180)>.)  This function gives the arc in the direction of increasing angles; see C<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 I<$x>, I<$y>, I<$width>, I<$height>:

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

=begin code
  method arc (
    Num() $xc, Num() $yc, Num() $radius, Num() $angle1, Num() $angle2
  )
=end code

=item $xc; X position of the center of the arc
=item $yc; Y position of the center of the arc
=item $radius; the radius of the arc
=item $angle1; the start angle, in radians
=item $angle2; the end angle, in radians
=end pod

method arc (
  Num() $xc, Num() $yc, Num() $radius, Num() $angle1, Num() $angle2
) {
  cairo_arc(
    self._get-native-object-no-reffing, $xc, $yc, $radius, $angle1, $angle2
  )
}

sub cairo_arc (
  cairo_t $cr, gdouble $xc, gdouble $yc, gdouble $radius, gdouble $angle1, gdouble $angle2
) is native(&cairo-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:1:arc-negative:
=begin pod
=head2 arc-negative

Adds a circular arc of the given I<$radius> to the current path.  The arc is centered at (I<$xc>, I<$yc>), begins at I<$angle1> and proceeds in the direction of decreasing angles to end at I<$angle2>. If I<$angle2> is greater than I<$angle1> it will be progressively decreased by C<2 * π> until it is less than I<$angle1>.  See C<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
  )

=item $xc; X position of the center of the arc
=item $yc; Y position of the center of the arc
=item $radius; the radius of the arc
=item $angle1; the start angle, in radians
=item $angle2; the end angle, in radians
=end pod

method arc-negative (
  Num() $xc, Num() $yc, Num() $radius, Num() $angle1, Num() $angle2
) {
  cairo_arc_negative(
    self._get-native-object-no-reffing, $xc, $yc, $radius, $angle1, $angle2
  )
}

sub cairo_arc_negative (
  cairo_t $cr, gdouble $xc, gdouble $yc, gdouble $radius, gdouble $angle1, gdouble $angle2
) is native(&cairo-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:1:clip:
=begin pod
=head2 clip

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

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

  method clip ( )

=end pod

method clip ( ) {
  cairo_clip(self._get-native-object-no-reffing)
}

sub cairo_clip (
  cairo_t $cr
) is native(&cairo-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:1:clip-extents:
=begin pod
=head2 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
=item Num $x1; left of the resulting extents
=item Num $y1; top of the resulting extents
=item Num $x2; right of the resulting extents
=item Num $y2; bottom of the resulting extents
=end pod

method clip-extents (  ) {
  my gdouble $x1;
  my gdouble $y1;
  my gdouble $x2;
  my gdouble $y2;
  cairo_clip_extents(
    self._get-native-object-no-reffing, $x1, $y1, $x2, $y2
  );

  ( $x1, $y1, $x2, $y2)
}

sub cairo_clip_extents (
  cairo_t $cr, gdouble $x1 is rw, gdouble $y1 is rw, gdouble $x2 is rw, gdouble $y2 is rw
) is native(&cairo-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:1:clip-preserve:
=begin pod
=head2 clip-preserve

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

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

  method clip-preserve ( )

=end pod

method clip-preserve ( ) {
  cairo_clip_preserve(self._get-native-object-no-reffing)
}

sub cairo_clip_preserve (
  cairo_t $cr
) is native(&cairo-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:1:close-path:
=begin pod
=head2 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 C<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 C<close-path()> is distinct from simply calling C<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 C<close-path()>, this function will have no effect.

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

=end pod

method close-path ( ) {
  cairo_close_path(self._get-native-object-no-reffing)
}

sub cairo_close_path (
  cairo_t $cr
) is native(&cairo-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:1:copy-clip-rectangle-list:
=begin pod
=head2 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 C<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
=comment , which should be destroyed using C<rectangle-list-destroy()>.

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

=end pod

method copy-clip-rectangle-list ( --> cairo_rectangle_list_t ) {
  cairo_copy_clip_rectangle_list(self._get-native-object-no-reffing)
}

sub cairo_copy_clip_rectangle_list (
  cairo_t $cr --> cairo_rectangle_list_t
) is native(&cairo-lib)
  { * }

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

  method copy-page ( )

=end pod

method copy-page ( ) {
  cairo_copy_page(self._get-native-object-no-reffing)
}

sub cairo_copy_page (
  cairo_t $cr
) is native(&cairo-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:2:copy-path:
=begin pod
=head2 copy-path

Creates a copy of the current path and returns it to the user as a B<cairo_path_t>. See B<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:
=item If there is insufficient memory to copy the path. In this case C<$path.status> will be set to C<CAIRO_STATUS_NO_MEMORY>.
=item If the context is already in an error state. In this case C<$path.status> will contain the same status that would be returned by C<.status()>.

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

  method copy-path ( --> cairo_path_t )

=end pod

method copy-path ( --> cairo_path_t ) {
  cairo_copy_path(self._get-native-object-no-reffing)
}

sub cairo_copy_path (
  cairo_t $cr --> cairo_path_t
) is native(&cairo-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:2:copy-path-flat:
=begin pod
=head2 copy-path-flat

Gets a flattened copy of the current path and returns it to the user as a B<cairo_path_t>. See B<cairo_path_data_t> for hints on how to iterate over the returned data structure.  This function is like C<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 C<CAIRO_PATH_CURVE_TO> which will instead be replaced by a series of C<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:
=item If there is insufficient memory to copy the path. In this case C<$path.status> will be set to C<CAIRO_STATUS_NO_MEMORY>.
=item If the context is already in an error state. In this case C<$path.status> will contain the same status that would be returned by C<.status()>.

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

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

=end pod

method copy-path-flat ( --> cairo_path_t ) {
  cairo_copy_path_flat(self._get-native-object-no-reffing)
}

sub cairo_copy_path_flat (
  cairo_t $cr --> cairo_path_t
) is native(&cairo-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:1:_cairo_create:
#`{{
=begin pod
=head2 create

Creates a new B<cairo_t> with all graphics state parameters set to default values and with I<target> as a target surface. The target surface should be constructed with a backend-specific function such as C<image-surface-create()> (or any other C<B<backend>_surface_create( )> variant).  This function references I<target>, so you can immediately call C<surface-destroy()> on it if you don't need to maintain a separate reference to it.  Return value: a newly allocated B<cairo_t> with a reference count of 1. The initial reference count should be released with C<destroy()> when you are done using the B<cairo_t>. This function never returns C<Any>. If memory cannot be allocated, a special B<cairo_t> object will be returned on which C<status()> returns C<CAIRO_STATUS_NO_MEMORY>. If you attempt to target a surface which does not support writing (such as B<cairo_mime_surface_t>) then a C<CAIRO_STATUS_WRITE_ERROR> will be raised.  You can use this object normally, but no drawing will be done.

  method create ( cairo_surface_t $target --> cairo_t )

=item $target; target surface for the context
=end pod

method create ( cairo_surface_t $target --> cairo_t ) {

  cairo_create(
    self._get-native-object-no-reffing, $target
  )
}
}}

sub _cairo_create (
  cairo_surface_t $target --> cairo_t
) is native(&cairo-lib)
  is symbol('cairo_create')
  { * }

#-------------------------------------------------------------------------------
#TM:2:curve-to:
=begin pod
=head2 curve-to

Adds a cubic Bézier spline to the path from the current point to position (I<x3>, I<y3>) in user-space coordinates, using (I<x1>, I<y1>) and (I<x2>, I<y2>) as the control points. After this call the current point will be (I<x3>, I<y3>).  If there is no current point before the call to C<curve-to()> this function will behave as if preceded by a call to cairo_move_to(this context, I<x1>, I<y1>).

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

=item $x1; the X coordinate of the first control point
=item $y1; the Y coordinate of the first control point
=item $x2; the X coordinate of the second control point
=item $y2; the Y coordinate of the second control point
=item $x3; the X coordinate of the end of the curve
=item $y3; the Y coordinate of the end of the curve
=end pod

method curve-to (
  Num() $x1, Num() $y1, Num() $x2, Num() $y2, Num() $x3, Num() $y3
) {
  cairo_curve_to(
    self._get-native-object-no-reffing, $x1, $y1, $x2, $y2, $x3, $y3
  )
}

sub cairo_curve_to (
  cairo_t $cr, gdouble $x1, gdouble $y1, gdouble $x2, gdouble $y2, gdouble $x3, gdouble $y3
) is native(&cairo-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:1:_cairo_destroy:
#`{{
=begin pod
=head2 destroy

Decreases the reference count on this context by one. If the result is zero, then this context and all associated resources are freed. See C<reference()>.

  method destroy ( )

=end pod

method destroy ( ) {

  cairo_destroy(
    self._get-native-object-no-reffing,
  )
}
}}

sub _cairo_destroy (
  cairo_t $cr
) is native(&cairo-lib)
  is symbol('cairo_destroy')
  { * }

#-------------------------------------------------------------------------------
#TM:1:device-to-user:
=begin pod
=head2 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 )

=item $x; X value of coordinate
=item $y; Y value of coordinate
=end pod

method device-to-user ( Num() $x is rw, Num() $y is rw ) {
  my gdouble $xx = $x;
  my gdouble $yy = $y;
  cairo_device_to_user( self._get-native-object-no-reffing, $xx, $yy);
  $x = $xx;
  $y = $yy;
}

sub cairo_device_to_user (
  cairo_t $cr, gdouble $x is rw, gdouble $y is rw
) is native(&cairo-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:1:device-to-user-distance:
=begin pod
=head2 device-to-user-distance

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

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

=item $dx; y component of a distance vector
=item $dy; X component of a distance vector
=end pod

method device-to-user-distance ( Num() $dx is rw, Num() $dy is rw ) {
  my gdouble $x = $dx;
  my gdouble $y = $dy;
  cairo_device_to_user_distance( self._get-native-object-no-reffing, $x, $y);
  $dx = $x;
  $dy = $y;
}

sub cairo_device_to_user_distance (
  cairo_t $cr, gdouble $dx is rw, gdouble $dy is rw
) is native(&cairo-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:4:fill:
=begin pod
=head2 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 C<fill()>, the current path will be cleared from the cairo context. See C<set-fill-rule()> and C<fill-preserve()>.

  method fill ( )

=end pod

method fill ( ) {
  cairo_fill(self._get-native-object-no-reffing)
}

sub cairo_fill (
  cairo_t $cr
) is native(&cairo-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:4:fill-extents:
=begin pod
=head2 fill-extents

Computes a bounding box in user coordinates covering the area that would be affected, (the "inked" area), by a C<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 C<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 C<fill-extents()> must necessarily do more work to compute the precise inked areas in light of the fill rule, so C<path-extents()> may be more desirable for sake of performance if the non-inked path extents are desired.

See C<fill()>, C<set-fill-rule()> and C<fill-preserve()>.

  method fill-extents ( --> List )

List returns
=item Num; left of the resulting extents
=item Num; top of the resulting extents
=item Num; right of the resulting extents
=item Num; bottom of the resulting extents
=end pod

method fill-extents ( --> List ) {
  my gdouble $x1;
  my gdouble $y1;
  my gdouble $x2;
  my gdouble $y2;

  cairo_fill_extents( self._get-native-object-no-reffing, $x1, $y1, $x2, $y2);

  ( $x1.Num, $y1.Num, $x2.Num, $y2.Num);
}

sub cairo_fill_extents (
  cairo_t $cr, gdouble $x1 is rw, gdouble $y1 is rw,
  gdouble $x2 is rw, gdouble $y2 is rw
) is native(&cairo-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:fill-preserve:
=begin pod
=head2 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 C<fill()>, C<fill-preserve()> preserves the path within the cairo context.  See C<set-fill-rule()> and C<fill()>.

  method fill-preserve ( )

=end pod

method fill-preserve ( ) {
  cairo_fill_preserve( self._get-native-object-no-reffing)
}

sub cairo_fill_preserve (
  cairo_t $cr
) is native(&cairo-lib)
  { * }

#`{{
#-------------------------------------------------------------------------------
#TM:0:font-extents:
=begin pod
=head2 font-extents

Gets the font extents for the currently selected font.

  method font-extents ( --> cairo_font_extents_t )

Returns B<a cairo_font_extents_t> structure
=end pod

method font-extents ( --> cairo_font_extents_t ) {
  my cairo_font_extents_t $extents .= new;
  cairo_font_extents( self._get-native-object-no-reffing, $extents);
  $extents
}

sub cairo_font_extents (
  cairo_t $cr, cairo_font_extents_t $extents
) is native(&cairo-lib)
  { * }
}}

#-------------------------------------------------------------------------------
#TM:1:get-antialias:
=begin pod
=head2 get-antialias

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

  method get-antialias ( --> cairo_antialias_t )

=end pod

method get-antialias ( --> cairo_antialias_t ) {
  cairo_antialias_t(cairo_get_antialias(self._get-native-object-no-reffing))
}

sub cairo_get_antialias (
  cairo_t $cr --> gint32
) is native(&cairo-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:1:get-current-point:
=begin pod
=head2 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, I<$x> and I<$y> will both be set to 0.0. It is possible to check this in advance with C<has-current-point()>.  Most path construction functions alter the current point.

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

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

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

The returned list has;
=item $x; X coordinate of the current point
=item $y; Y coordinate of the current point
=end pod

method get-current-point ( --> List ) {
  my gdouble $x_ret;
  my gdouble $y_ret;
  cairo_get_current_point(
    self._get-native-object-no-reffing, $x_ret, $y_ret
  );

  ( $x_ret, $y_ret);
}

sub cairo_get_current_point (
  cairo_t $cr, gdouble $x_ret is rw, gdouble $y_ret is rw
) is native(&cairo-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:1:get-dash:
=begin pod
=head2 get-dash

Gets the current dash array.

  method get-dash ( --> List )

List returns;
=item Array; the dash array
=item Num; the current dash offset, or C<Undefined>
=end pod

method get-dash ( --> List ) {
  my Int $ndashes = cairo_get_dash_count(self._get-native-object-no-reffing);

  my $dashes = CArray[gdouble].new( 0e0 xx $ndashes);
  my gdouble $offset;

  cairo_get_dash(
    self._get-native-object-no-reffing, $dashes, $offset
  );

  my Array $d = [];
  loop ( my $i = 0; $i < $ndashes; $i++ ) {
    $d.push: $dashes[$i];
  }

  ( $d, $offset)
}

sub cairo_get_dash (
  cairo_t $cr, CArray[gdouble] $dashes, gdouble $offset is rw
) is native(&cairo-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:1:get-dash-count:
=begin pod
=head2 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 C<set-dash()> and C<get-dash()>.  Return value: the length of the dash array, or 0 if no dash array set.

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

=end pod

method get-dash-count ( --> Int ) {
  cairo_get_dash_count(self._get-native-object-no-reffing)
}

sub cairo_get_dash_count (
  cairo_t $cr --> int32
) is native(&cairo-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:1:get-fill-rule:
=begin pod
=head2 get-fill-rule

Gets the current fill rule, as set by C<set-fill-rule()>.

Return value: the current fill rule.

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

=end pod

method get-fill-rule ( --> cairo_fill_rule_t ) {
  cairo_fill_rule_t(cairo_get_fill_rule(self._get-native-object-no-reffing))
}

sub cairo_get_fill_rule (
  cairo_t $cr --> gint32
) is native(&cairo-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:2:get-font-face:
=begin pod
=head2 get-font-face

Gets the current font face for a B<cairo_t>.

Return value: the current font face.
=comment This object is owned by cairo. To keep a reference to it, you must call C<font-face-reference()>.

This function never returns an undefined font face. If memory cannot be allocated, a special "nil" B<cairo_font_face_t> object will be returned on which C<Gnome::Cairo::FontFace.status()> returns C<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 C<set-font-face()> with a nil font will trigger an error that will shutdown the B<cairo_t> object).

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

=end pod

method get-font-face ( --> Any ) {
  self._wrap-native-type(
    'Gnome::Cairo::FontFace',
    cairo_get_font_face(self._get-native-object-no-reffing)
  )
}

sub cairo_get_font_face (
  cairo_t $cr --> cairo_font_face_t
) is native(&cairo-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:1:get-font-matrix:
=begin pod
=head2 get-font-matrix

Returns the current font matrix. See C<set-font-matrix()>.

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

=end pod

method get-font-matrix ( --> cairo_matrix_t ) {
  my cairo_matrix_t $matrix .= new;
  cairo_get_font_matrix( self._get-native-object-no-reffing, $matrix);
#  self._wrap-native-type( 'Gnome::Cairo::Matrix', $matrix)
  $matrix
}

sub cairo_get_font_matrix (
  cairo_t $cr, cairo_matrix_t $matrix
) is native(&cairo-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:1:get-font-options:
=begin pod
=head2 get-font-options

Retrieves font rendering options set via C<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 C<set-font-options()>.

  method get-font-options ( --> cairo_font_options_t )

Returns cairo_font_options_t structure
=end pod

=begin pod
=head3 Example

  my Gnome::Cairo::FontOptions() $fo = $c.get-font-options;
  if $fo.get-antialias ~~ CAIRO_ANTIALIAS_DEFAULT {
    …
  }

=end pod

method get-font-options ( --> cairo_font_options_t ) {
  my cairo_font_options_t $options .= new;
  cairo_get_font_options( self._get-native-object-no-reffing, $options);
  $options
}

sub cairo_get_font_options (
  cairo_t $cr, cairo_font_options_t $options
) is native(&cairo