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