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
</code><dt><code><dfnclass=idl-codedata-dfn-for=RGBColordata-dfn-type=attributedata-export="" id=dom-rgbcolor-stringifiers>stringifiers<aclass=self-linkhref=#dom-rgbcolor-stringifiers></a></dfn><spandata-attribute-info="" for=RGBColor/stringifiers> of type <adata-link-type=idl-namehref=#dictdef-colorstringifierstitle=colorstringifiers>ColorStringifiers</a></span>
2737
2737
</code><dd><code>
2738
-
The <adata-link-for=RGBColordata-link-type=idlhref=#dom-rgbcolor-stringifierstitle=stringifiers>stringifiers</a> static attribute on the <adata-link-type=idlhref=#dom-rgbcolortitle=rgbcolor>RGBColor</a> class
2739
-
initially contains callbacks assigned to the keys "rgb", "hsl", "hex", and "cmyk".
2740
-
2741
-
<p>Each callback,
2742
-
if its first argument is an <adata-link-type=idlhref=#dom-rgbcolortitle=rgbcolor>RGBColor</a> instance,
2743
-
returns a serialization of its first argument
2744
-
in the <aclass=cssdata-link-type=maybehref=#funcdef-rgbatitle=rgba()>rgba()</a> syntax, <aclass=cssdata-link-type=maybehref=#funcdef-hslatitle=hsla()>hsla()</a> syntax, <adata-link-type=dfnhref=#hex-colortitle="hex color">hex color</a> syntax, or <aclass=cssdata-link-type=maybehref=#funcdef-device-cmyktitle=device-cmyk()>device-cmyk()</a> syntax,
2745
-
as appropriate.
2746
-
Otherwise, it must throw an XXXError.</p>
2747
-
2748
-
<p>When serializing in the <aclass=cssdata-link-type=maybehref=#funcdef-rgbatitle=rgba()>rgba()</a> syntax,
2749
-
all components must be serialized as percentages.</p>
2750
-
2751
-
<p>When serializing in the <adata-link-type=dfnhref=#hex-colortitle="hex color">hex color</a> syntax,
2752
-
the 8-digit syntax must be used.</p>
2753
-
2754
-
<p>When serializing in the <aclass=cssdata-link-type=maybehref=#funcdef-device-cmyktitle=device-cmyk()>device-cmyk()</a> syntax,
2755
-
the color must be <adata-link-type=dfnhref=#naively-convert-from-rgba-to-cmyktitle="naively converted to cmyk">naively converted to CMYK</a>,
2756
-
and the fallback color must be serialized in the <aclass=cssdata-link-type=maybehref=#funcdef-rgbatitle=rgba()>rgba()</a> syntax.</p>
2738
+
Must be initially set to the following ECMAScript object:
2739
+
2740
+
<pre>{
2741
+
"rgb": function(color) {
2742
+
const r = color.r*100 + "%";
2743
+
const g = color.g*100 + "%";
2744
+
const b = color.b*100 + "%";
2745
+
const a = color.a*100 + "%";
2746
+
return "rgba(" + [r,g,b,a].join(", ") + ")";
2747
+
},
2748
+
"hsl": function(color) {
2749
+
return "" + color.toHSL();
2750
+
},
2751
+
"hex": function(color) {
2752
+
return "" + color.toHex();
2753
+
},
2754
+
"cmyk": function(color) {
2755
+
return "" + color.toCMYK();
2756
+
}
2757
+
}
2758
+
</pre>
2757
2759
2758
2760
</code><dt><code><dfnclass=idl-codedata-dfn-for=RGBColordata-dfn-type=attributedata-export="" id=dom-rgbcolor-defaultstringifier>defaultStringifier<aclass=self-linkhref=#dom-rgbcolor-defaultstringifier></a></dfn><spandata-attribute-info="" for=RGBColor/defaultStringifier> of type <adata-link-type=idl-namehref=#enumdef-colorstringifiertypetitle=colorstringifiertype>ColorStringifierType</a></span>
represent the hue, saturation, lightness, and alpha channels of the HSL color
2841
2843
that the <adata-link-for="" data-link-type=idlhref=#dom-hslcolortitle=hslcolor>HSLColor</a> instance represents.
2842
2844
2843
-
<pclass=note>Note: The <adata-link-for="" data-link-type=idlhref=#dom-hslcolortitle=hslcolor>HSLColor</a> class’s hue attribute has a normal range of 0 to 360,
2845
+
<pclass=note>Note: The <adata-link-for="" data-link-type=idlhref=#dom-hslcolortitle=hslcolor>HSLColor</a> class’s hue attribute has a normal range of 0 to 360 (denoted in degrees),
2844
2846
and its other attributes have a normal range of 0 to 1.</p>
2845
2847
2846
2848
<dt><dfnclass=idl-codedata-dfn-for=HSLColordata-dfn-type=attributedata-export="" id=dom-hslcolor-stringifiers>stringifiers<aclass=self-linkhref=#dom-hslcolor-stringifiers></a></dfn><spandata-attribute-info="" for=HSLColor/stringifiers> of type <adata-link-type=idl-namehref=#dictdef-colorstringifierstitle=colorstringifiers>ColorStringifiers</a></span>
2847
2849
<dd>
2848
-
Initialized to an empty object.
2850
+
Must be initially set to the following ECMAScript object:
2851
+
2852
+
<pre>{
2853
+
"hsl": function(color) {
2854
+
const h = color.h + "deg";
2855
+
const s = color.s*100 + "%";
2856
+
const l = color.l*100 + "%";
2857
+
const a = color.a*100 + "%";
2858
+
return "hsla(" + [h,s,l,a].join(", ") + ")";
2859
+
}
2860
+
}
2861
+
</pre>
2849
2862
2850
2863
<dt><dfnclass=idl-codedata-dfn-for=HSLColordata-dfn-type=attributedata-export="" id=dom-hslcolor-defaultstringifier>defaultStringifier<aclass=self-linkhref=#dom-hslcolor-defaultstringifier></a></dfn><spandata-attribute-info="" for=HSLColor/defaultStringifier> of type <adata-link-type=idl-namehref=#enumdef-colorstringifiertypetitle=colorstringifiertype>ColorStringifierType</a></span>
<dt><dfnclass=idl-codedata-dfn-for=HexColordata-dfn-type=attributedata-export="" id=dom-hexcolor-stringifiers>stringifiers<aclass=self-linkhref=#dom-hexcolor-stringifiers></a></dfn><spandata-attribute-info="" for=HexColor/stringifiers> of type <adata-link-type=idl-namehref=#dictdef-colorstringifierstitle=colorstringifiers>ColorStringifiers</a></span>
2924
2937
<dd>
2925
-
Initialized to an empty object.
2938
+
Must be initially set to the following ECMAScript object:
<dt><dfnclass=idl-codedata-dfn-for=HexColordata-dfn-type=attributedata-export="" id=dom-hexcolor-defaultstringifier>defaultStringifier<aclass=self-linkhref=#dom-hexcolor-defaultstringifier></a></dfn><spandata-attribute-info="" for=HexColor/defaultStringifier> of type <adata-link-type=idl-namehref=#enumdef-colorstringifiertypetitle=colorstringifiertype>ColorStringifierType</a></span>
<dt><dfnclass=idl-codedata-dfn-for=CMYKColordata-dfn-type=attributedata-export="" id=dom-cmykcolor-stringifiers>stringifiers<aclass=self-linkhref=#dom-cmykcolor-stringifiers></a></dfn><spandata-attribute-info="" for=CMYKColor/stringifiers> of type <adata-link-type=idl-namehref=#dictdef-colorstringifierstitle=colorstringifiers>ColorStringifiers</a></span>
3015
3039
<dd>
3016
-
Initialized to an empty object.
3040
+
Must be initially set to the following ECMAScript object:
3041
+
3042
+
<pre>{
3043
+
"cmyk": function(color) {
3044
+
const c = color.c;
3045
+
const m = color.m;
3046
+
const y = color.y;
3047
+
const k = color.k;
3048
+
const a = color.a;
3049
+
if(/* UA knows the output device’s color profile */) {
<dt><dfnclass=idl-codedata-dfn-for=CMYKColordata-dfn-type=attributedata-export="" id=dom-cmykcolor-defaultstringifier>defaultStringifier<aclass=self-linkhref=#dom-cmykcolor-defaultstringifier></a></dfn><spandata-attribute-info="" for=CMYKColor/defaultStringifier> of type <adata-link-type=idl-namehref=#enumdef-colorstringifiertypetitle=colorstringifiertype>ColorStringifierType</a></span>
0 commit comments