@pbroom/color-kit/driverColor input

getColorInputPrecisionFromStep

Number of decimal places needed to show values on a step grid: the count of decimals in |step|, capped at 6 (the most formatColorInputChannelValue shows), so steps finer than 1e-6, including exponent-notation steps such as 1e-9, return 6. Floating point noise is ignored (0.1 + 0.2 counts as one decimal). A zero or non-finite step returns 2.

functionimport { getColorInputPrecisionFromStep } from '@pbroom/color-kit/driver';color-input.ts:771
function getColorInputPrecisionFromStep(  step: number,): number;

Parameters

stepnumber

Returns

number

Example

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

getColorInputPrecisionFromStep(1); // → 0
getColorInputPrecisionFromStep(0.01); // → 2
getColorInputPrecisionFromStep(0.005); // → 3
getColorInputPrecisionFromStep(2.5e-5); // → 6
getColorInputPrecisionFromStep(1e-9); // → 6
getColorInputPrecisionFromStep(0); // → 2