UNPKG

nhb-toolbox

Version:

A versatile collection of smart, efficient, and reusable utility functions, classes and types for everyday development needs.

37 lines (36 loc) 1.63 kB
import type { AlphaValue, Hex, Hex8, HSL } from './types'; /** * * Applies an opacity value to a color string. * @param color The color string in hex to apply opacity to. * @param opacity The opacity value as a percentage (0-100). * @returns The color string with the opacity value applied. */ export declare const _applyOpacity: (color: Hex, opacity: string) => Hex8; /** * * Helper function to generate a random HSL color. * * @returns A random HSL color string. */ export declare const _generateRandomHSL: () => HSL; /** * * Helper function to check if the new color is visually too similar to the previous one. * * It compares the hue, saturation, and lightness difference between the new color and the last one generated. * * @param recentColors - Array of recently generated colors. * @param newColor - The new color to compare. * @returns `Boolean` : `true` if the new color is similar to the previous one. */ export declare const _isSimilarToLast: (recentColors: string[], newColor: string) => boolean; /** * @private Checks if a number is valid alpha value. * * @param value Alpha value to check. * @returns `true` if it's a valid alpha value, `false` if not. */ export declare function _isValidAlpha(value: number): value is AlphaValue; /** @private Validates RGB component (0–255). */ export declare function _isValidRGBComponent(value: number): boolean; /** @private Validates HSL hue (0–360). */ export declare function _isValidHue(value: number): boolean; /** @private Validates HSL percentage components (0–100). */ export declare function _isValidPercentage(value: number): boolean;