use 5.014;
use utf8;
-use List::Util qw( pairs sum );
+use List::Util qw( pairs pairmap sum );
my %C = qw(red #EC1C24 blue #3953A3 yellow #F9EC31 black #231F20);
my $U = 0; # optional unicode alternatives
}
sub dispbar {
- my @cols = split //, shift; # bar and space widths
+ my $code = shift;
+
+ return join '', pairmap {
+ ($a =~ tr/123/❘❙❚/r) . ($b =~ tr/321/ /dr)
+ } split //, $code if $U;
+
+ my @cols = split //, $code; # bar and space widths
my $width = sum(@cols);
return sprintf(
'<svg width="%d" height="%d" viewBox="-.5 0 %d %d"><path d="%s"/></svg>',