Skip to content

Commit bc7fd94

Browse files
committed
[css-color-4] More even-handed description of clipping, showing some cases which give acceptable results w3c#10579
1 parent 44ce4c2 commit bc7fd94

1 file changed

Lines changed: 63 additions & 0 deletions

File tree

css-color-4/Overview.bs

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5400,6 +5400,11 @@ Clipping</h4>
54005400
The simplest and least acceptable method
54015401
is simply to clip the component values
54025402
to the displayable range.
5403+
5404+
Since the motivation for this method is speed,
5405+
clipping is commonly done on gamma-encoded values
5406+
rather than converting them to linear-light.
5407+
54035408
This changes the proportions of
54045409
the three primary colors (for an RGB display),
54055410
resulting in a hue shift.
@@ -5423,6 +5428,64 @@ Clipping</h4>
54235428
a substantial change of 69°.
54245429
</div>
54255430

5431+
When colors are not too far out of gamut,
5432+
clipping can give acceptable results.
5433+
This is particularly true for darker (or negative)
5434+
component values.
5435+
5436+
<div class="example" id="ex-gamut-clip-good">
5437+
For example,
5438+
consider the color <code>color(rec2020 0.54 0.9 0)</code>
5439+
which is <code>oklch(80.72% 0.3296 141.6)</code>.
5440+
5441+
Converting to p3 colorspace, the negative blue value shows
5442+
the color is out of gamut:
5443+
<code>color(display-p3 0.3265 0.9165 -0.1262)</code>
5444+
which in linear-light is
5445+
<code>color(display-p3-linear 0.0871 0.8205 -0.0146)</code>.
5446+
5447+
Clipping the gamma-encoded p3 color to the p3 gamut gives
5448+
<code>color(display-p3 0.3265 0.9165 0)</code>
5449+
which in linear-light is
5450+
<code>color(display-p3-linear 0.0871 0.8205 0)</code>
5451+
which, for comparison, is
5452+
<code>oklch(80.79% 0.3221 142.3)</code>.
5453+
5454+
This is a good result;
5455+
the hue angle and lightness have barely changed
5456+
but the chroma is somewhat reduced, as expected.
5457+
5458+
In terms of percentages of linear-light red green and blue,
5459+
the red and green are identical
5460+
while the blue is -1.46% higher.
5461+
</div>
5462+
5463+
<div class="example" id="ex-gamut-clip-acceptable">
5464+
For example,
5465+
consider the color <code>color(prophoto-rgb 0.2 1.0 0.1)</code>
5466+
which is <code>oklch(85.07% 0.4873 151.4)</code>
5467+
5468+
Converting to p3 colorspace, the color is significantly
5469+
out of gamut:
5470+
<code>color(display-p3 -0.5782 1.067 -0.2363)</code>
5471+
which in linear-light is
5472+
<code>color(display-p3-linear -0.2937 1.158 -0.0456)</code>.
5473+
5474+
Clipping the gamma-encoded p3 color to the p3 gamut gives
5475+
<code>color(display-p3 0 1 0)</code>
5476+
which in linear-light is, again,
5477+
<code>color(display-p3-linear 0 1 0)</code>
5478+
(component values of exactly 0 or 1 are unaffected by gamma encoding)
5479+
which, for comparison, is
5480+
<code>oklch(84.88% 0.3685 145.6)</code>.
5481+
5482+
A less good but still visually acceptable result.
5483+
Here the hue is more affected, a 5.8° change.
5484+
5485+
In terms of percentages of linear-light red green and blue,
5486+
red is 57% higher, green is 6.7% lower and blue is 23% higher.
5487+
</div>
5488+
54265489
<h4 id="GM-closest">
54275490
Closest Color (MINDE)</h4>
54285491

0 commit comments

Comments
 (0)