diff options
Diffstat (limited to 'rect.c')
-rw-r--r-- | rect.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -1,5 +1,21 @@ #include "rect.h" +int rects_overlap(const Rect* a, const Rect* b) { + return + a->x + a->w > b->x && + a->y + a->h > b->y && + a->x < b->x + b->w && + a->y < b->y + b->h; +} + +int point_rect_overlap(const Rect* r, int px, int py) { + return + px >= r->x && + py >= r->y && + px <= r->x + r->w && + py <= r->y + r->h; +} + Rect* rect_clip(Rect* r, const Rect* c) { int n; if ((n = c->x - r->x) > 0) { |