API

@pbroom/color-kit/compute

Schedule plane compute on the JS backend, with telemetry.

26 exports10 values16 types

@pbroom/color-kit/compute runs batches of plane queries and returns the results packed into typed arrays, ready to post from a worker without copying. Use it when queries are heavy or frequent enough to leave the main thread, or when you want timing telemetry about them.

Domains

plane-worker.ts
import { parse } from '@pbroom/color-kit';
import {
  getPackedPlaneQueryTransferables,
  runPlaneCompute,
} from '@pbroom/color-kit/compute';

const { result } = runPlaneCompute({
  plane: { model: 'oklch', fixed: { h: 250 } },
  queries: [
    { kind: 'gamutRegion', gamut: 'srgb' },
    { kind: 'contrastRegion', reference: parse('#fff'), level: 'AA' },
  ],
});
result.queryDescriptors.map((query) => query.kind);
// → ['gamutRegion', 'contrastRegion']
self.postMessage(result, {
  transfer: getPackedPlaneQueryTransferables(result),
});

On the main thread, unpackPlaneQueryResults(result) restores the query results.

Scheduling

Packing

Types