public static RectI GetIntersection(RectI a, RectI b) { int a_x = a.x; int a_r = a.GetRight(); int a_y = a.y; int a_t = a.GetBottom(); int b_x = b.x; int b_r = b.GetRight(); int b_y = b.y; int b_t = b.GetBottom(); int i_x = MathUtils.Max(a_x, b_x); int i_r = MathUtils.Min(a_r, b_r); int i_y = MathUtils.Max(a_y, b_y); int i_t = MathUtils.Min(a_t, b_t); return(i_x < i_r && i_y < i_t ? new RectI(i_x, i_y, i_r - i_x, i_t - i_y) : null); }
public static RectI GetIntersection(RectI a, RectI b, RectI result) { int a_x = a.x; int a_r = a.GetRight(); int a_y = a.y; int a_t = a.GetBottom(); int b_x = b.x; int b_r = b.GetRight(); int b_y = b.y; int b_t = b.GetBottom(); int i_x = MathUtils.Max(a_x, b_x); int i_r = MathUtils.Min(a_r, b_r); int i_y = MathUtils.Max(a_y, b_y); int i_t = MathUtils.Min(a_t, b_t); if (i_x < i_r && i_y < i_t) { result.Set(i_x, i_y, i_r - i_x, i_t - i_y); return(result); } return(result); }