/** * Color Utilities — pure functions for color manipulation and accessibility. * * Supports hex (#RGB, #RRGGBB, #RRGGBBAA), rgb(), and hsl() formats. * WCAG contrast ratio calculations for accessibility compliance. * * @example * const rgb = hexToRgb('#3b82f6'); // { r: 59, g: 130, b: 246 } * const hex = rgbToHex(59, 130, 246); // '#3b82f6' * const hsl = hexToHsl('#3b82f6'); // { h: 217, s: 91, l: 60 } * const light = lighten('#3b82f6', 20); // '#7cabf9' * const ratio = getContrastRatio('#ffffff', '#3b82f6'); // 3.07 */ export interface RGB { r: number; g: number; b: number; a?: number; } export interface HSL { h: number; s: number; l: number; a?: number; } export interface HSV { h: number; s: number; v: number; } export type WCAGLevel = 'AA' | 'AAA'; /** Parse a hex string (#RGB, #RRGGBB, #RRGGBBAA) to RGB. Returns null for invalid input. */ export declare function hexToRgb(hex: string): RGB | null; /** Convert RGB components to a lowercase hex string (e.g. '#3b82f6'). */ export declare function rgbToHex(r: number, g: number, b: number, a?: number): string; /** Parse a hex string to HSL. Returns null for invalid input. */ export declare function hexToHsl(hex: string): HSL | null; /** Convert RGB to HSL. */ export declare function rgbToHsl(r: number, g: number, b: number, a?: number): HSL; /** Convert HSL to a hex string. */ export declare function hslToHex(h: number, s: number, l: number): string; /** Convert HSL to RGB. */ export declare function hslToRgb(h: number, s: number, l: number): RGB; /** Convert RGB to HSV. */ export declare function rgbToHsv(r: number, g: number, b: number): HSV; /** Lighten a hex color by `amount` percent (0-100). */ export declare function lighten(hex: string, amount: number): string; /** Darken a hex color by `amount` percent (0-100). */ export declare function darken(hex: string, amount: number): string; /** Saturate a hex color by `amount` percent. */ export declare function saturate(hex: string, amount: number): string; /** Desaturate a hex color by `amount` percent. */ export declare function desaturate(hex: string, amount: number): string; /** Rotate the hue of a hex color by `degrees`. */ export declare function rotateHue(hex: string, degrees: number): string; /** * Mix two hex colors together. * @param weight 0 = full color1, 100 = full color2. Default 50. */ export declare function mix(hex1: string, hex2: string, weight?: number): string; /** Set the opacity of a hex color (returns 8-char hex). */ export declare function withOpacity(hex: string, alpha: number): string; /** Invert a hex color. */ export declare function invert(hex: string): string; /** Calculate relative luminance of a hex color (WCAG 2.1). */ export declare function getLuminance(hex: string): number; /** * Calculate WCAG 2.1 contrast ratio between two colors. * @returns ratio between 1 and 21. */ export declare function getContrastRatio(fg: string, bg: string): number; /** * Check if a foreground/background pair meets WCAG contrast requirements. * - AA normal text: 4.5:1 * - AA large text (18pt+ or 14pt+ bold): 3:1 * - AAA normal text: 7:1 * - AAA large text: 4.5:1 */ export declare function isAccessible(fg: string, bg: string, level?: WCAGLevel, largeText?: boolean): boolean; /** * Choose the best readable foreground color (black or white) for a given background. */ export declare function getReadableColor(bg: string, dark?: string, light?: string): string; export interface ColorPalette { 50: string; 100: string; 200: string; 300: string; 400: string; 500: string; 600: string; 700: string; 800: string; 900: string; } /** * Generate a 10-shade palette (50–900) from a single base color. * The base color is placed at shade 500. */ export declare function generatePalette(baseHex: string): ColorPalette; /** * Parse any common color string (hex, rgb(), hsl()) to an RGB object. * Returns null if unrecognised. */ export declare function parseColor(color: string): RGB | null; /** Convert any supported color string to hex. */ export declare function toHex(color: string): string | null; /** Format an RGB object as a CSS rgb() / rgba() string. */ export declare function rgbToString(rgb: RGB): string; /** Format an HSL object as a CSS hsl() / hsla() string. */ export declare function hslToString(hsl: HSL): string; /** Check if a string is a valid color (hex, rgb, or hsl). */ export declare function isValidColor(color: string): boolean; //# sourceMappingURL=color-utils.d.ts.map