Skip to content

Instantly share code, notes, and snippets.

@exallium
Created September 11, 2012 18:40
Show Gist options
  • Select an option

  • Save exallium/3700712 to your computer and use it in GitHub Desktop.

Select an option

Save exallium/3700712 to your computer and use it in GitHub Desktop.
Function to give contrast to input color.
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