File Coverage

blib/lib/Text/ASCII/Stylize.pm
Criterion Covered Total %
statement 7 9 77.7
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 10 12 83.3


line stmt bran cond sub pod time code
1             # ABSTRACT: Turns figlets into styled figlets
2 1     1   873 use strict;
  1         3  
  1         51  
3 1     1   7 use warnings;
  1         2  
  1         59  
4             package Text::ASCII::Stylize;
5 1     1   292 use Moose;
  0            
  0            
6             use YAML::Tiny;
7             use Try::Tiny;
8             use Getopt::Long;
9             use Clone 'clone';
10             use Data::Dumper;
11              
12             use constant DEFAULT_FORMAT => 'id-software';
13              
14             has 'in' => (
15             is => 'rw',
16             isa => 'ArrayRef'
17             );
18              
19             has 'dib' => (
20             is => 'rw',
21             isa => 'ArrayRef'
22             );
23              
24             has 'stack' => (
25             is => 'rw',
26             isa => 'ArrayRef'
27             );
28              
29             has 'yaml' => (
30             is => 'rw',
31             isa => 'Object'
32             );
33              
34             has 'format' => (
35             is => 'rw',
36             isa => 'Str',
37             );
38              
39             has 'do_gap' => (
40             is => 'rw',
41             isa => 'Bool'
42             );
43              
44             has 'do_letters' => (
45             is => 'rw',
46             isa => 'Bool'
47             );
48              
49             has 'do_fill' => (
50             is => 'rw',
51             isa => 'Bool'
52             );
53              
54             has 'do_pad' => (
55             is => 'rw',
56             isa => 'Bool'
57             );
58              
59             has 'do_shadow' => (
60             is => 'rw',
61             isa => 'Bool'
62             );
63              
64             has 'do_margin' => (
65             is => 'rw',
66             isa => 'Bool'
67             );
68              
69             has 'do_sequences' => (
70             is => 'rw',
71             isa => 'Bool'
72             );
73             sub main {
74             my ($self) = @_;
75            
76             $self->proc_options();
77            
78             $self->defaults();
79            
80             $self->proc_yaml();
81            
82             $self->proc_in();
83            
84             $self->proc_seq();
85            
86             $self->blit();
87             }
88              
89             sub put {
90             my ($self,$x,$y,$ch) = @_;
91             try {
92             $self->dib->[$y]->[$x] = $ch;
93             } catch {
94             return(0);
95             };
96             }
97              
98             sub get {
99             my ($self,$x,$y) = @_;
100             my $ret;
101            
102             return(0) if $x < 0 || $y < 0;
103            
104             try {
105             $ret = $self->dib->[$y]->[$x];
106             } catch {
107             return(0);
108             };
109              
110             return($ret) if $ret;
111             return(0);
112             }
113              
114             sub rio {
115             my ($self,$x,$y,$ch,$w) = @_;
116             if(&$w) {
117             $self->put($x,$y,$ch);
118             }
119             }
120              
121             sub rio_deferred {
122             my ($self,$x,$y,$ch,$w) = @_;
123             if(&$w) {
124             my %item = ( x => $x, y=> $y,ch => $ch );
125             push(@{$self->stack}, \%item);
126             }
127             }
128              
129             sub put_stack {
130             my ($self,$x,$y,$ch,$w) = @_;
131            
132             my @stack = reverse(@{$self->stack});
133             for my $item (@stack) {
134             $self->put($item->{x},$item->{y},$item->{ch});
135             }
136             }
137              
138             sub proc {
139             my ($self) = @_;
140            
141             # fill
142             if($self->do_fill) {
143             $self->fill();
144             $self->put_stack();
145             }
146            
147             if($self->do_letters) {
148             # full
149             $self->letters_full();
150            
151             # horizontal
152             $self->letters_left();
153             $self->letters_right();
154            
155             # vertical
156             $self->letters_top_half();
157             $self->letters_bottom_half();
158            
159             # diagonal
160             $self->letters_top_left();
161             $self->letters_bottom_left();
162             $self->letters_top_right();
163             $self->letters_bottom_right();
164             }
165            
166             #gap
167             if($self->do_gap) {
168             $self->gap();
169             $self->put_stack();
170             }
171             }
172              
173             sub letters_full {
174             my ($self) = @_;
175             my ($idx_x,$idx_y) = (0,0);
176             for my $y (@{$self->dib}) {
177             for my $x (@{$y}) {
178             $self->rio($idx_x,$idx_y,$self->yaml->[0]->{preset}->{letters}->{blocks}->{full},sub {
179             my $block = $self->get($idx_x,$idx_y);
180             if($block =~ /[|\$&\()V\/\\=\:\<\>;8+#%MW]/) {
181             1;
182             } else {
183             0;
184             }
185             });
186             $idx_x++;
187             }
188             $idx_x = 0;
189             $idx_y++;
190             }
191             }
192              
193             sub letters_top_half {
194             my ($self) = @_;
195             my ($idx_x,$idx_y) = (0,0);
196             for my $y (@{$self->dib}) {
197             for my $x (@{$y}) {
198             $self->rio($idx_x,$idx_y,$self->yaml->[0]->{preset}->{letters}->{blocks}->{'top-half'},sub {
199             my $block = $self->get($idx_x,$idx_y);
200             if($block =~ /[-'`*Y"]/) {
201             1;
202             } else {
203             0;
204             }
205             });
206             $idx_x++;
207             }
208             $idx_x = 0;
209             $idx_y++;
210             }
211             }
212              
213             sub letters_top_left {
214             my ($self) = @_;
215             my ($idx_x,$idx_y) = (0,0);
216             for my $y (@{$self->dib}) {
217             for my $x (@{$y}) {
218             $self->rio($idx_x,$idx_y,$self->yaml->[0]->{preset}->{letters}->{blocks}->{'top-left'},sub {
219             my $block = $self->get($idx_x,$idx_y);
220             my $block_above = ($self->get($idx_x,$idx_y - 1) || ' ');
221             my $block_left = ($self->get($idx_x - 1,$idx_y) || ' ');
222             if($block_left =~ /[\s]/ && $block_above =~ /[\s]/ && $block =~ /[^\s]/) {
223             1;
224             } else {
225             0;
226             }
227             });
228             $idx_x++;
229             }
230             $idx_x = 0;
231             $idx_y++;
232             }
233             }
234              
235             sub letters_top_right {
236             my ($self) = @_;
237             my ($idx_x,$idx_y) = (0,0);
238             for my $y (@{$self->dib}) {
239             for my $x (@{$y}) {
240             $self->rio($idx_x,$idx_y,$self->yaml->[0]->{preset}->{letters}->{blocks}->{'top-right'},sub {
241             my $block = $self->get($idx_x,$idx_y);
242             my $block_above = ($self->get($idx_x,$idx_y - 1) || ' ');
243             my $block_diag = ($self->get($idx_x + 1,$idx_y - 1) || ' ');
244             my $block_right = ($self->get($idx_x + 1,$idx_y) || ' ');
245             if($block_right =~ /[\s]/ && $block_above =~ /[\s]/ && $block_diag =~ /[\s]/ && $block =~ /[^\s]/) {
246             return(1);
247             } else {
248             return(0);
249             }
250             });
251             $idx_x++;
252             }
253             $idx_x = 0;
254             $idx_y++;
255             }
256             }
257              
258             sub letters_left {
259             my ($self) = @_;
260             my ($idx_x,$idx_y) = (0,0);
261             for my $y (@{$self->dib}) {
262             for my $x (@{$y}) {
263             $self->rio($idx_x,$idx_y,$self->yaml->[0]->{preset}->{letters}->{blocks}->{'left'},sub {
264             my $block = $self->get($idx_x,$idx_y);
265             if($block =~ /[{\[]/) {
266             return(1);
267             } else {
268             return(0);
269             }
270             });
271             $idx_x++;
272             }
273             $idx_x = 0;
274             $idx_y++;
275             }
276             }
277              
278             sub letters_right {
279             my ($self) = @_;
280             my ($idx_x,$idx_y) = (0,0);
281             for my $y (@{$self->dib}) {
282             for my $x (@{$y}) {
283             $self->rio($idx_x,$idx_y,$self->yaml->[0]->{preset}->{letters}->{blocks}->{'right'},sub {
284             my $block = $self->get($idx_x,$idx_y);
285             if($block =~ /[}\]]/) {
286             return(1);
287             } else {
288             return(0);
289             }
290             });
291             $idx_x++;
292             }
293             $idx_x = 0;
294             $idx_y++;
295             }
296             }
297              
298             sub letters_bottom_left {
299             my ($self) = @_;
300             my ($idx_x,$idx_y) = (0,0);
301             for my $y (@{$self->dib}) {
302             for my $x (@{$y}) {
303             $self->rio($idx_x,$idx_y,$self->yaml->[0]->{preset}->{letters}->{blocks}->{'bottom-left'},sub {
304             my $block = $self->get($idx_x,$idx_y);
305             my $block_below = ($self->get($idx_x,$idx_y + 1) || ' ');
306             my $block_diag = ($self->get($idx_x - 1,$idx_y + 1) || ' ');
307             my $block_left = ($self->get($idx_x - 1,$idx_y) || ' ');
308             if($block_left =~ /[\s]/ && $block_below =~ /[\s]/ && $block_diag =~ /[\s]/ && $block =~ /[^\s]/) {
309             return(1);
310             } else {
311             return(0);
312             }
313             });
314             $idx_x++;
315             }
316             $idx_x = 0;
317             $idx_y++;
318             }
319             }
320              
321             sub letters_bottom_right {
322             my ($self) = @_;
323             my ($idx_x,$idx_y) = (0,0);
324             for my $y (@{$self->dib}) {
325             for my $x (@{$y}) {
326             $self->rio($idx_x,$idx_y,$self->yaml->[0]->{preset}->{letters}->{blocks}->{'bottom-right'},sub {
327             my $block = $self->get($idx_x,$idx_y);
328             my $block_below = ($self->get($idx_x,$idx_y + 1) || ' ');
329             my $block_diag = ($self->get($idx_x + 1,$idx_y + 1) || ' ');
330             my $block_right = ($self->get($idx_x + 1,$idx_y) || ' ');
331             if($block_right =~ /[\s]/ && $block_below =~ /[\s]/ && $block_diag =~ /[\s]/ && $block =~ /[^\s]/) {
332             return(1);
333             } else {
334             return(0);
335             }
336             });
337             $idx_x++;
338             }
339             $idx_x = 0;
340             $idx_y++;
341             }
342             }
343              
344             sub letters_bottom_half {
345             my ($self) = @_;
346             my ($idx_x,$idx_y) = (0,0);
347             for my $y (@{$self->dib}) {
348             for my $x (@{$y}) {
349             $self->rio($idx_x,$idx_y,$self->yaml->[0]->{preset}->{letters}->{blocks}->{'bottom-half'},sub {
350             my $block = $self->get($idx_x,$idx_y);
351             if($block =~ /[_,weaoxcnszmv]/) {
352             return(1);
353             } else {
354             return(0);
355             }
356             });
357             $idx_x++;
358             }
359             $idx_x = 0;
360             $idx_y++;
361             }
362             }
363              
364             sub fill {
365             my ($self) = @_;
366             my ($idx_x,$idx_y) = (0,0);
367             for my $y (@{$self->dib}) {
368             for my $x (@{$y}) {
369             $self->rio_deferred($idx_x,$idx_y,$self->yaml->[0]->{preset}->{letters}->{blocks}->{'fill'},sub {
370             my $block = $self->get($idx_x,$idx_y);
371             my $block_above = ($self->get($idx_x,$idx_y - 1) || ' ');
372             my $block_below = ($self->get($idx_x,$idx_y + 1) || ' ');
373             my $block_left = ($self->get($idx_x - 1,$idx_y) || ' ');
374             my $block_right = ($self->get($idx_x + 1,$idx_y) || ' ');
375             my $block_diag1 = ($self->get($idx_x - 1,$idx_y - 1) || ' ');
376             my $block_diag2 = ($self->get($idx_x - 1,$idx_y + 1) || ' ');
377             my $block_diag3 = ($self->get($idx_x + 1,$idx_y - 1) || ' ');
378             my $block_diag4 = ($self->get($idx_x + 1,$idx_y + 1) || ' ');
379             if(($block_below =~ /[\s]/ && $block_above =~ /[\s]/ && $block_right =~ /[\s]/ && $block_left =~ /[\s]/) && $block =~ /[\s]/ && $block_diag1 =~ /[\s]/ && $block_diag2 =~ /[\s]/ && $block_diag3 =~ /[\s]/ && $block_diag4 =~ /[\s]/) {
380             return(1);
381             } else {
382             return(0);
383             }
384             });
385             $idx_x++;
386             }
387             $idx_x = 0;
388             $idx_y++;
389             }
390             }
391              
392             sub gap {
393             my ($self) = @_;
394             my ($idx_x,$idx_y) = (0,0);
395             for my $y (@{$self->dib}) {
396             for my $x (@{$y}) {
397             $self->rio_deferred($idx_x,$idx_y,$self->yaml->[0]->{preset}->{letters}->{blocks}->{'gap'},sub {
398             my $block = $self->get($idx_x,$idx_y);
399             my $block_diag1 = ($self->get($idx_x - 1,$idx_y - 1) || ' ');
400             my $block_diag2 = ($self->get($idx_x + 1,$idx_y - 1) || ' ');
401             my $block_diag3 = ($self->get($idx_x - 1,$idx_y + 1) || ' ');
402             my $block_diag4 = ($self->get($idx_x + 1,$idx_y + 1) || ' ');
403             my $block_above = ($self->get($idx_x,$idx_y - 1) || ' ');
404             my $block_below = ($self->get($idx_x,$idx_y + 1) || ' ');
405             my $block_left = ($self->get($idx_x - 1,$idx_y) || ' ');
406             my $block_right = ($self->get($idx_x + 1,$idx_y) || ' ');
407             if((($block_below =~ /[^\s]/ && $block_above =~ /[^\s]/ && $block =~ /[\s]/) || ($block_left =~ /[^\s]/ && $block_right =~ /[^\s]/))&& ($block_diag1 =~ /[^\s]/ || $block_diag2 =~ /[^\s]/ || $block_diag3 =~ /[^\s]/ || $block_diag4 =~ /[^\s]/)) {
408             return(1);
409             } else {
410             return(0);
411             }
412             });
413             $idx_x++;
414             }
415             $idx_x = 0;
416             $idx_y++;
417             }
418            
419             return(0);
420             }
421              
422             sub proc_options {
423             my $self = shift;
424            
425             my $opt_format = DEFAULT_FORMAT;
426            
427             my $opt_do_fill = 0;
428             my $opt_do_gap = 0;
429             my $opt_do_letters = 0;
430             my $opt_do_pad = 0;
431             my $opt_do_shadow = 0;
432             my $opt_do_margin = 0;
433             my $opt_do_sequence = 0;
434            
435             #eval {
436             GetOptions(
437             'format=s' => \$opt_format,
438             'do-pad' => \$opt_do_pad,
439             'do-letters' => \$opt_do_letters,
440             'do-fill' => \$opt_do_fill,
441             'do-gap' => \$opt_do_gap,
442             'do-shadow' => \$opt_do_shadow,
443             'do-margin' => \$opt_do_margin,
444             'do-sequences' => \$opt_do_sequence,
445             );
446            
447             $self->format($opt_format);
448             $self->do_pad($opt_do_pad);
449             $self->do_letters($opt_do_letters);
450             $self->do_fill($opt_do_fill);
451             $self->do_gap($opt_do_gap);
452             $self->do_shadow($opt_do_shadow) if $opt_do_pad;
453             $self->do_margin($opt_do_margin) if $opt_do_pad;
454             $self->do_sequences($opt_do_sequence) if $opt_do_pad;
455             #};
456            
457             #die "Regrettably, this is not a valid format option. Choose one of (id-software or seth-able)." if $@;
458            
459             return(0);
460             }
461              
462             sub proc_seq {
463             my ($self) = @_;
464             $self->proc;
465             }
466              
467             sub proc_yaml {
468             my ($self) = @_;
469             open(my $yaml_filehandle,'<','/home/jmcveigh/.text-ascii-stylize/' . $self->format . '.yml') or die('cannot open < format.yml');
470             my @lines = <$yaml_filehandle>;
471             close($yaml_filehandle);
472              
473             my $yaml = YAML::Tiny->read_string("@lines");
474             $self->yaml($yaml);
475             }
476              
477             sub defaults {
478             my ($self) = @_;
479             my @in = <>;
480             my @stack = [];
481             $self->in(\@in);
482             $self->stack(@stack);
483             }
484              
485             sub blit {
486             my ($self) = @_;
487             for my $y (@{$self->dib}) {
488             for my $x (@{$y}) {
489             print $x if $x;
490             }
491             print "\n";
492             }
493             }
494              
495             sub proc_in {
496             my ($self) = @_;
497            
498             my @rows = @{$self->in};
499             my @dib;
500            
501             my @pad;
502             my (@seq_top,@seq_bottom,@seq_right,@seq_left);
503             my @shadow;
504             my (@margin_bottom,@margin_top);
505             my $max_length = 0;
506             my ($margin,$margin_unset);
507            
508             ($margin,$margin_unset) = (2,4) if $self->do_margin;
509             ($margin,$margin_unset) = (0,4) unless $self->do_margin;
510            
511             if($self->do_pad) {
512            
513             $max_length = length($rows[2]) + 3 if $self->do_pad;
514             $max_length = length($rows[2]) unless $self->do_pad;
515            
516             if($self->do_sequences) {
517             my $seq_length = $max_length + 2;
518             my $seq_height = $#rows + 2;
519             my $idx_center = $seq_length / 2;
520             my $idx_middle = $seq_height / 2;
521            
522             my $idx_top_seq_left_begin = 1;
523             my $idx_top_seq_center_begin = $idx_center - (length($self->yaml->[0]->{preset}->{sequences}->{top}->{center}) / 2);
524             my $idx_top_seq_right_begin = $seq_length - length($self->yaml->[0]->{preset}->{sequences}->{top}->{right});
525              
526             my $idx_bottom_seq_left_begin = 1;
527             my $idx_bottom_seq_center_begin = $idx_center - (length($self->yaml->[0]->{preset}->{sequences}->{bottom}->{center}) / 2);
528             my $idx_bottom_seq_right_begin = $seq_length - length($self->yaml->[0]->{preset}->{sequences}->{bottom}->{right});
529            
530             # blank row
531             for(my $icount = 0;$icount < $seq_length;$icount++) {
532             push(@seq_top,$self->yaml->[0]->{preset}->{letters}->{blocks}->{empty});
533             push(@seq_bottom,$self->yaml->[0]->{preset}->{letters}->{blocks}->{empty});
534             }
535            
536             # top left
537             for(my $icount = $idx_top_seq_left_begin;$icount < $idx_top_seq_left_begin + length($self->yaml->[0]->{preset}->{sequences}->{top}->{left});$icount++) {
538             $seq_top[$icount] = substr($self->yaml->[0]->{preset}->{sequences}->{top}->{left},$icount - $idx_top_seq_left_begin,1);
539             }
540            
541             # top center
542             for(my $icount = $idx_top_seq_center_begin;$icount < $idx_top_seq_center_begin + length($self->yaml->[0]->{preset}->{sequences}->{top}->{center});$icount++) {
543             $seq_top[$icount] = substr($self->yaml->[0]->{preset}->{sequences}->{top}->{center},$icount - $idx_top_seq_center_begin,1);
544             }
545            
546             # top right
547             for(my $icount = $idx_top_seq_right_begin;$icount < $idx_top_seq_right_begin + length($self->yaml->[0]->{preset}->{sequences}->{top}->{right});$icount++) {
548             $seq_top[$icount] = substr($self->yaml->[0]->{preset}->{sequences}->{top}->{right},$icount - $idx_top_seq_right_begin,1);
549             }
550            
551             # bottom left
552             for(my $icount = $idx_bottom_seq_left_begin;$icount < $idx_bottom_seq_left_begin + length($self->yaml->[0]->{preset}->{sequences}->{bottom}->{left});$icount++) {
553             $seq_bottom[$icount] = substr($self->yaml->[0]->{preset}->{sequences}->{bottom}->{left},$icount - $idx_bottom_seq_left_begin,1);
554             }
555            
556             # bottom center
557             for(my $icount = $idx_bottom_seq_center_begin;$icount < $idx_bottom_seq_center_begin + length($self->yaml->[0]->{preset}->{sequences}->{bottom}->{center});$icount++) {
558             $seq_bottom[$icount] = substr($self->yaml->[0]->{preset}->{sequences}->{bottom}->{center},$icount - $idx_bottom_seq_center_begin,1);
559             }
560            
561             # bottom right
562             for(my $icount = $idx_bottom_seq_right_begin;$icount < $idx_bottom_seq_right_begin + length($self->yaml->[0]->{preset}->{sequences}->{bottom}->{right});$icount++) {
563             $seq_bottom[$icount] = substr($self->yaml->[0]->{preset}->{sequences}->{bottom}->{right},$icount - $idx_bottom_seq_right_begin,1);
564             }
565             }
566            
567             push @pad,$self->yaml->[0]->{preset}->{letters}->{blocks}->{pad};
568             push @pad,$self->yaml->[0]->{preset}->{letters}->{blocks}->{pad};
569            
570             push @shadow,$self->yaml->[0]->{preset}->{letters}->{blocks}->{pad};
571             push @shadow,$self->yaml->[0]->{preset}->{letters}->{blocks}->{pad};
572             push @shadow,$self->yaml->[0]->{preset}->{letters}->{blocks}->{pad};
573             push @shadow,$self->yaml->[0]->{preset}->{letters}->{blocks}->{pad} if $self->do_margin;
574            
575             push @margin_top,$self->yaml->[0]->{preset}->{letters}->{blocks}->{pad};
576             push @margin_top,$self->yaml->[0]->{preset}->{letters}->{blocks}->{pad};
577             push @margin_top,$self->yaml->[0]->{preset}->{letters}->{blocks}->{pad};
578            
579             push @margin_bottom,$self->yaml->[0]->{preset}->{letters}->{blocks}->{pad};
580             push @margin_bottom,$self->yaml->[0]->{preset}->{letters}->{blocks}->{pad};
581             push @margin_bottom,$self->yaml->[0]->{preset}->{letters}->{blocks}->{pad};
582            
583             for(my $icount = 0;$icount < $max_length + $margin;$icount++) {
584             push @pad,$self->yaml->[0]->{preset}->{letters}->{blocks}->{pad};
585             }
586            
587             for(my $icount = 0;$icount < $max_length - ($margin_unset);$icount++) {
588             push @shadow,$self->yaml->[0]->{preset}->{letters}->{blocks}->{'shadow'};
589             }
590            
591             for(my $icount = 0;$icount < $max_length - $margin;$icount++) {
592             push @margin_bottom,$self->yaml->[0]->{preset}->{letters}->{blocks}->{'empty'};
593             push @margin_top,$self->yaml->[0]->{preset}->{letters}->{blocks}->{'empty'};
594             }
595            
596             push @shadow,$self->yaml->[0]->{preset}->{letters}->{blocks}->{pad} if $self->do_margin;
597             push @shadow,$self->yaml->[0]->{preset}->{letters}->{blocks}->{pad};
598             push @shadow,$self->yaml->[0]->{preset}->{letters}->{blocks}->{pad};
599             push @shadow,$self->yaml->[0]->{preset}->{letters}->{blocks}->{pad};
600            
601             push @margin_top,$self->yaml->[0]->{preset}->{letters}->{blocks}->{pad};
602             push @margin_top,$self->yaml->[0]->{preset}->{letters}->{blocks}->{pad};
603             push @margin_top,$self->yaml->[0]->{preset}->{letters}->{blocks}->{pad};
604            
605             push @margin_bottom,$self->yaml->[0]->{preset}->{letters}->{blocks}->{pad};
606             push @margin_bottom,$self->yaml->[0]->{preset}->{letters}->{blocks}->{pad};
607             push @margin_bottom,$self->yaml->[0]->{preset}->{letters}->{blocks}->{pad};
608            
609             push @dib,clone(\@seq_top) if $self->do_sequences;
610             push @dib,clone(\@pad);
611             push @dib,clone(\@pad);
612             push @dib,clone(\@shadow) if $self->do_shadow;
613             push @dib,clone(\@margin_top) if $self->do_margin;
614             }
615            
616             for my $y (@rows) {
617            
618             my @row;
619              
620             chomp($y);
621            
622             if($self->do_pad) {
623             push @row,$self->yaml->[0]->{preset}->{letters}->{blocks}->{pad};
624             push @row,$self->yaml->[0]->{preset}->{letters}->{blocks}->{pad};
625             push @row,$self->yaml->[0]->{preset}->{letters}->{blocks}->{pad};
626             push @row,' ' if $self->do_margin;
627            
628             for(my $x = 0;$x < length($y);$x++) {
629             push @row,substr($y,$x,1);
630             }
631            
632             push @row,' ' if $self->do_margin;
633             push @row,$self->yaml->[0]->{preset}->{letters}->{blocks}->{pad};
634             push @row,$self->yaml->[0]->{preset}->{letters}->{blocks}->{pad};
635             push @row,$self->yaml->[0]->{preset}->{letters}->{blocks}->{pad};
636             } else {
637             for(my $x = 0;$x < length($y);$x++) {
638             push @row,substr($y,$x,1);
639             }
640             }
641             push @dib,\@row;
642             }
643            
644             push @dib,clone(\@margin_bottom) if $self->do_margin;
645             push @dib,clone(\@pad);
646             push @dib,clone(\@pad);
647             push @dib,clone(\@shadow) if $self->do_shadow;
648             push @dib,clone(\@seq_bottom) if $self->do_sequences;
649             $self->dib(\@dib);
650             }
651              
652             1;