Skip to content

Commit

Permalink
model: Add a clamping step in iconOnBarBackground that might be unnec…
Browse files Browse the repository at this point in the history
…essary

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.
  • Loading branch information
chrisbobbe committed May 3, 2024
1 parent c3a3544 commit 1b97faf
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/api/model/model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ ColorSwatch<StreamColor> 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:
Expand Down

0 comments on commit 1b97faf

Please sign in to comment.