package bmsi.tui; import java.awt.Color; import java.awt.image.ColorModel; /** ColorModel for monochrome terminals. * Colors are black, gray, white, and transparent. */ public class TUIColorModel extends ColorModelPeer { public TUIColorModel() { super(2); } private static short[] alpha = { 255,255,255,0 }; private static short[] bright = { 0, 127, 255, 0 }; public int getAlpha(int pixel) { return alpha[pixel]; } public int getBlue(int pixel) { return bright[pixel]; } public int getRed(int pixel) { return bright[pixel]; } public int getGreen(int pixel) { return bright[pixel]; } static int getGrayLevel(Color c) { int red = c.getRed(); int blue = c.getBlue(); int green = c.getGreen(); return (red + blue + blue + green) / 4; } public int getPixel(Color c) { return getGrayLevel(c) / 100; } }