@pbroom/color-kitContrast

clampContrastRegionSampling

Returns the sampling contrastRegionPaths actually runs with: defaults filled in (32, 0.0015, 6), initialSamples capped at 512, maxDepth at 12, and errorTolerance raised to at least 1e-6.

functionimport { clampContrastRegionSampling } from '@pbroom/color-kit';region-shared.ts:111
function clampContrastRegionSampling(
  options: Pick<ContrastRegionPathOptions, 'initialSamples' | 'errorTolerance' | 'maxDepth'>,
): ContrastRegionSampling;

It does not validate; values the solver rejects (such as initialSamples: 1) are returned unchanged. Use it to show the effective fidelity of a contrast overlay or to key a cache.

Parameters

optionsPick<ContrastRegionPathOptions, 'initialSamples' | 'errorTolerance' | 'maxDepth'>
The initialSamples, errorTolerance and maxDepth fields of ContrastRegionPathOptions; other fields are ignored.

Returns

ContrastRegionSamplingA new ContrastRegionSampling object.

Example

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

clampContrastRegionSampling({ initialSamples: 1000, errorTolerance: 0 });
// → { initialSamples: 512, errorTolerance: 0.000001, maxDepth: 6 }