diff options
Diffstat (limited to 'lib/TextPrinter.pm')
-rw-r--r-- | lib/TextPrinter.pm | 35 |
1 files changed, 11 insertions, 24 deletions
diff --git a/lib/TextPrinter.pm b/lib/TextPrinter.pm index 7ef8572..1715959 100644 --- a/lib/TextPrinter.pm +++ b/lib/TextPrinter.pm @@ -1,42 +1,29 @@ package TextPrinter; -use strict; -use warnings; +use Moose; +use namespace::autoclean; use Term::ANSIColor; -my @colours = ( - color('reset'), # filler - ( - map { color($_,'on_white') } - 'blue', 'green', - ), - ( - map { color($_,'on_black') } - 'dark yellow','dark green', - ), -); - sub draw_cell { - my ($cell) = @_; + my ($self,$cell) = @_; - print $colours[$cell->[0]], - $cell->[1]; + die "unimplemented"; } { my $white = color('black','on_white'); my $reset = color('reset'); sub draw_row { - my ($row,$scale)=@_; + my ($self,$row,$scale)=@_; $scale||=1; print $white,' 'x(3*$scale); for my $cell (@$row) { - draw_cell($cell) for 1..$scale; + $self->draw_cell($cell) for 1..$scale; } print $white,' 'x(3*$scale); print $reset,"\n"; } sub draw_empty_row { - my ($row,$scale)=@_; + my ($self,$row,$scale)=@_; $scale||=1; print $white,' 'x((6+@$row)*$scale),$reset,"\n" for 1..(3*$scale); @@ -44,16 +31,16 @@ sub draw_empty_row { } sub draw_whole { - my ($arr,$scale)=@_; + my ($self,$arr,$scale)=@_; $scale||=1; - draw_empty_row($arr->[0],$scale); + $self->draw_empty_row($arr->[0],$scale); for my $row (@$arr) { - draw_row($row,$scale) for 1..$scale; + $self->draw_row($row,$scale) for 1..$scale; } - draw_empty_row($arr->[0],$scale); + $self->draw_empty_row($arr->[0],$scale); } 1; |