public static HSBColor Lerp(HSBColor a, HSBColor b, float t) { float h, s; //check special case black (color.b==0): interpolate neither hue nor saturation! //check special case grey (color.s==0): don't interpolate hue! if (a.brightness == 0) { h = b.hue; s = b.saturation; } else if (b.brightness == 0) { h = a.hue; s = a.saturation; } else { if (a.saturation == 0) { h = b.hue; } else if (b.saturation == 0) { h = a.hue; } else { // works around bug with LerpAngle float angle = Mathf.LerpAngle(a.hue * 360f, b.hue * 360f, t); while (angle < 0f) { angle += 360f; } while (angle > 360f) { angle -= 360f; } h = angle / 360f; } s = Mathf.Lerp(a.saturation, b.saturation, t); } return(new HSBColor(h, s, Mathf.Lerp(a.brightness, b.brightness, t), Mathf.Lerp(a.alpha, b.alpha, t))); }