Browse Source

LibDraw: Add a way to check for horizontal/vertical Rect intersections

Andreas Kling 5 năm trước cách đây
mục cha
commit
b909d991f1
1 tập tin đã thay đổi với 12 bổ sung0 xóa
  1. 12 0
      Libraries/LibDraw/Rect.h

+ 12 - 0
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()