diff options
Diffstat (limited to 'tools/256color.pl')
-rwxr-xr-x | tools/256color.pl | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/tools/256color.pl b/tools/256color.pl new file mode 100755 index 0000000..aee7fd4 --- /dev/null +++ b/tools/256color.pl | |||
@@ -0,0 +1,104 @@ | |||
1 | #!/usr/bin/perl | ||
2 | # Author: Todd Larason <jtl@molehill.org> | ||
3 | # $XFree86: xc/programs/xterm/vttests/256colors2.pl,v 1.1 1999/07/11 08:49:54 dawes Exp $ | ||
4 | |||
5 | # use the resources for colors 0-15 - usually more-or-less a | ||
6 | # reproduction of the standard ANSI colors, but possibly more | ||
7 | # pleasing shades | ||
8 | |||
9 | # colors 16-231 are a 6x6x6 color cube | ||
10 | for ($red = 0; $red < 6; $red++) { | ||
11 | for ($green = 0; $green < 6; $green++) { | ||
12 | for ($blue = 0; $blue < 6; $blue++) { | ||
13 | printf("\x1b]4;%d;rgb:%2.2x/%2.2x/%2.2x\x1b\\", | ||
14 | 16 + ($red * 36) + ($green * 6) + $blue, | ||
15 | int ($red * 42.5), | ||
16 | int ($green * 42.5), | ||
17 | int ($blue * 42.5)); | ||
18 | } | ||
19 | } | ||
20 | } | ||
21 | |||
22 | # colors 232-255 are a grayscale ramp, intentionally leaving out | ||
23 | # black and white | ||
24 | for ($gray = 0; $gray < 24; $gray++) { | ||
25 | $level = ($gray * 10) + 8; | ||
26 | printf("\x1b]4;%d;rgb:%2.2x/%2.2x/%2.2x\x1b\\", | ||
27 | 232 + $gray, $level, $level, $level); | ||
28 | } | ||
29 | |||
30 | |||
31 | # display the colors | ||
32 | |||
33 | # first the system ones: | ||
34 | print "(256) System colors: background\n"; | ||
35 | for ($color = 0; $color < 8; $color++) { | ||
36 | print "\x1b[48;5;${color}m "; | ||
37 | } | ||
38 | print "\x1b[0m\n"; | ||
39 | for ($color = 8; $color < 16; $color++) { | ||
40 | print "\x1b[48;5;${color}m "; | ||
41 | } | ||
42 | print "\x1b[0m\n\n"; | ||
43 | |||
44 | print "System colors: background\n"; | ||
45 | for ($color = 40; $color < 48; $color++) { | ||
46 | print "\x1b[${color}m "; | ||
47 | } | ||
48 | print "\x1b[0m\n"; | ||
49 | for ($color = 100; $color < 108; $color++) { | ||
50 | print "\x1b[${color}m "; | ||
51 | } | ||
52 | print "\x1b[0m\n\n"; | ||
53 | |||
54 | print "System colors: foreground\n"; | ||
55 | for ($color = 30; $color < 38; $color++) { | ||
56 | print "\x1b[0;${color}m██"; | ||
57 | } | ||
58 | print "\x1b[0m\n"; | ||
59 | for ($color = 90; $color < 98; $color++) { | ||
60 | print "\x1b[0;${color}m██"; | ||
61 | } | ||
62 | print "\x1b[0m\n\n"; | ||
63 | |||
64 | print "Bright colors:\n"; | ||
65 | for ($color = 30; $color < 38; $color++) { | ||
66 | print "\x1b[1;${color}m██"; | ||
67 | } | ||
68 | print "\x1b[0m\n"; | ||
69 | for ($color = 90; $color < 98; $color++) { | ||
70 | print "\x1b[1;${color}m██"; | ||
71 | } | ||
72 | print "\x1b[0m\n\n"; | ||
73 | |||
74 | print "Dim/Faint colors:\n"; | ||
75 | for ($color = 30; $color < 38; $color++) { | ||
76 | print "\x1b[2;${color}m██"; | ||
77 | } | ||
78 | print "\x1b[0m\n"; | ||
79 | for ($color = 90; $color < 98; $color++) { | ||
80 | print "\x1b[2;${color}m██"; | ||
81 | } | ||
82 | print "\x1b[0m\n\n"; | ||
83 | |||
84 | # now the color cube | ||
85 | print "Color cube, 6x6x6:\n"; | ||
86 | for ($green = 0; $green < 6; $green++) { | ||
87 | for ($red = 0; $red < 6; $red++) { | ||
88 | for ($blue = 0; $blue < 6; $blue++) { | ||
89 | $color = 16 + ($red * 36) + ($green * 6) + $blue; | ||
90 | print "\x1b[48;5;${color}m "; | ||
91 | } | ||
92 | print "\x1b[0m "; | ||
93 | } | ||
94 | print "\n"; | ||
95 | } | ||
96 | |||
97 | |||
98 | # now the grayscale ramp | ||
99 | print "Grayscale ramp:\n"; | ||
100 | for ($color = 232; $color < 256; $color++) { | ||
101 | print "\x1b[48;5;${color}m "; | ||
102 | } | ||
103 | print "\x1b[0m\n"; | ||
104 | |||