Skip to content

Commit

Permalink
Match to-gamut behavior described by w3c/csswg-drafts#10226 (comment)
Browse files Browse the repository at this point in the history
  • Loading branch information
nex3 committed Apr 19, 2024
1 parent 99adfe6 commit e80d382
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions lib/src/value/color/gamut_map_method/local_minde.dart
Expand Up @@ -55,12 +55,15 @@ final class LocalMindeGamutMap extends GamutMapMethod {
// just store it in that space to begin with.
var current =
ColorSpace.oklch.convert(color.space, lightness, chroma, hue, alpha);
if (current.isInGamut) {
// This behavior is unclear in the spec, and specifically returning the
// _last_ clipped value seems strange. But it's currently my best guess
// as to the intended behavior. See
// https://github.com/w3c/csswg-drafts/issues/10226.
if (!minInGamut) break;

// Per [this comment], the intention of the algorithm is to fall through
// this clause if `minInGamut = false` without checking
// `current.isInGamut` at all, even though that's unclear from the
// pseudocode. `minInGamut = false` *should* imply `current.isInGamut =
// false`.
//
// [this comment]: https://github.com/w3c/csswg-drafts/issues/10226#issuecomment-2065534713
if (minInGamut && current.isInGamut) {
min = chroma;
continue;
}
Expand Down

0 comments on commit e80d382

Please sign in to comment.