flat-colors
Find the nearest flat color for a RGB/Hex input.
Installation
$ npm i flat-colors
Example
// Dependenciesvar FlatColors = // Get the flat redconsole;// => [211, 84, 0] // Same thing, but using a rgb arrayconsole;// => [211, 84, 0] // Still same color but using hex colorconsole;// => [211, 84, 0] // Random flat colorconsole;// => [?, ?, ?]
Documentation
FlatColors(r, g, b)
Finds the nearest flat color for rgb and hex inputs.
Params
- String|Number|Array
r
: The color as string in hex format, the red value or the rgb passed as array. Ifundefined
, a random color will be returned. - Number
g
: The green value. - Number
b
: The blue value.
Return
- Array An array containing the rgb values of the flat color which was found.
toRgb(hex)
Converts a hex format color into rgb.
Params
- String
hex
: The color in the hex format.
Return
- Array The rgb array or null.
How to contribute
Have an idea? Found a bug? See how to contribute.
License
KINDLY © Ionică Bizău–The LICENSE file contains a copy of the license.