Article View: comp.lang.postscript
Article #7022Re: Postscript Shape filling
From: Geoffrey Cooper
Date: Fri, 25 Mar 1988 23:28
Date: Fri, 25 Mar 1988 23:28
60 lines
3006 bytes
3006 bytes
In article <253@helios.misemi>, dhesi@helios.misemi (dhesi) writes:
>
> I am trying to print pattern filled shapes so that
> in cases where they overlap, the overlapping section contains
> all of the fillpatterns of the individual shapes.
What you are trying to do is somewhat awkward in PostScript, because you
are requesting an operation (so-called "transparent" colors) that is not
in the imaging model for the language. In PostScript, all colors
("ink"s) are opaque.
There are two basic techniques for generating blending of textures in
PostScript. The simplest, which might not be powerful enough for you,
is to use the CLIP operator to segment each shape, and then laboriously
draw out the texture using stroke and fill operations. Since you have
arranged to only put down ink exactly where you wanted it, the apparent
texture acts transparently. This is reasonable only when the textures
involved are very simple, such as a cross-hatch pattern. Even so, see
the technique below:
Example:
Let us assume that procedures "a" and "b" append paths for two objects
to the current path. In this case they are circles.
/a { 200 200 100 0 360 arc closepath } def
/b { 300 200 100 0 360 arc closepath } def
/colora { 0 setlinewidth % vertical cross-hatch
0 2 1000 { 0 moveto 0 1000 rlineto stroke } for } def
/colorb { 0 setlinewidth % horizontal cross-hatch
0 2 1000 { 0 exch moveto 1000 0 rlineto stroke } for } def
gsave a clip newpath colora grestore
gsave b clip newpath colorb grestore
showpage
For more complex textures and more general blending of colors, you want
to paint each object in its own color/gray, then use the clip operator
to isolate intersections of the objects. Obviously you have to be
careful, or you will have (#objects)^2 tests for intersection (or
2^#objects, if you count multiple intersections). But for simple
drawings of complex patterns, or for situations where you know which
objects are intersecting, this is a good technique. Note that it
allows for arbitrary choice of the intersection fill, which gives it
applicability to true color drawings.
Example:
/colora { 60 0 { pop } setscreen .5 setgray } def
/colorb { 60 0 { exch pop } setscreen .5 setgray } def
/colorc { 60 45 { pop } setscreen .5 setgray } def
colora a fill
colorb b fill
colorc a clip newpath b clip fill
The second technique is probably the faster of the two, from an
execution point of view. It is also more flexible.
- Geof Cooper
IMAGEN
--
{decwrl,sun,saber}!imagen!geof
Technical Details
Message-ID:
<1667@imagen.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!mnetor!uunet!portal!atari!imagen!geofReferences:
<253@helios.misemi>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!portal!atari!imagen!geof From: geof@imagen.UUCP (Geoffrey Cooper) Newsgroups: comp.lang.postscript Subject: Re: Postscript Shape filling Message-ID: <1667@imagen.UUCP> Date: 25 Mar 88 23:28:24 GMT References: <253@helios.misemi> Distribution: na Organization: IMAGEN Corporation, Santa Clara, CA 95052-8101 Lines: 60 Keywords: comp.lang.postscript Summary: a fill b fill a b clip fill