SLUG mail archive
[Prev][Next][Index][Thread]
Setting Bounding Box in lispm postscript
Date: Mon, 5 Mar 90 18:04:57 EDT
From: "Bruce R. Miller" <MILLER@vax.cam.nist.gov>
Date: Sat, 3 Mar 90 00:33 EST
From: Chris Lindblad <cjl@ai.mit.edu>
[...]
This is all correct, but here at the AI lab Jerry Roylance has come up with a
tex macro that will reads the bounding box information in the the header of a
postscript file, and then automatically computes up with the right offsets for
the psfile special so that the lower left of the bounding box appears at the
(tex) point. It also makes a (tex) box the exact size of the bounding box, so
the macro semantically is the same as setting a character of the size of the
bounding box. See the comments in this file for more information:
% -*- Mode: TeX -*-
% Merging PostScript Illustrations
[...]
% The header looks like
%
% %!PS-Adobe-1.0
% %%Creator: Illustrate Version 11.0
% %%CreationDate: 6/23/87 17:35:01
% %%Pages: 1
% %%BoundingBox: 466.12912 718.63934 612.0283 792.0283
% %%EndComments
%
% *** Should complain if #2 is (atend)
[...]
Very nice macro!
The only thing I could want would be a sort of
\psadobe[desired_width][desired_height]{psfile}
which would set up the scaling the image up to the desired dimensions.
(complain, complain) Shouldn't be too hard given the tools Jerry has
given, though...
As you know, the standard lispm postscript output does not include the
bounding box; without making two passes, its got no way of knowing.
I've written a presentation based lispm graphics program that allows
drawing in arbitrary user coordinates. It also builds its own record of
what's being drawn; allowing you to `edit' the image, which updates the
record. The record is used to redraw the image as needed, to determine
the `allowable' operations on an image fragment, etc.
It also uses this record to `redraw' the whole thing onto a hardcopy
stream when hardcopy is requested. This keeps it close to whizywig
while still letting postscript do its best. Since when hardcopying,
the image is also already on the screen, I have a cheep shortcut to
determine the (approximate) bounding box; extract it from the
presentations dw:bounding-box'es. I did this primarily to translate
the postscript output so that its lower-left corner was at 0,0, to
simplify using psfile, as I described in an earlier message. It also
tells me the width & height, but I've got to make note of it to manually
insert the approp. \vspace etc into the TeX document.
I should be able to automatically use this info to generate a
%%bounding box in the ps output. But, it seems that I have to redefine
(or shadow)
(flavor:method :send-header-comments postscript-output-stream)
and either define additional optional/keyword args (and thus modify
:send-page-buffers, and who knows what else), or special-vars, or ...
Has anybody done such a thing, or have suggestions as to what the
cleanest way (ie least problems later) of doing this are? (or know if
this can be done cleanly in 8.0?)
In 8.0, the postscript-output-stream flavor has settable instance variable
eps-bounding-box that when non-nil is put in the header comments like this:
(when eps-bounding-box
(lexpr-funcall #'format output-stream
"~&%%BoundingBox: ~D ~D ~D ~D~%" eps-bounding-box))
So what you would do is have your code send a :set-eps-bounding-box to the
hardcopy stream and a bounding box comment appears in the header. To patch
your 7.2 to make it like release 8.,0, add a gettable and settable inst var
eps-bounding-box, initially nil to the postscript-output-stream flavor. Then
add the above code to the :send-header-comments method.
Main Index |
Thread Index