@pbroom/color-kit/interopTypes
PackColorsOptions
Options for packColors.
import type { PackColorsOptions } from '@pbroom/color-kit/interop';types.ts:71interface PackColorsOptions extends ArrayWriteOptions {
clamp?: boolean;
alpha?: boolean;
stride?: number;
offset?: number;
}Properties
- clamp?
booleandefaultfalse Clip RGB channels to
[0, 1]after conversion. Only affects the RGB spaces (linearSrgb,srgb,linearP3,display-p3); it is a no-op foroklab/oklch. Alpha is written unchanged. Clipping shifts hue and lightness; map withtoSrgbGamut/toP3Gamutfirst 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 clampsColorchannels.- alpha?
booleandefaultfalse - Write alpha as a fourth component after each color's three channels.
- stride?
numberdefaultalpha ? 4 : 3 Distance, in array elements, between the first components of consecutive colors. Must be at least 3 (or 4 with
alpha).Use
stride: 4withoutalphafor paddedvec3arrays (WGSLarray<vec3f>has a 16-byte stride); pad lanes are left untouched. Use a larger stride to interleave colors into a vertex buffer.- offset?
numberdefault0 - Array index of the first color's first component.
Also exported from
@pbroom/color-kitthe same declaration, re-exported