Gdk.Rectangle

Fields

Name

Type

Access

Description

height

int

r/w

the height of the rectangle

width

int

r/w

the width of the rectangle

x

int

r/w

the x coordinate of the top left corner

y

int

r/w

the y coordinate of the top left corner

Methods

contains_point (x, y)

equal (rect2)

intersect (src2)

union (src2)

Details

class Gdk.Rectangle

A GdkRectangle data type for representing rectangles.

GdkRectangle is identical to cairo_rectangle_t. Together with Cairo’s cairo_region_t data type, these are the central types for representing sets of pixels.

The intersection of two rectangles can be computed with [method`Gdk`.Rectangle.intersect]; to find the union of two rectangles use [method`Gdk`.Rectangle.union].

The cairo_region_t type provided by Cairo is usually used for managing non-rectangular clipping of graphical operations.

The Graphene library has a number of other data types for regions and volumes in 2D and 3D.

contains_point(x, y)[source]
Parameters:
  • x (int) – X coordinate

  • y (int) – Y coordinate

Returns:

True if self contains the point

Return type:

bool

Returns True if self contains the point described by x and y.

equal(rect2)[source]
Parameters:

rect2 (Gdk.Rectangle) – a GdkRectangle

Returns:

True if the rectangles are equal.

Return type:

bool

Checks if the two given rectangles are equal.

intersect(src2)[source]
Parameters:

src2 (Gdk.Rectangle) – a GdkRectangle

Returns:

True if the rectangles intersect.

dest:

return location for the intersection of self and src2

Return type:

(bool, dest: Gdk.Rectangle)

Calculates the intersection of two rectangles.

It is allowed for dest to be the same as either self or src2. If the rectangles do not intersect, dest’s width and height is set to 0 and its x and y values are undefined. If you are only interested in whether the rectangles intersect, but not in the intersecting area itself, pass None for dest.

union(src2)[source]
Parameters:

src2 (Gdk.Rectangle) – a GdkRectangle

Returns:

return location for the union of self and src2

Return type:

dest: Gdk.Rectangle

Calculates the union of two rectangles.

The union of rectangles self and src2 is the smallest rectangle which includes both self and src2 within it. It is allowed for dest to be the same as either self or src2.

Note that this function does not ignore ‘empty’ rectangles (ie. with zero width or height).