From c88756078ac7a575fed8449a4a36e2b1466fc673 Mon Sep 17 00:00:00 2001 From: FrHun <28605587+frhun@users.noreply.github.com> Date: Fri, 16 Jul 2021 22:47:21 +0200 Subject: [PATCH] LibGfx: Refactor Point.constrain to use AK --- Userland/Libraries/LibGfx/Point.cpp | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/Userland/Libraries/LibGfx/Point.cpp b/Userland/Libraries/LibGfx/Point.cpp index c2cdf7fda8..aaa2563362 100644 --- a/Userland/Libraries/LibGfx/Point.cpp +++ b/Userland/Libraries/LibGfx/Point.cpp @@ -15,17 +15,8 @@ namespace Gfx { template void Point::constrain(Rect 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(x(), rect.left(), rect.right()); + m_y = AK::clamp(y(), rect.top(), rect.bottom()); } template<>