About all my projects
Gnome::Gdk4::N-Rectangle

Gnome::Gdk4::N-Rectangle

Description

A Gnome::Gdk4::N-Rectangle data type for representing rectangles.

Gnome::Gdk4::N-Rectangle is identical to Cairo::cairo_rectangle_t. Together with Cairo’s Cairo::cairo_region_t data type, these are the central types for representing sets of pixels.

The intersection of two rectangles can be computed with .intersect(); to find the union of two rectangles use .union().

The Cairo::cairo_region_t type provided by Cairo is usually used for managing non-rectangular clipping of graphical operations.

The Graphene library has a number of other data types for regions and volumes in 2D and 3D.

Class initialization

new

:native-object

Create an object using a native object from elsewhere. See also Gnome::N::TopLevelSupportClass.

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

Methods

contains-point

Returns True if $rect contains the point described by $x and $y.

method contains-point ( Int() $x, Int() $y --> Bool )
  • $x; X coordinate.

  • $y; Y coordinate.

Return value; True if $rect contains the point.

equal

Checks if the two given rectangles are equal.

method equal ( N-Object $rect2 --> Bool )
  • $rect2; a Gnome::Gdk4::N-Rectangle

Return value; True if the rectangles are equal..

intersect

Calculates the intersection of two rectangles.

It is allowed for $dest to be the same as either $src1 or $src2. If the rectangles do not intersect, $dest’s width and height is set to 0 and its x and y values are undefined. If you are only interested in whether the rectangles intersect, but not in the intersecting area itself, pass undefined for $dest.

method intersect ( N-Object $src2, N-Object $dest --> Bool )
  • $src2; a Gnome::Gdk4::N-Rectangle

  • $dest; return location for the intersection of $src1 and $src2

Return value; True if the rectangles intersect..

union

Calculates the union of two rectangles.

The union of rectangles $src1 and $src2 is the smallest rectangle which includes both $src1 and $src2 within it. It is allowed for $dest to be the same as either $src1 or $src2.

Note that this function does not ignore 'empty' rectangles (ie. with zero width or height).

method union ( N-Object $src2, N-Object $dest )
  • $src2; a Gnome::Gdk4::N-Rectangle

  • $dest; return location for the union of $src1 and $src2