color
Converts an object to a colour.
Syntax
-
color(X)-
Xis any object
-
Description
If X is any object, color(X) tries to convert it to a colour.
-
If
Xis an integer, thencolor(X)is the colour withXas its colour code. This is a 32-bit integer of the form 16#RRGGBB. -
If
Xis a string containing a colour name, thencolor(X)is the colour with this name. Only the named colours returned byNamedColorsare recognised. -
If
Xis a string containing an HTML-like hexadecimal colour code (#RRGGBB), thencolor(X)is the colour with this HTML-like hexadecimal code. -
If
Xis a structure of typeRGB,HSV, orHSL, thencolor(X)is the colour with these coordinates. -
If
Xis a colour, thencolor(X)is the same colour.
Examples
color(16#FF0000)
rgba(1.000, 0.000, 0.000, 1.000) (#FF0000, red)
color("gold")
rgba(1.000, 0.843, 0.000, 1.000) (#FFD700, gold)
color("cornflowerblue")
rgba(0.392, 0.584, 0.929, 1.000) (#6495ED, cornflowerblue)
color("#B8860B")
rgba(0.722, 0.525, 0.043, 1.000) (#B8860B, darkgoldenrod)
GetHSV(color("coral"))
hue: 16.1142857143 saturation: 0.686274509804 value: 1
color(ans)
rgba(1.000, 0.498, 0.314, 1.000) (#FF7F50, coral)