Docs Navigation (Stage 03)›

OKLab Edge Contrast

Maximizes perceptual ΔE_OK across mesh edges and preserves chroma on barycentric bridge items.

Key Takeaways

  • Built-in default perceptual color strategy for dark canvases and headless snapshots.
  • Maximizes perceptual ΔE_OK separation across every 1-hop mesh edge so neighboring clusters never share confusable hues.

Visual Mechanism

1-Hop Mesh Graph Coloring (max min ΔE_OK)Naive sRGB midpoint (desaturated)Chroma-Preserving OKLab Mix
Optimizes vertex hue assignment via 1-hop edge swaps to maximize minimum ΔE_OK, then interpolates multi-cluster items in OKLab with chroma restoration.

Factory Signature

Re-exported from @simplex-viz/core, @simplex-viz/svg, and @simplex-viz/reactStage 03 Overview →
createOklabContrastColorStrategy<TItem, TTagMeta>(options?: OklabColorOptions): SimplexColorStrategy<TItem, TTagMeta>

Options & Defaults

lightnessDefault: 0.72

number

Target perceptual OKLab lightness L ∈ [0, 1] for generated vertex hues.

chromaDefault: 0.145

number

Target perceptual OKLab chroma C before sRGB gamut clamping.

preserveMatchedColorsDefault: true

boolean

Retains Hungarian-matched cluster colors across live updates.

Graph-Coloring Contrast & Chroma-Preserving Mixing

OKLab Edge Contrast generates a uniform ring of perceptual hues in Björn Ottosson’s OKLab space, seeds vertices greedily, and runs pairwise swap refinement to maximize the minimum perceptual distance ΔE_OK across all mesh edges. Multi-cluster bridge items interpolate linearly in (L, a, b) with chroma restoration so 50/50 edge midpoints remain vivid rather than collapsing to muddy sRGB grey.

Usage Example

import {
  SimplexTopicGraph,
  createOklabContrastColorStrategy,
} from '@simplex-viz/react';

<SimplexTopicGraph
  items={items}
  colorStrategy={createOklabContrastColorStrategy({
    lightness: 0.74,
    chroma: 0.15,
  })}
/>;