3 static inline int min(int x, int y)
8 static inline int max(int x, int y)
13 Rect rect_union(const Rect &a, const Rect &b)
16 uni.x = min(a.x, b.x);
17 uni.y = min(a.y, b.y);
18 uni.width = max(a.x + a.width, b.x + b.width) - uni.x;
19 uni.height = max(a.y + a.height, b.y + b.height) - uni.y;
24 Rect rect_intersection(const Rect &a, const Rect &b)
27 intersect.x = max(a.x, b.x);
28 intersect.y = max(a.y, b.y);
29 intersect.width = max(min(a.x + a.width, b.x + b.width) - intersect.x, 0);
30 intersect.height = max(min(a.y + a.height, b.y + b.height) - intersect.y, 0);