@pbroom/color-kitConversion

fromP3

Convert gamma-encoded Display P3 (0-1 per channel) to a Color. Colors outside sRGB keep their full chroma.

functionimport { fromP3 } from '@pbroom/color-kit';index.ts:424
function fromP3(p3: P3): Color;

Parameters

p3P3
Display P3 color; channels are not clamped

Returns

ColorA new OKLCH Color

Example

TypeScript
import { fromP3, inSrgbGamut, toCss } from '@pbroom/color-kit';

const red = fromP3({ r: 1, g: 0, b: 0, alpha: 1 });
toCss(red, 'oklch'); // → 'oklch(0.6486 0.2995 28.96)'
inSrgbGamut(red); // → false

See also