@pbroom/color-kitConversion

toP3Into

Convert a Color to Display P3 (gamma-encoded, clamped to 0-1 like toP3), writing into out (allocation-free).

functionimport { toP3Into } from '@pbroom/color-kit';into.ts:182
function toP3Into(  out: P3, ,  color: Color,): P3;

Parameters

outP3
Object to write the result into
colorColor
Color to convert

Returns

P3out

Example

TypeScript
import { parse, toP3Into } from '@pbroom/color-kit';

const p3 = { r: 0, g: 0, b: 0, alpha: 1 };
toP3Into(p3, parse('#ff0000'));
p3; // → ≈ { r: 0.9175, g: 0.2003, b: 0.1386, alpha: 1 }