Class (GI Struct)

Gsk-4.0GskRoundedRect

A rectangular region with rounded corners.

Application code should normalize rectangles using Gsk.RoundedRect.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 Gsk.RoundedRect as an argument will internally operate on a normalized copy; all functions returning a Gsk.RoundedRect will always return a normalized one.

The algorithm used for normalizing corner sizes is described in the CSS specification.

Index

Constructors

Properties

bounds: Graphene.Rect
corner: Size[]

Methods

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

    Parameters

    Returns boolean

    true if the point is inside the rounded rectangle

  • Checks if the given rectangle is contained inside the rounded rectangle.

    Parameters

    Returns boolean

    true if the rect is fully contained inside the rounded rectangle

  • Initializes a rounded rectangle with the given values.

    This function will implicitly normalize the rounded rectangle before returning.

    Parameters

    • bounds: Graphene.Rect

      a graphene_rect_t describing the bounds

    • top_left: Size

      the rounding radius of the top left corner

    • top_right: Size

      the rounding radius of the top right corner

    • bottom_right: Size

      the rounding radius of the bottom right corner

    • bottom_left: Size

      the rounding radius of the bottom left corner

    Returns RoundedRect

    the initialized rounded rectangle

  • Checks if part a rectangle is contained inside the rounded rectangle.

    Parameters

    Returns boolean

    true if the rect intersects with the rounded rectangle

  • Checks if all corners of a rounded rectangle are right angles and the rectangle covers all of its bounds.

    This information can be used to decide if Gsk.ClipNode.new or Gsk.RoundedClipNode.new should be called.

    Returns boolean

    true if the rounded rectangle is rectilinear

  • Normalizes a rounded rectangle.

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

    Returns RoundedRect

    the normalized rounded rectangle

  • Offsets the rounded rectangle's origin by dx and dy.

    The size and corners of the rounded rectangle are unchanged.

    Parameters

    • dx: number

      the horizontal offset

    • dy: number

      the vertical offset

    Returns RoundedRect

    the offset rounded rectangle

  • Shrinks (or grows) a rounded 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 rounded rectangles if you pass negative values for the top, right, bottom or left.

    Parameters

    • top: number

      how far to move the top side downwards

    • right: number

      how far to move the right side to the left

    • bottom: number

      how far to move the bottom side upwards

    • left: number

      how far to move the left side to the right

    Returns RoundedRect

    the resized rounded rectangle