2008-12-19 16:47:42 -06:00
|
|
|
|
#! /usr/bin/env perl
|
|
|
|
|
|
2008-12-19 18:44:48 -06:00
|
|
|
|
# Generate the array
|
2008-12-19 16:47:42 -06:00
|
|
|
|
|
2008-12-19 22:55:52 -06:00
|
|
|
|
# Fill in the first 16 colors. The exact hex codes vary by terminal and device
|
|
|
|
|
# This table comes from our .Xresources file. It should be close enough.
|
|
|
|
|
my @arr = qw(
|
|
|
|
|
2e/34/36 cc/00/00 4e/9a/06 c4/a0/00 34/65/a4 75/50/7b 06/98/9a d3/d7/cf
|
|
|
|
|
55/57/53 ef/29/29 8a/e2/34 fc/e9/4f 72/9f/cf ad/7f/a8 34/e2/e2 ee/ee/ec
|
|
|
|
|
);
|
2008-12-19 16:47:42 -06:00
|
|
|
|
|
2008-12-19 18:44:48 -06:00
|
|
|
|
# Main colors
|
2008-12-19 22:55:52 -06:00
|
|
|
|
for my $num (16 .. 231) {
|
|
|
|
|
push @arr, number_to_color($num);
|
2008-12-19 18:44:48 -06:00
|
|
|
|
}
|
2008-12-19 16:47:42 -06:00
|
|
|
|
|
2008-12-19 18:44:48 -06:00
|
|
|
|
# Gray scale
|
2008-12-19 22:55:52 -06:00
|
|
|
|
for my $num (232 .. 255) {
|
2008-12-20 01:43:19 -06:00
|
|
|
|
my $hex = sprintf '%02x', 0x08 + 0x0a * ($num - 232);
|
2008-12-19 22:55:52 -06:00
|
|
|
|
push @arr, join '/', ($hex) x 3;
|
2008-12-19 18:44:48 -06:00
|
|
|
|
}
|
2008-12-19 16:47:42 -06:00
|
|
|
|
|
2008-12-19 22:55:52 -06:00
|
|
|
|
print "This is your standard text color.\n";
|
2008-12-19 18:44:48 -06:00
|
|
|
|
my $width = 6;
|
2008-12-19 22:55:52 -06:00
|
|
|
|
for my $num (0 .. $#arr) {
|
2008-12-19 18:44:48 -06:00
|
|
|
|
print '[38;5;', $num, 'm';
|
2008-12-20 01:43:19 -06:00
|
|
|
|
printf '%03d: ', $num;
|
|
|
|
|
print "$arr[$num] [0m";
|
2008-12-19 22:55:52 -06:00
|
|
|
|
print "\n" if ($num + 1) % $width == 0;
|
2008-12-19 18:44:48 -06:00
|
|
|
|
}
|
2008-12-19 22:55:52 -06:00
|
|
|
|
print "\n";
|
2008-12-19 16:47:42 -06:00
|
|
|
|
|
|
|
|
|
|
2008-12-19 18:44:48 -06:00
|
|
|
|
sub number_to_color {
|
|
|
|
|
my $num = shift;
|
|
|
|
|
$num -= 16;
|
2008-12-19 16:47:42 -06:00
|
|
|
|
|
2008-12-19 22:55:52 -06:00
|
|
|
|
my @steps = qw(00 5f 87 af d7 ff);
|
2008-12-19 18:44:48 -06:00
|
|
|
|
return join('/', $steps[($num / 36) % 6], $steps[($num / 6) % 6], $steps[$num % 6]);
|
2008-12-19 16:47:42 -06:00
|
|
|
|
}
|