-
Notifications
You must be signed in to change notification settings - Fork 4
/
hitbar.pl
executable file
·101 lines (87 loc) · 2.08 KB
/
hitbar.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
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/usr/bin/perl
use strict;
use warnings;
my $players = ['p1', 'p2'];
my $colors = {
p1 => {
pure => {
r => 255,
g => 177,
b => 41,
},
text => 'black',
},
p2 => {
pure => {
r => 6,
g => 164,
b => 235,
},
text => 'black',
},
miss => {
color => '#000000',
text => 'white',
},
};
my $steps = 5;
sub initial_color{
my ($p) = @_;
return (
$colors->{$p}{pure}{r} * 0.75,
$colors->{$p}{pure}{g} * 0.75,
$colors->{$p}{pure}{b} * 0.75,
);
}
sub final_color{
my ($p) = @_;
return (
($colors->{$p}{pure}{r} + 0xff) / 2,
($colors->{$p}{pure}{g} + 0xff) / 2,
($colors->{$p}{pure}{b} + 0xff) / 2,
);
}
print <<EOF;
.hitbar {
width: 100%;
height: 2em;
border-spacing: 0px;
margin-top: 1em;
margin-bottom: 1em;
text-align: center;
}
EOF
print ".miss {\n";
print " color: $colors->{miss}{text};\n";
print " background-color: $colors->{miss}{color};\n";
print "}\n\n";
for my $p (@$players){
my ($r, $g, $b);
my ($final_r, $final_g, $final_b);
my ($step_r, $step_g, $step_b);
($r, $g, $b) = initial_color($p);
($final_r, $final_g, $final_b) = final_color($p);
$step_r = ($final_r - $r) / $steps;
$step_g = ($final_g - $g) / $steps;
$step_b = ($final_b - $b) / $steps;
# solid backgrounds
for my $i (1 .. $steps + 1){
print ".$p-hit-$i {\n";
print " color: $colors->{$p}{text};\n";
printf " background-color: #%02x%02x%02x;\n", $r, $g, $b;
print "}\n\n";
if($i < $steps){
$r += $step_r;
$g += $step_g;
$b += $step_b;
}
}
# Do another few steps at the same level in case they made a crazy
# custom unit
for my $i ($steps + 1 .. 2 * $steps){
print ".$p-hit-$i {\n";
print " color: $colors->{$p}{text};\n";
printf " background-color: #%02x%02x%02x;\n", $r, $g, $b;
print "}\n\n";
}
}