chris@zorin.UUCP (Chris Nielsen) (01/07/88)
I'm real glad to see a postscript newsgroup!
I've seen some requests for 'clippings', and I'd like to do the same.
But first, here's my contribution. Also, I'd like to be on anyone's PS
mailing list there may be.
Lately, I've discovered m4 as a postscript tool. I've developed a command,
psq, to do the printing for me. It prepends the ps-adobe header, defines
some well-used utilities, runs m4 to include others, and sends to the printer.
Included in psq is a graph-paper procedure I use very much. it does a grid
with dotted lines, and numbers across the bottom & left side. it does a 20
20 translate to move the artwork away from the numbers. To print I just do
a psq artfile.ps. the artfile.ps file contains the 'showpage'.
There are 3 files here. 'psq' is the shell command to print things. modify
the 'apr -qgrape' (our local printing method) to how ever you get a file to
the printer. 'curves.ps' is a file to demonstrate all this. It does the
grid, curveto 'debug', and inclusion. 'factory.ps' is just a 'clipping' of
which there would be many.
Oh.. I do have a specific request... If anyone knows how to make an error
handler that will print a page with thee name of the error, and offending
line (this is all in errordict) please tell me! I wrote one, but it doesn't
work, and I have no idea what's wrong with it. I read the blue & red, but
to no avail...
Please send comments, artwork, etc to address at bottom...
Thanks! -sdcrdcf!zorin!chris (Christopher Nielsen)
- - - Lazy-Arc - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
This is a 'Lazy-Arc' archive... I'm sorry, It's late, and I'm tired...
Just cut on the dotted lines, (3 files).
- - - cut cut cut file: psq - - - - - - - - - - - - - - - - - - - - - - -
cat > "/tmp/prg$$" << 'EOF'
%!PS-Adobe-1.0
% lib/psdit.pro
%%%%%%%%%%%%%%%% grid
/str 4 string def
/horiz % make horiz lines
{
newpath
0 10 700 % start, incr, end
{
dup /curval exch def % curval = top val of stack (y)
0 exch moveto
550 0 rlineto
} for
stroke
} def
/vert % make vert lines
{
newpath
0 10 550 % start, incr, end
{
0 moveto
0 700 rlineto
} for
stroke
} def
/hnum % make numbers for horiz lines
{
newpath
10 10 700 % start, incr, end
{
dup /curval exch def % curval = top val of stack (y)
4 add % start printing up a bit (added to y)
5 exch moveto
curval str cvs show
} for
} def
/vnum % numbers for vert
{
20 20 550 % for every other one.
{
dup /curval exch def
11 add % start printing a bit to the right.
0 moveto
curval str cvs show
} for
} def
% -------- Main
/grid {
20 20 translate
gsave
.005 setlinewidth
% [1 2] 0 setdash % 1 on 2 off 0 offset
horiz
vert
-15 -5 translate
/Helvetica findfont
5 scalefont
setfont
vnum
hnum
15 5 translate
0 0 moveto
grestore
} def
%%%%%%%%%%%%%%%% cvdebug
/cvtodict 10 dict def
/cvto {
cvtodict begin
/putx { % put an X at the current point.
-2 -2 rmoveto % get to position
4 4 rlineto % first leg
-4 0 rmoveto % next position
4 -4 rlineto % last leg
-2 2 rmoveto % back to center.
} def
/y3 exch def
/x3 exch def
/y2 exch def
/x2 exch def
/y1 exch def
/x1 exch def
currentpoint
/y0 exch def
/x0 exch def
gsave
x0 y0 moveto putx
x1 y1 lineto putx
x2 y2 lineto putx
x3 y3 lineto putx
.005 setlinewidth
stroke
grestore
x0 y0 moveto % now do real curveto.
x1 y1 x2 y2 x3 y3 curveto
end
} def
%%%%%%%%%%%%%%%% print line
/pl {
% p. 63, 82 blue for alt. method
currentpoint
/oy exch def % save old xy values
/ox exch def
show
currentpoint % stack: x,y
2 1 roll % now it's y,x
pop % y
ox % y,ox (old x value)
% 50 % y,50
2 1 roll % 50,y
15 sub % 50,y-15
moveto
} def
%%%%%%%%%%%%%%%%
% 20 20 translate
EOF
m4 $1 >> /tmp/prg$$
cat /tmp/prg$$ > psq.out
cat /tmp/prg$$ | apr -qgrape
rm /tmp/prg$$
- - - -cut cut cut file: curves.ps - - - - - - - - - - - - - - - - - - - - -
include(factory.ps)
% /cvto { curveto } def %% remove the first % to make curveto normal
/curves {
100 100 moveto
200 200 300 50 400 200 cvto % cvto is a curveto but with lines
} % to show the points.
curves stroke
0 500 translate
factory
showpage
- - - cut cut cut file: factory.ps - - - - - - - - - - - - - - - - - - - -
% Factory building
% --------- Procedures
/front
{
newpath
0 0 moveto
210 0 lineto
210 30 lineto
0 30 lineto
closepath
stroke
} def
/side
{
newpath
210 0 moveto
230 60 lineto
230 90 lineto
210 30 lineto
closepath
stroke
} def
/rpanel
{
newpath
30 50 moveto
30 30 lineto
50 90 lineto
50 110 lineto
20 90 lineto
0 30 lineto
30 50 lineto
50 110 lineto
stroke
} def
/roof
{
gsave
0 30 180 {
rpanel
30 0 translate
} for
grestore
} def
% -------- Main
/factory {
.05 setlinewidth
100 100 translate
front
side
% rpanel
roof
} def
- - - End of Lazy-Arc: good night. - - - - - - - - - - - - - - - - - - - - -
////////////////// Zorin Data Systems, Inc
////
//// 2910 Seventh Street, Santa Monica, CA 90405 (213)399-3804
//// UUCP: ucbvax!hplabs!sdcrdcf!zorin!chris
////
<<<<<<<<<<<<<<<<<<<<< Zorin... "A World of Information" >>>>>>>>>>>>>>>>>>>>>
tj@gpu.utcs.toronto.edu (Terry Jones) (01/09/88)
Sorry to put a damper on your day. There is an error handler available from Adobe that does exactly what you want and they will send it to you on flat would be the most up to date form of it. Now I could send you a version of it, but I know not whether it has changed recently. Now for the bad news. The PostScript code you posted has a minor problem. It may not stop it from working on some sites, it may on others. The first line of you code starts with %!PS-Adobe-1.0 This is a comment reserved for fully conforming PostScript code and I don't think the code you produce is fully conforming. If it is just straight PostScript code, start it with %!, if it conforms then use the %!PS-Adobe-1.0 comment. It makes a difference when the code is sent via a spooler that cans rder of the postscript code so the output comes out collated properly. Lots of people make this mistake, take for example Xerox with Ventura publisher!!! Their conforming postscript is real close but no cigar... It fails to come out when it gets reversed. The comments are wrong so it doesn't conform so the reversing filter messes up. It is just as bad NOT to start a postscript file with %! because the same spooling software assumes it ISN'T postscript then... Have a nice day. tj