|
|
|
@ -1,10 +1,17 @@ |
|
|
|
|
#!/usr/bin/env perl |
|
|
|
|
use YAML::XS qw(LoadFile); |
|
|
|
|
use Image::Magick; |
|
|
|
|
use Text::Wrap; |
|
|
|
|
|
|
|
|
|
$Text::Wrap::columns = 30; |
|
|
|
|
my $cards; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
my $cards = LoadFile('shopping.yml'); |
|
|
|
|
if($ARGV[0]){ |
|
|
|
|
$cards = LoadFile($ARGV[0]); |
|
|
|
|
}else{ |
|
|
|
|
print "Usage: CardGen.pl [yaml file of cards]\n"; |
|
|
|
|
exit 1; |
|
|
|
|
} |
|
|
|
|
if($cards->{Deck}->{Background}){ |
|
|
|
|
$bgcolour = $cards->{Deck}->{Background}; |
|
|
|
|
}else{ |
|
|
|
@ -36,10 +43,12 @@ foreach my $card (keys %{$cards->{Deck}->{Cards}}){ |
|
|
|
|
$image->Composite(compose => 'over', image => $surface, x => 0, y => 0); |
|
|
|
|
my $text; |
|
|
|
|
$image->Set(font => $mainfont, pointsize => 25); |
|
|
|
|
$Text::Wrap::columns = 30; |
|
|
|
|
foreach my $line (@{$cards->{Deck}->{Cards}->{$card}}){ |
|
|
|
|
$text = $text . wrap('', '', $line) . "\n"; |
|
|
|
|
} |
|
|
|
|
$image->Annotate(text => $card, x => 50, y => 100, font => $mainfont, fill => $txtcolour, pointsize => 60); |
|
|
|
|
$Text::Wrap::columns = 15; |
|
|
|
|
$image->Annotate(text => wrap('', '', $card), x => 50, y => 100, font => $mainfont, fill => $txtcolour, pointsize => 60); |
|
|
|
|
my $newlines = () = $text =~ /(\n)/g; |
|
|
|
|
$image->Annotate(text => $text, x => 50, y => (750-(25*$newlines)), font => $mainfont, fill => $txtcolour, pointsize => 25); |
|
|
|
|
$image->Write($card . '.png'); |
|
|
|
|