3 * - By John Hodge (thePowersGang)
10 #include <acess/sys.h>
14 CRect::CRect(int x, int y, unsigned int w, unsigned int h):
21 void CRect::Move(int NewX, int NewY)
23 // TODO: Add a parent rectangle, and prevent this from fully leaving its bounds
30 void CRect::Resize(int NewW, int NewH)
38 bool CRect::HasIntersection(const CRect& other) const
40 // If other's origin is past our far corner
41 if( m_x2 < other.m_x )
43 if( m_y2 < other.m_y )
46 // If other's far corner is before our origin
47 if( m_x > other.m_x2 )
49 if( m_y > other.m_y2 )
54 CRect CRect::Intersection(const CRect& other) const
56 int x1 = ::std::max(m_x, other.m_x);
57 int y1 = ::std::max(m_y, other.m_y);
58 int x2 = ::std::min(m_x2, other.m_x2);
59 int y2 = ::std::min(m_y2, other.m_y2);
61 if( x2 <= x1 || y2 <= y1 )
64 return CRect(x1, y1, x2-x1, y2-y1);
67 CRect CRect::RelativeIntersection(const CRect& area)
69 CRect ret = Intersection(area);