Skip to Content
CrowCrow

Perceptual Color & Palettes (crow-color)

OKLab and OKLCH color spaces, WCAG 2.1 and APCA contrast solvers, color harmonies, tonal ramps, and artwork palette extraction.

crow-color is a platform-free perceptual color library engineered for accessible UI systems, smooth animations, and dynamic theming across any design system (not just Material).

Perceptual Spaces (OKLab & OKLCH)

Standard sRGB interpolation muddies gradients through gray. crow-color converts ARGB colors into perceptual OklabColor and OklchColor for uniform lightness and vivid chroma:

val violet = 0xFF7C5CFF.toInt()
val cyan = 0xFF22D3EE.toInt()

val oklch = violet.toOklch()
val midpoint = blendOklab(violet, cyan, 0.5f)
val vibrantMidpoint = blendOklch(violet, cyan, 0.5f)

Contrast Solvers (WCAG & APCA)

Guarantee legible text on dynamic, user-chosen, or artwork-extracted surfaces at runtime:

val ratio = ColorContrast.wcagRatio(foreground, background)
val apca = ColorContrast.apcaContrast(foreground, background)

// Automatically pick white or dark ink for maximum legibility
val ink = ColorContrast.bestOnColor(background)

// Nudge foreground lightness in OKLCH until it satisfies WCAG AA (4.5:1)
val safeAccent = ColorContrast.ensureContrast(
    foreground = accent,
    background = surface,
    minRatio = ColorContrast.WCAG_AA,
)

Harmonies, Ramps & Artwork Swatches

  • ColorHarmonies: Compute complementary, analogous, triadic, splitComplementary, and tetradic palettes directly in OKLCH hue space.
  • ColorRamp: Sample smooth, perceptually spaced color stops (ramp.sample(t)).
  • ColorSwatch: Extract dominant and vibrant swatches from cover artwork, pre-paired with contrast-verified onTextArgb and onSubtitleArgb foreground colors so detail screens adapt to album art or photography with zero contrast bugs.

How is this guide?

On this page