Created
April 28, 2017 10:10
-
-
Save vaibhav-jani/508d95f71e7096907c77d2bf51498d53 to your computer and use it in GitHub Desktop.
Blend colors
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
| private static int blendColors(int color1, int color2, float ratio) { | |
| final float inverseRation = 1f - ratio; | |
| float r = (Color.red(color1) * ratio) + (Color.red(color2) * inverseRation); | |
| float g = (Color.green(color1) * ratio) + (Color.green(color2) * inverseRation); | |
| float b = (Color.blue(color1) * ratio) + (Color.blue(color2) * inverseRation); | |
| return Color.rgb((int) r, (int) g, (int) b); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment