@pbroom/color-kit/interopWriters
toOklchArray4
Write a color as OKLCH [l, c, h], with hue in degrees copied from the color as-is.
import { toOklchArray4 } from '@pbroom/color-kit/interop';writers.ts:619function toOklchArray4(
color: Color,
out?: undefined,
offset?: number,
options?: ArrayWriteOptions,
): ColorTuple4;
function toOklchArray4<T extends WritableArrayLike>(
color: Color,
out: T,
offset?: number,
options?: ArrayWriteOptions,
): T;
function toOklchArray4<T extends WritableArrayLike>(
color: Color,
out: T | undefined,
offset?: number,
options?: ArrayWriteOptions,
): ColorTuple4 | T;Alpha is written as the fourth component: [c0, c1, c2, alpha].
clamp is a no-op for this space.
Overload 1 of 3
Parameters
- out?
undefined - Destination (
number[],Float32Array, ...). When omitted a newColorTuple4is returned. - offset?
number - Index in
outof the first component to write. - options?
ArrayWriteOptions - Out-of-gamut handling (
clamp).
Returns
ColorTuple4out, or a new tuple when out is omitted.
Overload 2 of 3
Parameters
- out
T - Destination (
number[],Float32Array, ...). When omitted a newColorTuple4is returned. - offset?
number - Index in
outof 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
- out
T | undefined - Destination (
number[],Float32Array, ...). When omitted a newColorTuple4is returned. - offset?
number - Index in
outof the first component to write. - options?
ArrayWriteOptions - Out-of-gamut handling (
clamp).
Returns
ColorTuple4 | Tout, or a new tuple when out is omitted.
Example
// vec4 uniform: [c0, c1, c2, alpha]
const scratch = new Float32Array(4);
gl.uniform4fv(loc, toOklchArray4(color, scratch));Also exported from
@pbroom/color-kitthe same declaration, re-exported