From fa3a72c8f6321b03e9074c7d2fea6a1ac78cb3b5 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 31 May 2024 20:17:37 -0400 Subject: [PATCH] Fix oklch conversion We want to normalize angles to be in [0, 360). --- gtk/gtkcolorutils.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gtk/gtkcolorutils.c b/gtk/gtkcolorutils.c index 4abcddbdc0..acd7c84dcf 100644 --- a/gtk/gtkcolorutils.c +++ b/gtk/gtkcolorutils.c @@ -307,7 +307,10 @@ gtk_oklab_to_oklch (float L, float a, float b, { *L2 = L; *C = sqrtf (a * a + b * b); - *H = atan2 (b, a); + *H = RAD_TO_DEG (atan2 (b, a)); + *H = fmod (*H, 360); + if (*H < 0) + *H += 360; } void