chiark / gitweb /
wip text, 8 is wrong because off-by-one
[pandemic-rising-tide.git] / cmyk.ps
1 %!
2
3 %   16^3 x    0 .. 3       1 Y per page
4 %    8^3 x    4 .. 7       4 Y per page      8 = 0 2 4 6 8 10 12 15
5 %             8 10 13 15
6
7 /paperx 595 def
8 /papery 842 def
9
10 /margin 18 def
11
12 /printareax paperx margin 2 mul sub def
13 /printareay papery margin 2 mul sub def
14
15 /textx 20 def
16 /texty 12 def
17
18 /szox printareax textx sub def
19 /szoy printareay texty sub def
20
21 % o = outer, i = inner, f = final
22
23 /margox 5 def
24 /margoy 5 def
25
26 /margix 2 def
27 /margiy 2 def
28
29 /margbx 10 def
30 /margby 10 def
31
32 % strid = stride
33
34 /digits [ (0) (1) (2) (3) (4) (5) (6) (7) (8) (9)
35           (a) (b) (c) (d) (e) (f) ] def
36
37 /Helvetica findfont texty scalefont setfont
38
39 /klist_get {
40     klist
41         blackx
42         blacky  knx mul add
43         get
44 } def
45 /kentry_moveto {
46                 blackx                          stridix mul
47                  blacky  neg kmy add            stridiy mul
48                  szfy +0.5 mul add
49 } def
50
51 /someyellow {
52     
53     /gn     gm    1 add   def
54     /kmx    knx   1 sub   def
55     /kmy    kny   1 sub   def
56
57     /stridox  gridox  gn  div  def
58     /stridoy  gridoy  gn  div  def
59
60     /szix  stridox  margox sub  def
61     /sziy  stridoy  margoy sub  def
62
63     /stridix  szix  knx  div def
64     /stridiy  sziy  kny  div def
65
66     /szfx  stridix  margix sub  def
67     /szfy  stridiy  margiy sub  def
68
69     0 1 gm {            /magenta exch def
70     0 1 gm {            /cyan    exch def
71
72     gsave
73         textx  0      translate
74
75         magenta                 stridox mul
76         cyan    neg gm add      stridoy mul  translate
77
78         szfy setlinewidth
79  
80         0 1 kmx {       /blackx exch def
81         0 1 kmy {       /blacky exch def
82
83                 cyan            gn div
84                  magenta        gn div
85                  yellow         gn div
86
87                 klist_get base div
88
89                  setcmykcolor
90
91                 kentry_moveto moveto
92
93                 szfx 0 rlineto stroke
94
95         } for
96         } for
97
98     grestore
99     } for
100     } for
101
102     gsave
103
104       0  gridoy translate
105
106       text_l_p text_u_p and {
107         gsave
108           0 0 moveto  (K) show
109
110         gsave
111           0  stridoy neg  translate
112
113           0 1 kmx {     /blackx exch def
114           0 1 kmy {     /blacky exch def
115             kentry_moveto exch 0.65 mul exch moveto
116             klist_get digits exch get
117             show
118           } for
119           } for
120         grestore
121         grestore
122       } if
123
124       text_u_p {
125         gsave
126           textx 0 translate
127           0 0 moveto (Y) show ytext show
128
129           1 1 gm {              /magenta    exch def
130             gm stridox mul  0 moveto
131             digits gm get  show
132           } for
133
134         grestore  
135       } if
136
137     grestore
138
139 } def
140
141 /ranges {
142
143     0 1 gm {                    /yellow  exch def
144
145         /ytext digits yellow get def
146
147         someyellow
148
149     finish_page
150     } for
151
152 } def
153
154 /start_page {
155     margin margin translate
156 } def
157 start_page
158
159 /finish_page {
160     0 setgray
161
162     showpage
163     start_page
164 } def
165
166 /base 16 def
167
168 /gm 15 def
169
170 /knx 2 def
171 /kny 2 def
172
173 /klist [ 0 1 2 3 ] def
174 /ylist [ 0 1 2 3 5 8 11 15 ] def
175
176 /gridox szox def
177 /gridoy szoy def
178
179 /text_l_p true def
180 /text_u_p true def
181
182 ranges
183
184 /ranges2 {
185
186 /gm 8 def
187
188 /gridox szox 2 div margbx sub def
189 /gridoy szoy 2 div margby sub def
190
191 0 1 1 { /yellowpage exch def
192 0 1 1 { /yellowx exch def
193 0 1 1 { /yellowy exch def
194
195 /yellowix
196   yellowpage            4 mul
197   yellowy    neg 1 add  2 mul add
198   yellowx                     add def
199
200 gsave
201  yellowx  gridox margbx add  mul
202  yellowy  gridoy margby add  mul
203  translate
204
205  /yellow  ylist yellowix get  def
206
207  /text_l_p  yellowx 0 le  def
208  /text_u_p  yellowy 1 ge  def
209
210  someyellow
211 grestore
212
213 } for
214 } for
215 finish_page
216 } for
217
218 } def
219
220 /klist [ 4 5 6 7 ] def   ranges2
221 /klist [ 8 10 13 15 ] def ranges2