#include "teensy.h" bool ty_pointi_in_recti(ty_Vec2i point, ty_Recti rect) { return point.x > rect.x && point.x < rect.x + rect.w && point.y > rect.y && point.y < rect.y + rect.h; } bool ty_point_in_rect(ty_Vec2 point, ty_Rect rect) { return point.x > rect.x && point.x < rect.x + rect.w && point.y > rect.y && point.y < rect.y + rect.h; } ty_Recti ty_recti_shrink(ty_Recti rect, int p) { rect.x += p; rect.y += p; rect.w -= p * 2; rect.h -= p * 2; return rect; } ty_Recti ty_recti_grow(ty_Recti rect, int p) { rect.x -= p; rect.y -= p; rect.w += p * 2; 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 ); }