@pbroom/color-kit/driverColor input
formatColorInputChannelValue
Formats a channel value for display: rounds to precision decimals (itself rounded and clamped to 0-6) and drops trailing zeros. -0 and non-finite values format as '0'.
import { formatColorInputChannelValue } from '@pbroom/color-kit/driver';color-input.ts:805function formatColorInputChannelValue(
value: number,
precision: number,
): string;Parameters
Returns
string
Example
import { formatColorInputChannelValue } from '@pbroom/color-kit/driver';
formatColorInputChannelValue(0.62795, 3); // → '0.628'
formatColorInputChannelValue(120, 2); // → '120'
formatColorInputChannelValue(-0.0001, 2); // → '0'