of static method
The slice for rawTone.
Tones are quantized to 0.5 steps: bounds the cache at 201 entries and makes arbitrary real-world tones (T=47.238...) actually hit it. Callers re-tone results to the exact input tone; chromaticity error from a <=0.25 tone shift is far below a JND.
Implementation
static SliceCache of(double rawTone) {
final tone = (rawTone.clamp(0.0, 100.0) * 2.0).round() / 2.0;
return _byTone.putIfAbsent(tone, () {
final us = List.filled(360, 0.0);
final vs = List.filled(360, 0.0);
final cs = List.filled(360, 0.0);
for (var h = 0; h < 360; h++) {
final hct = Hct.from(h.toDouble(), 250.0, tone); // gamut-clamped
final uv = uvOfArgb(hct.toInt()) ?? whiteUvPoint;
us[h] = uv.$1;
vs[h] = uv.$2;
cs[h] = hct.chroma;
}
return SliceCache._(tone, us, vs, cs);
});
}