format Css String Or Null
Render this color in CSS functional notation if this color space is defined in the CSS standard, or return null if this color is in another color space.
If CSS defines a color function syntax for this color's model (e.g. lab()
), it will be used. Otherwise, the color()
syntax will be used.
Note that for LAB, and LCHab, the CSS standard requires that the D50 white point be used. For XYZ, D50 and D65 are supported. Colors using other white points will be adapted to D50 before being serialized. Most color models default to D65, so you should use XYZ50, XYZ, LAB50, and LCHab50 if you're serializing a color in those models.
Examples
> RGB(255, 0, 128, .5f).formatCssString()
"rgb(255 0 128 / .5)"
> ROMM_RGB(0.1, 0.2, 0.3).formatCssString()
"color(prophoto-rgb 0.1 0.2 0.3)"
> JzAzBz(0.1, 0.2, 0.3).formatCssString()
"color(--jzazbz 0.1 0.2 0.3)"
> JzAzBz(0.1, 0.2, 0.3).formatCssString(customColorSpaces= listOf("jzazbz" to JzAzBz))
"color(jzazbz 0.1 0.2 0.3)"
Parameters
The unit to use to render hue values, if this color has any.
Whether to render the alpha value.
If true, render this color's components as percentages if the color syntax supports it.
If true, render the alpha as a percentage. By default, it's rendered as a float.
If true, use the legacy names hsla
or rgba
instead of hsl
or `rgb for those functions.
If true, use commas instead of spaces as separators for rgb
and hsl
functions. Other colors are unaffected.
A list of custom color spaces to use in the color()
function. Each pair should be the identifier of the color and its ColorSpace.