summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2011-01-09 14:36:37 +0000
committerdakkar <dakkar@thenautilus.net>2011-01-09 14:37:33 +0000
commit47dca0dbb0ea0326a5c0b3283e5efa7e8c5628fe (patch)
tree7372bb2a86c6b581e4224bd667d631fe32b0ec73
parentstring length may depend on direction (diff)
downloadqr-builder-47dca0dbb0ea0326a5c0b3283e5efa7e8c5628fe.tar.gz
qr-builder-47dca0dbb0ea0326a5c0b3283e5efa7e8c5628fe.tar.bz2
qr-builder-47dca0dbb0ea0326a5c0b3283e5efa7e8c5628fe.zip
add border around QR
also, increase cell size
-rw-r--r--lib/GridFiller/Result/Pango.pm15
-rw-r--r--script/qr-color.pl1
2 files changed, 12 insertions, 4 deletions
diff --git a/lib/GridFiller/Result/Pango.pm b/lib/GridFiller/Result/Pango.pm
index 34b3401..442aa06 100644
--- a/lib/GridFiller/Result/Pango.pm
+++ b/lib/GridFiller/Result/Pango.pm
@@ -19,6 +19,12 @@ has cell_size => (
default => 20,
);
+has border => (
+ isa => Int,
+ is => 'rw',
+ default => 2,
+);
+
has _width => (
isa => Int,
is => 'ro',
@@ -29,7 +35,7 @@ has _width => (
sub _build__width {
my ($self) = @_;
- return $self->cell_size * @{$self->source_grid->[0]};
+ return $self->cell_size * (2*$self->border + @{$self->source_grid->[0]});
}
has _height => (
@@ -42,7 +48,7 @@ has _height => (
sub _build__height {
my ($self) = @_;
- return $self->cell_size * @{$self->source_grid};
+ return $self->cell_size * (2*$self->border + @{$self->source_grid});
}
has _cairo_s => (
@@ -129,9 +135,9 @@ sub _put_squares {
$cr->set_source_rgb(1,1,1);
$cr->fill;
- my $y=0;
+ my $y=$self->border*$size;
for my $row (@{$self->source_grid}) {
- my $x=0;
+ my $x=$self->border*$size;
for my $cell (@$row) {
if ($cell eq '*') {
$cr->rectangle($x,$y,$size,$size);
@@ -227,6 +233,7 @@ sub place_word_at {
my @colour = $self->colour_for_string($word,$x,$y,$dir);
my $size = $self->cell_size;
my $cr = $self->_cairo_c;
+ $x+=$self->border;$y+=$self->border;
$x*=$size;$y*=$size;
my ($w_adjustment,$h_adjustment) = $self->_center_adj($p,$space);
diff --git a/script/qr-color.pl b/script/qr-color.pl
index c665371..5942fca 100644
--- a/script/qr-color.pl
+++ b/script/qr-color.pl
@@ -34,6 +34,7 @@ my $filler=GridFiller->new({
my $result = GridFiller::Result::Pango->new({
source_grid => $filler->grid,
+ cell_size => 40,
( @ARGV ? (font_description => $ARGV[0]) : () ),
});