GdkRectangle

GdkRectangle — Simple graphical data type

Functions

Types and Values

Object Hierarchy

    GBoxed
    ╰── GdkRectangle

Includes

#include <gdk/gdk.h>

Description

GDK provides a GdkRectangle data type for representing rectangles. Together with Cairo’s cairo_region_t data type, these are the central types for representing sets of pixels.

A GdkRectangle represents the position and size of a rectangle. The intersection of two rectangles can be computed with gdk_rectangle_intersect(). To find the union of two rectangles use gdk_rectangle_union().

cairo_region_t is usually used for managing clipping of graphical operations.

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

Functions

gdk_rectangle_intersect ()

gboolean
gdk_rectangle_intersect (const GdkRectangle *src1,
                         const GdkRectangle *src2,
                         GdkRectangle *dest);

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 NULL for dest .

Parameters

src1

a GdkRectangle

 

src2

a GdkRectangle

 

dest

return location for the intersection of src1 and src2 , or NULL.

[out caller-allocates][allow-none]

Returns

TRUE if the rectangles intersect.


gdk_rectangle_union ()

void
gdk_rectangle_union (const GdkRectangle *src1,
                     const GdkRectangle *src2,
                     GdkRectangle *dest);

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).

Parameters

src1

a GdkRectangle

 

src2

a GdkRectangle

 

dest

return location for the union of src1 and src2 .

[out]

gdk_rectangle_equal ()

gboolean
gdk_rectangle_equal (const GdkRectangle *rect1,
                     const GdkRectangle *rect2);

Checks if the two given rectangles are equal.

Parameters

rect1

a GdkRectangle

 

rect2

a GdkRectangle

 

Returns

TRUE if the rectangles are equal.


gdk_rectangle_contains_point ()

gboolean
gdk_rectangle_contains_point (const GdkRectangle *rect,
                              int x,
                              int y);

Returns TRUE if rect contains the point described by x and y .

Parameters

rect

a GdkRectangle

 

x

X coordinate

 

y

Y coordinate

 

Returns

TRUE if rect contains the point

Types and Values

GdkRectangle

typedef struct {
    int x, y;
    int width, height;
} GdkRectangle;

Defines the position and size of a rectangle. It is identical to cairo_rectangle_int_t.

Members

int x;

the x coordinate of the top left corner

 

int y;

the y coordinate of the top left corner

 

int width;

the width of the rectangle

 

int height;

the height of the rectangle