@pbroom/color-kit/reactPlane geometry
UseContrastRegionOptions
Options for useContrastRegion.
import type { UseContrastRegionOptions } from '@pbroom/color-kit/react';use-contrast-region.ts:85interface UseContrastRegionOptions extends ColorPlaneQueryOptions {
quality?: ColorPlaneQualityLevel;
isDragging?: boolean;
performanceProfile?: ColorPlanePerformanceProfile;
reference?: Color;
hue?: number;
gamut?: GamutTarget;
metric?: ContrastMetric;
threshold?: number;
level?: ContrastRegionLevel;
apcaPreset?: ContrastApcaPreset;
apcaPolarity?: ContrastApcaPolarity;
apcaRole?: ContrastApcaRole;
initialSamples?: number;
errorTolerance?: number;
maxDepth?: number;
maxChroma?: number;
alpha?: number;
simplifyTolerance?: number;
onMetrics?: (metrics: ContrastRegionMetrics) => void;
includeSchedulerTelemetry?: boolean;
}Properties
- quality?
ColorPlaneQualityLeveldefault'high' - Sampling detail. Pass
useAdaptiveQuality'squalityto coarsen sampling while frames are slow. - isDragging?
booleandefaultfalse - Whether the plane is being dragged. While true, queries run in a shared Web Worker (when available) and the last result stays in place until a fresh one arrives; at rest they run synchronously.
- performanceProfile?
ColorPlanePerformanceProfiledefault'auto' - Profile forwarded to the worker's compute scheduler.
- reference?
Color - Color the region's samples are measured against (gamut-mapped into
gamutfirst). Defaults to the plane color, which is rarely what a text-on-background check wants: pass the fixed background or text color. - hue?
number - Hue of the plane slice in degrees. Defaults to the plane color's hue.
- gamut?
GamutTargetdefault'srgb' - Gamut the reference and samples are measured in; paths stay inside it.
- metric?
ContrastMetricdefault'wcag' - Contrast metric.
- threshold?
number - Explicit threshold; overrides
levelandapcaPreset. A WCAG contrast ratio, or withmetric: 'apca'a normalized Lc magnitude (0.6for Lc 60). - level?
ContrastRegionLeveldefault'AA' (4.5:1) - WCAG threshold preset used when
thresholdis omitted. - apcaPreset?
ContrastApcaPresetdefault'body' (Lc 60, normalized 0.6) - APCA threshold preset used with
metric: 'apca'whenthresholdis omitted. - apcaPolarity?
ContrastApcaPolaritydefault'absolute' - APCA polarity test with
metric: 'apca':absolute,positiveornegativeLc. - apcaRole?
ContrastApcaRoledefault'sample-text' - Whether samples are the text (
sample-text) or the background (sample-background) in APCA. - initialSamples?
numberdefault8 - Initial samples per gamut chroma extent, scaled down at lower
quality. Tuned for interactive use; seecontrastRegionPathsfor the solver's own defaults. - errorTolerance?
numberdefault0.004 - Largest distance, in l/c units, a sampled midpoint may lie from its chord before the interval is refined.
- maxDepth?
numberdefault3 at `high` quality, 2 at `medium`, 1 at `low - Maximum refinement depth per initial interval.
- maxChroma?
numberdefault0.4 - Upper chroma bound of the region.
- alpha?
number - Alpha used for the samples while measuring contrast.
- simplifyTolerance?
number - RDP simplification tolerance in (l, c) space; omit to disable.
- onMetrics?
(metrics: ContrastRegionMetrics) => void - Called after each sync or worker compute with sampling and timing stats.
- includeSchedulerTelemetry?
booleandefaultfalse - Include worker scheduler fields in
onMetrics.