Example #1
0
 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);
 }
Example #2
0
 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);
 }
Example #3
0
 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)));
 }
Example #4
0
 public static bool contains(int2 position, intRect rect)
 {
     return(contains(rect, position));
 }
Example #5
0
 public static float2 center(intRect rect)
 {
     return(float2(rect.x + rect.width / 2f, rect.y + rect.height / 2f));
 }