@pbroom/color-kit/interopTypes

ArrayWriteOptions

Out-of-gamut handling for the array writers.

interfaceimport type { ArrayWriteOptions } from '@pbroom/color-kit/interop';types.ts:54
interface ArrayWriteOptions {
  clamp?: boolean;
}

Gamut mapping is deliberately not an option: compose it instead, e.g. toLinearSrgbArray(toSrgbGamut(color), out) or packColors(colors.map(toSrgbGamut), 'linearSrgb'). This keeps the writers free of the gamut-mapping solver (~1 kB gzip) for callers that do not need it.

Properties

clamp?booleandefault false

Clip RGB channels to [0, 1] after conversion. Only affects the RGB spaces (linearSrgb, srgb, linearP3, display-p3); it is a no-op for oklab / oklch. Alpha is written unchanged. Clipping shifts hue and lightness; map with toSrgbGamut / toP3Gamut first to reduce chroma instead.

The default (false) writes unclamped floats, which is what HDR and linear-light GPU pipelines expect and matches three.js, which never clamps Color channels.

Also exported from