Color Generation
Complete reference for color generation, palettes, and harmonies
The generate API provides color generation, harmonies, palettes, and color manipulation. All functions are available via api.generate.
Shades, Tints & Scales
shades(rgb: RGB, count: number): RGB[]
Generate darker shades by mixing with black.
tints(rgb: RGB, count: number): RGB[]
Generate lighter tints by mixing with white.
tones(rgb: RGB, count: number): RGB[]
Generate tones by mixing with gray (desaturation).
scale(rgb: RGB, shadesCount: number, tintsCount: number): RGB[]
Generate complete color scale with shades, base, and tints.
perceptualShades(rgb: RGB, count: number): RGB[]
Generate perceptually uniform shades (using OKLAB).
Better for design systems where visual uniformity matters.
perceptualTints(rgb: RGB, count: number): RGB[]
Generate perceptually uniform tints (using OKLAB).
Color Harmonies
harmony(rgb: RGB, type: HarmonyType): RGB[]
Generic harmony generator.
Available Types:
'complementary''analogous''triadic''tetradic''splitComplementary''square''monochromatic'
complementary(rgb: RGB): RGB[]
Generate complementary colors (opposite on color wheel).
Returns: 2 colors (180° apart)
analogous(rgb: RGB): RGB[]
Generate analogous colors (adjacent on color wheel).
Returns: 3 colors (base ±30°)
triadic(rgb: RGB): RGB[]
Generate triadic colors (evenly spaced on wheel).
Returns: 3 colors (120° apart)
tetradic(rgb: RGB): RGB[]
Generate tetradic/rectangular colors.
Returns: 4 colors forming rectangle on color wheel
splitComplementary(rgb: RGB): RGB[]
Generate split-complementary colors.
Returns: 3 colors (base + two colors adjacent to complement)
square(rgb: RGB): RGB[]
Generate square harmony colors.
Returns: 4 colors (90° apart)
monochromatic(rgb: RGB): RGB[]
Generate monochromatic variations (same hue, different lightness).
Variations
hueVariations(rgb: RGB, count: number, step: number): RGB[]
Generate colors by shifting hue.
saturationVariations(rgb: RGB, count: number): RGB[]
Generate variations with different saturation.
lightnessVariations(rgb: RGB, count: number): RGB[]
Generate variations with different lightness.
subtleVariations(rgb: RGB, count: number): RGB[]
Generate subtle variations (small hue/saturation/lightness changes).
dramaticVariations(rgb: RGB, count: number): RGB[]
Generate dramatic variations (large changes).
Color Adjustments
adjustHue(rgb: RGB, degrees: number): RGB
Shift hue by specified degrees.
adjustSaturation(rgb: RGB, amount: number): RGB
Adjust saturation by amount (-100 to +100).
adjustLightness(rgb: RGB, amount: number): RGB
Adjust lightness by amount (-100 to +100).
saturate(rgb: RGB, amount: number): RGB
Increase saturation (convenience wrapper).
desaturate(rgb: RGB, amount: number): RGB
Decrease saturation (convenience wrapper).
lighten(rgb: RGB, amount: number): RGB
Make color lighter.
darken(rgb: RGB, amount: number): RGB
Make color darker.
invert(rgb: RGB): RGB
Invert color (complement in RGB space).
Formula: 255 - component
grayscale(rgb: RGB): RGB
Convert to grayscale.
Uses perceptual weighting for accurate grayscale.
mix(color1: RGB, color2: RGB, weight: number): RGB
Mix two colors (weight 0-1).
Weight: 0 = all color2, 1 = all color1
Color Blindness Simulation
simulateColorBlindness(rgb: RGB, type: ColorBlindnessType): RGB
Simulate how color appears with color vision deficiency.
Available Types:
'protanopia'- Red-blind (~1% males)'deuteranopia'- Green-blind (~1% males)'tritanopia'- Blue-blind (rare)'protanomaly'- Red-weak (~1% males)'deuteranomaly'- Green-weak (~5% males)'tritanomaly'- Blue-weak (rare)'achromatopsia'- Complete color blindness (very rare)'achromatomaly'- Partial color blindness (very rare)
simulateAllColorBlindness(rgb: RGB): ColorBlindnessSimulation
Simulate all types at once.
Color Matching
findClosestColor(rgb: RGB): ColorMatch
Find closest named color from 300+ database.
Uses Delta-E 2000 for perceptually accurate matching.
findClosestColors(rgb: RGB, count: number): ColorMatch[]
Find N closest named colors.
getColorCategories(): string[]
Get all color categories.
findColorsByCategory(category: string): NamedColor[]
Get all colors in a category.
Palette Generation
semanticPalette(rgb: RGB, mode: ThemeMode): SemanticPalette
Generate complete UI palette from base color.
Modes: 'light' or 'dark'
Perfect for generating complete design system palettes.
primaryScale(rgb: RGB): RGB[]
Generate 10-step primary color scale.
neutralScale(rgb: RGB): RGB[]
Generate 10-step neutral/gray scale based on color.
darkModeColor(rgb: RGB): RGB
Generate dark mode variant of color.
lightModeColor(rgb: RGB): RGB
Generate light mode variant of color.