Skip to content

Commit 3974fd8

Browse files
committed
[css-color-4] correct prophoto transfer function, fix #5229
1 parent 9c24748 commit 3974fd8

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

css-color-4/Overview.bs

+10-1
Original file line numberDiff line numberDiff line change
@@ -2448,11 +2448,20 @@ Predefined colorspaces: ''srgb'', ''display-p3'', ''a98-rgb'', ''prophoto-rgb'',
24482448
<tr><th>Green chromaticity</th><td>0.159597</td><td>0.840403</td></tr>
24492449
<tr><th>Blue chromaticity</th><td>0.036598</td><td>0.000105</td></tr>
24502450
<tr><th>White chromaticity</th><td>0.345704</td><td>0.358540</td></tr>
2451-
<tr><th>Transfer function</th><td colspan="2">1/1.800 </td></tr>
2451+
<tr><th>Transfer function</th><td colspan="2">see below </td></tr>
24522452
<tr><th>White luminance</th><td colspan="2">160.0 to 640.0 cd/m<sup>2</sup></td></tr>
24532453
<tr><th>Black luminance</th><td colspan="2">See text</td></tr>
24542454
</table>
24552455

2456+
<pre class="lang-javascript">
2457+
var Cl;
2458+
if (C <= (16/512))
2459+
Cl = C / 16;
2460+
else
2461+
Cl = Math.pow(C, 1.8);
2462+
</pre>
2463+
C is the red, green or blue component.
2464+
24562465
<dt><dfn>rec2020</dfn>
24572466
<dd>
24582467
The ''rec2020'' [[!Rec.2020]] colorspace accepts three numeric parameters,

css-color-4/conversions.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,9 @@ function lin_ProPhoto(RGB) {
107107
// to linear light (un-companded) form.
108108
// Transfer curve is gamma 1.8 with a small linear portion
109109
// TODO for negative values, extend linear portion on reflection of axis, then add pow below that
110+
const Et2 = 16/512;
110111
return RGB.map(function (val) {
111-
if (val < 0.031248) {
112+
if (val < Et2) {
112113
return val / 16;
113114
}
114115

@@ -121,8 +122,9 @@ function gam_ProPhoto(RGB) {
121122
// to gamma corrected form
122123
// Transfer curve is gamma 1.8 with a small linear portion
123124
// TODO for negative values, extend linear portion on reflection of axis, then add pow below that
125+
const Et = 1/512;
124126
return RGB.map(function (val) {
125-
if (val > 0.001953) {
127+
if (val > Et) {
126128
return Math.pow(val, 1/1.8);
127129
}
128130

0 commit comments

Comments
 (0)