+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 . chr(0x1F031 + ($2 * 7) + $3) if $U; # offset from domino tile horizontal-00-00
+ 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 or return '';
+
+ 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
+ )
+ );
+}
(
'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 }],
'Lowercase' => [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 }],
-'Sütterlin' => [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 }],
+'Sütterlin' => [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 }],
'Old Roman Cursive' => [
map { m/^(-?)(\w.*)/ ? $1.'<svg width="20" height="20" viewBox="0 0 12 20"><path d="'.$2.'"/></svg>' : $_ }
"m2,4 c1,2 8,9 8,9 M2,15 6,9",
806a9c 89Aa9c 800a9c945aaa
0 965aa6
}],
+'Unistrokes' => [
+ map { '<svg width="14" height="16" viewBox="-1 -1 8 10">'.$_.'</svg>' }
+ map {
+ sprintf('<circle cx="%s" cy="%s" r="1"/>', m/\AM(\d+),(\d+)(.?)/) . # start point
+ (!!$3 && qq(<path d="$_"/>))
+ }
+ 'M3,8 V0',
+ 'M0,0 6,4 0,8',
+ 'M6,0 0,4 6,8',
+ 'M6,0 0,4 6,8',
+ 'M6,4 H0',
+ 'M6,0 0,0 0,8',
+ 'M0,8 6,8 6,0',
+ 'M0,0 6,0 6,8',
+ 'M3,0 V8',
+ 'M6,0 6,8 0,8',
+ 'M0,8 6,0',
+ 'M0,0 0,8 6,8',
+ 'M6,8 3,0 0,8',
+ 'M0,8 3,0 6,8',
+ 'M6,0 Q0,6 3,8 6,6 0,0',
+ 'M0,0 Q4,8 6,4 4,0 0,8',
+ 'M6,0 Q2,8 0,4 2,0 6,8',
+ 'M0,0 6,8',
+ 'M6,0 0,0 6,8 0,8',
+ 'M0,4 H6',
+ 'M6,0 3,8 0,0',
+ 'M0,0 3,8 6,0',
+ 'M0,0 0,8 6,0 6,8',
+ 'M0,0 Q6,6 3,8 0,6 6,0',
+ 'M6,0 0,8',
+ 'M0,0 6,0 0,8 6,8',
+ 'M3,4',
+],
+# 'Palm Graffiti' => [
'<abbr title="International Telegraph Alphabet">ITA</abbr>2' => [
map { tr/01/○●/r =~ s/..\K/ /r } qw(
11000 10011 01110 10010 10000 10110 01011 00101 01100 11010 11110 01001 00111
.- -... -.-. -.. . ..-. --. .... .. .--- -.- .-.. --
-. --- .--. --.- .-. ... - ..- ...- .-- -..- -.-- --..
}],
-'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
-})],
-'Tap simplified' => [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('<b>%s</b>', chr(0x1F0B0 + $_)) } # spades, hearts
1 .. 11, 13, 14 # A 2-10 J Q K
131001 231301 000202 023302 230003 032003 201003 101003
)
],
-'Code 39' => [
- # ISO/IEC 16388
- map { tr/012/ ❘❙/r } qw(
- 211012 121012 221011 112012 212011 122011 111022 211021 121021 112021
- 211102 121102 221101 112102 212101 122101 111202 211201 121201 112201
- 201112 102112 202111 101212 201211 102211 102121
- )
-],
-'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 31121
- )
-],
-'Code 128' => [
- map { $U ? tr/1-3-/❘❙❚ /r : sprintf
- '<svg width="22" height="14" viewBox="-.5 0 11 7"><path d="M0,0 %s"/></svg>',
- join ' ',
- map {
- $_ eq '' ? 'm2,-7' :
- $_ eq '.' ? 'm3,-7' :
- $_ eq ':' ? 'm4,-7' :
- join 'm1,-7', ('v7') x $_
- }
- split /([.:])?/ # each bar [123] and space [ .:]
- }
- # bar widths (1-3) followed by space of width 1 (implied), 2 (.) or 3 (:)
- qw(
- 11:2 1:12 1:1:2 12:1 1:21 1:2:1 21:1 2:11 2:1:1 123 12:3 1:23 132
- 13:2 1:32 332 21:3 2:13 231 23:1 233 312 31:2 3:12 321 32:1 22.2
- )
-],
+'Code 39' => [map { dispbar($_) } qw(
+ 2111121121 1121121121 2121121111 1111221121 2111221111 1121221111
+ 1111122121 2111122111 1121122111 1111222111 2111111221 1121111221
+ 2121111211 1111211221 2111211211 1121211211 1111112221 2111112211
+ 1121112211 1111212211 2211111121 1221111121 2221111111 1211211121
+ 2211211111 1221211111 1221112111 0 1211212111
+)], # ISO/IEC 16388
+'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 0 111141
+)],
+'Code 128' => [map { dispbar($_) } qw(
+ 111323 131123 131321 112313 132113 132311 211313 231113 231311 112133
+ 112331 132131 113123 113321 133121 313121 211331 231131 213113 213311
+ 213131 311123 311321 331121 312113 312311 212222 0 211412 2331112
+)],
'<abbr title="Royal Mail 4-State Customer Code">RM4SCC</abbr>' => [
- map { sprintf
- '<svg width="20" height="20" viewBox="0 0 8 6">'
- . '<path d="M1%s"/></svg>',
- join ' m2',
- map { sprintf ',%dv%dm0,-%d',
- ($_ & 1 ? 0 : 2), 2 + ($_ & 2) + ($_ & 1) * 2,
- ($_ & 1 ? 0 : 2) + 2 + ($_ & 2) + ($_ & 1) * 2,
- }
- split //
+ map {
+ my $len = length $_;
+ !$len ? '' : sprintf(
+ '<svg width="%d" height="20" viewBox="0 0 %d 6">'
+ . '<path d="M1%s"/></svg>',
+ $len * 5, $len * 2,
+ join ' m2',
+ map { sprintf ',%dv%dm0,-%d',
+ ($_ & 1 ? 0 : 2), 2 + ($_ & 2) + ($_ & 1) * 2,
+ ($_ & 1 ? 0 : 2) + 2 + ($_ & 2) + ($_ & 1) * 2,
+ }
+ split //
+ );
}
qw(
2121 2301
1032 1212 1230 3012 3030 3210
1122 1302 1320 3102 3120 3300
0033
- ) # 0 for space
+ ), # 0 for space
+ '', 1, 3 # start/end
+],
+"D'ni" => [
+ map {
+ state $window = 'M-.5,-.5H8.5V8.5H-.5Z';
+ state $v = [
+ '',
+ 'M0,4 8,4',
+ 'M0,8 Q4,4 8,8',
+ 'M0,4 4,8 8,4',
+ 'M2,0 2,4 8,4',
+ 'M0,0 8,8 M0,8 8,0', # cross
+ 'M3.5,4 h1', # dot
+ ];
+ state $h = [
+ '',
+ 'M4,0 4,8',
+ 'M0,0 Q4,4 0,8',
+ 'M4,-.5 0,4 4,8.5',
+ 'M4,8 4,2 8,2',
+ ];
+ sprintf '<svg width="16" height="16" viewBox="-.5 -.5 9 9"><path d="%s"/></svg>',
+ $window . ($h->[$_ % 5] . $v->[$_ / 5] || $v->[6]);
+ } 0 .. 5*5
],
'Pigpen' => [
map {