Want more features on Pastebin? Sign Up, it's FREE!
Guest

Java2D_Colors

By: a guest on Nov 11th, 2012  |  syntax: None  |  size: 0.40 KB  |  views: 3  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. package j2dgame.gfx;
  2.  
  3. public class Colors {
  4.         public static int get(int color1, int color2, int color3, int color4) {
  5.                 return (get(color4) << 24) + (get(color3) << 16) + (get(color2) << 8)
  6.                                 + get(color1);
  7.         }
  8.  
  9.         private static int get(int color) {
  10.                 if (color < 0)
  11.                         return 255;
  12.                 int r = color / 100 % 10;
  13.                 int g = color / 10 % 10;
  14.                 int b = color % 10;
  15.                 return r * 36 + g * 6 + b;
  16.         }
  17.  
  18. }
clone this paste RAW Paste Data