Added some text wrapping and some improved filename handling

Text wrapping is a little gross if I want to change the title case
Also the body text case and pinning to the bottom is gonna suck
master
silverwizard 4 years ago
parent aeae68ed48
commit 7ba190bfbf
  1. 15
      CardGen.pl

@ -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');

Loading…
Cancel
Save