flatcolors

Find the nearest flat color for a RGB/Hex input.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
flatcolors
1723.0.08 years ago9 years agoMinified + gzip package size for flatcolors in KB

Readme


flat-colorsFind 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. If undefined, 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 contributecontributing.

License

KINDLYlicense © Ionică Bizăuwebsite–The LICENSE file contains a copy of the license.