Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package window;
- public class ColorLine {
- public static int[] get(double a, double b, double t) {
- int[] color = new int[3];
- int where = (int)(1152.0*(t - a)/(b - a));
- if ((where >= 0)&&(where < 128))
- {
- color[0] = 128 - where;
- color[1] = 0;
- color[2] = 255;
- }
- else
- if ((where >= 128)&&(where < 384))
- {
- color[0] = 0;
- color[1] = where - 128;
- color[2] = 255;
- }
- else
- if ((where >= 384)&&(where < 640))
- {
- color[0] = 0;
- color[1] = 255;
- color[2] = 255-(where-384);
- }
- else
- if ((where >= 640)&&(where < 896))
- {
- color[0] = where - 640;
- color[1] = 255;
- color[2] = 0;
- }
- else
- if ((where >= 896)&&(where < 1152))
- {
- color[0] = 255;
- color[1] = 255 - (where - 896);
- color[2] = 0;
- }
- else
- if (where >= 1152)
- {
- color[0] = 255;
- color[1] = 0;
- color[2] = 0;
- }
- else
- if (where < 0)
- {
- color[0] = 128;
- color[1] = 0;
- color[2] = 255;
- }
- return color;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement