Last active
January 3, 2016 20:59
-
-
Save kamilZ/8518939 to your computer and use it in GitHub Desktop.
Android darken color.
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 static int brighten(int color, double fraction) { | |
int red = (int) Math.round(Math.max(0,Color.red(color) - 255 * fraction)); | |
int green = (int) Math.round(Math.max(0,Color.green(color) - 255 * fraction)); | |
int blue = (int) Math.round(Math.max(0,Color.blue(color) - 255 * fraction)); | |
return Color.argb(Color.alpha(color);, red, green, blue); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment