-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathcolorx
executable file
·57 lines (51 loc) · 1.56 KB
/
colorx
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/perl
# abstract: print defined colors in an X shape
use strict;
my @c = map { sprintf("\e[38;5;%dm", $_) } (0..15);
my $ws = ' ';
my $color = {
0 => sprintf("%12s", 'black'),
8 => sprintf("%12s", 'bright black'),
1 => sprintf("%12s", 'red'),
9 => sprintf("%12s", 'bright red'),
2 => sprintf("%12s", 'green'),
10 => sprintf("%12s", 'bright green'),
3 => sprintf("%12s", 'yellow'),
11 => sprintf("%12s", 'bright yellow'),
4 => sprintf("%12s", 'blue'),
12 => sprintf("%12s", 'bright blue'),
5 => sprintf("%12s", 'magenta'),
13 => sprintf("%12s", 'bright magenta'),
6 => sprintf("%12s", 'cyan'),
14 => sprintf("%12s", 'bright cyan'),
7 => sprintf("%12s", 'white'),
15 => sprintf("%12s", 'bright white'),
};
for(my $i = 0; $i < 15; $i++) {
my $j = (2 * 16) - ($i * 2);
my $ci = $i;
if($ci == 15) {
$ci = 0;
}
printf("%s%s%s%s\e[m%s%s%s%s\e[m%s%s\n",
$c[ $ci ], $ws x $i, $c[$ci + 0],
($color->{$i} =~ m/bright/) ? "\e[1m$color->{$i}\e[m" : $color->{$i},
$c[$ci], $ws x $j, $c[$ci + 0],
($color->{$i} =~ m/bright/) ? "\e[1m$color->{$i}\e[m" : $color->{$i},
$c[$ci], $ws x $i,
);
}
for(my $k = 15; $k > -1; $k--) {
my $j = (2 * 16) - ($k * 2);
my $ci = $k;
if($ci == 0) {
$ci = 15;
}
printf("%s%s%s%s\e[m%s%s%s%s\e[m%s%s\n",
$c[ $ci ], $ws x $k, $c[$ci + 0],
($color->{$k} =~ m/bright/) ? "\e[1m$color->{$k}\e[m" : $color->{$k},
$c[$ci], $ws x $j, $c[$ci + 0],
($color->{$k} =~ m/bright/) ? "\e[1m$color->{$k}\e[m" : $color->{$k},
$c[$ci], $ws x $k,
);
}