rgbArrayToObj
Using
Convert RGB color [red, green, blue]
as an array to a format object {r: red, g: green, b: blue}
Demo - use JSON
rgbArrayToObj( )
{"r":85,"g":91,"b":119}
Arguments
Argument | Type | Description | Example |
---|---|---|---|
array | number[] function | Rgb color array. | [15, 76, 213] |
Returns
object
— Returns RGB object in format {r: red, g: green, b: blue}
.
Examples
rgbArrayToObj([15, 76, 213]);
// {r: 15, g: 76, b: 213}
rgbArrayToObj(() => [500, () => 213, -1000]);
// {r: 255, g: 213, b: 0}
rgbArrayToObj(['99', '+245', false]);
// {r: 99, g: 245, b: 0}
rgbArrayToObj([99, 245, 0]);
// {r: 99, g: 245, b: 0}