From b909d991f1c14acadf0ea35d2a30e37e1f52870b Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 13 Dec 2019 23:35:44 +0100 Subject: [PATCH] LibDraw: Add a way to check for horizontal/vertical Rect intersections --- Libraries/LibDraw/Rect.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Libraries/LibDraw/Rect.h b/Libraries/LibDraw/Rect.h index e496e4de9b6..08758593353 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()