3 * - By John Hodge (thePowersGang)
13 CRect::CRect(int x, int y, unsigned int w, unsigned int h):
20 void CRect::Move(int NewX, int NewY)
22 // TODO: Add a parent rectangle, and prevent this from fully leaving its bounds
29 void CRect::Resize(int NewW, int NewH)
37 bool CRect::HasIntersection(const CRect& other) const
39 // If other's origin is past our far corner
40 if( m_x2 < other.m_x )
42 if( m_y2 < other.m_y )
45 // If other's far corner is before our origin
46 if( m_x > other.m_x2 )
48 if( m_y > other.m_y2 )
53 CRect CRect::Intersection(const CRect& other) const
55 int x1 = ::std::max(m_x, other.m_x);
56 int y1 = ::std::max(m_y, other.m_y);
57 int x2 = ::std::min(m_x2, other.m_x2);
58 int y2 = ::std::min(m_y2, other.m_y2);
60 if( x1 <= x2 || y2 <= y1 )
63 return CRect(x1, y1, x2-x1, y2-y2);
66 CRect CRect::RelativeIntersection(const CRect& area)
68 CRect ret = Intersection(area);