From f12ecf7f9de6eb140e662f16483893689aa776b0 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Fri, 23 Nov 2012 20:48:35 +0100 Subject: utils/rectangle: add is_in(Point) Add possibility to check whether a Point is inside the rectangle. --- src/utils/rectangle.hpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src') diff --git a/src/utils/rectangle.hpp b/src/utils/rectangle.hpp index 5ea2787f..1d8abda2 100644 --- a/src/utils/rectangle.hpp +++ b/src/utils/rectangle.hpp @@ -163,6 +163,21 @@ namespace usdx this->point2 = Point(left + width, top + height); return *this; } + + bool is_in(const Point& p) const + { + if (p.get_x() < get_left()) + return false; + if (p.get_x() > get_right()) + return false; + + if (p.get_y() < get_top()) + return false; + if (p.get_y() > get_bottom()) + return false; + + return true; + } }; }; -- cgit v1.2.3