18 Rect(int l, int b, unsigned w, unsigned h): left(l), bottom(b), width(w), height(h) { }
20 static Rect max() { unsigned s = std::numeric_limits<unsigned>::max(); return Rect(0, 0, s, s); }
22 bool operator==(const Rect &) const;
23 bool operator!=(const Rect &r) const { return !operator==(r); }
25 Rect intersect(const Rect &) const;
28 inline bool Rect::operator==(const Rect &other) const
30 return left==other.left && bottom==other.bottom && width==other.width && height==other.height;
33 inline Rect Rect::intersect(const Rect &other) const
35 auto intersect_axis = [](int &s1, unsigned &z1, int s2, unsigned z2){
39 z1 = (d>z1 ? 0 : std::min(z1-d, z2));
45 z1 = (d>z2 ? 0 : std::min(z2-d, z1));
50 intersect_axis(result.left, result.width, other.left, other.width);
51 intersect_axis(result.bottom, result.height, other.bottom, other.height);