Advertisement
Guest User

Well

a guest
Apr 24th, 2014
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.08 KB | None | 0 0
  1. package window;
  2.  
  3. public class ColorLine {
  4. public static int[] get(double a, double b, double t) {
  5.     int[] color = new int[3];
  6.     int where = (int)(1152.0*(t - a)/(b - a));
  7.     if ((where >= 0)&&(where < 128))
  8.     {
  9.         color[0] = 128 - where;
  10.         color[1] = 0;
  11.         color[2] = 255;
  12.     }
  13.     else
  14.         if ((where >= 128)&&(where < 384))
  15.         {
  16.             color[0] = 0;
  17.             color[1] = where - 128;
  18.             color[2] = 255;
  19.         }
  20.         else
  21.             if ((where >= 384)&&(where < 640))
  22.             {
  23.                 color[0] = 0;
  24.                 color[1] = 255;
  25.                 color[2] = 255-(where-384);
  26.             }
  27.             else
  28.                 if ((where >= 640)&&(where < 896))
  29.                 {
  30.                     color[0] = where - 640;
  31.                     color[1] = 255;
  32.                     color[2] = 0;
  33.                 }
  34.                 else
  35.                     if ((where >= 896)&&(where < 1152))
  36.                     {
  37.                         color[0] = 255;
  38.                         color[1] = 255 - (where - 896);
  39.                         color[2] = 0;
  40.                     }
  41.                     else
  42.                         if (where >= 1152)
  43.                         {
  44.                             color[0] = 255;
  45.                             color[1] = 0;
  46.                             color[2] = 0;
  47.                         }
  48.                         else
  49.                             if (where < 0)
  50.                             {
  51.                                 color[0] = 128;
  52.                                 color[1] = 0;
  53.                                 color[2] = 255;
  54.                             }
  55.                            
  56.     return color;
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement