Created
May 13, 2018 13:57
-
-
Save vsay01/ab72627cd18d15534d879712580b2562 to your computer and use it in GitHub Desktop.
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
| /** | |
| * https://stackoverflow.com/questions/33072365/how-to-darken-a-given-color-int | |
| * @param color color provided | |
| * @param factor factor to make color darker | |
| * @return int as darker color | |
| */ | |
| public static int manipulateColor(int color, float factor) { | |
| int a = Color.alpha(color); | |
| int r = Math.round(Color.red(color) * factor); | |
| int g = Math.round(Color.green(color) * factor); | |
| int b = Math.round(Color.blue(color) * factor); | |
| return Color.argb(a, | |
| Math.min(r, 255), | |
| Math.min(g, 255), | |
| Math.min(b, 255)); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment