Client Library - Rect API


Detailed Description

s_rect_* api is designed for rectangular operations.

Example:
typical usage of rect api;
 {
        s_rect_t r
        s_rect_t rect r1 = (s_rect_t) {10, 10, 20, 20};
        s_rect_t rect r2 = (s_rect_t) {15, 15, 20, 20};
        if (s_rect_intersect(&r1, &r2, &r)) {
                // no intersection
        }
        // intersectig region is r
 }

 {
        s_list_t *diff;
        s_rect_t rect r1 = (s_rect_t) {10, 10, 20, 20};
        s_rect_t rect r2 = (s_rect_t) {15, 15, 20, 20};

        s_list_init(&diff);
        if (s_rect_difference(&r1, &r2, diff) < 0) {
                // will not happen
        }

        // walk through the difference list
        for (pos = 0; !s_list_eol(list, pos); pos++) {
                s_rect_t *rtmp = (s_rect_t *) s_list_get(list, pos);
                // do what ever you want with the rectangle
                s_list_remove(list, pos);
                s_free(rtmp);
        }

        s_list_uninit(list);
 }


Data Structures

struct  s_rect_s
 rect struct More...

Functions

int s_rect_merge (s_rect_t *r1, s_rect_t *r2, s_rect_t *r)
 calculates the merging area of r1 and r2.
int s_rect_intersect (s_rect_t *r1, s_rect_t *r2, s_rect_t *r)
 calculates the intersection area of r1 and r2.
int s_rect_clip_virtual (s_surface_t *surface, int x, int y, int w, int h, s_rect_t *coor)
 performs clip on rectangle (x, y, w, h).
int s_rect_clip_real (s_surface_t *surface, int x, int y, int w, int h, s_rect_t *coor)
 performs clip on rectangle (x, y, w, h).
int s_rect_difference_add (s_list_t *list, int x, int y, int w, int h)
 adds the rectangle (x, y, w, h) to the list
int s_rect_difference (s_rect_t *r1, s_rect_t *r0, s_list_t *list)
 adds the difference of r1 form r0 to the list


Function Documentation

int s_rect_clip_real ( s_surface_t surface,
int  x,
int  y,
int  w,
int  h,
s_rect_t coor 
)

performs clip on rectangle (x, y, w, h).

clip region is the surface's virtual buffer area

Parameters:
*surface - surface
x - x
y - y
w - w
h - h
*coor - on success coor will be the clipped area
Returns:
0 on success, 1 on error.

int s_rect_clip_virtual ( s_surface_t surface,
int  x,
int  y,
int  w,
int  h,
s_rect_t coor 
)

performs clip on rectangle (x, y, w, h).

clip region is the surface's virtual buffer area

Parameters:
*surface - surface
x - x
y - y
w - w
h - h
*coor - on success coor will be the clipped area
Returns:
0 on success, 1 on error.

int s_rect_difference ( s_rect_t r1,
s_rect_t r0,
s_list_t list 
)

adds the difference of r1 form r0 to the list

Parameters:
*r1 - rectangle
*r0 - rectangle
*list - list
Returns:
number of differences on success, -1 on error.

int s_rect_difference_add ( s_list_t list,
int  x,
int  y,
int  w,
int  h 
)

adds the rectangle (x, y, w, h) to the list

Parameters:
*list - list to add
x - x
y - y
w - w
h - h
Returns:
0 on success, 1 on error.

int s_rect_intersect ( s_rect_t r1,
s_rect_t r2,
s_rect_t r 
)

calculates the intersection area of r1 and r2.

Parameters:
*r1 - pointer to a rect
*r2 - pointer to a rect
*r - on success r will be the intersection area
Returns:
0 on success, 1 on error.

int s_rect_merge ( s_rect_t r1,
s_rect_t r2,
s_rect_t r 
)

calculates the merging area of r1 and r2.

Parameters:
*r1 - pointer to a rect
*r2 - pointer to a rect
*r - on success r will be the merging area
Returns:
0 on success, 1 on error.


Generated on Wed Dec 27 17:53:06 2006 for xynth-0.8.40 by  doxygen 1.4.7