5 x = y = width = height = 0;
8 Rect::Rect(int x, int y, int w, int h)
16 static inline int min(int x, int y)
21 static inline int max(int x, int y)
26 Rect rect_union(const Rect &a, const Rect &b)
29 uni.x = min(a.x, b.x);
30 uni.y = min(a.y, b.y);
31 uni.width = max(a.x + a.width, b.x + b.width) - uni.x;
32 uni.height = max(a.y + a.height, b.y + b.height) - uni.y;
37 Rect rect_intersection(const Rect &a, const Rect &b)
40 intersect.x = max(a.x, b.x);
41 intersect.y = max(a.y, b.y);
42 intersect.width = max(min(a.x + a.width, b.x + b.width) - intersect.x, 0);
43 intersect.height = max(min(a.y + a.height, b.y + b.height) - intersect.y, 0);