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: Computecomplementary,analogous,triadic,splitComplementary, andtetradicpalettes 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-verifiedonTextArgbandonSubtitleArgbforeground colors so detail screens adapt to album art or photography with zero contrast bugs.
How is this guide?
Schemas & Reactive Forms (crow-schema)
Zod-style Kotlin validation DSL with typed ParseResults, cross-field rules, signal-backed FormState, and JSON Schema export.
Dependency Injection (crow-inject)
Compile-time K2 scoped lifetime graphs, injected @Ui screens, Async dependencies under Loading, keyed session scopes, and two-line test overrides.