瀏覽代碼

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

Andreas Kling 6 年之前
父節點
當前提交
72a29d72d3
共有 1 個文件被更改,包括 10 次插入0 次删除
  1. 10 0
      Libraries/LibDraw/Rect.h

+ 10 - 0
Libraries/LibDraw/Rect.h

@@ -115,6 +115,16 @@ public:
         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
     {
         return x >= m_location.x() && x <= right() && y >= m_location.y() && y <= bottom();