summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-12-13 23:35:44 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-12-13 23:36:17 +0100
commitb909d991f1c14acadf0ea35d2a30e37e1f52870b (patch)
tree6b3ad6476f6a58e206355d18f889cdb44201bd81
parent2d39bce3f6244fa270c6c909023475a481436681 (diff)
downloadserenity-b909d991f1c14acadf0ea35d2a30e37e1f52870b.zip
LibDraw: Add a way to check for horizontal/vertical Rect intersections
-rw-r--r--Libraries/LibDraw/Rect.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/Libraries/LibDraw/Rect.h b/Libraries/LibDraw/Rect.h
index e496e4de9b..0875859335 100644
--- a/Libraries/LibDraw/Rect.h
+++ b/Libraries/LibDraw/Rect.h
@@ -200,6 +200,18 @@ public:
move_by(0, delta);
}
+ bool intersects_vertically(const Rect& other) const
+ {
+ return top() <= other.bottom()
+ && other.top() <= bottom();
+ }
+
+ bool intersects_horizontally(const Rect& other) const
+ {
+ return left() <= other.right()
+ && other.left() <= right();
+ }
+
bool intersects(const Rect& other) const
{
return left() <= other.right()