Created
January 20, 2014 12:15
-
-
Save kamilZ/8519003 to your computer and use it in GitHub Desktop.
Darken Android 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 darken(int color, double fraction) { | |
int red = (int) Math.round(Math.max(Color.red(color) + 255 * fraction,255)); | |
int green = (int) Math.round(Math.max( Color.green(color) + 255 * fraction,255)); | |
int blue = (int) Math.round(Math.max( Color.blue(color) + 255 * fraction,255)); | |
int alpha = Color.alpha(color); | |
return Color.argb(alpha, red, green, blue); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This doesn't work, here is a link to a working lighten and darken piece of code https://gist.github.com/martintreurnicht/f6bbb20a43211bc2060e