SwfdecRectangle

## SwfdecRectangle SwfdecRectangle — handling regions on the screen |

## Synopsis

    #include <swfdec/swfdec.h>

                        SwfdecRectangle;
    gboolean            swfdec_rectangle_contains           (const SwfdecRectangle *container,
                                                             const SwfdecRectangle *content);
    gboolean            swfdec_rectangle_contains_point     (const SwfdecRectangle *rectangle,
                                                             int x,
                                                             int y);
    void                swfdec_rectangle_init_empty         (SwfdecRectangle *rectangle);
    gboolean            swfdec_rectangle_intersect          (SwfdecRectangle *dest,
                                                             const SwfdecRectangle *a,
                                                             const SwfdecRectangle *b);
    gboolean            swfdec_rectangle_is_empty           (const SwfdecRectangle *rectangle);
    void                swfdec_rectangle_union              (SwfdecRectangle *dest,
                                                             const SwfdecRectangle *a,
                                                             const SwfdecRectangle *b);

## Description

This section describes how regions are handled in Swfdec. Regions are important when tracking which parts of the screen have been invalidated and need to be repainted. See SwfdecPlayer::invalidate for an example.

## Details

### SwfdecRectangle

    typedef struct {
      int		x;			/* x coordinate of top-left point */
      int		y;			/* y coordinate of top left point */
      int		width;			/* width of rectangle or 0 for empty */
      int		height;			/* height of rectangle or 0 for empty */
    } SwfdecRectangle;

This structure represents a rectangular region. It is identical to the GdkRectangle structure, so you can cast freely between them. The only difference is that Gdk does not allow empty rectangles, while Swfdec does. You can use `swfdec_rectangle_is_empty()` to check for this.

int `x`; | x coordinate of top-left point
int `y`; | y coordinate of top-left point
int `width`; | width of rectangle or 0 for empty
int `height`; | height of rectangle or 0 for empty

### swfdec_rectangle_contains ()

    gboolean            swfdec_rectangle_contains           (const SwfdecRectangle *container,
                                                             const SwfdecRectangle *content);

Checks if `container` contains the whole rectangle `content`.

`container` : | the supposedly bigger rectangle
`content` : | the supposedly smaller rectangle
Returns : | `TRUE` if `container` contains `content`.

### swfdec_rectangle_contains_point ()

    gboolean            swfdec_rectangle_contains_point     (const SwfdecRectangle *rectangle,
                                                             int x,
                                                             int y);

Checks if the given point is inside the given rectangle.

`rectangle` : | a rectangle
`x` : | x coordinate of point to check
`y` : | y coordinate of point to check
Returns : | `TRUE` if the point is inside the rectangle

### swfdec_rectangle_init_empty ()

    void                swfdec_rectangle_init_empty         (SwfdecRectangle *rectangle);

Initializes the rectangle as empty.

`rectangle` : | rectangle to initialize

### swfdec_rectangle_intersect ()

    gboolean            swfdec_rectangle_intersect          (SwfdecRectangle *dest,
                                                             const SwfdecRectangle *a,
                                                             const SwfdecRectangle *b);

Intersects the rectangles `a` and `b` and puts the result into `dest`. It is allowed if `dest` is the same as `a` or `b`.

`dest` : | the rectangle to take the result or `NULL`
`a` : | first rectangle to intersect
`b` : | second rectangle to intersect
Returns : | `TRUE` if the intersection is not empty.

### swfdec_rectangle_is_empty ()

    gboolean            swfdec_rectangle_is_empty           (const SwfdecRectangle *rectangle);

Checks if the given `rectangle` is empty.

`rectangle` : | rectangle to check
Returns : | `TRUE` if the rectangle is emtpy

### swfdec_rectangle_union ()

    void                swfdec_rectangle_union              (SwfdecRectangle *dest,
                                                             const SwfdecRectangle *a,
                                                             const SwfdecRectangle *b);

Computes the smallest rectangle that contains both `a` and `b` and puts it in `dest`.

`dest` : | destination to take the union
`a` : | first rectangle to union
`b` : | second rectangle to union