@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.
87 lines (86 loc) • 3.68 kB
TypeScript
import { Vec3 } from "@fimbul-works/vec";
/**
* Generates the complementary color
* @param color - Input color as Vec3 RGB (each channel from 0 to 1)
* @returns Vec3 containing the complementary color
*/
export declare function complement(color: Vec3): Vec3;
/**
* Generates split-complementary colors
* @param color Base color as Vec3 RGB
* @returns Array of three colors: base and two split complements
*/
export declare function splitComplementary(color: Vec3): Vec3[];
/**
* Generates an analogous color scheme
* @param color - Input color as Vec3 RGB (each channel from 0 to 1)
* @returns Array of three Vec3 colors: the original and two analogous colors
*/
export declare function analogous(color: Vec3): Vec3[];
/**
* Generates a triadic color scheme
* @param color - Input color as Vec3 RGB (each channel from 0 to 1)
* @returns Array of three Vec3 colors: the original and two triadic colors
*/
export declare function triadic(color: Vec3): Vec3[];
/**
* Generates a tetradic (double complementary) color scheme
* @param color Base color as Vec3 RGB
* @returns Array of four colors in tetradic arrangement
*/
export declare function tetradic(color: Vec3): Vec3[];
/**
* Generates a monochromatic color palette
* @param color - Input color as Vec3 RGB (each channel from 0 to 1)
* @returns Array of 5 colors with varying lightness (20%, 40%, original, 60%, 80%)
*/
export declare function monochromatic(color: Vec3): Vec3[];
/**
* Generates a compound color scheme
* Base color, complement, and two analogous colors to the complement
* @param color Base color as Vec3 RGB
* @returns Array of four colors in compound arrangement
*/
export declare function compound(color: Vec3): Vec3[];
/**
* Generates a series of shades (darker variations) of a color
* @param color Base color as Vec3 RGB
* @param steps Number of shades to generate (default: 5)
* @returns Array of colors from darkest to original
*/
export declare function shades(color: Vec3, steps?: number): Vec3[];
/**
* Generates a series of tints (lighter variations) of a color
* @param color Base color as Vec3 RGB
* @param steps Number of tints to generate (default: 5)
* @returns Array of colors from original to lightest
*/
export declare function tints(color: Vec3, steps?: number): Vec3[];
/**
* Generates a series of tones (reduced saturation variations) of a color
* @param color Base color as Vec3 RGB
* @param steps Number of tones to generate (default: 5)
* @returns Array of colors from original to fully desaturated
*/
export declare function tones(color: Vec3, steps?: number): Vec3[];
/**
* Determines the best text color (black or white) for a given background color
* @param backgroundColor - Background color as Vec3 RGB (each channel from 0 to 1)
* @returns Vec3 containing either black or white RGB values
*/
export declare function getTextColor(backgroundColor: Vec3): Vec3;
/**
* Generates an accessible color palette that meets WCAG contrast requirements
* @param baseColor - Starting color as Vec3 RGB (each channel from 0 to 1)
* @param count - Number of colors to generate (default: 5)
* @param minContrast - Minimum contrast ratio required (default: 4.5)
* @returns Array of Vec3 colors that meet contrast requirements
*/
export declare function generateAccessiblePalette(baseColor: Vec3, count?: number, minContrast?: number): Vec3[];
/**
* Harmonizes a set of colors while maintaining WCAG compliance
* @param colors Array of colors to harmonize
* @param wcagLevel WCAG compliance level to maintain
* @returns Harmonized colors
*/
export declare function harmonizePalette(colors: Vec3[], wcagLevel?: "AA" | "AAA"): Vec3[];