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