Jelajahi Sumber

Rect: Add contains_vertically(y) and contains_horizontally(x)

Andreas Kling 6 tahun lalu
induk
melakukan
72a29d72d3
1 mengubah file dengan 10 tambahan dan 0 penghapusan
  1. 10 0
      Libraries/LibDraw/Rect.h

+ 10 - 0
Libraries/LibDraw/Rect.h

@@ -115,6 +115,16 @@ public:
         return rect;
         return rect;
     }
     }
 
 
+    bool contains_vertically(int y) const
+    {
+        return y >= top() && y <= bottom();
+    }
+
+    bool contains_horizontally(int x) const
+    {
+        return x >= left() && x <= right();
+    }
+
     bool contains(int x, int y) const
     bool contains(int x, int y) const
     {
     {
         return x >= m_location.x() && x <= right() && y >= m_location.y() && y <= bottom();
         return x >= m_location.x() && x <= right() && y >= m_location.y() && y <= bottom();