Skip to content

Commit 5bc5700

Browse files
chrisbobbegnprice
authored andcommitted
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.
1 parent 5635745 commit 5bc5700

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/api/model/model.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ class StreamColorSwatch extends ColorSwatch<StreamColorVariant> {
529529
// TODO fix bug where our results differ from the replit's (see unit tests)
530530
StreamColorVariant.iconOnBarBackground:
531531
clamped20to75AsHsl
532-
.withLightness(clamped20to75AsHsl.lightness - 0.12)
532+
.withLightness(clampDouble(clamped20to75AsHsl.lightness - 0.12, 0.0, 1.0))
533533
.toColor(),
534534

535535
// Follows `.recepient` in Vlad's replit:

0 commit comments

Comments
 (0)