5 use POSIX qw/ceil floor/;
7 # particlefont.txt generator for DarkPlaces
9 # this is eval'ed to not fail if Image::Magick is not installed
15 or warn "Image::Magick not installed, not generating a TGA\n";
24 my ($pixw, $pixh, $cols, $rows, $beamoffset, $beams) = @ARGV;
26 or die "Usage: $0 pixw pixh columns rows beamoffset beams\n";
30 checkmagick $magick->Set(size => "${pixw}x${pixh}");
31 checkmagick $magick->ReadImage("xc:white");
34 my $square_x = 1.0 / $cols;
35 my $square_y = 1.0 / $rows;
42 for my $row(0..$rows-1)
44 for my $col(0..$cols-1)
46 my $s0 = $col * $square_x + $dx;
47 my $s1 = ($col+1) * $square_x - $dx;
48 my $t0 = $row * $square_y + $dy;
49 my $t1 = ($row+1) * $square_y - $dy;
50 print "$i $s0 $t0 $s1 $t1\n";
53 checkmagick $magick->Draw(
54 fill => (($row + $col)%2 ? 'green' : 'cyan'),
55 primitive => 'rectangle',
56 points => sprintf "%d,%d %d,%d", ceil($s0 * $pixw), ceil($t0 * $pixh), floor($s1 * $pixw)-1, floor($t1 * $pixh)-1
58 checkmagick $magick->Annotate(
62 font => '/usr/share/fonts/TTF/DejaVuSansMono.ttf'
69 $i = $beamoffset if $i < $beamoffset;
70 for my $beam(0..$beams-1)
74 my $row = $beam + $rows;
75 my $t0 = $row * $square_y + $dy;
76 my $t1 = ($row+1) * $square_y - $dy;
77 print "$i $s0 $t0 $s1 $t1\n";
80 checkmagick $magick->Draw(
81 fill => (($beam)%2 ? 'yellow' : 'red'),
82 primitive => 'rectangle',
83 points => sprintf "%d,%d %d,%d", ceil($s0 * $pixw), ceil($t0 * $pixh), floor($s1 * $pixw)-1, floor($t1 * $pixh)-1
85 checkmagick $magick->Annotate(
89 font => '/usr/share/fonts/TTF/DejaVuSansMono.ttf'
97 $magick->Write("particlefont-template.png");