diff options
| author | iamcheeseman <[email protected]> | 2026-05-21 20:52:19 -0400 |
|---|---|---|
| committer | iamcheeseman <[email protected]> | 2026-05-21 20:52:19 -0400 |
| commit | c2861def8f13c647bdd5c970ef7568d15821e0e2 (patch) | |
| tree | 9366c135550a2016e6df3d0d5d33f35774241bfa /teensy/teensy_math.c | |
| parent | bc5203f5a2e88aa6dd9f3ed54496d9813dfbc84e (diff) | |
clip all ui elements
Diffstat (limited to 'teensy/teensy_math.c')
| -rw-r--r-- | teensy/teensy_math.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/teensy/teensy_math.c b/teensy/teensy_math.c index 5da800c..9247bd0 100644 --- a/teensy/teensy_math.c +++ b/teensy/teensy_math.c @@ -36,3 +36,22 @@ ty_Recti ty_recti_grow(ty_Recti rect, int p) rect.h += p * 2; return rect; } + +ty_Recti ty_recti_clamp(ty_Recti rect, ty_Recti minmax) +{ + ty_Vec2i start = ty_recti_start(rect); + ty_Vec2i end = ty_recti_end(rect); + + ty_Vec2i min = ty_recti_start(minmax); + ty_Vec2i max = ty_recti_end(minmax); + + start.x = ty_clamp(start.x, min.x, max.x); + start.y = ty_clamp(start.y, min.y, max.y); + end.x = ty_clamp(end.x, min.x, max.x); + end.y = ty_clamp(end.y, min.y, max.y); + + return ty_recti( + start.x, start.y, + end.x - start.x, end.y - start.y + ); +} |
