Find nearest color in a list of colors
npm install find-color```
$ npm install find-color
#### Compile ES6 to ES5 with Babel
``
$ npm run compile
#### ESLint
``
$ npm run jslint
`javascriptfind-color
import * as findColor from
findColor.fromHex(hexColors).find(color)
`
Find the nearest color, from the list of Google logo colors.
`javascript
import {fromHex} from 'find-color'
var googleColors = [
'#4885ed', // blue
'#f4c20d', // yellow
'#3cba54', // green
'#db3236' // red
]
function findNearest(color) {
var nearest = fromHex(googleColors).find(color)
return (nearest >= 0 ? '#' + nearest.toString(16).toUpperCase() : false)
}
findNearest('#FF7BAC') // => "#DB3236" (red)
`
See examples/google-colors.js directory
Creates a new object, with the find(color) method
colors must be an array of hex encoded string values.hash
For each hex value, the character is removed, and the string trimmed.
Creates a new object, with the find(color) method
colors must be an array of RGB array tuple values (e.g. [[255,0,0], ...]).
Finds the nearest color to color, from a list of pre-compiled colors, asfromHex()
provided by or fromRGB()
Returns a Number`, the decimal representation of the RGB color.