public static Rect RectUnion(Rect a, Rect b) {
float x1 = Math.Min(a.x, b.x);
float x2 = Math.Max(a.x + a.width, b.x + b.width);
float y1 = Math.Min(a.y, b.y);
float y2 = Math.Max(a.y + a.height, b.y + b.height);
return new Rect(x1, y1, x2 - x1, y2 - y1);
}