[comp.lang.postscript] Calculating bounding box information

fjensen@sbstark.cs.sunysb.edu (Frank Jensen) (06/11/90)

I have just tried to use the `bb.ps' code.  It is supposed to
keep track of bounding box information while it draws the figure.

This sounds to be difficult in general: it is hard to keep track of
something being drawn and then - maybe partially - erased later.  So,
sometimes you will get a bounding box that is too large.

But I didn't expect to get a too small bounding box!

I then looked at the code, and I found that the code (a least the
version I have) do not save changes made to the bounding box between
save/restore pairs.  I therefore added the following lines to the code:

	/-restore /restore load def

	/restore
	{   	bb-llx bb-lly bb-urx bb-ury
		5 -1 roll
		-restore
		/bb-ury xstore /bb-urx xstore
		/bb-lly xstore /bb-llx xstore
	} def

This code ensures that the bounding box information is preserved when
VM is restored to a previous snapshot.


Frank Jensen
Department of Computer Science
State University of New York at Stony Brook