@pbroom/color-kit/driverColor area
colorFromColorAreaKey
Keyboard model for a 2D color-area thumb:
import { colorFromColorAreaKey } from '@pbroom/color-kit/driver';color-area.ts:783function colorFromColorAreaKey(
color: Color,
axes: ResolvedColorAreaAxes,
key: string,
stepRatio: number,
options?: ColorAreaKeyOptions,
): Color | null;- Arrow Left/Right step the x axis; Arrow Up/Down step the y axis, by
stepRatioof the axis range (up moves the thumb up). - PageUp/PageDown step the y axis by
largeStepRatio. - Home/End jump the x axis to its range start/end.
Hue axes wrap by default; other channels clamp. Returns null for keys the area does not handle. Modifier keys are not read: pass a larger stepRatio for Shift+Arrow.
Parameters
- key
string - stepRatio
number - Arrow-key step as a fraction of the axis range, e.g.
0.01. - options?
ColorAreaKeyOptionsdefault{}
Returns
Color | null
Example
import { colorFromColorAreaKey, resolveColorAreaAxes } from '@pbroom/color-kit/driver';
const axes = resolveColorAreaAxes(); // x: l [0, 1], y: c [0, 0.4]
const color = { l: 0.6, c: 0.1, h: 250, alpha: 1 };
colorFromColorAreaKey(color, axes, 'ArrowRight', 0.01); // → { l: 0.61, c: 0.1, h: 250, alpha: 1 }
colorFromColorAreaKey(color, axes, 'PageUp', 0.01); // → { l: 0.6, c: 0.14, h: 250, alpha: 1 }
colorFromColorAreaKey(color, axes, 'Enter', 0.01); // → null