@pbroom/color-kitConversion

linearP3ToP3Into

Apply Display P3 gamma encoding (same as sRGB transfer function), writing the clamped [0, 1] channels into out (allocation-free). out may be the same object as linear.

functionimport { linearP3ToP3Into } from '@pbroom/color-kit';p3.ts:139
function linearP3ToP3Into(  out: P3, ,  linear: P3,): P3;

Parameters

outP3
Object to write the result into
linearP3
Linear-light Display P3 color

Returns

P3out

Example

TypeScript
import { linearP3ToP3Into } from '@pbroom/color-kit';

const p3 = { r: 0, g: 0, b: 0, alpha: 1 };
linearP3ToP3Into(p3, { r: 0.2, g: 0.5, b: 0.8, alpha: 1 });
p3.g; // → ≈ 0.7354

See also