@pbroom/color-kit/driverColor state

mapDisplayedColors

Maps a requested color into both display gamuts and reports whether it was outside each one. Gamut membership is tested on the unmapped color.

functionimport { mapDisplayedColors } from '@pbroom/color-kit/driver';color-state.ts:151
function mapDisplayedColors(
  requested: Color,
  options?: MapDisplayedColorsOptions,
): { srgb: Color; p3: Color; outOfGamut: { srgb: boolean; p3: boolean } };

Parameters

Returns

{ srgb: Color; p3: Color; outOfGamut: { srgb: boolean; p3: boolean } }

Example

TypeScript
import { toHex } from '@pbroom/color-kit';
import { mapDisplayedColors } from '@pbroom/color-kit/driver';

const mapped = mapDisplayedColors({ l: 0.75, c: 0.22, h: 150, alpha: 1 });
toHex(mapped.srgb); // → '#00d061'
mapped.outOfGamut; // → { srgb: true, p3: false }