Gsk.RoundedRect

Fields

Name

Type

Access

Description

bounds

Graphene.Rect

r/w

the bounds of the rectangle

corner

[Graphene.Size]

r/w

the size of the 4 rounded corners

Methods

contains_point (point)

contains_rect (rect)

init (bounds, top_left, top_right, bottom_right, bottom_left)

init_copy (src)

init_from_rect (bounds, radius)

intersects_rect (rect)

is_rectilinear ()

normalize ()

offset (dx, dy)

shrink (top, right, bottom, left)

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 a GskRoundedRect 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:

bool

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:

bool

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

init(bounds, top_left, top_right, bottom_right, bottom_left)
Parameters:
  • bounds (Graphene.Rect) – a graphene_rect_t describing the bounds

  • top_left (Graphene.Size) – the rounding radius of the top left corner

  • top_right (Graphene.Size) – the rounding radius of the top right corner

  • bottom_right (Graphene.Size) – the rounding radius of the bottom right corner

  • bottom_left (Graphene.Size) – the rounding radius of the bottom left corner

Returns:

the initialized rectangle

Return type:

Gsk.RoundedRect

Initializes the given GskRoundedRect with the given values.

This function will implicitly normalize the GskRoundedRect before returning.

init_copy(src)
Parameters:

src (Gsk.RoundedRect) – a GskRoundedRect

Returns:

the initialized rectangle

Return type:

Gsk.RoundedRect

Initializes self using the given src rectangle.

This function will not normalize the GskRoundedRect, so make sure the source is normalized.

init_from_rect(bounds, radius)
Parameters:
Returns:

the initialized rectangle

Return type:

Gsk.RoundedRect

Initializes self to the given bounds and sets the radius of all four corners to radius.

intersects_rect(rect)
Parameters:

rect (Graphene.Rect) – the rectangle to check

Returns:

True if the rect intersects with the rounded rectangle

Return type:

bool

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

is_rectilinear()
Returns:

True if the rectangle is rectilinear

Return type:

bool

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 [ctor`Gsk`.ClipNode.new] or [ctor`Gsk`.RoundedClipNode.new] should be called.

normalize()
Returns:

the normalized rectangle

Return type:

Gsk.RoundedRect

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.

offset(dx, dy)
Parameters:
  • dx (float) – the horizontal offset

  • dy (float) – the vertical offset

Returns:

the offset rectangle

Return type:

Gsk.RoundedRect

Offsets the bound’s origin by dx and dy.

The size and corners of the rectangle are unchanged.

shrink(top, right, bottom, left)
Parameters:
  • top (float) – How far to move the top side downwards

  • right (float) – How far to move the right side to the left

  • bottom (float) – How far to move the bottom side upwards

  • left (float) – How far to move the left side to the right

Returns:

the resized GskRoundedRect

Return type:

Gsk.RoundedRect

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.