You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
or an RGB colorspace (such as ProPhoto <!-- ref -->, <!-- would be good to mention AdobeRGB 1998 here too, need to check trademark and copyright issues first --> widely used by photographers), or any other color or monochrome output device which has been characterized.
1715
1718
In addition, for convenience,
1716
1719
CSS provides two predefined RGB color spaces:
1717
-
DCI P3[[!DCI-P3]],
1720
+
image-p3[[!DCI-P3]],
1718
1721
which is a wide gamut space typical of current wide-gamut monitors,
1719
1722
and Rec. 2020 [[[!Rec.2020]],
1720
1723
which is a ultra-wide gamut space capable of representing almost all visible real-world colors.
<tr><th>Transfer function</th><td>1/2.4 (see note)</td></tr>
1876
1894
</table>
1877
1895
1878
-
''rec2020'' transfer function has the same form as the one for sRGB, but with
1879
-
the constants at higher precision to cope with 10 or 12-bit components:
1896
+
Note: Rec2020 references a different transfer curve for cameras. However
1897
+
this curve is never used in production cameras or 2020 displays.<br/>
1898
+
"In typical production practice the encoding function of image sources is adjusted so that the final picture has the desired look, as viewed on a reference monitor having the reference decoding function of Recommendation ITU-R BT.1886, in the reference viewing environment defined in Recommendation ITU-R BT.2035."<br/>
1899
+
The transfer function (1886) for reference Rec.2020 displays is gamma 2.4 [[!Rec.2020]]
1880
1900
1881
-
<pre class="lang-javascript">
1882
-
E < β ? 4.5 * E : α * Math.pow(E, 0.45) - (α - 1);
1883
-
</pre>
1884
-
1885
-
Where α=1.09929682680944 and β=0.018053968510807
1886
-
<!-- full-precision constants here, not the rounded ones for 10 or 12bit components -->.
1887
1901
</dl>
1888
1902
1889
1903
<h4 id="predefined-to-lab">
@@ -1895,9 +1909,9 @@ Converting predefined colorspaces to Lab</h4>
1895
1909
1896
1910
<!-- make these steps links to the appropriate section in a calculations appendix -->
1897
1911
<ol>
1898
-
<li>Convert from gamma-corrected RGB to linear-light RGB (undo gamma correction)
1912
+
<li>Convert from gamma-corrected RGB to linear-light RGB (undo gamma encoding)
1899
1913
<li>Convert from linear RGB to CIE XYZ
1900
-
<li>Convert from a D65 whitepoint (used by both dci-p3 and rec2020) to the D50 whitepoint used in Lab,
1914
+
<li>Convert from a D65 whitepoint (used by both image-p3 and rec2020) to the D50 whitepoint used in Lab,
1901
1915
with the Bradford transform
1902
1916
<li>Convert D50-adapted XYZ to Lab
1903
1917
</ol>
@@ -1907,15 +1921,15 @@ Converting predefined colorspaces to Lab</h4>
1907
1921
<h4 id="lab-to-predefined">
1908
1922
Converting Lab to predefined colorspaces</h4>
1909
1923
1910
-
Conversion from Lab to dci-p3 or rec2020 also requires multiple steps,
1924
+
Conversion from Lab to image-p3 or rec2020 also requires multiple steps,
1911
1925
and again in practice all but the last step are linear calculations and can be combined.
1912
1926
1913
1927
<ol>
1914
1928
<li>Convert Lab to (D50-adapted) XYZ
1915
1929
<li>Convert from a D50 whitepoint (used by Lab) to the D65 whitepoint used in sRGB,
1916
1930
with the Bradford transform
1917
1931
<li>Convert from (D65-adapted) CIE XYZ to linear RGB
1918
-
<li>Convert from linear-light RGB to RGB (do gamma correction)
1932
+
<li>Convert from linear-light RGB to RGB (do gamma encoding)
1919
1933
</ol>
1920
1934
1921
1935
Implementations may choose to implement these steps in some other way
@@ -1936,7 +1950,7 @@ Specifying a color profile: the ''color-profile'' at-rule</h3>
1936
1950
1937
1951
The <<custom-ident>> gives the <a>color profile's</a> name.
1938
1952
All of the predefined colorspace keywords
1939
-
(''srgb'', ''dci-p3'', ''rec2020'')
1953
+
(''srgb'', ''image-p3'', ''rec2020'')
1940
1954
are excluded from this <<custom-ident>>,
1941
1955
as they're predefined by this specification and always available.
1942
1956
@@ -2653,9 +2667,6 @@ Issue: The code below is only for sRGB, and duplicates the
2653
2667
Otherwise, set the channel's value to
2654
2668
<code>((channel + 0.055) / 1.055) ^ 2.4</code>.
2655
2669
2656
-
Note: This reverses the logarithmic power scaling of the sRGB gamut,
2657
-
so the value of the channel is linear with respect to the amount of light produced.
2658
-
2659
2670
<li>
2660
2671
The luminance is:
2661
2672
@@ -2741,11 +2752,7 @@ Transparency: the 'opacity' property</h2>
2741
2752
Simple alpha compositing</h3>
2742
2753
2743
2754
When drawing, implementations must handle alpha
2744
-
according to the rules in <a href="https://www.w3.org/TR/2003/REC-SVG11-20030114/masking.html#SimpleAlphaBlending">Section 14.2 Simple alpha compositing</a> of [[!SVG11]].
2745
-
(If the <a property spec=svg2>color-interpolation</a>
2746
-
or 'color-rendering' properties mentioned in that section
2747
-
are not implemented or do not apply, implementations must act as though they have their initial values.)
2748
-
2755
+
according to the rules in <a href="https://www.w3.org/TR/compositing-1/#simplealphacompositing">Section 5.1 Simple alpha compositing</a> of [[!Compositing]].
2749
2756
2750
2757
<h2 id='color-adjust'>
2751
2758
Preserving Colors in Different-Capability Devices: the 'color-adjust' property</h2>
@@ -2846,6 +2853,8 @@ Default Style Rules</h2>
2846
2853
2847
2854
<h2 id="color-conversion-code">Sample code for color conversions</h2>
2848
2855
2856
+
<em>This section is not normative.</em>
2857
+
2849
2858
<pre class="lang-javascript">
2850
2859
<!-- imported 11 May 2016-->
2851
2860
// sRGB-related functions
@@ -2900,15 +2909,19 @@ function XYZ_to_lin_sRGB(XYZ) {
2900
2909
return math.multiply(M, XYZ).valueOf();
2901
2910
}
2902
2911
2903
-
// DCI P3-related functions
2912
+
// image-p3-related functions
2904
2913
2905
2914
2906
2915
function lin_P3(RGB) {
2907
-
// convert an array of DCI P3 RGB values in the range 0.0 - 1.0
2916
+
// convert an array of image-p3 RGB values in the range 0.0 - 1.0
2908
2917
// to linear light (un-companded) form.
2909
2918
2910
2919
return RGB.map(function (val) {
2911
-
return Math.pow(val, 2.6);
2920
+
if (val < 0.04045) {
2921
+
return val / 12.92;
2922
+
}
2923
+
2924
+
return Math.pow((val + 0.055) / 1.055, 2.4);
2912
2925
});
2913
2926
}
2914
2927
@@ -2917,7 +2930,11 @@ function gam_P3(RGB) {
2917
2930
// to gamma corrected form
2918
2931
2919
2932
return RGB.map(function (val) {
2920
-
return Math.pow(val, 1/2.6);
2933
+
if (val > 0.0031308) {
2934
+
return 1.055 * Math.pow(val, 1/2.4) - 0.055;
2935
+
}
2936
+
2937
+
return 12.92 * val;
2921
2938
});
2922
2939
}
2923
2940
@@ -2951,31 +2968,17 @@ function XYZ_to_lin_P3(XYZ) {
2951
2968
function lin_2020(RGB) {
2952
2969
// convert an array of Rec. 2020 RGB values in the range 0.0 - 1.0
2953
2970
// to linear light (un-companded) form.
2954
-
const α = 1.09929682680944 ;
2955
-
const β = 0.018053968510807;
2956
-
2957
2971
return RGB.map(function (val) {
2958
-
if (val < β * 4.5 ) {
2959
-
return val / 4.5;
2960
-
}
2961
-
2962
-
return Math.pow((val + α -1 ) / α, 2.4);
2972
+
return Math.pow(val, 2.4);
2963
2973
});
2964
2974
}
2965
2975
//check with standard this really is 2.4 and 1/2.4, not 0.45 was wikipedia claims
2966
2976
2967
2977
function gam_2020(RGB) {
2968
2978
// convert an array of linear-light Rec. 2020 RGB in the range 0.0-1.0
0 commit comments