Skip to main content
Version: 1.0.3

toColor

Using

Convert a color of one type to another.

Demo - use JSON
toColor(
,
)
{"r":0,"g":0,"b":0,"a":1}

Arguments

ArgumentTypeDescriptionPossible ValuesExample
colornumber[] | objectRGB color.[15, 76, 213]
{r: 255, g: 14, b: 148 }
tostringreturn 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}

Resources

📦 Since:1.0.1
📦 Last updated:1.1.0
📦 Available in:1.3.0