aboutsummaryrefslogtreecommitdiff
path: root/teensy/teensy.h
diff options
context:
space:
mode:
authoriamcheeseman <[email protected]>2026-05-21 20:52:19 -0400
committeriamcheeseman <[email protected]>2026-05-21 20:52:19 -0400
commitc2861def8f13c647bdd5c970ef7568d15821e0e2 (patch)
tree9366c135550a2016e6df3d0d5d33f35774241bfa /teensy/teensy.h
parentbc5203f5a2e88aa6dd9f3ed54496d9813dfbc84e (diff)
clip all ui elements
Diffstat (limited to 'teensy/teensy.h')
-rw-r--r--teensy/teensy.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/teensy/teensy.h b/teensy/teensy.h
index e5954fc..80f9a71 100644
--- a/teensy/teensy.h
+++ b/teensy/teensy.h
@@ -22,6 +22,7 @@
#define ty_max(a, b) ((a) > (b) ? (a) : (b))
#define ty_min(a, b) ((a) < (b) ? (a) : (b))
+#define ty_clamp(a, mi, ma) (ty_max(ty_min(a, ma), mi))
#define TY_CLIP_NONE (ty_recti(0, 0, -1, -1))
@@ -155,6 +156,8 @@ bool ty_point_in_rect(ty_Vec2 point, ty_Rect rect);
ty_Recti ty_recti_shrink(ty_Recti rect, int p);
// Grows a rect by `p`.
ty_Recti ty_recti_grow(ty_Recti rect, int p);
+// Clamps a rect's bounds to be entirely within another.
+ty_Recti ty_recti_clamp(ty_Recti rect, ty_Recti minmax);
// Creates an image using the relevant data (formatted in RGB8). You may free
// the passed data after this call as it is copied.