clayNightShadowHue function
The night drop-shadow hue (tenths) for face at shadow lightness l:
the face hue (bile-applied) when the face has C ≥ 0.035 and
maxChroma(l, hue) ≥ clayNightShadowMinChroma, else the body hue
turned 10° at a time toward 270° (≤ 6 steps) until maxChroma(l, hue)
reaches it.
Implementation
int clayNightShadowHue(
int face,
int bodyHueTenths,
double l, {
BileRule bile = BileRule.v2,
}) {
const minC = clayNightShadowMinChroma;
final f = argbToOklch(face | 0xFF000000);
if (f.c >= 0.035) {
final hue = bile.apply(_hueTenths(f), l, 0.1);
if (maxChroma(l, hue / 10) >= minC) return hue;
}
var hue = bile.apply(_wrap(bodyHueTenths), l, 0.1);
for (var i = 0; i < 6 && maxChroma(l, hue / 10) < minC; i++) {
// Clockwise distance to 270°; turn the shorter way, 10° at a time.
final d = _wrap(2700 - hue);
if (d == 0) break;
final up = d <= 1800;
final left = up ? d : 3600 - d;
final step = left < 100 ? left : 100;
hue = _wrap(hue + (up ? step : -step));
}
return hue;
}