From 1b97fafad16a157298187f4b0bcb4a25bd3fdb46 Mon Sep 17 00:00:00 2001 From: Chris Bobbe Date: Fri, 3 May 2024 15:21:15 -0700 Subject: [PATCH] model: Add a clamping step in iconOnBarBackground that might be unnecessary We'll get an error if `clamped20to75AsHsl.lightness - 0.12` ends up being below 0.0 or above 1.0... ...which probably can't happen? The value `clamped20to75AsHsl.lightness` is the "L" of an HSL representation of a certain color. That certain color is *supposed* to be the result of clamping an *LCH* "L" value between 20 and 75...but it actually comes from clamping a LAB color's "L" value between those numbers...but we have a comment saying the "L" axis might be the same between LCH and LAB... ...but I think HSL "L" probably doesn't match either LCH "L" or LAB "L"...which still might not matter in this case? Anyway, with some uncertainty, it seems like it might be wise to do this clamping to avoid an error. --- lib/api/model/model.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api/model/model.dart b/lib/api/model/model.dart index 5fef1fefea..1b4aef45ce 100644 --- a/lib/api/model/model.dart +++ b/lib/api/model/model.dart @@ -494,7 +494,7 @@ ColorSwatch streamColorSwatch(int base) { // TODO fix bug where our results differ from the replit's (see unit tests) StreamColor.iconOnBarBackground: clamped20to75AsHsl - .withLightness(clamped20to75AsHsl.lightness - 0.12) + .withLightness((clamped20to75AsHsl.lightness - 0.12).clamp(0.0, 1.0)) .toColor(), // Follows `.recepient` in Vlad's replit: