X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/54c3aaa2e77d7a750f5e2173ae2f56bbe17988a2..9f0a6057388ceffc00f22ae5fe9a28250cc338be:/writing-latn.inc.pl diff --git a/writing-latn.inc.pl b/writing-latn.inc.pl index 2fbdb46..5921802 100644 --- a/writing-latn.inc.pl +++ b/writing-latn.inc.pl @@ -1,18 +1,37 @@ use 5.014; use utf8; -use List::Util qw( pairs ); +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 disptap { - return map { - !m/\A(-?)(\d)(\d)/ ? $_ : - $1.join(' ', - '·' x $2, '·' x $3, - ); - } @_; + my $code = shift; + $code =~ m/\A(-?)(\d)(\d)/ or return $code; + return $1 . join(' ', '·' x $2, '·' x $3); } -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( + '', + $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 + ) + ); +} ( 'Uppercase' => [qw{ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z }], @@ -84,14 +103,14 @@ my $U = 0; # optional unicode alternatives .- -... -.-. -.. . ..-. --. .... .. .--- -.- .-.. -- -. --- .--. --.- .-. ... - ..- ...- .-- -..- -.-- --.. }], -'Tap code' => [disptap(qw{ +'Tap code' => [map { disptap($_) } qw{ 11 12 13 14 15 21 22 23 > 24 25 31 32 33 34 35 41 42 43 44 45 51 52 53 54 55 -})], -'Short Tap' => [disptap(qw{ +}], +'Short Tap' => [map { disptap($_) } qw{ 11 12 13 14 21 22 23 20 > 31 -13 32 33 30 41 42 -13 43 40 10 51 52 53 50 -31 -40 -})], +}], 'Cards' => [( map { chr(0x1F0A0 + $_), sprintf('%s', chr(0x1F0B0 + $_)) } # spades, hearts 1 .. 11, 13, 14 # A 2-10 J Q K @@ -265,24 +284,11 @@ my $U = 0; # optional unicode alternatives 201112 102112 202111 101212 201211 102211 102121 0 101221 ) ], -'Code 93' => [ - map { - sprintf - '', - 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 31121 - ) -], +'Code 93' => [map { dispbar($_) } qw( + 211113 211212 211311 221112 221211 231111 112113 112212 112311 122112 + 132111 111123 111222 111321 121122 131121 212112 212211 211122 211221 + 221121 222111 112122 112221 122121 123111 311211 +)], 'Code 128' => [ map { $U ? tr/1-3-/❘❙❚ /r : sprintf '',