Points and Rectangles

Points and Rectangles — Simple graphical data types

Synopsis

#include <gdk/gdk.h>

struct              GdkPoint;

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

Description

GDK provides the GdkPoint and GdkRectangle data types for representing pixels and sets of pixels on the screen. Together with Cairo's cairo_region_t data type, they make up the central types for representing graphical data.

GdkPoint is a simple structure containing an x and y coordinate of a point.

GdkRectangle is a structure holding 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.

Details

struct GdkPoint

struct GdkPoint {
  gint x;
  gint y;
};

Defines the x and y coordinates of a point.

gint x;

the x coordinate of the point.

gint y;

the y coordinate of the point.

GdkRectangle

typedef cairo_rectangle_int_t         GdkRectangle;

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


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.

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.

src1 :

a GdkRectangle

src2 :

a GdkRectangle

dest :

return location for the union of src1 and src2. [out]