3 * - By John Hodge (thePowersGang)
13 CRect::CRect(int x, int y, unsigned int w, unsigned int h):
20 bool CRect::HasIntersection(const CRect& other) const
22 // If other's origin is past our far corner
23 if( m_x2 < other.m_x )
25 if( m_y2 < other.m_y )
28 // If other's far corner is before our origin
29 if( m_x > other.m_x2 )
31 if( m_y > other.m_y2 )
36 CRect CRect::Intersection(const CRect& other) const
38 int x1 = ::std::max(m_x, other.m_x);
39 int y1 = ::std::max(m_y, other.m_y);
40 int x2 = ::std::min(m_x2, other.m_x2);
41 int y2 = ::std::min(m_y2, other.m_y2);
43 if( x1 <= x2 || y2 <= y1 )
46 return CRect(x1, y1, x2-x1, y2-y2);
49 CRect CRect::RelativeIntersection(const CRect& area)
51 CRect ret = Intersection(area);