@pbroom/color-kit/driverColor state
resolveIncomingRequested
Resolves a new requested color against the previous one so an achromatic input does not discard the hue.
import { resolveIncomingRequested } from '@pbroom/color-kit/driver';color-state.ts:335function resolveIncomingRequested(
previous: Color,
incoming: Color,
options: ResolveIncomingRequestedOptions,
): Color;When incoming is achromatic (chroma at or below ACHROMATIC_CHROMA_THRESHOLD) and its hue is not explicit (or is not finite), the result keeps previous.h; lightness, chroma and alpha stay as converted. Raising chroma afterwards therefore resumes the previous hue instead of jumping to the canonical achromatic hue 0 that conversions report. Chromatic inputs and explicit hues are returned unchanged (same reference), as is incoming when it already holds previous.h.
Parameters
Returns
Example
import { parse } from '@pbroom/color-kit';
import { resolveIncomingRequested } from '@pbroom/color-kit/driver';
const gray = resolveIncomingRequested(
{ l: 0.6, c: 0.15, h: 250, alpha: 1 },
parse('#808080'), // h: 0
{ explicitHue: false },
);
gray.h; // → 250
gray.l.toFixed(2); // → '0.60'