@pbroom/color-kit/computePacking

unpackPlaneQueryResults

Decodes a packed plane query payload back into query results.

functionimport { unpackPlaneQueryResults } from '@pbroom/color-kit/compute';unpack.ts:219
function unpackPlaneQueryResults(
  packed: PackedPlaneQueryResult,
): PlaneQueryResult[];

The whole payload is validated before any geometry is rebuilt, so it is safe to call on data received from a worker. Values come back as the 32-bit floats they were packed as.

Parameters

Returns

PlaneQueryResult[]One result per descriptor, in order.

Throws

  • Invalid packed plane query result: … when the payload has the wrong ABI version, missing or mistyped buffers, unknown kinds, missing or invalid descriptor fields, non-contiguous ranges, or non-finite point data. Nothing is defaulted.

Example

TypeScript
import { parse } from '@pbroom/color-kit';
import { packPlaneQueryResults, unpackPlaneQueryResults } from '@pbroom/color-kit/compute';
import { runPlaneQueries } from '@pbroom/color-kit/plane';

const packed = packPlaneQueryResults(
  runPlaneQueries({ model: 'oklch' }, [
    { kind: 'gradient', from: parse('#000'), to: parse('#fff'), steps: 3 },
  ]),
);
const [gradient] = unpackPlaneQueryResults(packed);

gradient.kind; // → 'gradient'