[comp.lang.postscript] Need simple way to save/restore clip path

kap121@ztivax.UUCP (Thomas Oeser) (06/12/89)

Hi there,

we need a a simple way to save the current clip path. This should happen
without saving the whole graphics context.

This feature is required, since we want use the PostScript clipping facility
to realize:

	1) filling arbitraily shaped objects with hatch styles (avoiding to use
	the time consuming operator "setscreen", that may define an hatch look
	alike pattern);

	2) local clipping in an composed document (i.e., a document handler
	provides for some space within which the image represented by the
	piece of PostScript code is to be imaged but still using clipping
	locally to build this image (e.g., a frame displaying the graph of a
	function versus the decoration -axes, legend etc.- around)).


M. Mucke, Th. Oeser

------------------------------------------------------------------------------
ARPA:		kap121@ztivax.siemens.com
UUCP:		kap121@ztivax.uucp (may work only in Europe...)
Postal mail:	Siemens AG, K Sys Ap 121, Otto-Hahn-Ring 6, P.O. Box 830951,
		D-8000 Munich 83, West Germany
Phone:		+ 49 (89) 636-47537
FAX:		+ 49 (89) 636-41477

Disclaimer:
The opinions expressed are my own, and should not be attributed to anyone else
living or dead.
------------------------------------------------------------------------------

zben@umd5.umd.edu (Ben Cranston) (06/14/89)

The Postscript "clippath" verb makes the current path into a copy of the
current clipping path.  The "pathforall" verb walks the current path calling
one of four routines you supply.  There is one called for "move", one for
"line", one for "curve", and one for "close".  These routines can build a
data structure which you can then pull later.

I have seen this technique used to build a procedure body on the stack that
when later bound to a name and called restores the clipping path to that which
was in effect when the technique was used.  This is in Apple's laserwriter
prologue from printing 5.2 (prologue level 68).  If you can get a Macintosh
command-K dump you could probably extract much of the code from that.  Look
in the "od" procedure, which seems to bind the name "gc" to the enumerated
path (the transform-itransform is snapping to integer device coordinates).

N.B. This technique is deliberately and specifically DISallowed when the
outline of an Adobe character is in the clipping path.  This is to prevent
you from stealing the Adobe fonts...
-- 
Ben Cranston <zben@umd2.UMD.EDU>    (Kingdom of Merryland UniSys 1100/92)
Copyright 1989 (you may redistribute ONLY if your recipients can).