line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Spreadsheet::HTML::Presets::Beadwork; |
2
|
5
|
|
|
5
|
|
17
|
use strict; |
|
5
|
|
|
|
|
5
|
|
|
5
|
|
|
|
|
120
|
|
3
|
5
|
|
|
5
|
|
14
|
use warnings FATAL => 'all'; |
|
5
|
|
|
|
|
5
|
|
|
5
|
|
|
|
|
112
|
|
4
|
5
|
|
|
5
|
|
15
|
use Carp; |
|
5
|
|
|
|
|
4
|
|
|
5
|
|
|
|
|
238
|
|
5
|
|
|
|
|
|
|
|
6
|
5
|
|
|
5
|
|
1833
|
use Spreadsheet::HTML::File::Loader; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
4223
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub beadwork { |
9
|
0
|
|
|
0
|
1
|
|
my ($self,$data,$args); |
10
|
0
|
0
|
|
|
|
|
$self = shift if ref($_[0]) =~ /^Spreadsheet::HTML/; |
11
|
0
|
0
|
|
|
|
|
($self,$data,$args) = $self ? $self->_args( @_ ) : Spreadsheet::HTML::_args( @_ ); |
12
|
|
|
|
|
|
|
|
13
|
0
|
|
|
|
|
|
my %presets = ( |
14
|
|
|
|
|
|
|
dk => \&_dk, |
15
|
|
|
|
|
|
|
mario => \&_mario, |
16
|
|
|
|
|
|
|
'1up' => \&_1up, |
17
|
|
|
|
|
|
|
apple => \&_apple, |
18
|
|
|
|
|
|
|
cartman => \&_cartman, |
19
|
|
|
|
|
|
|
homer => \&_homer, |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
0
|
0
|
|
|
|
|
if ($args->{preset}) { |
23
|
0
|
|
|
|
|
|
my $sub = $presets{ $args->{preset} }; |
24
|
0
|
0
|
|
|
|
|
$sub->( $args ) if ref $sub eq 'CODE'; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
0
|
0
|
0
|
|
|
|
unless (defined $args->{art} and defined $args->{map}) { |
28
|
0
|
0
|
|
|
|
|
if (defined $args->{art}) { |
|
|
0
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
$args->{data} = [[ 'Error' ],[ 'map is required' ]]; |
30
|
|
|
|
|
|
|
} elsif (defined $args->{map}) { |
31
|
0
|
|
|
|
|
|
$args->{data} = [[ 'Error' ],[ 'art is required' ]]; |
32
|
|
|
|
|
|
|
} else { |
33
|
0
|
|
|
|
|
|
$args->{data} = [[ 'Error' ],[ 'art is required' ],[ 'map is required' ]]; |
34
|
|
|
|
|
|
|
} |
35
|
0
|
0
|
|
|
|
|
return $self ? $self->generate( %$args ) : Spreadsheet::HTML::generate( %$args ); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
0
|
0
|
|
|
|
|
if ($args->{art} !~ /\n/) { |
39
|
0
|
0
|
|
|
|
|
if (open FH, '<', $args->{art}) { |
40
|
0
|
|
|
|
|
|
$args->{art} = do{ local $/; }; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
close FH; |
42
|
|
|
|
|
|
|
} else { |
43
|
0
|
|
|
|
|
|
$args->{data} = [[ 'Error' ], ["Cannot read $args->{art}"]]; |
44
|
0
|
0
|
|
|
|
|
return $self ? $self->generate( %$args ) : Spreadsheet::HTML::generate( %$args ); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
0
|
0
|
0
|
|
|
|
if (!ref $args->{map} and -r $args->{map}) { |
49
|
0
|
|
|
|
|
|
$args->{map} = Spreadsheet::HTML::File::Loader::_parse({ file => $args->{map} }); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
0
|
0
|
|
|
|
|
unless (ref $args->{map}) { |
53
|
0
|
|
|
|
|
|
$args->{data} = [[ 'Error' ],[ 'map is not valid JSON' ]]; |
54
|
0
|
0
|
|
|
|
|
return $self ? $self->generate( %$args ) : Spreadsheet::HTML::generate( %$args ); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# override any mapped colors |
58
|
0
|
0
|
|
|
|
|
$args->{map}{'.'} = $args->{bgcolor} if defined $args->{bgcolor}; |
59
|
0
|
|
|
|
|
|
my %map_args = map {($_ => $args->{$_})} grep /^-\d+$/, keys %$args; |
|
0
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
for (keys %map_args) { |
61
|
0
|
|
|
|
|
|
(my $key) = $_ =~ /(\d+)/; |
62
|
0
|
|
|
|
|
|
$args->{map}{$key} = $map_args{$_}; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
my @lines = grep ! $_ =~ /^\s*$/, split /\n/, $args->{art}; |
66
|
0
|
|
|
|
|
|
my $total_rows = scalar @lines; |
67
|
0
|
|
|
|
|
|
my $total_cols; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
my @cells; |
70
|
0
|
|
|
|
|
|
for my $row (0 .. $#lines) { |
71
|
0
|
|
|
|
|
|
my @chars = split //, $lines[$row]; |
72
|
0
|
|
0
|
|
|
|
$total_cols ||= scalar @chars; |
73
|
0
|
|
|
|
|
|
for my $col (0 .. $#chars) { |
74
|
0
|
0
|
|
|
|
|
next unless my $color = $args->{map}{ $chars[$col] }; |
75
|
0
|
|
|
|
|
|
push @cells, ( |
76
|
|
|
|
|
|
|
"-r${row}c${col}" => { |
77
|
|
|
|
|
|
|
width => 16, |
78
|
|
|
|
|
|
|
height => 8, |
79
|
|
|
|
|
|
|
style => { 'background-color' => $color }, |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
my @args = ( |
86
|
|
|
|
|
|
|
@_, |
87
|
|
|
|
|
|
|
@cells, |
88
|
|
|
|
|
|
|
pinhead => 0, |
89
|
|
|
|
|
|
|
tgroups => 0, |
90
|
|
|
|
|
|
|
headless => 0, |
91
|
|
|
|
|
|
|
matrix => 1, |
92
|
|
|
|
|
|
|
fill => join( 'x', $total_rows, $total_cols ), |
93
|
|
|
|
|
|
|
); |
94
|
|
|
|
|
|
|
|
95
|
0
|
0
|
|
|
|
|
$self ? $self->generate( @args ) : Spreadsheet::HTML::generate( @args ); |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub _dk { |
99
|
0
|
|
|
0
|
|
|
my $args = shift; |
100
|
0
|
|
|
|
|
|
$args->{art} = ' |
101
|
|
|
|
|
|
|
.......................................... |
102
|
|
|
|
|
|
|
..................1111111................. |
103
|
|
|
|
|
|
|
.................414141414................ |
104
|
|
|
|
|
|
|
................11221112211............... |
105
|
|
|
|
|
|
|
...............1122221222211.............. |
106
|
|
|
|
|
|
|
............221122233233222122............ |
107
|
|
|
|
|
|
|
...........22211122312132211222........... |
108
|
|
|
|
|
|
|
...........22211122222222211222........... |
109
|
|
|
|
|
|
|
.........511122222221112222221115......... |
110
|
|
|
|
|
|
|
.......5511122222222222222222211155....... |
111
|
|
|
|
|
|
|
......511111222211111111111222111115...... |
112
|
|
|
|
|
|
|
....5511111122212222222222212211111155.... |
113
|
|
|
|
|
|
|
...511111111111222222222222211111111115... |
114
|
|
|
|
|
|
|
..11111511111112222222222222111111511111.. |
115
|
|
|
|
|
|
|
..11111155111111122222222211111155111111.. |
116
|
|
|
|
|
|
|
..11111115551111111111111111115551111111.. |
117
|
|
|
|
|
|
|
..11111111555122211111111222155511111111.. |
118
|
|
|
|
|
|
|
...111111111112222251152222211111111111... |
119
|
|
|
|
|
|
|
....1111111111121222552221211111111111.... |
120
|
|
|
|
|
|
|
.....11111111111222255222211111111111..... |
121
|
|
|
|
|
|
|
........11111112122255222121111111........ |
122
|
|
|
|
|
|
|
........51151522222522522222515115........ |
123
|
|
|
|
|
|
|
.......5111151555552222555551511115....... |
124
|
|
|
|
|
|
|
......511111111522222222225111111115...... |
125
|
|
|
|
|
|
|
.....51111111115252522525251111111115..... |
126
|
|
|
|
|
|
|
....5111111111115252521525111111111115.... |
127
|
|
|
|
|
|
|
....5111111111151151511511511111111115.... |
128
|
|
|
|
|
|
|
....5111111111111........1111111111115.... |
129
|
|
|
|
|
|
|
.....11111111111..........11111111111..... |
130
|
|
|
|
|
|
|
.....1111111111............1111111111..... |
131
|
|
|
|
|
|
|
...21221112212..............21221112212... |
132
|
|
|
|
|
|
|
..252212222122..............221222212252.. |
133
|
|
|
|
|
|
|
.252222222222................22222222225.. |
134
|
|
|
|
|
|
|
.......................................... |
135
|
|
|
|
|
|
|
'; |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
$args->{map} = { |
138
|
0
|
|
|
|
|
|
'.' => '#FFFFFF', |
139
|
|
|
|
|
|
|
1 => '#AA0000', |
140
|
|
|
|
|
|
|
2 => '#FFAA55', |
141
|
|
|
|
|
|
|
3 => '#FFFFFF', |
142
|
|
|
|
|
|
|
4 => '#D50000', |
143
|
|
|
|
|
|
|
5 => '#FF5500', |
144
|
|
|
|
|
|
|
}; |
145
|
|
|
|
|
|
|
|
146
|
0
|
|
|
|
|
|
return $args; |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
sub _1up { |
150
|
0
|
|
|
0
|
|
|
my $args = shift; |
151
|
|
|
|
|
|
|
|
152
|
0
|
|
|
|
|
|
$args->{art} = ' |
153
|
|
|
|
|
|
|
.................. |
154
|
|
|
|
|
|
|
......111111...... |
155
|
|
|
|
|
|
|
....1122223311.... |
156
|
|
|
|
|
|
|
...133222233331... |
157
|
|
|
|
|
|
|
..13222222233331.. |
158
|
|
|
|
|
|
|
..13223333222331.. |
159
|
|
|
|
|
|
|
.1222333333222221. |
160
|
|
|
|
|
|
|
.1222333333223321. |
161
|
|
|
|
|
|
|
.1322333333233331. |
162
|
|
|
|
|
|
|
.1332233332233331. |
163
|
|
|
|
|
|
|
.1332222222223321. |
164
|
|
|
|
|
|
|
.1322111111112221. |
165
|
|
|
|
|
|
|
..11133133133111.. |
166
|
|
|
|
|
|
|
...133313313331... |
167
|
|
|
|
|
|
|
...133333333331... |
168
|
|
|
|
|
|
|
....1333333331.... |
169
|
|
|
|
|
|
|
....11111111...... |
170
|
|
|
|
|
|
|
.................. |
171
|
|
|
|
|
|
|
'; |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
$args->{map} = { |
174
|
0
|
|
|
|
|
|
'.' => 'white', |
175
|
|
|
|
|
|
|
1 => 'black', |
176
|
|
|
|
|
|
|
2 => 'green', |
177
|
|
|
|
|
|
|
3 => 'white', |
178
|
|
|
|
|
|
|
}; |
179
|
|
|
|
|
|
|
|
180
|
0
|
|
|
|
|
|
return $args; |
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
sub _mario { |
184
|
0
|
|
|
0
|
|
|
my $args = shift; |
185
|
|
|
|
|
|
|
|
186
|
0
|
|
|
|
|
|
$args->{art} = ' |
187
|
|
|
|
|
|
|
............... |
188
|
|
|
|
|
|
|
....111111..... |
189
|
|
|
|
|
|
|
...1111111111.. |
190
|
|
|
|
|
|
|
...22244434.... |
191
|
|
|
|
|
|
|
..24244443444.. |
192
|
|
|
|
|
|
|
..242244442444. |
193
|
|
|
|
|
|
|
..22444442222.. |
194
|
|
|
|
|
|
|
....44444444... |
195
|
|
|
|
|
|
|
...3313331..... |
196
|
|
|
|
|
|
|
..33313331333.. |
197
|
|
|
|
|
|
|
.3333111113333. |
198
|
|
|
|
|
|
|
.4431111111344. |
199
|
|
|
|
|
|
|
.4441111111444. |
200
|
|
|
|
|
|
|
.4411111111144. |
201
|
|
|
|
|
|
|
...111...111... |
202
|
|
|
|
|
|
|
..333.....333.. |
203
|
|
|
|
|
|
|
.2222.....2222. |
204
|
|
|
|
|
|
|
............... |
205
|
|
|
|
|
|
|
'; |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
$args->{map} = { |
208
|
0
|
|
|
|
|
|
'.' => 'white', |
209
|
|
|
|
|
|
|
1 => '#D91F26', # red |
210
|
|
|
|
|
|
|
2 => '#481E1D', # black |
211
|
|
|
|
|
|
|
3 => '#3D59A8', # blue |
212
|
|
|
|
|
|
|
4 => '#F5Af9D', # flesh |
213
|
|
|
|
|
|
|
}; |
214
|
|
|
|
|
|
|
|
215
|
0
|
|
|
|
|
|
return $args; |
216
|
|
|
|
|
|
|
} |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
sub _apple { |
219
|
0
|
|
|
0
|
|
|
my $args = shift; |
220
|
|
|
|
|
|
|
|
221
|
0
|
|
|
|
|
|
$args->{art} = ' |
222
|
|
|
|
|
|
|
............................... |
223
|
|
|
|
|
|
|
...................11.......... |
224
|
|
|
|
|
|
|
..................111.......... |
225
|
|
|
|
|
|
|
.................111........... |
226
|
|
|
|
|
|
|
................111............ |
227
|
|
|
|
|
|
|
................11............. |
228
|
|
|
|
|
|
|
................1.............. |
229
|
|
|
|
|
|
|
.........111111...1111111...... |
230
|
|
|
|
|
|
|
.......11111111111111111111.... |
231
|
|
|
|
|
|
|
.....111111111111111111111111.. |
232
|
|
|
|
|
|
|
....2222222222222222222222222.. |
233
|
|
|
|
|
|
|
...2222222222222222222222222... |
234
|
|
|
|
|
|
|
..2222222222222222222222222.... |
235
|
|
|
|
|
|
|
..2222222222222222222222222.... |
236
|
|
|
|
|
|
|
..333333333333333333333333..... |
237
|
|
|
|
|
|
|
.3333333333333333333333333..... |
238
|
|
|
|
|
|
|
.3333333333333333333333333..... |
239
|
|
|
|
|
|
|
.3333333333333333333333333..... |
240
|
|
|
|
|
|
|
.4444444444444444444444444..... |
241
|
|
|
|
|
|
|
..4444444444444444444444444.... |
242
|
|
|
|
|
|
|
..4444444444444444444444444.... |
243
|
|
|
|
|
|
|
..444444444444444444444444444.. |
244
|
|
|
|
|
|
|
..5555555555555555555555555555. |
245
|
|
|
|
|
|
|
...555555555555555555555555555. |
246
|
|
|
|
|
|
|
...555555555555555555555555555. |
247
|
|
|
|
|
|
|
....5555555555555555555555555.. |
248
|
|
|
|
|
|
|
.....66666666666666666666666... |
249
|
|
|
|
|
|
|
......666666666...666666666.... |
250
|
|
|
|
|
|
|
.......6666666.....6666666..... |
251
|
|
|
|
|
|
|
........66666.......66666...... |
252
|
|
|
|
|
|
|
............................... |
253
|
|
|
|
|
|
|
'; |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
$args->{map} = { |
256
|
0
|
|
|
|
|
|
'.' => 'white', |
257
|
|
|
|
|
|
|
1 => '#28921c', # green |
258
|
|
|
|
|
|
|
2 => '#ffc620', # yellow |
259
|
|
|
|
|
|
|
3 => '#ff7f27', # orange |
260
|
|
|
|
|
|
|
4 => '#ff1c1c', # red |
261
|
|
|
|
|
|
|
5 => '#ba2049', # purple |
262
|
|
|
|
|
|
|
6 => '#1c51db', # blue |
263
|
|
|
|
|
|
|
}; |
264
|
|
|
|
|
|
|
|
265
|
0
|
|
|
|
|
|
return $args; |
266
|
|
|
|
|
|
|
} |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
sub _cartman { |
269
|
0
|
|
|
0
|
|
|
my $args = shift; |
270
|
|
|
|
|
|
|
|
271
|
0
|
|
|
|
|
|
$args->{art} = ' |
272
|
|
|
|
|
|
|
................................. |
273
|
|
|
|
|
|
|
..............11111.............. |
274
|
|
|
|
|
|
|
............112222211............ |
275
|
|
|
|
|
|
|
..........1122322322311.......... |
276
|
|
|
|
|
|
|
........11333333333333311........ |
277
|
|
|
|
|
|
|
.......1333333333333333331....... |
278
|
|
|
|
|
|
|
......133333313333313333331...... |
279
|
|
|
|
|
|
|
......133444441222144443331...... |
280
|
|
|
|
|
|
|
.....13444411111411111444431..... |
281
|
|
|
|
|
|
|
.....14444155551415555144441..... |
282
|
|
|
|
|
|
|
....1444415555551555555144441.... |
283
|
|
|
|
|
|
|
....1444415555151515555144441.... |
284
|
|
|
|
|
|
|
....1444415555551555555144441.... |
285
|
|
|
|
|
|
|
....1444441555514155551444441.... |
286
|
|
|
|
|
|
|
....1444444111144411114444441.... |
287
|
|
|
|
|
|
|
.....14444444444444444444441..... |
288
|
|
|
|
|
|
|
.....14444444444444444444441..... |
289
|
|
|
|
|
|
|
....1114444444444444444444111.... |
290
|
|
|
|
|
|
|
...166614444444444444444416661... |
291
|
|
|
|
|
|
|
..16666614444444111444441666661.. |
292
|
|
|
|
|
|
|
..11666661444441444444416666611.. |
293
|
|
|
|
|
|
|
.1221661661144444444411661661221. |
294
|
|
|
|
|
|
|
.1222116666611111111166666112221. |
295
|
|
|
|
|
|
|
.1222216666666666666666666122221. |
296
|
|
|
|
|
|
|
.1221216666666666666666666121221. |
297
|
|
|
|
|
|
|
..11616666666666666666666661611.. |
298
|
|
|
|
|
|
|
...166666666666666666666666661... |
299
|
|
|
|
|
|
|
...111111116666666666666666661... |
300
|
|
|
|
|
|
|
...177777771166661111111111111... |
301
|
|
|
|
|
|
|
...17777777771111777777777771.... |
302
|
|
|
|
|
|
|
....1771111117777111111117771.... |
303
|
|
|
|
|
|
|
....1111111111111111111111111.... |
304
|
|
|
|
|
|
|
................................. |
305
|
|
|
|
|
|
|
'; |
306
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
$args->{map} = { |
308
|
0
|
|
|
|
|
|
'.' => 'white', |
309
|
|
|
|
|
|
|
1 => 'black', # black |
310
|
|
|
|
|
|
|
2 => '#ffd800', # yellow |
311
|
|
|
|
|
|
|
3 => '#0094ff', # blue |
312
|
|
|
|
|
|
|
4 => '#ffbd77', # tan |
313
|
|
|
|
|
|
|
5 => 'white', # white |
314
|
|
|
|
|
|
|
6 => 'red', # red |
315
|
|
|
|
|
|
|
7 => '#7f3300', # brown |
316
|
|
|
|
|
|
|
}; |
317
|
|
|
|
|
|
|
|
318
|
0
|
|
|
|
|
|
return $args; |
319
|
|
|
|
|
|
|
} |
320
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
sub _homer { |
322
|
0
|
|
|
0
|
|
|
my $args = shift; |
323
|
|
|
|
|
|
|
|
324
|
0
|
|
|
|
|
|
$args->{art} = ' |
325
|
|
|
|
|
|
|
........................ |
326
|
|
|
|
|
|
|
....1111................ |
327
|
|
|
|
|
|
|
...111..1............... |
328
|
|
|
|
|
|
|
..11..111111............ |
329
|
|
|
|
|
|
|
.1.11122222211.......... |
330
|
|
|
|
|
|
|
.1.122222222221......... |
331
|
|
|
|
|
|
|
..12122222222221........ |
332
|
|
|
|
|
|
|
..12222222222221........ |
333
|
|
|
|
|
|
|
.1222222222222221....... |
334
|
|
|
|
|
|
|
.122222222222222111..... |
335
|
|
|
|
|
|
|
.1222222222111113331.... |
336
|
|
|
|
|
|
|
.12222222213333133331... |
337
|
|
|
|
|
|
|
.12222222133333313131... |
338
|
|
|
|
|
|
|
.12222222133333313331... |
339
|
|
|
|
|
|
|
..122122213331331111.... |
340
|
|
|
|
|
|
|
..1221122213333122221... |
341
|
|
|
|
|
|
|
..1112212221111222221... |
342
|
|
|
|
|
|
|
..1.1122222222221111.... |
343
|
|
|
|
|
|
|
....11122222211144441... |
344
|
|
|
|
|
|
|
....122222221444444441.. |
345
|
|
|
|
|
|
|
....122122214444444441.. |
346
|
|
|
|
|
|
|
.....112221444444444441. |
347
|
|
|
|
|
|
|
......12221414444444441. |
348
|
|
|
|
|
|
|
......1222141111111111.. |
349
|
|
|
|
|
|
|
......1222144444441..... |
350
|
|
|
|
|
|
|
......122221444441...... |
351
|
|
|
|
|
|
|
......122221444441...... |
352
|
|
|
|
|
|
|
.....112222214441....... |
353
|
|
|
|
|
|
|
....13311222211111...... |
354
|
|
|
|
|
|
|
....133331122222131..... |
355
|
|
|
|
|
|
|
...113333331122213311... |
356
|
|
|
|
|
|
|
..1331333333112213331... |
357
|
|
|
|
|
|
|
........................ |
358
|
|
|
|
|
|
|
'; |
359
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
$args->{map} = { |
361
|
0
|
|
|
|
|
|
'.' => 'white', |
362
|
|
|
|
|
|
|
1 => 'black', # black |
363
|
|
|
|
|
|
|
2 => '#ffd800', # yellow |
364
|
|
|
|
|
|
|
3 => 'white', # white |
365
|
|
|
|
|
|
|
4 => '#7f3300', # brown |
366
|
|
|
|
|
|
|
}; |
367
|
|
|
|
|
|
|
|
368
|
0
|
|
|
|
|
|
return $args; |
369
|
|
|
|
|
|
|
} |
370
|
|
|
|
|
|
|
|
371
|
|
|
|
|
|
|
1; |
372
|
|
|
|
|
|
|
|
373
|
|
|
|
|
|
|
=head1 NAME |
374
|
|
|
|
|
|
|
|
375
|
|
|
|
|
|
|
Spreadsheet::HTML::Presets::Beadwork - Generate patterns in HTML table cell backgrounds. |
376
|
|
|
|
|
|
|
|
377
|
|
|
|
|
|
|
=head1 DESCRIPTION |
378
|
|
|
|
|
|
|
|
379
|
|
|
|
|
|
|
This is a container for L preset methods. |
380
|
|
|
|
|
|
|
These methods are not meant to be called from this package. |
381
|
|
|
|
|
|
|
Instead, use the Spreadsheet::HTML interface: |
382
|
|
|
|
|
|
|
|
383
|
|
|
|
|
|
|
use Spreadsheet::HTML; |
384
|
|
|
|
|
|
|
my $generator = Spreadsheet::HTML->new; |
385
|
|
|
|
|
|
|
print $generator->beadwork( |
386
|
|
|
|
|
|
|
art => '/path/to/ascii-art.txt', |
387
|
|
|
|
|
|
|
map => '/path/to/mappings.json', |
388
|
|
|
|
|
|
|
); |
389
|
|
|
|
|
|
|
|
390
|
|
|
|
|
|
|
# or |
391
|
|
|
|
|
|
|
use Spreadsheet::HTML qw( beadwork ); |
392
|
|
|
|
|
|
|
print beadwork( |
393
|
|
|
|
|
|
|
art => '/path/to/ascii-art.txt', |
394
|
|
|
|
|
|
|
map => '/path/to/mappings.json', |
395
|
|
|
|
|
|
|
); |
396
|
|
|
|
|
|
|
|
397
|
|
|
|
|
|
|
=head1 METHODS |
398
|
|
|
|
|
|
|
|
399
|
|
|
|
|
|
|
=over 4 |
400
|
|
|
|
|
|
|
|
401
|
|
|
|
|
|
|
=item * C |
402
|
|
|
|
|
|
|
|
403
|
|
|
|
|
|
|
Generates beadwork patters in the name of ASCII art. |
404
|
|
|
|
|
|
|
|
405
|
|
|
|
|
|
|
beadwork( |
406
|
|
|
|
|
|
|
art => '/path/to/ascii-art.txt', |
407
|
|
|
|
|
|
|
map => '/path/to/mappings.json', |
408
|
|
|
|
|
|
|
bgcolor => 'gray', |
409
|
|
|
|
|
|
|
) |
410
|
|
|
|
|
|
|
|
411
|
|
|
|
|
|
|
C contains the ASCII picture and C |
412
|
|
|
|
|
|
|
for each symbol in the ASCII picture in a hash. See source code |
413
|
|
|
|
|
|
|
for preset examples of the art and map data structures. |
414
|
|
|
|
|
|
|
|
415
|
|
|
|
|
|
|
Some prefabricated examples are available via the C param: |
416
|
|
|
|
|
|
|
|
417
|
|
|
|
|
|
|
=over 4 |
418
|
|
|
|
|
|
|
|
419
|
|
|
|
|
|
|
=item * C |
420
|
|
|
|
|
|
|
|
421
|
|
|
|
|
|
|
=item * C |
422
|
|
|
|
|
|
|
|
423
|
|
|
|
|
|
|
=item * C<1up> |
424
|
|
|
|
|
|
|
|
425
|
|
|
|
|
|
|
=item * C |
426
|
|
|
|
|
|
|
|
427
|
|
|
|
|
|
|
=item * C |
428
|
|
|
|
|
|
|
|
429
|
|
|
|
|
|
|
=item * C |
430
|
|
|
|
|
|
|
|
431
|
|
|
|
|
|
|
=back |
432
|
|
|
|
|
|
|
|
433
|
|
|
|
|
|
|
beadwork( preset => 'dk' ) |
434
|
|
|
|
|
|
|
|
435
|
|
|
|
|
|
|
Mapped colors can be overriden by their key number: |
436
|
|
|
|
|
|
|
|
437
|
|
|
|
|
|
|
beadwork( |
438
|
|
|
|
|
|
|
art => '/path/to/ascii-art.txt', |
439
|
|
|
|
|
|
|
map => '/path/to/mappings.json', |
440
|
|
|
|
|
|
|
-3 => 'blue', |
441
|
|
|
|
|
|
|
) |
442
|
|
|
|
|
|
|
|
443
|
|
|
|
|
|
|
Works well with presets. Change Cartman's cap and mitten colors: |
444
|
|
|
|
|
|
|
|
445
|
|
|
|
|
|
|
beadwork( preset => 'cartman', -2 => 'purple', -3 => 'green' ) |
446
|
|
|
|
|
|
|
|
447
|
|
|
|
|
|
|
=back |
448
|
|
|
|
|
|
|
|
449
|
|
|
|
|
|
|
=head1 SEE ALSO |
450
|
|
|
|
|
|
|
|
451
|
|
|
|
|
|
|
=over 4 |
452
|
|
|
|
|
|
|
|
453
|
|
|
|
|
|
|
=item L |
454
|
|
|
|
|
|
|
|
455
|
|
|
|
|
|
|
The interface for this functionality. |
456
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
=item L |
458
|
|
|
|
|
|
|
|
459
|
|
|
|
|
|
|
More presets. |
460
|
|
|
|
|
|
|
|
461
|
|
|
|
|
|
|
=back |
462
|
|
|
|
|
|
|
|
463
|
|
|
|
|
|
|
=head1 AUTHOR |
464
|
|
|
|
|
|
|
|
465
|
|
|
|
|
|
|
Jeff Anderson, C<< >> |
466
|
|
|
|
|
|
|
|
467
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
468
|
|
|
|
|
|
|
|
469
|
|
|
|
|
|
|
Copyright 2017 Jeff Anderson. |
470
|
|
|
|
|
|
|
|
471
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
472
|
|
|
|
|
|
|
under the terms of the the Artistic License (2.0). You may obtain a |
473
|
|
|
|
|
|
|
copy of the full license at: |
474
|
|
|
|
|
|
|
|
475
|
|
|
|
|
|
|
L |
476
|
|
|
|
|
|
|
|
477
|
|
|
|
|
|
|
Any use, modification, and distribution of the Standard or Modified |
478
|
|
|
|
|
|
|
Versions is governed by this Artistic License. By using, modifying or |
479
|
|
|
|
|
|
|
distributing the Package, you accept this license. Do not use, modify, |
480
|
|
|
|
|
|
|
or distribute the Package, if you do not accept this license. |
481
|
|
|
|
|
|
|
|
482
|
|
|
|
|
|
|
If your Modified Version has been derived from a Modified Version made |
483
|
|
|
|
|
|
|
by someone other than you, you are nevertheless required to ensure that |
484
|
|
|
|
|
|
|
your Modified Version complies with the requirements of this license. |
485
|
|
|
|
|
|
|
|
486
|
|
|
|
|
|
|
This license does not grant you the right to use any trademark, service |
487
|
|
|
|
|
|
|
mark, tradename, or logo of the Copyright Holder. |
488
|
|
|
|
|
|
|
|
489
|
|
|
|
|
|
|
This license includes the non-exclusive, worldwide, free-of-charge |
490
|
|
|
|
|
|
|
patent license to make, have made, use, offer to sell, sell, import and |
491
|
|
|
|
|
|
|
otherwise transfer the Package with respect to any patent claims |
492
|
|
|
|
|
|
|
licensable by the Copyright Holder that are necessarily infringed by the |
493
|
|
|
|
|
|
|
Package. If you institute patent litigation (including a cross-claim or |
494
|
|
|
|
|
|
|
counterclaim) against any party alleging that the Package constitutes |
495
|
|
|
|
|
|
|
direct or contributory patent infringement, then this Artistic License |
496
|
|
|
|
|
|
|
to you shall terminate on the date that such litigation is filed. |
497
|
|
|
|
|
|
|
|
498
|
|
|
|
|
|
|
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER |
499
|
|
|
|
|
|
|
AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. |
500
|
|
|
|
|
|
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
501
|
|
|
|
|
|
|
PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY |
502
|
|
|
|
|
|
|
YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR |
503
|
|
|
|
|
|
|
CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR |
504
|
|
|
|
|
|
|
CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, |
505
|
|
|
|
|
|
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
506
|
|
|
|
|
|
|
|
507
|
|
|
|
|
|
|
=cut |
508
|
|
|
|
|
|
|
|
509
|
|
|
|
|
|
|
1; |