Support 256 color

This commit is contained in:
Daniel Imms
2017-08-31 00:25:52 -07:00
parent d601f0aec2
commit dff3d16831
3 changed files with 43 additions and 11 deletions
+31
View File
@@ -21,3 +21,34 @@ export const TANGO_COLORS = [
'#34e2e2',
'#eeeeec'
];
export const COLORS: string[] = (function(): string[] {
let colors = TANGO_COLORS.slice();
let r = [0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff];
let i;
// 16-231
i = 0;
for (; i < 216; i++) {
out(r[(i / 36) % 6 | 0], r[(i / 6) % 6 | 0], r[i % 6]);
}
// 232-255 (grey)
i = 0;
let c: number;
for (; i < 24; i++) {
c = 8 + i * 10;
out(c, c, c);
}
function out(r: number, g: number, b: number): void {
colors.push('#' + hex(r) + hex(g) + hex(b));
}
function hex(c: number): string {
let s = c.toString(16);
return s.length < 2 ? '0' + s : s;
}
return colors;
})();