summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2010-11-23 23:03:04 +0000
committerdakkar <dakkar@thenautilus.net>2010-11-23 23:03:04 +0000
commit91425983bfa5f1cbaf008c8252e961354102bc93 (patch)
tree4be9e3cefb38998885bce78cfe21f3106f99b68b
parentgitignore (diff)
downloadqr-builder-91425983bfa5f1cbaf008c8252e961354102bc93.tar.gz
qr-builder-91425983bfa5f1cbaf008c8252e961354102bc93.tar.bz2
qr-builder-91425983bfa5f1cbaf008c8252e961354102bc93.zip
more colours!
-rw-r--r--lib/GridFiller.pm59
-rw-r--r--lib/TextPrinter/ColourGrid.pm8
2 files changed, 44 insertions, 23 deletions
diff --git a/lib/GridFiller.pm b/lib/GridFiller.pm
index ebeb933..4ab25ac 100644
--- a/lib/GridFiller.pm
+++ b/lib/GridFiller.pm
@@ -90,18 +90,6 @@ has result => (
clearer => '_reset_result',
);
-sub _build_result {
- return [
- map {
- [
- map {
- [ ( $_ eq '*' ? 3 : 1 ), ' ' ],
- } @$_
- ]
- } @{shift->grid}
- ];
-}
-
sub _reset {
my ($self) = @_;
@@ -190,16 +178,49 @@ sub _put_letter_at {
return;
}
+{
+my %colourmap = (
+ '*' => {
+ $HORIZONTAL => {
+ 0 => 1,
+ 1 => 2,
+ },
+ $VERTICAL => {
+ 0 => 3,
+ 1 => 4,
+ },
+ },
+ ' ' => {
+ $HORIZONTAL => {
+ 0 => 5,
+ 1 => 6,
+ },
+ $VERTICAL => {
+ 0 => 7,
+ 1 => 8,
+ },
+ },
+);
+
+sub _build_result {
+ return [
+ map {
+ [
+ map {
+ [ $colourmap{$_}->{$HORIZONTAL}->{0}, ' ' ],
+ } @$_
+ ]
+ } @{shift->grid}
+ ];
+}
+
sub _find_colour_for {
my ($self,$x,$y,$dir) = @_;
- # let's be easy
- if ($dir == $HORIZONTAL) {
- return $self->grid->[$y][$x] eq '*' ? 3 : 1;
- }
- else {
- return $self->grid->[$y][$x] eq '*' ? 4 : 2;
- }
+ return $colourmap{$self->grid->[$y][$x]}->{$dir}->{
+ ($dir == $HORIZONTAL) ? ($y % 2) : ($x % 2)
+ };
+}
}
sub _find_place_for {
diff --git a/lib/TextPrinter/ColourGrid.pm b/lib/TextPrinter/ColourGrid.pm
index fdb9949..441956c 100644
--- a/lib/TextPrinter/ColourGrid.pm
+++ b/lib/TextPrinter/ColourGrid.pm
@@ -8,12 +8,12 @@ extends 'TextPrinter';
my @colours = (
color('reset'), # filler
(
- map { color($_,'on_white') }
- 'blue', 'green',
+ map { color($_,'on_black') }
+ 'dark yellow', 'dark green', 'dark red', 'dark white',
),
(
- map { color($_,'on_black') }
- 'dark yellow','dark green',
+ map { color($_,'on_white') }
+ 'blue', 'green', 'red', 'dark magenta',
),
);