/** * Color Utility Functions for mjo-litui * * This module provides comprehensive color conversion and manipulation utilities * supporting various color formats including HEX, RGB, RGBA, HSL, HSLA, and HWB. */ export type ColorFormat = "hex" | "hexalpha" | "rgb" | "rgba" | "hsl" | "hsla" | "hwb" | "oklch" | "lab" | "lch" | "oklab" | "color"; export interface RGBColor { r: number; g: number; b: number; } export interface RGBAColor { r: number; g: number; b: number; a: number; } export interface HSLColor { h: number; s: number; l: number; } export interface HSLAColor { h: number; s: number; l: number; a: number; } export interface HWBColor { h: number; w: number; b: number; } export interface HWBAColor { h: number; w: number; b: number; a?: number; } export interface OKLCHColor { l: number; c: number; h: number; } export interface LABColor { l: number; a: number; b: number; } export interface LCHColor { l: number; c: number; h: number; } export interface OKLABColor { l: number; a: number; b: number; } /** * Convert any supported color format to HEX * @param color - Color string in any supported format * @param sourceFormat - Source color format (optional, will auto-detect if not provided) * @returns Hex color string */ export declare function toHex(color: string, sourceFormat?: ColorFormat): string; /** * Convert any supported color format to hex with alpha * @param color - Color string in any supported format * @param alpha - Alpha value (0-1), optional. If not provided, will preserve intrinsic alpha from source color, or default to 1 * @param sourceFormat - Source color format (optional, will auto-detect if not provided) * @returns Hex color string with alpha */ export declare function toHexAlpha(color: string, alpha?: number, sourceFormat?: ColorFormat): string; /** * Convert any supported color format to RGB * @param color - Color string in any supported format * @param sourceFormat - Source color format (optional, will auto-detect if not provided) * @returns RGB color string */ export declare function toRgb(color: string, sourceFormat?: ColorFormat): string; /** * Convert any supported color format to RGBA * @param color - Color string in any supported format * @param alpha - Alpha value (0-1), optional. If not provided, will preserve intrinsic alpha from source color, or default to 1 * @param sourceFormat - Source color format (optional, will auto-detect if not provided) * @returns RGBA color string */ export declare function toRgba(color: string, alpha?: number, sourceFormat?: ColorFormat): string; /** * Convert any supported color format to HSL * @param color - Color string in any supported format * @param sourceFormat - Source color format (optional, will auto-detect if not provided) * @returns HSL color string */ export declare function toHsl(color: string, sourceFormat?: ColorFormat): string; /** * Convert any supported color format to HSLA * @param color - Color string in any supported format * @param alpha - Alpha value (0-1), optional. If not provided, will preserve intrinsic alpha from source color, or default to 1 * @param sourceFormat - Source color format (optional, will auto-detect if not provided) * @returns HSLA color string */ export declare function toHsla(color: string, alpha?: number, sourceFormat?: ColorFormat): string; /** * Convert any supported color format to HWB * @param color - Color string in any supported format * @param alpha - Alpha value (0-1), optional. If not provided, will preserve intrinsic alpha from source color, or default to undefined (no alpha) * @param sourceFormat - Source color format (optional, will auto-detect if not provided) * @returns HWB color string */ export declare function toHwb(color: string, alpha?: number, sourceFormat?: ColorFormat): string; /** * Convert any supported color format to OKLCH * @param color - Color string in any supported format * @param sourceFormat - Source color format (optional, will auto-detect if not provided) * @returns OKLCH color string */ export declare function toOklch(color: string, sourceFormat?: ColorFormat): string; /** * Convert any supported color format to LAB * @param color - Color string in any supported format * @param sourceFormat - Source color format (optional, will auto-detect if not provided) * @returns LAB color string */ export declare function toLab(color: string, sourceFormat?: ColorFormat): string; /** * Convert any supported color format to LCH * @param color - Color string in any supported format * @param sourceFormat - Source color format (optional, will auto-detect if not provided) * @returns LCH color string */ export declare function toLch(color: string, sourceFormat?: ColorFormat): string; /** * Convert any supported color format to OKLAB * @param color - Color string in any supported format * @param sourceFormat - Source color format (optional, will auto-detect if not provided) * @returns OKLAB color string */ export declare function toOklab(color: string, sourceFormat?: ColorFormat): string; /** * Convert any supported color format to color() function format * @param color - Color string in any supported format * @param alpha - Alpha value (0-1), optional. If not provided, will preserve intrinsic alpha from source color, or default to 1 * @param sourceFormat - Source color format (optional, will auto-detect if not provided) * @returns color() function string (e.g., "color(srgb 0.5 0.3 0.8 / 0.5)") */ export declare function toColor(color: string, alpha?: number, sourceFormat?: ColorFormat): string; /** * Convert any supported color format to RGB object * @param color - Color string in any supported format * @param sourceFormat - Source color format (optional, will auto-detect if not provided) * @returns RGB color object */ export declare function toRgbObject(color: string, sourceFormat?: ColorFormat): RGBColor; /** * Convert any supported color format to RGBA object * @param color - Color string in any supported format * @param alpha - Alpha value (0-1), optional. If not provided, will preserve intrinsic alpha from source color, or default to 1 * @param sourceFormat - Source color format (optional, will auto-detect if not provided) * @returns RGBA color object */ export declare function toRgbaObject(color: string, alpha?: number, sourceFormat?: ColorFormat): RGBAColor; /** * Convert any supported color format to HSL object * @param color - Color string in any supported format * @param sourceFormat - Source color format (optional, will auto-detect if not provided) * @returns HSL color object */ export declare function toHslObject(color: string, sourceFormat?: ColorFormat): HSLColor; /** * Convert any supported color format to HSLA object * @param color - Color string in any supported format * @param alpha - Alpha value (0-1), optional. If not provided, will preserve intrinsic alpha from source color, or default to 1 * @param sourceFormat - Source color format (optional, will auto-detect if not provided) * @returns HSLA color object */ export declare function toHslaObject(color: string, alpha?: number, sourceFormat?: ColorFormat): HSLAColor; /** * Convert any supported color format to HWB object * @param color - Color string in any supported format * @param sourceFormat - Source color format (optional, will auto-detect if not provided) * @returns HWB color object */ export declare function toHwbObject(color: string, sourceFormat?: ColorFormat): HWBColor; /** * Convert any supported color format to OKLCH object * @param color - Color string in any supported format * @param sourceFormat - Source color format (optional, will auto-detect if not provided) * @returns OKLCH color object */ export declare function toOklchObject(color: string, sourceFormat?: ColorFormat): OKLCHColor; /** * Convert any supported color format to LAB object * @param color - Color string in any supported format * @param sourceFormat - Source color format (optional, will auto-detect if not provided) * @returns LAB color object */ export declare function toLabObject(color: string, sourceFormat?: ColorFormat): LABColor; /** * Convert any supported color format to LCH object * @param color - Color string in any supported format * @param sourceFormat - Source color format (optional, will auto-detect if not provided) * @returns LCH color object */ export declare function toLchObject(color: string, sourceFormat?: ColorFormat): LCHColor; /** * Convert any supported color format to OKLAB object * @param color - Color string in any supported format * @param sourceFormat - Source color format (optional, will auto-detect if not provided) * @returns OKLAB color object */ export declare function toOklabObject(color: string, sourceFormat?: ColorFormat): OKLABColor; /** * Convert color from one format to another * @param color - Source color string * @param targetFormat - Target color format * @param sourceFormat - Source color format (optional, will auto-detect if not provided) * @param alpha - Alpha value for formats that support it (0-1). If not provided, will preserve intrinsic alpha from source color, or default to 1 * @returns Color string in target format */ export declare function convertColor(color: string, targetFormat: ColorFormat, sourceFormat?: ColorFormat, alpha?: number): string; /** * Detect the format of a color string * @param color - Color string to analyze * @returns Detected color format */ export declare function detectColorFormat(color: string): ColorFormat; /** * Check if a color string is valid * @param color - Color string to validate * @param format - Expected color format (optional, will auto-detect if not provided) * @returns True if valid, false otherwise */ export declare function isValidColor(color: string, format?: ColorFormat): boolean; //# sourceMappingURL=colors.d.ts.map