package TextPrinter; use Moose; use namespace::autoclean; use Term::ANSIColor; sub draw_cell { my ($self,$cell) = @_; die "unimplemented"; } { my $white = color('black','on_white'); my $reset = color('reset'); sub draw_row { my ($self,$row,$scale)=@_; $scale||=1; print $white,' 'x(3*$scale); for my $cell (@$row) { $self->draw_cell($cell) for 1..$scale; } print $white,' 'x(3*$scale); print $reset,"\n"; } sub draw_empty_row { my ($self,$row,$scale)=@_; $scale||=1; print $white,' 'x((6+@$row)*$scale),$reset,"\n" for 1..(3*$scale); } } sub draw_whole { my ($self,$arr,$scale)=@_; $scale||=1; $self->draw_empty_row($arr->[0],$scale); for my $row (@$arr) { $self->draw_row($row,$scale) for 1..$scale; } $self->draw_empty_row($arr->[0],$scale); } 1; __END__ =head1 AUTHOR Gianni Ceccarelli =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2012 by Gianni Ceccarelli. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, version 3. =cut