toColor
Using
Convert a color of one type to another.
Demo - use JSON
toColor( , )
{"r":0,"g":0,"b":0,"a":1}
Arguments
Argument | Type | Description | Possible Values | Example |
---|---|---|---|---|
color | number[] | object | RGB color. | [15, 76, 213] {r: 255, g: 14, b: 148 } | |
to | string | return type | "object" | "object" |
Returns
object
— Returns the color in one of the formats.
Examples
toColor([93, 255, 101], 'object');
// {r: 93, g: 255, b: 101}
toColor(['+53', false, true], 'object');
// {r: 53, g: 0, b: 1}
toColor([500, 177, -100], 'object');
// {r: 255, g: 177, b: 0}
toColor(() => [156.9, () => '202', -100], 'object');
// {r: 156, g: 202, b: 0}
toColor({ r: 55, g: 55, b: 199 }, 'object');
// {r: 55, g: 55, b: 199}