03. Perceptual OKLab Color Strategies
Why SimplexViz assigns cluster hues via perceptual OKLab graph-coloring optimization and mixes multi-cluster items without muddy sRGB midpoints.
- Core Strategies
- 2 min read
- Updated 2026-11-15
Key Takeaways
- Adjacent mesh vertices maximize minimum perceptual distance ΔE_OK via greedy seeding plus pairwise swap refinement.
- Barycentric item colors interpolate in Björn Ottosson's OKLab space with chroma preservation so bridge items stay vivid and legible.
- Hungarian cluster matching preserves assigned vertex colors across live item additions, removals, and resizes.
Stage 3 (SimplexColorStrategy) assigns a canonical hex color to each vertex cluster and computes mixedColorHex for every content item from its barycentric simplex weights (w₁, …, w_m).
OKLab Edge Contrast Optimization
Adjacent mesh vertices maximize perceptual distance ΔE_OK
Barycentric Mixing: sRGB vs. OKLab
Preserves lightness L and chroma C across bridge items
Why sRGB Fails on Triangulated Meshes
Linearly averaging sRGB hex values along a mesh edge—for instance between Cyan (#06B6D4) and Amber (#F59E0B)—collapses perceptual lightness and chroma near w = (0.5, 0.5), turning bridge items into dull grey-brown dots that look visually inactive rather than interdisciplinary.
SimplexViz converts cluster colors into OKLab (L, a, b), computes the weighted barycentric sum, gently restores perceptual chroma C = √(a² + b²) toward the weighted mean chroma of the contributing clusters, and clamps cleanly into the sRGB gamut.
Strategy Decision Matrix
createOklabContrastColorStrategy(options?)
Generates high-chroma perceptual hues and optimizes 1-hop mesh edge swaps to maximize minimum ΔE_OK between neighboring cluster vertices.
Open strategy reference →
createThemeAdaptiveOklabColorStrategy(options?)
Shifts target perceptual lightness and chroma automatically when theme toggles (L ≈ 0.56 on light surfaces for WCAG contrast; L ≈ 0.74 on dark surfaces).
Open strategy reference →
createPaletteColorStrategy(hexColors, options?)
Assigns your exact hex colors onto the mesh using edge-contrast optimization (default) or sequential order while interpolating bridge items in OKLab.
Open strategy reference →
Custom Brand Palette Example
import { createPaletteColorStrategy } from '@simplex-viz/core';
const corporatePalette = createPaletteColorStrategy(
['#0891b2', '#d97706', '#c026d3', '#059669', '#2563eb', '#e11d48'],
{
mode: 'edge-contrast',
preserveMatchedColors: true,
},
);