@pbroom/color-kit/interopTypes

PackColorsOptions

Options for packColors.

interfaceimport type { PackColorsOptions } from '@pbroom/color-kit/interop';types.ts:71
interface PackColorsOptions extends ArrayWriteOptions {
  clamp?: boolean;
  alpha?: boolean;
  stride?: number;
  offset?: number;
}

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.

alpha?booleandefault false
Write alpha as a fourth component after each color's three channels.
stride?numberdefault alpha ? 4 : 3

Distance, in array elements, between the first components of consecutive colors. Must be at least 3 (or 4 with alpha).

Use stride: 4 without alpha for padded vec3 arrays (WGSL array<vec3f> has a 16-byte stride); pad lanes are left untouched. Use a larger stride to interleave colors into a vertex buffer.

offset?numberdefault 0
Array index of the first color's first component.

Also exported from