clayCandyHue function
The candy-hue rule: hue inside band leaves it on the side of
whichever of targets is circularly nearer pivot (the hue itself for
candy and night themes, the body hue for tonal ones; ties go to the
first). It lands on the target pushed away from the band by half the
hue's depth into the band from that side, at most maxPush — so the
band stays empty without piling every moved hue onto one colour.
Pure integer tenths.
Implementation
int clayCandyHue(
int hue,
IntRange band,
(int, int) targets,
int pivot, {
int maxPush = 0,
}) {
final h = _wrap(hue);
if (!band.contains(h)) return h;
final (a, b) = targets;
if (_hueDistance(a, pivot) <= _hueDistance(b, pivot)) {
final push = (h - band.lo) ~/ 2;
return _wrap(a - (push < maxPush ? push : maxPush));
}
final push = (band.hi - h) ~/ 2;
return _wrap(b + (push < maxPush ? push : maxPush));
}