value colorRecode(color, transform, alpha)
Returns color transcoded according transform, optionally with alpha.
Used for converting between color models, decoding (unpack) a single color value into an array of color components, encoding (pack) an array of color components into a single color value, or any combination thereof.
For consistency, the element in an array of color components are always numbers between 0 and 1, even if they represent degrees such as in Hue, etc..
Transform “stages”, names are case-insensitive:
RGB
—
RGB color model, where components represent Red, Green and Blue.
Used as first “stage” to specify or decode the initial color into components as/of this model, otherwise for converting to this model.
Can be followed by PACK
or HEX
for encoding into a single color value.HSV
—
HSV color model, where components represent Hue, Saturation and (lightness) Value.
Used as first “stage” to specify the initial color components as this model, otherwise for converting to this model.PACK
—
Encode components into a single number.
Currently only allowed after a RGB color model, for encoding it into a
32-bit ARGB color number.HEX
—
Encode components into a single hexadecimal text.
Currently only allowed after a RGB color model, for encoding it into a hexadecimal text
(i.e. hexEncode) of its 32-bit ARGB color number.colorRecode(0xFFFF0000, "rgb")
returns [1,0,0]
colorRecode(0xFFFF0000, "rgb hsv")
returns [0,1,1]
colorRecode([0,1,1], "hsv rgb pack")
returns 0xFFFF0000
colorRecode([1,0,0], "rgb hex", 0.5)
returns "80ff0000"