-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
crossmake
executable file
·75 lines (64 loc) · 1.51 KB
/
crossmake
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/perl
# vim:ft=perl:
# abstract: makes cross's in all kinds of shapes and colors
# btime 2010-04-02
# mtime 2016-09-03 22:21:23
use strict;
use Getopt::Long;
use List::Util qw(shuffle);
our($color, $char, $space, $ansi, $size);
my @colors;
GetOptions(
'color!' => \$color,
'char=s' => \$char,
'space=s' => \$space,
'size=i' => \$size,
'ansi!' => \$ansi,
'help' => \&help,
);
for(my $i = 0; $i < ($ansi ? 16 : 256); $i++) {
push(@colors, sprintf("\033[38;5;%dm", $i));
}
my @chars = shuffle(qw([♥] ♥ o O x X));
my @space = shuffle(('▇', '▕', '#'));
my $token = $char // $chars[0];
my $ws = $space // $space[0];
my $count = $size // 8;
my $endesc = "\033[0m";
my $c;
for(my $i = 0; $i < $count; ++$i) {
if($i % 2 == 0) {
@colors = shuffle(@colors);
$c = $colors[0] unless ! $color;
}
else {
@colors = shuffle(@colors);
$c = $colors[0] unless ! $color;
}
my $j = (2 * $count) - ($i * 2);
print $c, $ws x $i, $token, $ws x $j, $token, $ws x $i, "\n";
}
for(my $i = $count; $i > 0; --$i) {
if($i % 2 == 0) {
@colors = shuffle(@colors);
$c = $colors[0] unless ! $color;
}
else {
@colors = shuffle(@colors);
$c = $colors[0] unless ! $color;
}
my $j = (2 * $count) - ($i * 2);
print $c, $ws x $i, $token, $ws x $j, $token, $ws x $i, "\n";
}
sub help {
print << "HLEP";
USAGE
$0 [OPTIONS]
OPTIONS
--(no)color
--char char
--space " "
--size size of painting (default: 8)
HLEP
exit 0;
}