summaryrefslogtreecommitdiff
path: root/utils/Etgen-color-cube
blob: 959072b54cd9a1597efc8ccc530a08776daecc79 (plain)
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
#!/usr/bin/perl
# Built from 
# Author: Todd Larason <jtl@molehill.org>
# $XFree86: xc/programs/xterm/vttests/256colors2.pl,v 1.1 1999/07/11 08:49:54 dawes Exp $
# adapted to the special needs for Eterm by Fredrik Svensson <fred@ludd.ltu.se>


$redmax   = 1;
$greenmax = 1;
$bluemax  = 2*3*2*3*2*3;
# adjust if 255 color should be included use adj = 1. Not possible if any maxvalue is 1.
$adj = 0;

# colors 16-231 are a 6x6x6 color cube
for ($red = 0; $red < $redmax; $red++) {
    for ($green = 0; $green < $greenmax; $green++) {
	for ($blue = 0; $blue < $bluemax; $blue++) {
	    printf("\x1b]4;%d;rgb:%2.2x/%2.2x/%2.2x\x1b\\",
		   16 + ($red * $greenmax * $bluemax) + ($green * $bluemax) + $blue,
		   int ($red   * 255 / ($redmax - $adj) ),
		   int ($green * 255 / ($greenmax - $adj)),
		   int ($blue  * 255 / ($bluemax - $adj )));
	}
    }
}

# colors 232-255 are a grayscale ramp, intentionally leaving out
# black and white
for ($gray = 0; $gray < 24; $gray++) {
    $level = ($gray * 10) + 8;
    printf("\x1b]4;%d;rgb:%2.2x/%2.2x/%2.2x\x1b\\",
	   232 + $gray, $level, $level, $level);
}