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