flatcolors

3.0.0 • Public • Published

flat-colors

flat-colors Donate now

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. 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 contribute.

License

KINDLY © Ionică Bizău–The LICENSE file contains a copy of the license.

Readme

Keywords

Package Sidebar

Install

npm i flatcolors

Weekly Downloads

125

Version

3.0.0

License

KINDLY

Last publish

Collaborators

  • ionicabizau