Klasse RoundedRect

Alle implementierten Schnittstellen:
PointerInterface

public class RoundedRect extends Record
A rectangular region with rounded corners.

Application code should normalize rectangles using
[method@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 `GskRoundedRect` as an argument will internally
operate on a normalized copy; all functions returning a `GskRoundedRect`
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).

https://docs.gtk.org/gsk4/struct.RoundedRect.html

  • Felddetails

    • BOUNDS

      public static final String BOUNDS
      the bounds of the rectangle
      Private field: direct-type
      Siehe auch:
  • Konstruktordetails

  • Methodendetails

    • getClassHandler

      public static ClassHandler getClassHandler()
    • containsPoint

      public boolean containsPoint(@Nonnull Point point)
      Checks if the given point is inside the rounded rectangle.
      Parameter:
      point - the point to check
      Gibt zurück:
      true if the point is inside the rounded rectangle
    • containsRect

      public boolean containsRect(@Nonnull Rect rect)
      Checks if the given rectangle is contained inside the rounded rectangle.
      Parameter:
      rect - the rectangle to check
      Gibt zurück:
      true if the @rect is fully contained inside the rounded rectangle
    • init

      public RoundedRect init(@Nonnull Rect bounds, @Nonnull Size top_left, @Nonnull Size top_right, @Nonnull Size bottom_right, @Nonnull Size bottom_left)
      Initializes a rounded rectangle with the given values.

      This function will implicitly normalize the rounded rectangle
      before returning.
      Parameter:
      bounds - a `graphene_rect_t` 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
      Gibt zurück:
      the initialized rounded rectangle
    • initCopy

      public RoundedRect initCopy(@Nonnull RoundedRect src)
      Initializes a rounded rectangle with a copy.

      This function will not normalize the rounded rectangle,
      so make sure the source is normalized.
      Parameter:
      src - another rounded rectangle
      Gibt zurück:
      the initialized rounded rectangle
    • initFromRect

      public RoundedRect initFromRect(@Nonnull Rect bounds, float radius)
      Initializes a rounded rectangle to the given bounds
      and sets the radius of all four corners equally.
      Parameter:
      bounds - a `graphene_rect_t`
      radius - the border radius
      Gibt zurück:
      the initialized rounded rectangle
    • intersectsRect

      public boolean intersectsRect(@Nonnull Rect rect)
      Checks if part a rectangle is contained
      inside the rounded rectangle.
      Parameter:
      rect - the rectangle to check
      Gibt zurück:
      true if the @rect intersects with the rounded rectangle
    • isRectilinear

      public boolean isRectilinear()
      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 [ctor@Gsk.ClipNode.new]
      or [ctor@Gsk.RoundedClipNode.new] should be called.
      Gibt zurück:
      true if the rounded rectangle is rectilinear
    • normalize

      public RoundedRect normalize()
      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.
      Gibt zurück:
      the normalized rounded rectangle
    • offset

      public RoundedRect offset(float dx, float dy)
      Offsets the rounded rectangle's origin by @dx and @dy.

      The size and corners of the rounded rectangle are unchanged.
      Parameter:
      dx - the horizontal offset
      dy - the vertical offset
      Gibt zurück:
      the offset rounded rectangle
    • shrink

      public RoundedRect shrink(float top, float right, float bottom, float left)
      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.
      Parameter:
      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
      Gibt zurück:
      the resized rounded rectangle