diff options
Diffstat (limited to 'lib/GridFiller')
-rw-r--r-- | lib/GridFiller/Chooser/Smarter.pm | 2 | ||||
-rw-r--r-- | lib/GridFiller/Result/Pango.pm | 35 |
2 files changed, 36 insertions, 1 deletions
diff --git a/lib/GridFiller/Chooser/Smarter.pm b/lib/GridFiller/Chooser/Smarter.pm index fd21dae..43ad530 100644 --- a/lib/GridFiller/Chooser/Smarter.pm +++ b/lib/GridFiller/Chooser/Smarter.pm @@ -16,6 +16,8 @@ sub find_place_for { my $length = $self->length->($word); + $self->log->debug("looking for $length of space"); + my @candidates; push @candidates, $self->_find_places_horiz($length); diff --git a/lib/GridFiller/Result/Pango.pm b/lib/GridFiller/Result/Pango.pm index 504f2a7..81eba04 100644 --- a/lib/GridFiller/Result/Pango.pm +++ b/lib/GridFiller/Result/Pango.pm @@ -83,6 +83,8 @@ sub _put_squares { my $size = $self->cell_size; + $cr->save; + $cr->rectangle(0,0,$self->_width,$self->_height); $cr->set_source_rgb(1,1,1); $cr->fill; @@ -101,15 +103,46 @@ sub _put_squares { $y+=$size; } + $cr->restore; + return; } +sub layout_for_word { + my ($self,$word) = @_; + + my $p = Pango::Cairo::create_layout($self->_cairo_c); + $p->set_text($word); + + return $p; +} + +my $PI=3.1415926; + sub place_word_at { my ($self, $word, $x, $y, $dir) = @_; $self->log->debug("Placing $word at ${x}:${y} ($dir)"); - $self->_cairo_c; + my $p = $self->layout_for_word($word); + my $size = $self->cell_size; + my $cr = $self->_cairo_c; + $x*=$size;$y*=$size; + + $cr->save; + if ($dir == $HORIZONTAL) { + $cr->move_to($x,$y); + } + else { + $cr->move_to($x+$size,$y); + $cr->rotate($PI/2); + } + Pango::Cairo::update_layout($cr,$p); + $cr->set_source_rgb(1,1,0); + Pango::Cairo::show_layout($cr,$p); + $cr->restore; + + return; } sub as_png { |