-my %C = qw(red #EC1C24 blue #3953A3 yellow #F9EC31 black #231F20);
-my $U = 0; # optional unicode alternatives
+sub dispbar {
+ 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>',
+ $width * 2, 14, $width, 7, join(' ',
+ 'M0,0',
+ map {
+ join('m1,-7', ('v7') x $_->[0]), # line per bar width
+ (map { sprintf 'm%d,-7', $_ + 1 } $_->[1] || ()), # space forward
+ }
+ pairs @cols
+ )
+ );
+}