summaryrefslogtreecommitdiff
path: root/Libraries
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-09-01 17:28:49 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-09-01 17:28:49 +0200
commit72a29d72d3c9461fd093ef76ca27bb0f23d3ec9b (patch)
tree8d499c4ddb161a6df02a90b4b835d6753db99a47 /Libraries
parentc6862647034b9480c2e14ed072b93d394ea89ab8 (diff)
downloadserenity-72a29d72d3c9461fd093ef76ca27bb0f23d3ec9b.zip
Rect: Add contains_vertically(y) and contains_horizontally(x)
Diffstat (limited to 'Libraries')
-rw-r--r--Libraries/LibDraw/Rect.h10
1 files changed, 10 insertions, 0 deletions
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();