Color builds a color from one input form and converts it to any other. Construct it as a
call or with new; both work. You cannot mix input forms in a single call.
Input forms
AColor takes exactly one of the following keys. The shape of the accepted argument is the
ColorInput type.
A hex string such as
"#2563eb".Red, green, and blue channels from 0 to 255.
Red, green, and blue channels from 0 to 255, plus an alpha from 0 to 1.
Hue, saturation, and lightness.
Hue, saturation, and lightness, plus an alpha from 0 to 1.
Pass a single input form per
Color. Mixing forms, for example { hex, rgb }, is not supported.Conversions and operations
AColor converts to any output form and supports common color operations. The operations
that return a color produce a new Color and leave the original unchanged.
Returns the color as a hex string.
Returns the color as a hex string including the alpha channel.
Returns an
"rgb(...)" string.Returns an
"rgba(...)" string.Returns an
"hsl(...)" string.Returns an
"hsla(...)" string.Returns a new
Color with the given alpha, from 0 to 1.Returns a new
Color lightened by amount.Returns a new
Color darkened by amount.Returns a new
Color blended with other by ratio.Returns the relative luminance of the color.
Returns whether the color reads as dark.
Using a Color anywhere a color is accepted
AColor is accepted anywhere a color is, so ColorLike = string | Color. Any color,
background_color, or shape color field takes a hex string or a Color.
ColorLike, ColorInput, and ColorValue.