@pbroom/color-kit/computePacking
unpackPlaneQueryResults
Decodes a packed plane query payload back into query results.
import { unpackPlaneQueryResults } from '@pbroom/color-kit/compute';unpack.ts:219function 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
- packed
PackedPlaneQueryResult - Payload from
packPlaneQueryResultsor a compute run.
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
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'