- int getPrimaryColorForHue(int degrees) {
- // 0/360f becomes -0.000something for some reason
- if (degrees == 0) return getPrimaryColorForHue(0f);
- return getPrimaryColorForHue(degrees / 360f);
- }
- public static @ColorInt
- int getPrimaryColorForHue(float hue) {
-// int result = hsvColor(hue, 0.61f, 0.95f);
- int result = hslColor(hue, 0.60f, 0.60f);
- Log.d("colors", String.format("getPrimaryColorForHue(%1.2f) = %x", hue, result));
+ int getPrimaryColorForHue(int hueDegrees) {
+// int result = hsvColor(hueDegrees, 0.61f, 0.95f);
+ float y = hueDegrees - 60;
+ if (y < 0) y += 360;
+ float l = yellowLightness + (blueLightness - yellowLightness) *
+ (float) Math.cos(Math.toRadians(Math.abs(180 - y) / 2f));
+ int result = hslColor(hueDegrees/360f, 0.845f, l);
+ debug("colors", String.format("getPrimaryColorForHue(%d) = %x", hueDegrees, result));