From 72a29d72d3c9461fd093ef76ca27bb0f23d3ec9b Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 1 Sep 2019 17:28:49 +0200 Subject: Rect: Add contains_vertically(y) and contains_horizontally(x) --- Libraries/LibDraw/Rect.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'Libraries') diff --git a/Libraries/LibDraw/Rect.h b/Libraries/LibDraw/Rect.h index 363f491b11..0b309ea85e 100644 --- a/Libraries/LibDraw/Rect.h +++ b/Libraries/LibDraw/Rect.h @@ -115,6 +115,16 @@ public: return rect; } + bool contains_vertically(int y) const + { + return y >= top() && y <= bottom(); + } + + bool contains_horizontally(int x) const + { + return x >= left() && x <= right(); + } + bool contains(int x, int y) const { return x >= m_location.x() && x <= right() && y >= m_location.y() && y <= bottom(); -- cgit v1.2.3