@pbroom/color-kit/interopBuffers

unpackColors

Read colors back out of a flat array written by packColors (or any buffer with the same layout).

functionimport { unpackColors } from '@pbroom/color-kit/interop';pack.ts:197
function unpackColors(
  array: ArrayLike<number>,
  space: ArraySpace,
  options?: UnpackColorsOptions,
): Color[];

Parameters

arrayArrayLike<number>
Source array.
spaceArraySpace
Channel layout of array.

Returns

Color[]New Color objects (OKLCH).

Example

TypeScript
const packed = packColors(colors, 'oklab', undefined, { stride: 4 });
const restored = unpackColors(packed, 'oklab', { stride: 4 });

Also exported from