summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorBoris Faure <billiob@gmail.com>2014-05-07 20:47:50 +0200
committerBoris Faure <billiob@gmail.com>2014-05-07 20:47:50 +0200
commit3635ab98bd8cf2ea72095ede057f766b00266791 (patch)
tree670d8da06809c2e38768608fffa501a9cbc4629f /tools
parentdda26aa4bdf2ec4b60fdb4aae19427840a066f31 (diff)
add 256color.pl
Diffstat (limited to 'tools')
-rwxr-xr-xtools/256color.pl104
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
10for ($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
24for ($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:
34print "(256) System colors: background\n";
35for ($color = 0; $color < 8; $color++) {
36 print "\x1b[48;5;${color}m ";
37}
38print "\x1b[0m\n";
39for ($color = 8; $color < 16; $color++) {
40 print "\x1b[48;5;${color}m ";
41}
42print "\x1b[0m\n\n";
43
44print "System colors: background\n";
45for ($color = 40; $color < 48; $color++) {
46 print "\x1b[${color}m ";
47}
48print "\x1b[0m\n";
49for ($color = 100; $color < 108; $color++) {
50 print "\x1b[${color}m ";
51}
52print "\x1b[0m\n\n";
53
54print "System colors: foreground\n";
55for ($color = 30; $color < 38; $color++) {
56 print "\x1b[0;${color}m██";
57}
58print "\x1b[0m\n";
59for ($color = 90; $color < 98; $color++) {
60 print "\x1b[0;${color}m██";
61}
62print "\x1b[0m\n\n";
63
64print "Bright colors:\n";
65for ($color = 30; $color < 38; $color++) {
66 print "\x1b[1;${color}m██";
67}
68print "\x1b[0m\n";
69for ($color = 90; $color < 98; $color++) {
70 print "\x1b[1;${color}m██";
71}
72print "\x1b[0m\n\n";
73
74print "Dim/Faint colors:\n";
75for ($color = 30; $color < 38; $color++) {
76 print "\x1b[2;${color}m██";
77}
78print "\x1b[0m\n";
79for ($color = 90; $color < 98; $color++) {
80 print "\x1b[2;${color}m██";
81}
82print "\x1b[0m\n\n";
83
84# now the color cube
85print "Color cube, 6x6x6:\n";
86for ($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
99print "Grayscale ramp:\n";
100for ($color = 232; $color < 256; $color++) {
101 print "\x1b[48;5;${color}m ";
102}
103print "\x1b[0m\n";
104