Renamed "shopping" to CardGen

Fixed some word wrapping and off the end run
Added font choices
Added tech for changing background colour eventually
master
silverwizard 5 years ago
parent f88e2bc339
commit 6383e25554
  1. 17
      CardGen.pl
  2. 5
      shopping.yml

@ -5,24 +5,25 @@ use Text::Wrap;
$Text::Wrap::columns = 30; $Text::Wrap::columns = 30;
my $cards = LoadFile('shopping.yml'); my $cards = LoadFile('shopping.yml');
my @card_table; $bgcolour = $cards->{Deck}->{Background};
foreach my $card (keys %{$cards->{Cards}}){ $mainfont = $cards->{Deck}->{Font};
foreach my $card (keys %{$cards->{Deck}->{Cards}}){
my $image = Image::Magick->new(size=>'600x825'); my $image = Image::Magick->new(size=>'600x825');
$image->ReadImage('canvas:white'); $image->ReadImage('canvas:white');
$image->Draw(stroke=>'red', fill => 'none', strokewidth=>1, primitive=>'rectangle', points=>'38,38 562,787'); $image->Draw(stroke=>'red', fill => 'none', strokewidth=>1, primitive=>'rectangle', points=>'38,38 562,787');
my $surface = Image::Magick->new; my $surface = Image::Magick->new;
$surface->ReadImage('surface-p17.jpg');
$surface->Rotate(90); $surface->Rotate(90);
$surface->Resize('600x825!'); $surface->Resize('600x825!');
$image->Composite(compose => 'over', image => $surface, x => 0, y => 0); $image->Composite(compose => 'over', image => $surface, x => 0, y => 0);
$image->Annotate(text => $card, font => 'Courier.ttf', y => -275, fill => 'black', pointsize => 70, gravity => 'Center');
my $text; my $text;
$image->Set(font => 'Courier', pointsize => 25); $image->Set(font => $mainfont, pointsize => 25);
foreach my $line (@{$cards->{Cards}->{$card}}){ foreach my $line (@{$cards->{Deck}->{Cards}->{$card}}){
$text = $text . wrap('', '', $line) . "\n"; $text = $text . wrap('', '', $line) . "\n";
} }
$image->Annotate(text => $card, x => 50, y => 100, font => 'Courier', fill => 'black', pointsize => 35); $image->Annotate(text => $card, x => 50, y => 100, font => $mainfont, fill => 'black', pointsize => 60);
$image->Annotate(text => $text, x => 50, y => 600, font => 'Courier', fill => 'black', pointsize => 25); my $newlines = () = $text =~ /(\n)/g;
$image->Annotate(text => $text, x => 50, y => (750-(25*$newlines)), font => $mainfont, fill => 'black', pointsize => 25);
$image->Write($card . '.png'); $image->Write($card . '.png');
} }

@ -1,3 +1,6 @@
Deck:
Background: White
Font: Courier
Cards: Cards:
Leg Boost: Leg Boost:
- Grants +1d6 when jumping - Grants +1d6 when jumping
@ -141,8 +144,6 @@ Cards:
Sword: Sword:
- 1d8 damage - 1d8 damage
- Melee - Melee
Common Cards: Common Cards:
Heavy Chain: Heavy Chain:
- 1d8 damage - 1d8 damage

Loading…
Cancel
Save