@pbroom/color-kit/driverColor state

ColorState

Single-color picker state. requested is the OKLCH color the user or code asked for, kept unclamped even when it lies outside every display gamut so that later edits do not drift. displayed holds that color gamut-mapped into sRGB and Display P3, which is what should be painted; activeGamut picks which of the two the UI shows (see getActiveDisplayedColor).

interfaceimport type { ColorState } from '@pbroom/color-kit/driver';color-state.ts:44
interface ColorState {
  requested: Color;
  displayed: { srgb: Color; p3: Color };
  activeGamut: GamutTarget;
  activeView: ViewModel;
  meta: { source: ColorSource; outOfGamut: { srgb: boolean; p3: boolean }; gamutMapMethod: GamutMapMethod };
}

Create it with createColorState and update it with the setColor* reducers, which return the same object for a no-op.

Properties

requestedColor
Requested OKLCH color, possibly out of gamut.
displayed{ srgb: Color; p3: Color }
requested mapped into each display gamut with meta.gamutMapMethod.
activeGamutGamutTarget
Gamut whose displayed color the UI renders.
activeViewViewModel
Model the picker shows channels or text in.
meta{ source: ColorSource; outOfGamut: { srgb: boolean; p3: boolean }; gamutMapMethod: GamutMapMethod }
Provenance and gamut status of the current state.

Also exported from