[comp.sys.mac] Laserwriter, PostScript, and Patterns

tjs@cec2.UUCP (Thomas Justin Sullivan) (03/09/87)

We recently installed an Apple Laserwriter on our VAX. We would
like to make plots of VLSI layouts. It is fairly straight forward
to convert from Magic files to PostScript; however, I would like 
to find an "easy" way to fill boxes with patterns (like those 
in MacPaint). I would like to know if the patterns are in the 
Laserwriter's memory, and if so, how does one access them them?
I have been unable to find any information in the PostScript and
Apple manuals.


Thanks
tom sullivan
Washington University in St. Louis
tjs@wucec2.uucp

jdm@gssc.UUCP (03/11/87)

From my dealings with PostScript, I have not found any indication of the
ability to fill with a pattern, which is a real shame.  "Color" fills only,
which means you can greyscale.

My guess is that the Mac jams down the pictures from MacPaint with the 
PostScript "image" operator.  Please let me know if you find out otherwise.

-- jdm
-- 
in real life:  John D. Miller, Graphic Software Systems, Inc., Beaverton OR
...!{tektronix!verdix}!sequent!gssc!jdm                      (503) 641-2200

eric@batcomputer.UUCP (03/21/87)

In article <345@gssc.UUCP> jdm@gssc.UUCP (John D. Miller) writes:
>From my dealings with PostScript, I have not found any indication of the
>ability to fill with a pattern, which is a real shame.  "Color" fills only,
>which means you can greyscale.

>in real life:  John D. Miller, Graphic Software Systems, Inc., Beaverton OR
>...!{tektronix!verdix}!sequent!gssc!jdm                      (503) 641-2200

I don't know what the mac does to download it's patterns, but one of 
us has written a PostScript driver that creates its own pattern fills.

One has to figure out the bit map for the pattern and send it to PostScript
in hex.  To get a fine-scale pattern you need a lot of bits, coarser
patterns (fewer bits) can be enlarged but look cruder.

					++Eric Fielding
eric@tcgould.tn.cornell.edu

mrh@Shasta.UUCP (03/25/87)

In article <465@batcomputer.tn.cornell.edu>, eric@batcomputer.tn.cornell.edu (Eric Fielding) writes:
> In article <345@gssc.UUCP> jdm@gssc.UUCP (John D. Miller) writes:
> >From my dealings with PostScript, I have not found any indication of the
> >ability to fill with a pattern, which is a real shame.  "Color" fills only,
> >which means you can greyscale.

> I don't know what the mac does to download it's patterns, but one of 
> us has written a PostScript driver that creates its own pattern fills.
> One has to figure out the bit map for the pattern and send it to PostScript
> in hex.  To get a fine-scale pattern you need a lot of bits, coarser
> patterns (fewer bits) can be enlarged but look cruder.
> 					++Eric Fielding
 
   It seems to me that this violates the idea of device independence with 
postscript. The bitmap of the pattern you download would be different sizes
depending on what your printer resolution is. There may be no practical way
around this but I just wanted to point that out.
David Gelphman                  BITNET address: DAVEG@SLACVM
Bin #88 SLAC                    ARPANET address:  DAVEG@SLACVM.BITNET
Stanford, Calif. 94305          UUCP address: ...psuvax1!daveg%slacvm.bitnet
415-854-3300 x2538
usual disclaimer #432 applies: my employer apologizes for the fact
that I have access to this net.

jdm@gssc.UUCP (03/27/87)

Originally, I replied to someone wanting to do pattern fills in PostScript
by saying that PostScript only fills area with "color."

Eric Fielding responded by saying that it could be done with the bitmap
imaging operator, which is true to the extent that it CAN be done this way, 
it just is not even close to being done for you.

PostScript does NOT have any direct support for filling an area with anything
other than a "color."  What Eric describes involves defining a "character"
with the bitmap pattern that you want and tiling the area you want filled and
temporarily setting the clipping path to the outline of the filled area.

This sucks.  Granted, if your only other choice is to send down the bits 
for the entire area, the tiling approach will be faster, but you've got some
programming to do.

My point was that native PostScript does not have built-in pattern filling.
You have to do it yourself, one way or the other.  As management would say,
"It's just a simple matter of programming."  =) =)


-- jdm
-- 
in real life:  John D. Miller, Graphic Software Systems, Inc., Beaverton OR
...!{tektronix!verdix}!sequent!gssc!jdm                      (503) 641-2200
...!mntgfx!gssc!jdm                          "Roger.  Go with throttle up."

stew@endor.UUCP (03/28/87)

Obviously, it's possible to fill an area with a pattern;  the Macintosh
Laser Prep does it.  Look at that for an example.  Basically, you
use the setscreen operator to define a halftone screen with a procedure
that orders the pixels in the halftone screen cell so that the pixels
you want white in your pattern are the ones that the fill operator
whitens to form the halftone screen.

Normally, the standard spot function is used which is optimized for the
device.  You can get "line screen" or "dot screen" effects fairly easily
by redefining the spot function.  Try:

	/shape{newpath
		0 0 moveto 20 100 lineto 80 100 lineto 100 0 lineto
		closepath fill
	}def
	gsave
	50 50 translate
	/dotFreq 10.0 def
	dotFreq 0 {dup mul exch dup mul add 1 exch sub} setscreen
	0.05 0.05 0.99 {setgray shape 72 dotFreq div dup 3 mul translate}for
	grestore

If you just want to get patterns with 72 dpi resolution like you get
from quickdraw, use the routines defined in the Laser Prep: try
something like

	md begin
	gsave
	50 300 translate
	48<C06030180C060381>pat  % a simple striped pattern
	shape
	grestore
	showpage

where 48 is the number of zero bits in the 8-byte pattern.

Obtaining patterns finer-grained than that by modifying the Laser Prep
definitions for pat is left as an exercise for the reader.