Created
March 1, 2015 06:58
-
-
Save vinaysshenoy/f54a208ad93b10e94a3a to your computer and use it in GitHub Desktop.
Android check if color is dark
This file contains 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 boolean isColorDark(int color){ | |
double darkness = 1-(0.299*Color.red(color) + 0.587*Color.green(color) + 0.114*Color.blue(color))/255; | |
if(darkness<0.5){ | |
return false; // It's a light color | |
}else{ | |
return true; // It's a dark color | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment