@pbroom/color-kit/driverColor state
setColorChannel
Sets one requested channel. No-op when the channel already holds value (regardless of source) and options.gamutMapMethod does not change the stored method; a source-only change is therefore dropped. options is forwarded to setColorRequested (with explicitHue left at true). value is not clamped.
import { setColorChannel } from '@pbroom/color-kit/driver';color-state.ts:434function setColorChannel(
state: ColorState,
channel: ColorChannel,
value: number,
source: ColorSource,
options?: MapDisplayedColorsOptions,
): ColorState;Parameters
- value
number - options?
MapDisplayedColorsOptionsdefault{}
Returns
Example
import { parse, toHex } from '@pbroom/color-kit';
import { createColorState, setColorChannel } from '@pbroom/color-kit/driver';
const state = createColorState(parse('#3b82f6'));
const next = setColorChannel(state, 'l', 0.4, 'user');
toHex(next.requested); // → '#003baa'
setColorChannel(next, 'l', 0.4, 'programmatic') === next; // → true