{
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 | |
| 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
| *surface | - surface | |
| x | - x | |
| y | - y | |
| w | - w | |
| h | - h | |
| *coor | - on success coor will be the clipped area |
| 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
| *surface | - surface | |
| x | - x | |
| y | - y | |
| w | - w | |
| h | - h | |
| *coor | - on success coor will be the clipped area |
adds the difference of r1 form r0 to the list
| *r1 | - rectangle | |
| *r0 | - rectangle | |
| *list | - list |
| 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
| *list | - list to add | |
| x | - x | |
| y | - y | |
| w | - w | |
| h | - h |
calculates the intersection area of r1 and r2.
| *r1 | - pointer to a rect | |
| *r2 | - pointer to a rect | |
| *r | - on success r will be the intersection area |
calculates the merging area of r1 and r2.
| *r1 | - pointer to a rect | |
| *r2 | - pointer to a rect | |
| *r | - on success r will be the merging area |
1.4.7