Skip to content

Instantly share code, notes, and snippets.

@vaibhav-jani
Created April 28, 2017 10:10
Show Gist options
  • Select an option

  • Save vaibhav-jani/508d95f71e7096907c77d2bf51498d53 to your computer and use it in GitHub Desktop.

Select an option

Save vaibhav-jani/508d95f71e7096907c77d2bf51498d53 to your computer and use it in GitHub Desktop.
Blend colors
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