use utf8;
+use List::Util qw( pairs );
sub disptap {
return map {
!m/\A(-?)(\d)(\d)/ ? $_ :
- $1.sprintf('%s<br>%s',
+ $1.join(' ',
'·' x $2, '·' x $3,
);
} @_;
'Flag semaphore' => [
map {
local $_ = $_;
- s/[1-4]\K(?=[4-9])/ /;
+ s/[1-4]\K(?=[4-9])/ /; # prevent unwanted vertical crossing
tr/1-9/↙←↖↑↗→↘↓/;
s{(\S)(?=.)}{<span style="position:absolute">$1</span>};
$_
my ($r, $pr, $pl) = split //, $_;
/^\D$/ ? $_ : sprintf(
join('',
- '<svg width="20" height="20" viewBox="0 0 10 15">',
+ '<svg width="16" height="20" viewBox="0 0 10 15">',
'<path d="M5,6 v7"/>',
'<path d="M0,%s h10 %s" transform="rotate(%d 5 6)"/>',
'</svg>',
'Prussian semaphore' => [
map { /^\D+$/ ? $_ : sprintf
join('',
- '<svg width="20" height="20" viewBox="0 0 8 18">',
+ '<svg width="10" height="20" viewBox="0 0 8 18">',
'<path d="M4,1 v18"/>',
(map {(
qq(<path d="M0 $_ h4" transform="rotate(%d 4 $_)"/>),
201112 102112 202111 101212 201211 102211
)
],
+'Code 93' => [
+ map {
+ sprintf
+ '<svg width="18" height="14" viewBox="-.5 0 9 7"><path d="M0,0 %s"/></svg>',
+ join ' ',
+ map {
+ join('m1,-7', ('v7') x $_->[0]), # line per bar width
+ (map { sprintf 'm%d,-7', $_ + 1 } $_->[1] || ()), # space forward
+ }
+ pairs split //
+ }
+ # bar and space widths (1-3)
+ qw(
+ 21111 21121 21131 22111 22121 23111 11211 11221 11231
+ 12211 13211 11112 11122 11132 12112 13112 21211 21221
+ 21112 21122 22112 22211 11212 11222 12212 12311
+ )
+],
'Code 128' => [
map { $U ? tr/1-3-/❘❙❚ /r : sprintf
- '<svg width="20" height="14" viewBox="-.5 0 10 7"><path d="M0,0 %s"/></svg>',
+ '<svg width="22" height="14" viewBox="-.5 0 11 7"><path d="M0,0 %s"/></svg>',
join ' ',
map {
$_ eq '' ? 'm2,-7' :