+ public static float baseHueLightness(int baseHueDegrees) {
+ switch (baseHueDegrees % 360) {
+ case 0:
+ return 0.450f; // red
+ case 60:
+ return 0.400f; // yellow
+ case 120:
+ return 0.400f; // green
+ case 180:
+ return 0.400f; // cyan
+ case 240:
+ return 0.750f; // blue
+ case 300:
+ return 0.500f; // magenta
+ default:
+ throw new IllegalStateException(
+ String.format(Locale.US, "baseHueLightness called with invalid value %d",
+ baseHueDegrees));
+ }
+ }
+ public static float hueLightness(int hueDegrees) {
+ int mod = hueDegrees % baseHueStep;
+ int x0 = hueDegrees - mod;
+ int x1 = x0 + baseHueStep;
+
+ float y0 = baseHueLightness(x0);
+ float y1 = baseHueLightness(x1);
+
+ return y0 + (hueDegrees - x0) * (y1 - y0) / (x1 - x0);
+ }