Gsk.RoundedRect¶
Fields¶
Name |
Type |
Access |
Description |
---|---|---|---|
bounds |
r/w |
the bounds of the rectangle |
|
corner |
r/w |
the size of the 4 rounded corners |
Methods¶
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Details¶
- class Gsk.RoundedRect¶
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 aGskRoundedRect
will always return a normalized one.The algorithm used for normalizing corner sizes is described in the CSS specification.
- contains_point(point)¶
- Parameters:
point (
Graphene.Point
) – the point to check- Returns:
true if the point is inside the rounded rectangle
- Return type:
Checks if the given point is inside the rounded rectangle.
- contains_rect(rect)¶
- Parameters:
rect (
Graphene.Rect
) – the rectangle to check- Returns:
true if the rect is fully contained inside the rounded rectangle
- Return type:
Checks if the given rectangle is contained inside the rounded rectangle.
- init(bounds, top_left, top_right, bottom_right, bottom_left)¶
- Parameters:
bounds (
Graphene.Rect
) – agraphene_rect_t
describing the boundstop_left (
Graphene.Size
) – the rounding radius of the top left cornertop_right (
Graphene.Size
) – the rounding radius of the top right cornerbottom_right (
Graphene.Size
) – the rounding radius of the bottom right cornerbottom_left (
Graphene.Size
) – the rounding radius of the bottom left corner
- Returns:
the initialized rounded rectangle
- Return type:
Initializes a rounded rectangle with the given values.
This function will implicitly normalize the rounded rectangle before returning.
- init_copy(src)¶
- Parameters:
src (
Gsk.RoundedRect
) – another rounded rectangle- Returns:
the initialized rounded rectangle
- Return type:
Initializes a rounded rectangle with a copy.
This function will not normalize the rounded rectangle, so make sure the source is normalized.
- init_from_rect(bounds, radius)¶
- Parameters:
bounds (
Graphene.Rect
) – agraphene_rect_t
radius (
float
) – the border radius
- Returns:
the initialized rounded rectangle
- Return type:
Initializes a rounded rectangle to the given bounds and sets the radius of all four corners equally.
- intersects_rect(rect)¶
- Parameters:
rect (
Graphene.Rect
) – the rectangle to check- Returns:
true if the rect intersects with the rounded rectangle
- Return type:
Checks if part a rectangle is contained inside the rounded rectangle.
- is_rectilinear()¶
- Returns:
true if the rounded rectangle is rectilinear
- Return type:
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.
- normalize()¶
- Returns:
the normalized rounded rectangle
- Return type:
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.
- offset(dx, dy)¶
- Parameters:
- Returns:
the offset rounded rectangle
- Return type:
Offsets the rounded rectangle’s origin by dx and dy.
The size and corners of the rounded rectangle are unchanged.
- shrink(top, right, bottom, left)¶
- Parameters:
- Returns:
the resized rounded rectangle
- Return type:
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.