ppamorim

Untitled

Nov 13th, 2014
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.68 KB | None | 0 0
  1. /**
  2.      * Blend {@code color1} and {@code color2} using the given ratio.
  3.      *
  4.      * @param ratio of which to blend. 1.0 will return {@code color1}, 0.5 will give an even blend,
  5.      *              0.0 will return {@code color2}.
  6.      */
  7.     private static int blendColors(int color1, int color2, float ratio) {
  8.         final float inverseRation = 1f - ratio;
  9.         float r = (Color.red(color1) * ratio) + (Color.red(color2) * inverseRation);
  10.         float g = (Color.green(color1) * ratio) + (Color.green(color2) * inverseRation);
  11.         float b = (Color.blue(color1) * ratio) + (Color.blue(color2) * inverseRation);
  12.         return Color.rgb((int) r, (int) g, (int) b);
  13.     }
Advertisement
Add Comment
Please, Sign In to add comment