@pbroom/color-kitConversion

toP3

Convert a Color to gamma-encoded Display P3 (0-1 per channel).

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

Channels outside the P3 gamut are clipped to [0, 1]; values are not rounded. Use toP3Gamut first for a perceptual gamut map instead of a clip.

Parameters

colorColor
Color to convert

Returns

P3A new P3

Example

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

toP3(parse('#ff0000')); // → ≈ { r: 0.9175, g: 0.2003, b: 0.1386, alpha: 1 }

See also