Function Oklch.isNearAchromatic

Tests chroma against a caller-selected near-achromatic threshold.

bool isNearAchromatic(
  T epsilon
) const pure nothrow @nogc @safe;

Use this when exact zero is too strict for the caller's task. The library does not impose a global chroma epsilon.

Parameters

NameDescription
epsilon Non-negative caller-selected chroma magnitude threshold.

Returns

true when abs(c) <= epsilon.

Preconditions

epsilon >= 0. This is a programmer precondition; callers that need recoverable validation must validate external input before calling.

Example

const color = Oklchd(0.5, 1e-4, OklabHued.fromDegrees(120.0));
assert(color.isNearAchromatic(1e-3));
assert(!color.isNearAchromatic(1e-5));