We can rotate the hue 360 degrees. However rotating it by 1 degree would not provide enough visual distinction, so we would have to increase it by more than so.
If we benchmark 4 items, we can use 360 / 4 and hence the hue gets rotated by 90 degrees.
But if we have 50 items we benchmark, then 360 / 50 = 7.2 which would not be a hue leap enough to provide visual distinction, so at one point we would have to resort to also changing the color intensity.
But rotating by 45 degrees we could fit 8 hues in 360 degrees. This would be visuablly distinctive. If we need to benchmark more than 8 items, we change the intensity and keep on rotating the hue.
PHP Code:
$items_to_benchmark = 16;
$h = 0;
$s = 100;
$l = 50;
if ($items_to_benchmark < 8) {
$increase_hue_by = (int)(360 / $items_to_benchmark);
} else {
$increase_hue_by = 45;
}
for ($i=0; $i<$items_to_benchmark; $i++) {
if ($h == 360) {
$s -= 33;
$l += 10;
}
$color = 'hsl(' + $h + ',' + $s + '%,' + $l + '%)':
$h += $increase_hue_by;
}