From 58669f2b9fa389765c22f1d03bf28b828da1a188 Mon Sep 17 00:00:00 2001
From: John Beard <john.j.beard@gmail.com>
Date: Wed, 9 Oct 2024 08:28:58 +0800
Subject: [PATCH] BOX2: Correct a clamp

std::clamp is (v, min, max), but alg::clamp is (min, v, max).

I can't quite get my head round why this only causes test failures
on some platforms.
---
 libs/kimath/include/math/box2.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libs/kimath/include/math/box2.h b/libs/kimath/include/math/box2.h
index 00f4d5ab7b..5076cae389 100644
--- a/libs/kimath/include/math/box2.h
+++ b/libs/kimath/include/math/box2.h
@@ -855,8 +855,8 @@ public:
         me.Normalize(); // ensure size is >= 0
 
         // Determine closest point to the circle centre within this rect
-        const coord_type nx = std::clamp( me.GetLeft(), aPoint.x, me.GetRight() );
-        const coord_type ny = std::clamp( me.GetTop(), aPoint.y, me.GetBottom() );
+        const coord_type nx = std::clamp( aPoint.x, me.GetLeft(), me.GetRight() );
+        const coord_type ny = std::clamp( aPoint.y, me.GetTop(), me.GetBottom() );
 
         return Vec( nx, ny );
     }