public static bool overlaps(intRect a, intRect b) { return(b.xMin < a.xMax && b.xMax > a.xMin && b.yMin < a.yMax && b.yMax > a.yMin); }
public static bool contains(intRect rect, int2 position) { return(position.x >= rect.xMin && position.y >= rect.yMin && position.x < rect.xMax && position.y < rect.yMax); }
public static intRect clamp(intRect rect, intRect bounds) { return(new intRect( xMin: math.clamp(rect.x, bounds.xMin, bounds.xMax), yMin: math.clamp(rect.y, bounds.yMin, bounds.yMax), width: min(bounds.xMax - rect.x, rect.width), height: min(bounds.yMax - rect.y, rect.height))); }
public static bool contains(int2 position, intRect rect) { return(contains(rect, position)); }
public static float2 center(intRect rect) { return(float2(rect.x + rect.width / 2f, rect.y + rect.height / 2f)); }