Checks the distance between 2 hex colors and finds the closest color to a given sample.
Looking for demo? Check the demo page then.
If you want to know more how it's done, I suggest reading this article.
npm install @sunpietro/color-finder
import ColorFinder from `@sunpietro/color-finder`;
const colorsLibrary = [
'#bb3300',
'#aa22ff',
'#b00053'
];
const finder = ColorFinder(colorsLibrary);
There are finder methods available:
Updates a collection of colors used for comparing with sample colors. Takes one param: colors
as string[]
.
Finds the closest color to a sample color, in a colors library. Takes one param: color
as string
. Returns the closest color as string
.
Compares 2 hex colors in terms of color similarity. Takes two params: color1
as string
and color2
as string
. Returns an Euclidean distance value as number
. The lowest value, the more similar colors are.