renamed&fixed contains(Rect) -> intersects(Rect); added extend() method

svn-id: r8246
This commit is contained in:
Max Horn 2003-06-01 17:06:07 +00:00
parent ff5705b32c
commit f91de2ae1e

View File

@ -23,6 +23,7 @@
#define COMMON_RECT_H
#include "scummsys.h"
#include "util.h"
namespace ScummVM {
@ -78,14 +79,25 @@ struct Rect {
return (left <= p.x) && (p.x < right) && (top <= p.y) && (p.y < bottom);
}
/*! @brief check if given rectangle is inside this rectangle
/*! @brief check if given rectangle intersects with this rectangle
@param r the rectangle to check
@return true if the given rectangle is inside the rectangle, false otherwise
*/
bool contains(const Rect & r) const {
return (left <= r.right) && (r.left < right) && (top <= r.bottom) && (r.top < bottom);
bool intersects(const Rect & r) const {
return (left < r.right) && (r.left < right) && (top < r.bottom) && (r.top < bottom);
}
/*! @brief extend this rectangle so that it contains r
@param r the rectangle to extend by
*/
void extend(const Rect & r) {
left = MIN(left, r.left);
right = MAX(right, r.right);
top = MIN(top, r.top);
bottom = MAX(bottom, r.bottom);
}
void grow(int16 offset) {