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 bool CRect::HasIntersection(const CRect& other) const
31 // If other's origin is past our far corner
32 if( m_x2 < other.m_x )
34 if( m_y2 < other.m_y )
37 // If other's far corner is before our origin
38 if( m_x > other.m_x2 )
40 if( m_y > other.m_y2 )
45 CRect CRect::Intersection(const CRect& other) const
47 int x1 = ::std::max(m_x, other.m_x);
48 int y1 = ::std::max(m_y, other.m_y);
49 int x2 = ::std::min(m_x2, other.m_x2);
50 int y2 = ::std::min(m_y2, other.m_y2);
52 if( x1 <= x2 || y2 <= y1 )
55 return CRect(x1, y1, x2-x1, y2-y2);
58 CRect CRect::RelativeIntersection(const CRect& area)
60 CRect ret = Intersection(area);