Fix kabouzeid/phonograph-issue-tracker#51: Shuffle button in now playing becomes hard to tell

We check for the difference between the default and the activated colors. If the difference value is less than 55000, the activated color is shifted up.
This commit is contained in:
Ihsan Isik 2015-09-22 20:11:25 +03:00
commit a1fb2d3c9d
2 changed files with 31 additions and 2 deletions

View file

@ -137,4 +137,17 @@ public class ColorUtil {
}
return backgroundColor;
}
/**
* Calculates the distance of two colors in 3D Space.
*
* Taken from http://stackoverflow.com/a/1725535/984061
*/
public static boolean calculateColorDistance(int color1, int color2) {
double red = Math.pow(Math.abs(Color.red(color2) - Color.red(color1)), 2);
double green = Math.pow(Math.abs(Color.green(color2) - Color.green(color1)), 2);
double blue = Math.pow(Math.abs(Color.blue(color2) - Color.blue(color1)), 2);
double distance = red + green + blue;
return distance < 55000;
}
}