Docs
/
engines/adapters/domain/color

color

Color capability pack: conversions between hex/rgb/hsl/cmyk, a universal parse() that normalizes hex/rgb()/hsl()/named colors into { hex, rgb, hsl }, WCAG contrast ratio with AA/AAA pass flags...

color (engines/adapters/domain/color)

Self-contained color capability pack. Zero deps, pure JS. Colors are held internally as { r, g, b } bytes; every tool takes one args object and returns plain JSON.

toolwhat it does
hexToRgb / rgbToHexhex ⇄ {r,g,b} (accepts #fff, #ffffff, bare, and #rgba/#rrggbbaa)
rgbToHsl / hslToRgbrgb ⇄ hsl
rgbToCmykrgb → cmyk (print)
parseany color (hex / rgb() / hsl() / CSS name) → { hex, rgb, hsl, cmyk, name }
contrastWCAG ratio between a & b + { ratio, AA, AAA, AALarge, AAALarge } pass flags
luminancerelative luminance (WCAG) of one color
lighten / darkenshift HSL lightness by amount (0-1)
saturate / desaturateshift HSL saturation by amount (0-1)
mixblend a & b by weight (0-1, toward a)
palettecomplementary / analogous / triadic / tetradic / monochromatic → hex array
randomPalettepleasant palette of count colors; optional seed = deterministic
namedColorslist the ~148 CSS named colors (or look one up by name)

Usage

import color from './index.js';
color.adapters.parse({ color: 'rebeccapurple' });
// → { hex: '#663399', rgb: { r:102, g:51, b:153 }, hsl: { h:270, s:50, l:40 }, cmyk: {...}, name: 'rebeccapurple' }

color.adapters.contrast({ a: '#000', b: '#fff' }).ratio;      // 21
color.adapters.palette({ color: '#3498db', scheme: 'triadic' }).colors;
color.adapters.randomPalette({ count: 5, seed: 42 }).colors;  // deterministic

DRY boundary

This pack does color math (space conversions, contrast, palettes). It does not own design tokens or theme UI — that's @leumas/theme. It does not validate arbitrary strings (that's the validation pack's hexColor); parse() throws on unparseable input. The ~148 CSS named colors live in data/named-colors.json.

Source shared/engines/adapters/domain/color/README.md (no-git)markdownjson
Generated from the Leumas repository. Every page cites the file it came from.leumas.techllms.txt