mirror of
https://github.com/NaomiAmethyst/dots.git
synced 2025-08-05 16:48:38 +00:00
colortest.pl: chmod +x and add the first 16 colors
This commit is contained in:
parent
02d6dffb6e
commit
b53f13f59c
1 changed files with 15 additions and 10 deletions
25
colortest.pl
Normal file → Executable file
25
colortest.pl
Normal file → Executable file
|
@ -5,29 +5,33 @@ use warnings;
|
||||||
|
|
||||||
# Generate the array
|
# Generate the array
|
||||||
|
|
||||||
my @steps = qw(00 5f 87 af d7 ff);
|
# Fill in the first 16 colors. The exact hex codes vary by terminal and device
|
||||||
my @arr;
|
# 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
|
||||||
|
);
|
||||||
|
|
||||||
# Main colors
|
# Main colors
|
||||||
my $COLOR_BASE = 16;
|
for my $num (16 .. 231) {
|
||||||
for my $num ($COLOR_BASE .. 231) {
|
push @arr, number_to_color($num);
|
||||||
$arr[$num] = number_to_color($num);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Gray scale
|
# Gray scale
|
||||||
my $GRAY_BASE = 232;
|
for my $num (232 .. 255) {
|
||||||
for my $num ($GRAY_BASE .. 255) {
|
|
||||||
my $hex = sprintf '%02x', 0x08 + 0x0a * ($num - $GRAY_BASE);
|
my $hex = sprintf '%02x', 0x08 + 0x0a * ($num - $GRAY_BASE);
|
||||||
$arr[$num] = join '/', ($hex) x 3;
|
push @arr, join '/', ($hex) x 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print "This is your standard text color.\n";
|
||||||
my $width = 6;
|
my $width = 6;
|
||||||
for my $num ($COLOR_BASE .. $#arr) {
|
for my $num (0 .. $#arr) {
|
||||||
print '[38;5;', $num, 'm';
|
print '[38;5;', $num, 'm';
|
||||||
printf '%02x: ', $num;
|
printf '%02x: ', $num;
|
||||||
print "$arr[$num] [0m ";
|
print "$arr[$num] [0m ";
|
||||||
print "\n" if ($num - $COLOR_BASE + 1) % $width == 0;
|
print "\n" if ($num + 1) % $width == 0;
|
||||||
}
|
}
|
||||||
|
print "\n";
|
||||||
|
|
||||||
|
|
||||||
sub number_to_color {
|
sub number_to_color {
|
||||||
|
@ -35,5 +39,6 @@ sub number_to_color {
|
||||||
my $num = shift;
|
my $num = shift;
|
||||||
$num -= 16;
|
$num -= 16;
|
||||||
|
|
||||||
|
my @steps = qw(00 5f 87 af d7 ff);
|
||||||
return join('/', $steps[($num / 36) % 6], $steps[($num / 6) % 6], $steps[$num % 6]);
|
return join('/', $steps[($num / 36) % 6], $steps[($num / 6) % 6], $steps[$num % 6]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue