summaryrefslogtreecommitdiff
path: root/lib/GridFiller/Status.pm
diff options
context:
space:
mode:
authorGianni Ceccarelli <dakkar@thenautilus.net>2010-12-26 16:59:19 +0000
committerGianni Ceccarelli <dakkar@thenautilus.net>2010-12-26 16:59:19 +0000
commit4bea68faa549c6725c4af9c94a3565d5bd78729a (patch)
tree58e69a65b8ffee0082e699226811be1c614d7ef6 /lib/GridFiller/Status.pm
parentadd missing dep (diff)
downloadqr-builder-4bea68faa549c6725c4af9c94a3565d5bd78729a.tar.gz
qr-builder-4bea68faa549c6725c4af9c94a3565d5bd78729a.tar.bz2
qr-builder-4bea68faa549c6725c4af9c94a3565d5bd78729a.zip
string length may depend on direction
Diffstat (limited to 'lib/GridFiller/Status.pm')
-rw-r--r--lib/GridFiller/Status.pm8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/GridFiller/Status.pm b/lib/GridFiller/Status.pm
index bf5e9e6..bccb20f 100644
--- a/lib/GridFiller/Status.pm
+++ b/lib/GridFiller/Status.pm
@@ -62,8 +62,8 @@ sub _build_words_to_use {
given ($mode) {
when ('random') { return [ shuffle uniq @$words ] }
when ('given') { return [ uniq @$words ] }
- when ('longest') { return [ sort {$l->($b) <=> $l->($a)} uniq @$words ] }
- when ('shortest') { return [ sort {$l->($a) <=> $l->($b)} uniq @$words ] }
+ when ('longest') { return [ sort {$l->($b,$HORIZONTAL) <=> $l->($a,$HORIZONTAL)} uniq @$words ] }
+ when ('shortest') { return [ sort {$l->($a,$HORIZONTAL) <=> $l->($b,$HORIZONTAL)} uniq @$words ] }
default { croak "Unknown mode $mode" }
}
}
@@ -87,12 +87,12 @@ sub place_word_at {
$self->log->debug("Marking <$word> occupied at ${x}:${y} ($dir)");
if ($dir == $HORIZONTAL) {
- for my $i (0..$self->length->($word)+$space-1) {
+ for my $i (0..$self->length->($word,$dir)+$space-1) {
$self->_mark_occupied($x+$i,$y);
}
}
elsif ($dir == $VERTICAL) {
- for my $i (0..$self->length->($word)+$space-1) {
+ for my $i (0..$self->length->($word,$dir)+$space-1) {
$self->_mark_occupied($x,$y+$i);
}
}