-
Notifications
You must be signed in to change notification settings - Fork 84
/
color_palette.pl
executable file
·41 lines (37 loc) · 973 Bytes
/
color_palette.pl
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
#!/usr/bin/perl
#
# Copyright (c) 2020 Ran Panfeng. All rights reserved.
# Author: satanson
# Email: ranpanf@gmail.com
# Github repository: https://github.com/satanson/cpp_etudes.git
use strict;
use warnings;
my ($expect_fg, $expect_bg, $expect_ef) = @ARGV;
my @fg = (31 .. 37, 90 .. 97);
my @bg = (31 .. 47, 100 .. 106);
my @ef = (1 .. 7);
my $count = 0;
for (1 .. @fg * @bg * @ef) {
#my $i=($_-1)/(@bg*@ef);
#my $j=($_-1)%(@bg*@ef)/@ef;
#my $k=($_-1)%@ef;
my $i = ($_ - 1) / (@bg * @ef);
my $j = ($_ - 1) % (@bg * @ef) / @ef;
my $k = ($_ - 1) % @ef;
my $fg = $fg[$i];
my $bg = $bg[$j];
my $ef = $ef[$k];
if ((!defined($expect_fg) || $expect_fg == $fg) &&
(!defined($expect_bg) || $expect_bg == $bg) &&
(!defined($expect_ef) || $expect_ef == $ef)) {
print "\e[${fg};${bg};${ef}m \\e[${fg};${bg};${ef}m\\e[m\e[m";
if (($count) % 7 == 6) {
print "\n";
}
else {
print " ";
}
$count += 1;
}
}
print "\n";