浏览代码

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

Andreas Kling 5 年之前
父节点
当前提交
b909d991f1
共有 1 个文件被更改,包括 12 次插入0 次删除
  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()