color-2-name
Version:
Finds the closest color name to a given hex, rgb and hsl color (with and without alpha). It uses the Euclidean distance formula to calculate the distance between colors in the RGB color space
25 lines (22 loc) • 624 B
text/typescript
import { RGBCOLORDEF } from './types.cjs';
/**
* This function was the opposite of the name of the repo and returns the color of the colorSet given the name
*
* @param {string} searchedColor -the name of the color to search for
* @param {Array} set - the colorSet to search in
*/
declare function getColor(searchedColor: string, set?: RGBCOLORDEF[] | undefined): {
hex: `#${string}`;
rgb: string;
hsl: string;
};
/**
* Get all the colors from the colorSet
*/
declare function getColors(): {
name: string;
hex: `#${string}`;
rgb: string;
hsl: string;
}[];
export { getColor, getColors };