# Perceptual Color & Palettes (crow-color) (https://crow.build/docs/stack/color)

`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`) [#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:

```kotlin
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) [#contrast-solvers-wcag--apca]

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

```kotlin
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 [#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.