@fimbul-works/vec-color
Version:
A comprehensive, type-safe color manipulation library for TypeScript that provides a wide range of color space conversions, blending operations, and accessibility utilities.
84 lines (83 loc) • 2.1 kB
TypeScript
import { Vec3 } from "@fimbul-works/vec";
import { classifyColor } from "./analyze";
interface ColorDebugInfo {
original: {
vec3: string;
rgb: string;
hex: string;
hsl: string;
};
colorSpaces: {
rgb: {
r: number;
g: number;
b: number;
};
hsl: {
h: number;
s: number;
l: number;
};
lab: {
l: number;
a: number;
b: number;
};
};
characteristics: {
luminance: number;
temperature: number | null;
classification: ReturnType<typeof classifyColor>;
};
accessibility: {
contrastRatios: {
onWhite: number;
onBlack: number;
onGray: number;
};
wcag: {
AANormal: boolean;
AAANormal: boolean;
AALarge: boolean;
AAALarge: boolean;
};
};
colorBlindness: {
protanopia: string;
deuteranopia: string;
tritanopia: string;
achromatopsia: string;
};
}
type ColorChannelValidation = {
valid: boolean;
value: number;
min: number;
max: number;
};
export interface ColorValidationResult {
valid: boolean;
issues: string[];
warnings: string[];
colorSpace: {
inGamut: boolean;
channelValidation: {
[channel: string]: ColorChannelValidation;
};
};
}
/**
* Provides comprehensive debug information about a color
* @param color Color to analyze
* @returns Detailed color information for debugging
*/
export declare function debugColor(color: Vec3): ColorDebugInfo;
/**
* Validates if a color is within valid ranges for its color space
* and provides detailed validation information
* @param color Color to validate
* @param space Color space to validate against
* @returns Validation results with detailed information
*/
export declare function validateColorSpace(color: Vec3, space?: "RGB" | "HSL" | "LAB"): ColorValidationResult;
export {};