Skip to content

Commit e30aec4

Browse files
committed
[css-color-4] Update pseudocode for GMA per #7135
1 parent d452a10 commit e30aec4

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

css-color-4/Overview.bs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5553,23 +5553,36 @@ Sample Pseudocode for the Binary Search Gamut Mapping Algorithm with Local MINDE
55535553
<li>if inGamut(|origin_OKLCH|) is true, convert |origin_OKLCH| to |destination| and return it as the gamut mapped color</li>
55545554
<li>otherwise, let delta(|one|, |two|) be a function which returns the deltaEOK of color |one| compared to color |two|</li>
55555555
<li>let |JND| be 0.02</li>
5556+
<li>let |epsilon| be 0.0001</li>
5557+
<!-- we already excluded spaces with no gamut limits in the first step, so this is fine -->
55565558
<li>let clip(|color|)| be a function which converts |color| to |destination|,
55575559
converts all negative components to zero,
55585560
converts all components greater that one to one,
55595561
and returns the result
55605562
</li>
55615563
<li>set |min| to zero</li>
55625564
<li>set |max| to the OKLCH chroma of |origin_OKLCH|</li>
5563-
<li>repeat the following steps
5565+
<li> let |min_inGamut| be a boolean that represents when |min| is still in gamut, and set it to true
5566+
<li>while (|max| - |min| is greater than |epsilon|) repeat the following steps
55645567
<ol>
55655568
<li>set |chroma| to (|min| + |max|) /2</li>
55665569
<li>set |current| to |origin_OKLCH| and then set the chroma component to |chroma|</li>
5567-
<li>if inGamut(|current|) is true, set |min| to |chroma| and continue to repeat these steps</li>
5570+
<li>if |min_inGamut| is true and also if inGamut(|current|) is true, set |min| to |chroma| and continue to repeat these steps</li>
55685571
<li>otherwise, if inGamut(|current|) is false carry out these steps:
55695572
<ol>
55705573
<li>set |clipped| to clip(|current|)</li>
55715574
<li>set |E| to delta(|clipped|, |current|)</li>
5572-
<li>if |E| < |JND| return |clipped| as the gamut mapped color</li>
5575+
<li>if |E| < |JND|
5576+
<ol>
5577+
<li>if (|E| - |JND| < |epsilon|) return |clipped| as the gamut mapped color</li>
5578+
<li>otherwise,
5579+
<ol>
5580+
<li>set |min_inGamut| to false</li>
5581+
<li>set |min| to |chroma|</li>
5582+
</ol>
5583+
</li>
5584+
</ol>
5585+
</li>
55735586
<li>otherwise, set |max| to |chroma| and continue to repeat these steps</li>
55745587
</ol>
55755588
</li>

0 commit comments

Comments
 (0)