Thank you to anyone who has already donated - your generous donations helped make three months of treatment possible.

My brother Nate continues to fight stage IV Hodgkin's lymphoma. He's just 31, with a wife and baby girl. They have no active income (since he's been unable to return to work), no insurance, and cannot afford the treatment he needs. Nate and his family need your help. Please consider a donation, every dollar helps. Thanks.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import java.awt.Color;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;

import javax.imageio.ImageIO;

public class EGA {
	
	private static final int[] HEX_VALUES = new int[]{
		0x000000, 0x0000aa, 0x00aa00, 0x00aaaa, 0xaa0000, 0xaa00aa, 0xaaaa00, 0xaaaaaa,
		0x000055, 0x0000ff, 0x00aa55, 0x00aaff, 0xaa0055, 0xaa00ff, 0xaaaa55, 0xaaaaff,
		0x005500, 0x0055aa, 0x00ff00, 0x00ffaa, 0xaa5500, 0xaa55aa, 0xaaff00, 0xaaffaa,
		0x005555, 0x0055ff, 0x00ff55, 0x00ffff, 0xaa5555, 0xaa55ff, 0xaaff55, 0xaaffff,
		0x550000, 0x5500aa, 0x55aa00, 0x55aaaa, 0xff0000, 0xff00aa, 0xffaa00, 0xffaaaa,
		0x550055, 0x5500ff, 0x55aa55, 0x55aaff, 0xff0055, 0xff00ff, 0xffaa55, 0xffaaff,
		0x555500, 0x5555aa, 0x55ff00, 0x55ffaa, 0xff5500, 0xff55aa, 0xffff00, 0xffffaa,
		0x555555, 0x5555ff, 0x55ff55, 0x55ffff, 0xff5555, 0xff55ff, 0xffff55, 0xffffff
	};
	
	private static final Color[] COLORS = new Color[64];
	
	static {
		for(int i = 0; i < HEX_VALUES.length; i++){
			COLORS[i] = new Color(HEX_VALUES[i]);
		}
	}

	//Test code for generating an image of the colors
	public static void main(String[] args) throws Exception {
		final BufferedImage img = new BufferedImage(128, 32*64, BufferedImage.TYPE_INT_RGB);
		final Graphics gfx = img.getGraphics();
		
		for(int i = 0; i < COLORS.length; i++){
			gfx.setColor(COLORS[i]);
			gfx.fillRect(0, i*32, 128, 32);
			
			//Find opposite color so it isn't unreadable on some colors
			final Color textColor = new Color(255-COLORS[i].getRed(), 255-COLORS[i].getGreen(), 255-COLORS[i].getBlue());
			gfx.setColor(textColor);
			gfx.drawString(String.valueOf(i), 8, i*32+20);
		}
		
		gfx.dispose();
		
		ImageIO.write(img, "PNG", new File("ega_colors.png"));
	}
}