| 1 |
#! /usr/bin/perl |
| 2 |
|
| 3 |
# Copyright (C) 2000, 2001 Kaoru Maeda. |
| 4 |
# All rights reserved. |
| 5 |
|
| 6 |
# This file can be freely distributed |
| 7 |
# under the same condition as Perl. |
| 8 |
|
| 9 |
$argc = 0; |
| 10 |
$opt_resolution = "800x600"; |
| 11 |
$opt_opts = ""; |
| 12 |
while ($argc <= $#ARGV) { |
| 13 |
if ($ARGV[$argc] eq "-h" || $ARGV[$argc] eq "--help") { |
| 14 |
"$0 [-g WIDTHxHEIGHT] [-o mgp-option] mgp-file\n"; |
| 15 |
exit; |
| 16 |
} elsif ($ARGV[$argc] eq "-g") { |
| 17 |
if (($argc < $#ARGV) && ($ARGV[$argc+1] !~ /^-/)) { |
| 18 |
$opt_resolution = $ARGV[++$argc]; |
| 19 |
} |
| 20 |
} elsif ($ARGV[$argc] eq "-o") { |
| 21 |
if (($argc < $#ARGV)) { |
| 22 |
$opt_opts = $ARGV[++$argc]; |
| 23 |
} |
| 24 |
} else { |
| 25 |
$stem = $ARGV[$argc]; |
| 26 |
$stem =~ s/\.mgp?//; |
| 27 |
} |
| 28 |
$argc++; |
| 29 |
} |
| 30 |
|
| 31 |
$tmpdir = "PRINT6"; |
| 32 |
|
| 33 |
@PAGES = glob("$tmpdir/mgp00???.eps"); |
| 34 |
|
| 35 |
if (!-d $tmpdir || !@PAGES) { |
| 36 |
|
| 37 |
if (-d $tmpdir) { |
| 38 |
system("rm -rf $tmpdir"); |
| 39 |
} |
| 40 |
mkdir $tmpdir, 0777; |
| 41 |
|
| 42 |
system("mgp -D $tmpdir -E png -o -g $opt_resolution+0+0 -X ppmraw+ $opt_opts $stem.mgp"); |
| 43 |
|
| 44 |
@PNGS = glob("$tmpdir/mgp00???.png"); |
| 45 |
for $png (@PNGS) { |
| 46 |
($eps = $png) =~ s/\.png/.eps/; |
| 47 |
print STDERR "$png -> $eps\n"; |
| 48 |
system("pngtopnm $png | ppmtopgm | perl -pe 'tr/\\372/\\377/' | pnmtops -dpi 600 -scale 0.6 -noturn > $eps"); |
| 49 |
} |
| 50 |
|
| 51 |
@PAGES = glob("$tmpdir/mgp00???.eps"); |
| 52 |
} |
| 53 |
|
| 54 |
$pages = 0; |
| 55 |
$o = 0; |
| 56 |
@LOC = ('48,128,509,474', |
| 57 |
'544,128,1005,474', |
| 58 |
'48,576,509,922', |
| 59 |
'544,576,1005,922', |
| 60 |
'48,1024,509,1370', |
| 61 |
'544,1024,1005,1370', |
| 62 |
); |
| 63 |
|
| 64 |
while (@PAGES) { |
| 65 |
@P = splice(@PAGES, 0, scalar @LOC); |
| 66 |
$pages++; |
| 67 |
push(@out, qq[page($pages,"",1,'').\n]); |
| 68 |
@loc = @LOC; |
| 69 |
for $file (@P) { |
| 70 |
$mtime = (stat $file)[9]; |
| 71 |
$mtime = localtime($mtime); |
| 72 |
$loc = shift(@loc); |
| 73 |
$x = <<EOL; |
| 74 |
group([ |
| 75 |
xbm('black','',$loc,0,OBJID,0,461,346,0,0,1,75000,208000,536000,554000,1,0,0,0,0,0,0, |
| 76 |
"$mtime","$file",[ |
| 77 |
]), |
| 78 |
box('black','',$loc,0,1,1,OBJID,0,0,0,0,0,'1',0,[ |
| 79 |
]) |
| 80 |
], |
| 81 |
OBJID,0,0,[ |
| 82 |
]). |
| 83 |
EOL |
| 84 |
; |
| 85 |
$x =~ s/OBJID/$o++/ge; |
| 86 |
push(@out, $x); |
| 87 |
} |
| 88 |
} |
| 89 |
|
| 90 |
unshift(@out, <<'EOL'); |
| 91 |
% |
| 92 |
% @(#)$Header: /var/cvs/debian/mgp/debian/Attic/mgp-print6,v 1.1.6.1 2001/09/27 15:24:40 ukai Exp $ |
| 93 |
% %W% |
| 94 |
% |
| 95 |
unit("1 pixel/pixel"). |
| 96 |
color_info(12,65535,0,[ |
| 97 |
"magenta", 65535, 0, 65535, 65535, 0, 65535, 1, |
| 98 |
"red", 65535, 0, 0, 65535, 0, 0, 1, |
| 99 |
"green", 0, 65535, 0, 0, 65535, 0, 1, |
| 100 |
"blue", 0, 0, 65535, 0, 0, 65535, 1, |
| 101 |
"yellow", 65535, 65535, 0, 65535, 65535, 0, 1, |
| 102 |
"pink", 65535, 49931, 53052, 65535, 49344, 52171, 1, |
| 103 |
"cyan", 0, 65535, 65535, 0, 65535, 65535, 1, |
| 104 |
"CadetBlue", 22885, 40569, 42649, 24415, 40606, 41120, 1, |
| 105 |
"white", 65535, 65535, 65535, 65535, 65535, 65535, 1, |
| 106 |
"black", 0, 0, 0, 0, 0, 0, 1, |
| 107 |
"DarkSlateGray", 10402, 19764, 18724, 12079, 20303, 20303, 1, |
| 108 |
"AntiqueWhite2", 61374, 57213, 53052, 61166, 57311, 52428, 1 |
| 109 |
]). |
| 110 |
script_frac("0.6"). |
| 111 |
fg_bg_colors('black','AntiqueWhite2'). |
| 112 |
EOL |
| 113 |
; |
| 114 |
|
| 115 |
unshift(@out, <<EOL); |
| 116 |
%TGIF 4.1.39 |
| 117 |
state(0,37,100.000,0,0,2,8,1,9,1,1,0,0,1,0,1,0,'Helvetica',0,80640,0,0,0,10,0,0,1,0,0,16,0,0,$pages,$pages,1,1,1050,1485,1,0,2880,0). |
| 118 |
EOL |
| 119 |
; |
| 120 |
|
| 121 |
|
| 122 |
open (OUT, ">$stem-6.obj"); |
| 123 |
print OUT @out; |
| 124 |
close OUT; |
| 125 |
|
| 126 |
system("tgif -print -ps $stem-6.obj"); |
| 127 |
unlink("$stem-6.obj"); |
| 128 |
__END__ |