🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.postscript
Article #4208

drawing a filled box

#4208
From: Tomas G. Rokicki
Date: Tue, 11 Dec 1990 19:50
42 lines
1822 bytes
Does anyone know how to draw a filled box to a precise device-dependent size?
For instance, I want exactly a 2 pixel by 100 pixel filled rectangle on a
300 dpi device.

Now some constraints.  If that same image is printed at 1270, I want to get
the correct (ie, 2*1270/300, 100*1270/300) size, within a pixel or two.
(So just subtracting one from the size and using fill doesn't work.)  I
want to get the same size rectangle no matter where on the page it is
found (so transform/itransform should help.)

I can do this with image.  Let us say for the moment that image and
imagemask don't exist; I need to do this with fill.

I need this to work on an original LaserWriter and more recent PostScript
devices.

Any suggestions?

This is a recent attempt:

%! PostScript
72 300 div dup scale
1000 1000 moveto
% width height drawfilledbox -
/baddrawfilledbox {
   .01 sub /height exch def .01 sub /width exch def
   gsave
      currentpoint transform round exch round exch itransform moveto
      0 width rlineto height 0 rlineto 0 width neg rlineto fill
   grestore
} def
/gooddrawfilledbox {
   /height exch def /width exch def
   gsave
      currentpoint translate height width scale
      1 1 false [1 0 0 1 0 0] { 8 string } imagemask
   grestore
} def
100 { 2 100 baddrawfilledbox 0 4 rmoveto } repeat
0 100 rmoveto
100 { 2 100 gooddrawfilledbox 0 4 rmoveto } repeat
showpage
Technical Details
Message-ID: <1990Dec11.195032.245@Neon.Stanford.EDU>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!julius.cs.uiuc.edu!apple!agate!shelby!neon!rokicki

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!julius.cs.uiuc.edu!apple!agate!shelby!neon!rokicki
From: rokicki@Neon.Stanford.EDU (Tomas G. Rokicki)
Newsgroups: comp.lang.postscript
Subject: drawing a filled box
Message-ID: <1990Dec11.195032.245@Neon.Stanford.EDU>
Date: 11 Dec 90 19:50:32 GMT
Organization: Computer Science Department, Stanford University
Lines: 42