About my projects, examples and tutorials
Gnome::Gsk4::N-RoundedRect

Gnome::Gsk4::N-RoundedRect

Description§

A rectangular region with rounded corners.

Application code should normalize rectangles using .normalize(); this function will ensure that the bounds of the rectangle are normalized and ensure that the corner values are positive and the corners do not overlap.

All functions taking a Gnome::Gsk4::N-RoundedRect as an argument will internally operate on a normalized copy; all functions returning a Gnome::Gsk4::N-RoundedRect will always return a normalized one.

The algorithm used for normalizing corner sizes is described in [the CSS specification](https://drafts.csswg.org/css-backgrounds-3/#border-radius).

Class initialization§

new§

:native-object§

Create an object using a native object from an object of the same type found elsewhere. See also Gnome::N::TopLevelSupportClass.

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

Methods§

contains-point§

Checks if the given $point is inside the rounded rectangle.

method contains-point ( N-Object $point --> Bool )
Code
  • $point; the point to check

Return value; True if the $point is inside the rounded rectangle.

contains-rect§

Checks if the given $rect is contained inside the rounded rectangle.

method contains-rect ( N-Object $rect --> Bool )
Code
  • $rect; the rectangle to check

Return value; True if the $rect is fully contained inside the rounded rectangle.

init§

Initializes the given Gnome::Gsk4::N-RoundedRect with the given values.

This function will implicitly normalize the Gnome::Gsk4::N-RoundedRect before returning.

method init ( N-Object $bounds, N-Object $top-left, N-Object $top-right, N-Object $bottom-right, N-Object $bottom-left --> N-Object )
Code
  • $bounds; a Gnome::Graphene::N-Rect describing the bounds
  • $top-left; the rounding radius of the top left corner
  • $top-right; the rounding radius of the top right corner
  • $bottom-right; the rounding radius of the bottom right corner
  • $bottom-left; the rounding radius of the bottom left corner

Return value; the initialized rectangle.

init-copy§

Initializes $self using the given $src rectangle.

This function will not normalize the Gnome::Gsk4::N-RoundedRect, so make sure the source is normalized.

method init-copy ( N-Object $src --> N-Object )
Code
  • $src; a Gnome::Gsk4::N-RoundedRect

Return value; the initialized rectangle.

init-from-rect§

Initializes $self to the given $bounds and sets the radius of all four corners to $radius.

method init-from-rect ( N-Object $bounds, Num() $radius --> N-Object )
Code
  • $bounds; a Gnome::Graphene::N-Rect
  • $radius; the border radius.

Return value; the initialized rectangle.

intersects-rect§

Checks if part of the given $rect is contained inside the rounded rectangle.

method intersects-rect ( N-Object $rect --> Bool )
Code
  • $rect; the rectangle to check

Return value; True if the $rect intersects with the rounded rectangle.

is-rectilinear§

Checks if all corners of $self are right angles and the rectangle covers all of its bounds.

This information can be used to decide if .newroundedrect() in class Gnome::Gsk4::ClipNode or .newroundedrect() in class Gnome::Gsk4::RoundedClipNode should be called.

method is-rectilinear (--> Bool )
Code

Return value; True if the rectangle is rectilinear.

normalize§

Normalizes the passed rectangle.

This function will ensure that the bounds of the rectangle are normalized and ensure that the corner values are positive and the corners do not overlap.

method normalize (--> N-Object )
Code

Return value; the normalized rectangle.

offset§

Offsets the bound's origin by $dx and $dy.

The size and corners of the rectangle are unchanged.

method offset ( Num() $dx, Num() $dy --> N-Object )
Code
  • $dx; the horizontal offset.
  • $dy; the vertical offset.

Return value; the offset rectangle.

shrink§

Shrinks (or grows) the given rectangle by moving the 4 sides according to the offsets given.

The corner radii will be changed in a way that tries to keep the center of the corner circle intact. This emulates CSS behavior.

This function also works for growing rectangles if you pass negative values for the $top, $right, $bottom or $left.

method shrink ( Num() $top, Num() $right, Num() $bottom, Num() $left --> N-Object )
Code
  • $top; How far to move the top side downwards.
  • $right; How far to move the right side to the left.
  • $bottom; How far to move the bottom side upwards.
  • $left; How far to move the left side to the right.

Return value; the resized Gnome::Gsk4::N-RoundedRect.