nhb-toolbox
Version:
A versatile collection of smart, efficient, and reusable utility functions and classes for everyday development needs.
87 lines • 3.41 kB
TypeScript
import type { Percent } from '../number/types';
import type { AlphaValue, Hex6, Hex8, HSL, HSLA, RGB, RGBA } from './types';
/**
* * Converts opacity percentage (0-100) to a 2-digit hex string.
*
* @param opacity - The opacity value as a percentage (0-100).
* @returns A 2-digit hex string representing the alpha value.
*/
export declare const _convertOpacityToHex: (opacity: Percent) => string;
/**
* * Applies an opacity value to a color string.
* @param color The color string 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: string, opacity: string) => string;
/**
* * 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 color is in `Hex` format.
*
* @param color Color to check.
* @returns Boolean: `true` if it's a `Hex` color, `false` if not.
*/
export declare function _isHex6(color: string): color is Hex6;
/**
* @private Checks if a color is in `Hex8` format.
*
* @param color Color to check.
* @returns Boolean: `true` if it's a `Hex8` color, `false` if not.
*/
export declare function _isHex8(color: string): color is Hex8;
/**
* @private Checks if a color is in `RGB` format and within valid ranges.
*
* @param color Color to check.
* @returns `true` if it's a `RGB` color, `false` if not.
*/
export declare function _isRGB(color: string): color is RGB;
/**
* @private Checks if a color is in `RGBA` format and within valid ranges.
*
* @param color Color to check.
* @returns `true` if it's a `RGBA` color, `false` if not.
*/
export declare function _isRGBA(color: string): color is RGBA;
/**
* @private Checks if a color is in `HSL` format and within valid ranges.
*
* @param color Color to check.
* @returns `true` if it's a `HSL` color, `false` if not.
*/
export declare function _isHSL(color: string): color is HSL;
/**
* @private Checks if a color is in `HSLA` format and within valid ranges.
*
* @param color Color to check.
* @returns `true` if it's a `HSLA` color, `false` if not.
*/
export declare function _isHSLA(color: string): color is HSLA;
/**
* @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;
//# sourceMappingURL=helpers.d.ts.map