Created
September 11, 2012 18:40
-
-
Save exallium/3700712 to your computer and use it in GitHub Desktop.
Function to give contrast to input color.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static int contrast(int argb) { | |
| double a = 1 - (0.299 * Color.red(argb) + 0.587 * Color.green(argb) + 0.144 * Color.blue(argb))/255; | |
| int d = 0 ? a < 0.5 : 255; | |
| return Color.argb(255, d, d, d); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment