chiark / gitweb /
debug
[pandemic-rising-tide.git] / cmyk.ps
1 %!
2
3 %    CYM     K
4 %
5 %    9^3     0 1 2     9 pagex   @   9 x 9 x 3       = 243
6 %
7 %    pages Y
8 %      horiz M         } M-C-K grid
9 %        vert C        } M-C-K grid
10 %           veert' K   } M-C-K grid
11 %
12 %    5^3     3 4       1 page    @   5 x 5 x 5 x 2   = 250
13 %    5^3     6 8       1 page    @   5 x 5 x 5 x 2   = 250
14 %
15 %    pages K
16 %      columns K'
17 %        vert Y
18 %          horiz M     } M-C-K grid
19 %            vert' C   } M-C-K grid
20
21 % OLD
22 %   16^3 x    0 .. 3       1 Y per page
23 %    8^3 x    4 .. 7       4 Y per page      8 = 0 2 4 6 8 10 12 15
24 %             8 10 13 15
25
26 /debug false def
27 /debug true def
28
29 /paperx 595 def
30 /papery 842 def
31
32 /margin 18 def
33
34 /printareax paperx margin 2 mul sub def
35 /printareay papery margin 2 mul sub def
36
37 /textx 20 def
38 /texty 12 def
39
40 /szox printareax textx sub def
41 /szoy printareay texty sub def
42
43 % o = outer, i = inner, f = final
44
45 /margox 5 def
46 /margoy 5 def
47
48 /margix 2 def
49 /margiy 2 def
50
51 /margbx 10 def
52 /margby 10 def
53
54 % strid = stride
55
56 /digits [ (0) (1) (2) (3) (4) (5) (6) (7) (8) (9)
57           (a) (b) (c) (d) (e) (f) ] def
58
59 /Helvetica findfont texty scalefont setfont
60
61 /ifdebug { debug exch if } def
62
63 /klist_get {
64     klist
65         blackx
66         blacky  knx mul add
67         get
68 } def
69 /kentry_x {
70     textx
71     magentax stridox mul  add
72     blackx   stridix mul  add
73     
74 } def
75 /kentry_y {
76     blacky  neg kmy add  stridiy mul
77     cyany   neg  gm add  stridoy mul  add
78 } def 
79
80 /cmy_xy2val {
81     maxval gm div mul round cvi
82 } def
83
84 /someyellow {
85     
86     /gn     gm    1 add   def
87     /kmx    knx   1 sub   def
88     /kmy    kny   1 sub   def
89
90     /stridox  gridox  gn  div  def
91     /stridoy  gridoy  gn  div  def
92
93     /szix  stridox  margox sub  def
94     /sziy  stridoy  margoy sub  def
95
96     /stridix  szix  knx  div def
97     /stridiy  sziy  kny  div def
98
99     /szfx  stridix  margix sub  def
100     /szfy  stridiy  margiy sub  def
101
102     0 1 gm {            /cyany    exch def
103     0 1 kmy {           /blacky   exch def
104
105     0 1 gm {            /magentax exch def
106     0 1 kmx {           /blackx   exch def
107
108     gsave
109         szfy setlinewidth
110         kentry_x kentry_y translate
111
112                 cyany           gn div
113                  magentax       gn div
114                  yellowval      gn div
115                  klist_get maxval div
116  { 4 copy } ifdebug
117
118                  setcmykcolor
119
120                 0  szfy +0.5 mul  moveto
121                 szfx 0 rlineto stroke
122
123  { gsave
124     /Helvetica findfont 6.5 scalefont setfont
125       0
126         1 1 4 {
127             index
128             0.5 ge {
129                 pop 1
130             } if
131         } for
132         setgray
133         0 1 3 {
134             6.5 mul  0 exch  moveto
135             20 string cvs   show
136         } for
137  grestore } ifdebug
138
139
140
141       cyany 0 le  blacky 0 le  and {  % top row
142           0  setgray
143           0  stridiy margoy add  translate
144           0 0 moveto
145           text_u
146       } if
147
148     grestore
149
150     } for
151     } for
152
153       gsave
154         0  kentry_y  translate
155         0 0 moveto
156         text_l
157       grestore
158
159     } for
160     } for
161
162     gsave
163       0  printareay texty sub  translate
164       0 0 moveto  text_ul
165     grestore
166
167 } def
168
169 /start_page {
170     margin margin translate
171 } def
172 start_page
173
174 /finish_page {
175     0 setgray
176
177     showpage
178     start_page
179 } def
180
181 /maxval 8 def
182
183 /gm 8 def
184
185 /knx 1 def
186 /kny 3 def
187
188 /klist [ 0 1 2 ] def
189 /ylist [ 0 1 2 3 5 8 11 15 ] def
190
191 /gridox szox def
192 /gridoy szoy def
193
194 /text_yellow {
195     (Y) show
196     yellowval (_) cvs show
197 } def
198
199 /text_ul { text_yellow } def
200
201 /text_cyan {
202     (C) show
203     cyany cmy_xy2val (_) cvs show
204 } def
205 /text_magenta {
206     (M) show
207     magentax cmy_xy2val (_) cvs show
208     magentax gm ge {
209         (/) show
210         maxval (_) cvs show
211     } if
212 } def
213
214 /text_l {
215      0  texty 0.25 mul  translate
216     cyany 0 le {
217         (K) show
218         klist blacky get (_) cvs show
219         0 texty moveto
220     } if
221     blacky 0 le {
222         text_cyan
223     } if
224 } def
225 /text_u {
226     text_magenta
227 } def
228
229 /ranges {
230     0 1 maxval {                /yellowval  exch def
231
232         /ytext { digits yellow get } def
233
234         someyellow
235
236     finish_page
237     } for
238 } def
239 ranges
240
241 /gm 4 def
242 /gn 5 def
243
244 /knx 2 def
245 /kny 1 def
246
247 /text_u {
248     yellowy 0 le {
249         magentax 0 le {
250             (K) show
251             klist blackx get (_) cvs show
252             ( ) show
253         } if
254         blackx 0 le {
255             text_magenta
256         } if
257     } if
258 } def
259 /text_ul {
260     text_yellow
261 } def
262 /text_l {
263     0 texty 0.5 mul rmoveto text_cyan
264 } def
265
266 /ranges2 {
267
268   /gridoy szoy   margby 4 mul sub   gn div  def
269
270   0 1 gm { /yellowy exch def
271
272     /yellowval yellowy cmy_xy2val  def
273     /text_u_p  yellowy 1 ge  def
274     gsave
275       0
276         yellowy  neg gm add   gridoy margby add  mul
277         translate
278      someyellow
279     grestore
280   } for
281
282   finish_page
283
284 } def
285
286   /text_l_p true  def  
287
288 /klist [ 3 4 ] def  ranges2
289 /klist [ 6 8 ] def  /text_l_p false def  ranges2