diff options
author | Max Horn | 2004-01-08 03:24:01 +0000 |
---|---|---|
committer | Max Horn | 2004-01-08 03:24:01 +0000 |
commit | ab2192761d77b1acfc7da2038d65c151ab048a70 (patch) | |
tree | e506250a37213204b97280f7f22d17b246341d83 | |
parent | d852e2855a837c0c686ad9cbe0810577e0c2ff6a (diff) | |
download | scummvm-rg350-ab2192761d77b1acfc7da2038d65c151ab048a70.tar.gz scummvm-rg350-ab2192761d77b1acfc7da2038d65c151ab048a70.tar.bz2 scummvm-rg350-ab2192761d77b1acfc7da2038d65c151ab048a70.zip |
useful convenience method
svn-id: r12233
-rw-r--r-- | common/rect.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/common/rect.h b/common/rect.h index 49709b0b2f..83e29fe232 100644 --- a/common/rect.h +++ b/common/rect.h @@ -100,12 +100,27 @@ struct Rect { bottom = MAX(bottom, r.bottom); } + /*! @brief extend this rectangle in all four directions by the given number of pixels + + @param offset the size to grow by + */ void grow(int16 offset) { top -= offset; left -= offset; bottom += offset; right += offset; } + + void clip(const Rect & r) { + if (top < r.top) top = r.top; + if (left < r.left) left = r.left; + if (bottom > r.bottom) bottom = r.bottom; + if (right > r.right) right = r.right; + } + + void clip(int maxw, int maxh) { + clip(Rect(0, 0, maxw, maxh)); + } }; } // End of namespace Common |