Advertisement
Leo40Bin

what a mess I've made

May 3rd, 2020
676
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.70 KB | None | 0 0
  1. private int[] separateColor(int color) {
  2.     return new int[] {
  3.             (color >> 16) & 0xFF,
  4.             (color >> 8) & 0xFF,
  5.             color & 0xFF
  6.     };
  7. }
  8.  
  9. private int combineColor(int[] rgb) {
  10.     return (rgb[0] << 16) & 0xFF0000 | (rgb[1] << 8) & 0xFF00 | rgb[2] & 0xFF;
  11. }
  12.  
  13. private int[] lerpArrays(float delta, int[] a1, int[] a2) {
  14.     if (a1.length != a2.length)
  15.         throw new RuntimeException("a1.length != a2.length");
  16.     int[] a3 = new int[a1.length];
  17.     for (int i = 0; i < a1.length; i++)
  18.         a3[i] = MathHelper.floor(MathHelper.lerp(delta, a1[i], a2[i]));
  19.     return a3;
  20. }
  21.  
  22. private int lerpColors(float delta, int color1, int color2) {
  23.     return combineColor(lerpArrays(delta, separateColor(color1), separateColor(color2)));
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement