aboutsummaryrefslogtreecommitdiff
path: root/rect.c
diff options
context:
space:
mode:
Diffstat (limited to 'rect.c')
-rw-r--r--rect.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/rect.c b/rect.c
index 69758c1..a35052d 100644
--- a/rect.c
+++ b/rect.c
@@ -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) {