Prechádzať zdrojové kódy

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

Andreas Kling 5 rokov pred
rodič
commit
b909d991f1
1 zmenil súbory, kde vykonal 12 pridanie a 0 odobranie
  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()