RoundedRect#
- class RoundedRect(*args, **kwargs)#
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 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.
Methods#
- class RoundedRect
- contains_point(point: Point) bool#
Checks if the given point is inside the rounded rectangle.
- Parameters:
point – the point to check
- contains_rect(rect: Rect) bool#
Checks if the given rectangle is contained inside the rounded rectangle.
- Parameters:
rect – the rectangle to check
- init(bounds: Rect, top_left: Size, top_right: Size, bottom_right: Size, bottom_left: Size) RoundedRect#
Initializes a rounded rectangle with the given values.
This function will implicitly normalize the rounded rectangle before returning.
- Parameters:
bounds – a
graphene_rect_tdescribing the boundstop_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
- init_from_rect(bounds: Rect, radius: float) RoundedRect#
Initializes a rounded rectangle to the given bounds and sets the radius of all four corners equally.
- Parameters:
bounds – a
graphene_rect_tradius – the border radius
- intersects_rect(rect: Rect) bool#
Checks if part a rectangle is contained inside the rounded rectangle.
- Parameters:
rect – the rectangle to check
- is_rectilinear() bool#
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
newornewshould be called.
- normalize() RoundedRect#
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: float, dy: float) RoundedRect#
Offsets the rounded rectangle’s origin by
dxanddy.The size and corners of the rounded rectangle are unchanged.
- Parameters:
dx – the horizontal offset
dy – the vertical offset
- shrink(top: float, right: float, bottom: float, left: float) RoundedRect#
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,bottomorleft.- Parameters:
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