3.0.0 • Published 9 years ago
flatcolors v3.0.0
flat-colors
Find the nearest flat color for a RGB/Hex input.
Installation
$ npm i flat-colors
Example
// Dependencies
var FlatColors = require("flat-colors")
// Get the flat red
console.log(FlatColors(255, 0, 0));
// => [211, 84, 0]
// Same thing, but using a rgb array
console.log(FlatColors([255, 0, 0]));
// => [211, 84, 0]
// Still same color but using hex color
console.log(FlatColors("#f00"));
// => [211, 84, 0]
// Random flat color
console.log(FlatColors());
// => [?, ?, ?]
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.