diff options
author | Matthew Hoops | 2011-09-17 12:02:15 -0400 |
---|---|---|
committer | Matthew Hoops | 2011-09-17 12:02:15 -0400 |
commit | 3b9ab4f5cf6a868300e49067ec116ca8b15903c8 (patch) | |
tree | e5e09186f7439d441db0fdf0e0f1e6c14cc27151 /common | |
parent | da74436aa4d1c25f5120caa75197c2c4d9e0d1bc (diff) | |
download | scummvm-rg350-3b9ab4f5cf6a868300e49067ec116ca8b15903c8.tar.gz scummvm-rg350-3b9ab4f5cf6a868300e49067ec116ca8b15903c8.tar.bz2 scummvm-rg350-3b9ab4f5cf6a868300e49067ec116ca8b15903c8.zip |
COMMON: Add function to find the intersecting rectangle
Diffstat (limited to 'common')
-rw-r--r-- | common/rect.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/common/rect.h b/common/rect.h index 768d1ebbb9..1106ec1714 100644 --- a/common/rect.h +++ b/common/rect.h @@ -170,6 +170,20 @@ struct Rect { } /** + * Find the intersecting rectangle between this rectangle and the given rectangle + * + * @param r the intersecting rectangle + * + * @return the intersection of the rectangles or an empty rectangle if not intersecting + */ + Rect findIntersectingRect(const Rect &r) const { + if (!intersects(r)) + return Rect(); + + return Rect(MAX(r.left, left), MAX(r.top, top), MIN(r.right, right), MIN(r.bottom, bottom)); + } + + /** * Extend this rectangle so that it contains r * * @param r the rectangle to extend by |