Browse Source

LibGfx: Refactor Point.constrain to use AK

FrHun 4 years ago
parent
commit
c88756078a
1 changed files with 2 additions and 11 deletions
  1. 2 11
      Userland/Libraries/LibGfx/Point.cpp

+ 2 - 11
Userland/Libraries/LibGfx/Point.cpp

@@ -15,17 +15,8 @@ namespace Gfx {
 template<typename T>
 template<typename T>
 void Point<T>::constrain(Rect<T> const& rect)
 void Point<T>::constrain(Rect<T> const& rect)
 {
 {
-    if (x() < rect.left()) {
-        set_x(rect.left());
-    } else if (x() > rect.right()) {
-        set_x(rect.right());
-    }
-
-    if (y() < rect.top()) {
-        set_y(rect.top());
-    } else if (y() > rect.bottom()) {
-        set_y(rect.bottom());
-    }
+    m_x = AK::clamp<T>(x(), rect.left(), rect.right());
+    m_y = AK::clamp<T>(y(), rect.top(), rect.bottom());
 }
 }
 
 
 template<>
 template<>