Added background colour settings and text colour settings

master
silverwizard 5 years ago
parent 6383e25554
commit 2774479e22
  1. 7
      CardGen.pl
  2. 3
      shopping.yml

@ -7,10 +7,11 @@ $Text::Wrap::columns = 30;
my $cards = LoadFile('shopping.yml'); my $cards = LoadFile('shopping.yml');
$bgcolour = $cards->{Deck}->{Background}; $bgcolour = $cards->{Deck}->{Background};
$mainfont = $cards->{Deck}->{Font}; $mainfont = $cards->{Deck}->{Font};
$txtcolour = $cards->{Deck}->{TextColour};
foreach my $card (keys %{$cards->{Deck}->{Cards}}){ 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:' . $bgcolour);
$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->Rotate(90); $surface->Rotate(90);
@ -21,9 +22,9 @@ foreach my $card (keys %{$cards->{Deck}->{Cards}}){
foreach my $line (@{$cards->{Deck}->{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 => $mainfont, fill => 'black', pointsize => 60); $image->Annotate(text => $card, x => 50, y => 100, font => $mainfont, fill => $txtcolour, pointsize => 60);
my $newlines = () = $text =~ /(\n)/g; my $newlines = () = $text =~ /(\n)/g;
$image->Annotate(text => $text, x => 50, y => (750-(25*$newlines)), font => $mainfont, fill => 'black', pointsize => 25); $image->Annotate(text => $text, x => 50, y => (750-(25*$newlines)), font => $mainfont, fill => $txtcolour, pointsize => 25);
$image->Write($card . '.png'); $image->Write($card . '.png');
} }

@ -1,6 +1,7 @@
Deck: Deck:
Background: White Background: black
Font: Courier Font: Courier
TextColour: white
Cards: Cards:
Leg Boost: Leg Boost:
- Grants +1d6 when jumping - Grants +1d6 when jumping

Loading…
Cancel
Save