29 |
#ifndef PG_RECT_H |
#ifndef PG_RECT_H |
30 |
#define PG_RECT_H |
#define PG_RECT_H |
31 |
|
|
32 |
#ifdef SWIG |
#include "SDL.h" |
33 |
%include "swigcommon.h" |
#include "pgpoint.h" |
|
%module pgrect |
|
|
%include "pgrect.h" |
|
|
#endif |
|
|
|
|
|
#include "paragui.h" |
|
34 |
|
|
35 |
/** |
/** |
36 |
@author Alexander Pipelka |
@author Alexander Pipelka |
120 |
return ( (x <= p.x) && (p.x <= x + w) && (y <= p.y) && (p.y <= y + h) ); |
return ( (x <= p.x) && (p.x <= x + w) && (y <= p.y) && (p.y <= y + h) ); |
121 |
} |
} |
122 |
|
|
|
#ifndef SWIG |
|
123 |
/** |
/** |
124 |
Intersect two rectangles |
Intersect two rectangles |
125 |
@param p reference rectangle |
@param p reference rectangle |
127 |
@return resulting intersection rectangle |
@return resulting intersection rectangle |
128 |
*/ |
*/ |
129 |
static PG_Rect IntersectRect(const PG_Rect& p, const PG_Rect& c); |
static PG_Rect IntersectRect(const PG_Rect& p, const PG_Rect& c); |
|
#endif |
|
130 |
|
|
131 |
/** |
/** |
132 |
Intersect two rectangles |
Intersect two rectangles |
168 |
\param p, c rectangles to check for overlap |
\param p, c rectangles to check for overlap |
169 |
\return true if the rectangles overlap, false otherwise |
\return true if the rectangles overlap, false otherwise |
170 |
*/ |
*/ |
|
#ifndef SWIG |
|
171 |
inline bool OverlapRect(const PG_Rect& p, const PG_Rect& c) { |
inline bool OverlapRect(const PG_Rect& p, const PG_Rect& c) { |
172 |
return !( (p.x + p.w < c.x) || (p.x > c.x + c.w) || (p.y + p.h < c.y) || (p.y > c.y + c.h) || (p.IntersectRect(c).IsNull()) ); |
return !( (p.x + p.w < c.x) || (p.x > c.x + c.w) || (p.y + p.h < c.y) || (p.y > c.y + c.h) || (p.IntersectRect(c).IsNull()) ); |
173 |
} |
} |
|
#endif |
|
174 |
|
|
175 |
//! Check if this rectangle overlap another one |
//! Check if this rectangle overlap another one |
176 |
/*! |
/*! |
190 |
return OverlapRect(*p, *this); |
return OverlapRect(*p, *this); |
191 |
} |
} |
192 |
|
|
|
#ifndef SWIG |
|
193 |
Sint16& my_xpos; |
Sint16& my_xpos; |
194 |
Sint16& my_ypos; |
Sint16& my_ypos; |
195 |
Uint16& my_width; |
Uint16& my_width; |
196 |
Uint16& my_height; |
Uint16& my_height; |
|
#endif |
|
197 |
}; |
}; |
198 |
|
|
199 |
#endif // PG_RECT_H |
#endif // PG_RECT_H |