:right-sidebar: True Rectangle =================================================================== .. currentmodule:: gi.repository.Gdk .. class:: Rectangle(*args, **kwargs) :no-contents-entry: 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 :obj:`~gi.repository.Gdk.Rectangle.intersect`; to find the union of two rectangles use :obj:`~gi.repository.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. Methods ------- .. rst-class:: interim-class .. class:: Rectangle :no-index: .. method:: contains_point(x: int, y: int) -> bool Returns :const:`True` if ``rect`` contains the point described by ``x`` and ``y``. :param x: X coordinate :param y: Y coordinate .. method:: equal(rect2: ~gi.repository.Gdk.Rectangle) -> bool Checks if the two given rectangles are equal. :param rect2: a ``GdkRectangle`` .. method:: intersect(src2: ~gi.repository.Gdk.Rectangle) -> tuple[bool, ~gi.repository.Gdk.Rectangle] Calculates the intersection of two rectangles. It is allowed for ``dest`` to be the same as either ``src1`` 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 :const:`None` for ``dest``. :param src2: a ``GdkRectangle`` .. method:: union(src2: ~gi.repository.Gdk.Rectangle) -> ~gi.repository.Gdk.Rectangle Calculates the union of two rectangles. The union of rectangles ``src1`` and ``src2`` is the smallest rectangle which includes both ``src1`` and ``src2`` within it. It is allowed for ``dest`` to be the same as either ``src1`` or ``src2``. Note that this function does not ignore 'empty' rectangles (ie. with zero width or height). :param src2: a ``GdkRectangle`` Fields ------ .. rst-class:: interim-class .. class:: Rectangle :no-index: .. attribute:: height The height of the rectangle .. attribute:: width The width of the rectangle .. attribute:: x The x coordinate of the top left corner .. attribute:: y The y coordinate of the top left corner