]> git.lizzy.rs Git - plan9front.git/blob - sys/src/cmd/postscript/postmd/postmd.ps
delete old NOTICE file
[plan9front.git] / sys / src / cmd / postscript / postmd / postmd.ps
1 %
2 % Version 3.3.2 prologue for matrix display files.
3 %
4
5 /#copies 1 store
6 /aspectratio 1 def
7 /font /Helvetica def
8 /formsperpage 1 def
9 /landscape false def
10 /magnification 1 def
11 /margin 10 def
12 /orientation 0 def
13 /rotation 1 def
14 /size 9 def
15 /statspace 1.6 def
16 /ticklength .06 def
17 /tickspacing 10 def
18 /xoffset 0 def
19 /yoffset 0 def
20
21 /useclippath true def
22 /pagebbox [0 0 612 792] def
23
24 /inch {72 mul} bind def
25 /min {2 copy gt {exch} if pop} bind def
26
27 /show {show} bind def           % so later references don't bind
28 /stringwidth {stringwidth} bind def
29
30 /setup {
31         counttomark 2 idiv {def} repeat pop
32
33         landscape {/orientation 90 orientation add def} if
34
35         pagedimensions
36         height width lt {
37                 /statspace statspace height width div mul def
38                 /size size height width div mul def
39                 /ticklength ticklength height width div mul def
40         } if
41         /height height margin sub statspace inch sub ticklength inch sub size 6 mul sub def
42         /width width margin sub ticklength inch sub def
43         xcenter ycenter translate
44         orientation rotation mul rotate
45         xoffset inch yoffset inch translate
46         0 height 2 div height width min 2 div sub translate
47         0 statspace inch 2 div translate
48         magnification dup aspectratio mul scale
49
50         0 setlinewidth
51 } def
52
53 /pagedimensions {
54         useclippath {
55                 /pagebbox [clippath pathbbox newpath] def
56         } if
57         pagebbox aload pop
58         4 -1 roll exch 4 1 roll 4 copy
59         landscape {4 2 roll} if
60         sub /width exch def
61         sub /height exch def
62         add 2 div /xcenter exch def
63         add 2 div /ycenter exch def
64         userdict /gotpagebbox true put
65 } def
66
67 /pagesetup {/page exch def} bind def
68
69 /bitmap {
70         /scanlines exch def
71         /scanlength exch def
72
73         /picstr scanlength string def
74
75         gsave
76         height scanlines div width scanlength div min
77         /scaling exch def
78         scaling scaling scale
79
80         scanlength neg 2 div scanlines neg 2 div translate
81         scanlength scanlines scale
82         getbitmap
83         grestore
84 } bind def
85
86 /getbitmap {
87         scanlength scanlines 8 [scanlength 0 0 scanlines neg 0 scanlines] {
88                 0 {
89                         currentfile token pop dup
90                         0 eq {pop pop exit} if
91                         /charcount exch def
92                         picstr 1 index charcount getinterval
93                         /repl exch def
94                         currentfile repl readhexstring pop pop
95                         charcount add
96                         currentfile token pop {
97                                 picstr 1 index repl putinterval
98                                 charcount add
99                         } repeat
100                 } loop
101                 picstr
102         } image
103 } bind def
104
105 /labelmatrix {
106         /matrixlimits exch def
107         /matrixname exch def
108
109         gsave
110         scaling scaling scale
111         font findfont size scaling div scalefont setfont
112         scanlength neg 2 div scanlines 2 div translate
113
114         0 scanlines size 1.5 mul scaling div add neg moveto
115         matrixname show
116
117         scanlength scanlines size 1.5 mul scaling div add neg moveto
118         matrixlimits stringwidth pop neg 0 rmoveto
119         matrixlimits show
120
121         newpath
122         0 0 moveto
123         scanlength 0 rlineto
124         0 scanlines neg rlineto
125         scanlength neg 0 rlineto
126         closepath stroke
127
128         scanlength tickspacing idiv 1 add tickspacing 0 ticks
129         scanlines tickspacing idiv 1 add 0 tickspacing neg ticks
130         grestore
131 } bind def
132
133 /ticks {
134         /dy exch def
135         /dx exch def
136
137         /tl ticklength inch scaling div def
138         newpath
139         0 0 moveto
140         {
141                 gsave dx 0 eq {tl neg 0} {0 tl} ifelse rlineto stroke grestore
142                 dx dy rmoveto
143         } repeat
144 } bind def
145
146 /legend {
147         /regions exch def
148         /total exch def
149
150         gsave
151         width height min 2 div neg dup size 2 mul sub translate
152         0 statspace inch neg translate
153
154         gsave
155         regions {
156                 gsave
157                 total div statspace inch size 2 mul sub mul size 2 mul add
158                 width height min regions div exch scale
159                 1 1 8 [1 0 0 1 0 0] 5 -1 roll image
160                 grestore
161                 width height min regions div 0 translate
162         } repeat
163         grestore
164
165         width height min size 1.5 mul neg translate
166         font findfont size scalefont setfont
167         dup dup add 1 add width height min exch div /interval exch def
168         {
169                 interval neg 0 translate
170                 interval 2 div neg 0 translate
171                 dup stringwidth pop 2 div neg 0 moveto show
172                 interval 2 div neg 0 translate
173         } repeat
174         grestore
175 } bind def
176
177 /done {/lastpage where {pop lastpage} if} def