summaryrefslogtreecommitdiff
path: root/math.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2021-01-21 11:50:51 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2021-01-21 11:50:51 -0500
commitdd91d6c72625cc7ed2ec5954a5cbca35fd7655d4 (patch)
tree4b1e52098e3fdbb9a36395c33ad057b7cbaf0d01 /math.c
parent3d86329abd754319a36459f8eb3e4bce6efffe1e (diff)
split file selector into its own thing
Diffstat (limited to 'math.c')
-rw-r--r--math.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/math.c b/math.c
index 8de9daf..c920a80 100644
--- a/math.c
+++ b/math.c
@@ -738,5 +738,14 @@ static float rects_intersect(Rect r1, Rect r2) {
if (r2.pos.y >= r1.pos.y + r1.size.y) return false; // r2 is above r1
return true;
}
+
+// returns whether or not there is any of the clipped rectangle left
+static bool rect_clip_to_rect(Rect *clipped, Rect clipper) {
+ clipped->pos.x = maxf(clipped->pos.x, clipper.pos.x);
+ clipped->pos.y = maxf(clipped->pos.y, clipper.pos.y);
+ clipped->size.x = clampf(clipped->size.x, 0, clipper.pos.x + clipper.size.x - clipped->pos.x);
+ clipped->size.y = clampf(clipped->size.y, 0, clipper.pos.y + clipper.size.y - clipped->pos.y);
+ return clipped->size.x > 0 && clipped->size.y > 0;
+}
#endif