pic: use troff drawing commands for filling objects
[troff.git] / home / ps / shade.ps
blob47e3167988c648cbf83407219109013612dcbf0d
2 % Shading support - primarily for ASCII file translators.
5 /grays [0.98 0.9 0.75 0.6] def
7 /setshade {
8         /level exch def
9         level 0 le {
10                 /textgray 0 def
11                 /backgray 1 def
12         }{
13                 /backgray level grays length gt
14                         {/textgray 1 def 0}
15                         {/textgray 0 def grays level 1 sub get}
16                 ifelse def
17         } ifelse
18         textgray setgray
19         /dY1 0 def
20         /dY2 0 def
21 } bind def
23 /drawrvbox {
24         /x2 exch charwidth mul def
25         /x1 exch charwidth mul def
27         x1 x2 lt {
28                 dup             % expects y on top
29                 /y1 exch linespace mul def
30                 /y2 y1 def
32                 dY1 0 eq dY2 0 eq and {
33                         currentfont /FontBBox get aload pop
34                         160 sub
35                         currentfont /FontMatrix get dtransform /dY2 exch def pop
36                         100 add
37                         currentfont /FontMatrix get dtransform /dY1 exch def pop
38                 } if
40                 /y1 y1 dY1 add def
41                 /y2 y2 dY2 add def
43                 backgray setgray
44                 newpath
45                 x1 y1 moveto
46                 x2 y1 lineto
47                 x2 y2 lineto
48                 x1 y2 lineto
49                 closepath fill
50         } if
51         textgray setgray
52 } bind def