Gnome::Gsk4::N-RoundedRect

#------------------------------------------------------------------------------- #--[Class Description]---------------------------------------------------------- #-------------------------------------------------------------------------------

=begin rakudoc

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

=end rakudoc

#------------------------------------------------------------------------------- #--[Class Initialization]------------------------------------------------------- #-------------------------------------------------------------------------------

=begin rakudoc

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

=end rakudoc

#------------------------------------------------------------------------------- #--[Methods]-------------------------------------------------------------------- #-------------------------------------------------------------------------------

=begin rakudoc

Methods =end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

contains-point

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

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

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

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

contains-rect

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

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

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

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

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

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

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 )
  • $src; a Gnome::Gsk4::N-RoundedRect

Return value; the initialized rectangle.

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

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 )
  • $bounds; a Gnome::Graphene::N-Rect

  • $radius; the border radius.

Return value; the initialized rectangle.

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

intersects-rect

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

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

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

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

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 )

Return value; True if the rectangle is rectilinear.

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

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 )

Return value; the normalized rectangle.

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

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 )
  • $dx; the horizontal offset.

  • $dy; the vertical offset.

Return value; the offset rectangle.

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

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

=end rakudoc

Gnome::Gsk4 v0.2.1

GSK is the rendering and scene graph API

Authors

  • Marcel Timmerman

License

Artistic-2.0

Dependencies

Gnome::Gdk4:api<2>Gnome::Graphene:api<2>Gnome::GObject:api<2>Gnome::Glib:api<2>Gnome::N:api<2>

Test Dependencies

Provides

  • Gnome::Gsk4::BlendNode
  • Gnome::Gsk4::BlurNode
  • Gnome::Gsk4::BorderNode
  • Gnome::Gsk4::CairoNode
  • Gnome::Gsk4::CairoRenderer
  • Gnome::Gsk4::ClipNode
  • Gnome::Gsk4::ColorMatrixNode
  • Gnome::Gsk4::ColorNode
  • Gnome::Gsk4::ConicGradientNode
  • Gnome::Gsk4::ContainerNode
  • Gnome::Gsk4::CrossFadeNode
  • Gnome::Gsk4::DebugNode
  • Gnome::Gsk4::GLRenderer
  • Gnome::Gsk4::GLShader
  • Gnome::Gsk4::GLShaderNode
  • Gnome::Gsk4::InsetShadowNode
  • Gnome::Gsk4::LinearGradientNode
  • Gnome::Gsk4::MaskNode
  • Gnome::Gsk4::N-RoundedRect
  • Gnome::Gsk4::N-ShaderArgsBuilder
  • Gnome::Gsk4::N-Transform
  • Gnome::Gsk4::OpacityNode
  • Gnome::Gsk4::OutsetShadowNode
  • Gnome::Gsk4::RadialGradientNode
  • Gnome::Gsk4::RenderNode
  • Gnome::Gsk4::Renderer
  • Gnome::Gsk4::RepeatNode
  • Gnome::Gsk4::RepeatingLinearGradientNode
  • Gnome::Gsk4::RepeatingRadialGradientNode
  • Gnome::Gsk4::RoundedClipNode
  • Gnome::Gsk4::ShadowNode
  • Gnome::Gsk4::T-enums
  • Gnome::Gsk4::T-glshader
  • Gnome::Gsk4::T-path
  • Gnome::Gsk4::T-rendernode
  • Gnome::Gsk4::T-roundedrect
  • Gnome::Gsk4::T-stroke
  • Gnome::Gsk4::T-transform
  • Gnome::Gsk4::T-types
  • Gnome::Gsk4::TextNode
  • Gnome::Gsk4::TextureNode
  • Gnome::Gsk4::TextureScaleNode
  • Gnome::Gsk4::TransformNode

The Camelia image is copyright 2009 by Larry Wall. "Raku" is a trademark of the Yet Another Society. All rights reserved.

Built with Podlite — the markup and publishing tools behind this site.