UNPKG

hex-to-css-filter

Version:

hex-to-css-filter - Easy way to generate colors from HEX to CSS Filters

52 lines (50 loc) 1.73 kB
interface HexToCssResult { /** How many times the script was called to solve the color */ called: number; /** CSS filter generated based on the Hex color */ filter: string; /** The received color */ hex: string; /** Percentage loss value for the generated filter */ loss: number; /** Hex color in RGB */ rgb: [number, number, number]; /** Percentage loss per each color type organized in RGB: red, green, blue, h, s, l. */ values: [number, number, number, number, number, number]; /** Boolean that returns true if value was previously computed. * So that means the returned value is coming from the in-memory cached */ cache: boolean; } interface HexToCssConfiguration { /** * Acceptable color percentage to be lost. * @default 5 */ acceptanceLossPercentage?: number; /** * Maximum checks that needs to be done to return the best value. * @default 10 */ maxChecks?: number; /** * Boolean value that forces recalculation for CSS filter generation. * @default false */ forceFilterRecalculation?: boolean; } /** * A function that transforms a HEX color into CSS filters * * @param colorValue string hexadecimal color * @param opts HexToCssConfiguration function configuration * */ declare const hexToCSSFilter: (colorValue: string, opts?: HexToCssConfiguration) => HexToCssResult; /** * A function that clears cached results * * @param {string} key? HEX string value passed previously `#24639C`. If not passed, it clears all cached results * @returns void */ declare const clearCache: (key?: string) => void; export { HexToCssConfiguration, HexToCssResult, clearCache, hexToCSSFilter };