@pbroom/color-kit/interopWriters

toOklchArray

Write a color as OKLCH [l, c, h], with hue in degrees copied from the color as-is.

functionimport { toOklchArray } from '@pbroom/color-kit/interop';writers.ts:570
function toOklchArray(
  color: Color,
  out?: undefined,
  offset?: number,
  options?: ArrayWriteOptions,
): ColorTuple;

function toOklchArray<T extends WritableArrayLike>(
  color: Color,
  out: T,
  offset?: number,
  options?: ArrayWriteOptions,
): T;

function toOklchArray<T extends WritableArrayLike>(
  color: Color,
  out: T | undefined,
  offset?: number,
  options?: ArrayWriteOptions,
): ColorTuple | T;

clamp is a no-op for this space.

Overload 1 of 3

Parameters

colorColor
Color to convert.
out?undefined
Destination (number[], Float32Array, ...). When omitted a new ColorTuple is returned.
offset?number
Index in out of the first component to write.
options?ArrayWriteOptions
Out-of-gamut handling (clamp).

Returns

ColorTupleout, or a new tuple when out is omitted.

Overload 2 of 3

Parameters

colorColor
Color to convert.
outT
Destination (number[], Float32Array, ...). When omitted a new ColorTuple is returned.
offset?number
Index in out of the first component to write.
options?ArrayWriteOptions
Out-of-gamut handling (clamp).

Returns

Tout, or a new tuple when out is omitted.

Overload 3 of 3

Parameters

colorColor
Color to convert.
outT | undefined
Destination (number[], Float32Array, ...). When omitted a new ColorTuple is returned.
offset?number
Index in out of the first component to write.
options?ArrayWriteOptions
Out-of-gamut handling (clamp).

Returns

ColorTuple | Tout, or a new tuple when out is omitted.

Example

TypeScript
toOklchArray(parse('#ff8800')); // => [c0, c1, c2]

// Write into an existing buffer, starting at element 6.
toOklchArray(color, buffer, 6);

Also exported from