Back to home page

Project CMSSW displayed by LXR

 
 

    


Warning, /Utilities/ReleaseScripts/ignominy/ps2map is written in an unsupported language. File is not indexed.

0001 #!/usr/bin/env perl
0002 use warnings;
0003 use strict;
0004 
0005 my $target = undef;
0006 while ($ARGV[0] =~ /--(.*)/) {
0007   if ($1 =~ /target=(.*)/) {
0008     $target = $1;
0009   }
0010   shift(@ARGV);
0011 }
0012 
0013 my $usage = "$0 [--target=TARGET] NAME SCALE CROP-Y-TOP CROP-X-LEFT CROP-Y-BOTTOM CROP-X-RIGHT FILE";
0014 die "$usage\n" if @ARGV != 7;
0015 my ($name, $scale, $ycroptop, $xcropleft, $ycropbottom, $xcropright, $file) = @ARGV;
0016 # $scale *= .75;
0017 
0018 open(IN, "< $file") || die "$file: cannot read\n";
0019 
0020 print "<MAP NAME='$name'>\n";
0021 my @page = (0, 0, 595, 841);
0022 my @bbox;
0023 
0024 while (<IN>) {
0025   chomp;
0026   if (/%%BoundingBox:\s*(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s*$/) {
0027     @page = ($1, $2, $3, $4);
0028   } elsif (/\/Rect \[ (\d+) (\d+) (\d+) (\d+) \]/) {
0029     @bbox = (int(($1 + $page[0]) * $scale - $xcropleft),
0030              int(($page[3] - ($page[1] + $4)) * $scale - $ycroptop),
0031              int(($3 + $page[0]) * $scale - $xcropleft),
0032              int(($page[3] - ($page[1] + $2)) * $scale - $ycroptop));
0033   } elsif (/\/URI \((.*)\) >>/) {
0034     print "<AREA";
0035     print " TARGET='$target'" if $target;
0036     print " HREF='$1' SHAPE='rect' COORDS='" . join(",", @bbox) . "'>\n";
0037   }
0038 }
0039 print "</MAP>\n";
0040 
0041 close(IN);