summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrHun <28605587+frhun@users.noreply.github.com>2021-07-16 22:47:21 +0200
committerAndreas Kling <kling@serenityos.org>2021-07-30 13:21:27 +0200
commitc88756078ac7a575fed8449a4a36e2b1466fc673 (patch)
tree94a324a9518784c22e10a4436e542e91d43b7fcd
parentcc829ed9d278570d7bc2a7b0f877238b7f416fb5 (diff)
downloadserenity-c88756078ac7a575fed8449a4a36e2b1466fc673.zip
LibGfx: Refactor Point.constrain to use AK
-rw-r--r--Userland/Libraries/LibGfx/Point.cpp13
1 files 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<typename T>
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<>