chiark / gitweb /
preview png, actually make it a png
[pandemic-rising-tide.git] / cmyk.ps
1 %!
2
3 /copyright [
4     (cmyk.{ps,pdf})
5     (v0.1)
6     (Copyright 2019)
7     (Ian Jackson)
8     (GNU AGPL v3+)
9     (NO WARRANTY)
10 ] def
11
12 %    cmyk printer sample test
13 %
14 %    Copyright (C) 2019 Ian Jackson
15 %
16 %    This program is free software: you can redistribute it and/or modify
17 %    it under the terms of the GNU Affero General Public License as
18 %    published by the Free Software Foundation, either version 3 of the
19 %    License, or (at your option) any later version.
20 %
21 %    This program is distributed in the hope that it will be useful,
22 %    but WITHOUT ANY WARRANTY; without even the implied warranty of
23 %    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24 %    GNU Affero General Public License for more details.
25 %
26 %    You can obtain a copy of the GNU Affero General Public License
27 %    from <http://www.gnu.org/licenses/>.
28
29 %    CYM     K
30 %
31 %    9^3     0 1 2     9 pagex   @   9 x 9 x 3       = 243
32 %
33 %    pages Y
34 %      horiz M         } M-C-K grid
35 %        vert C        } M-C-K grid
36 %           veert' K   } M-C-K grid
37 %
38 %    5^3     3 4       1 page    @   5 x 5 x 5 x 2   = 250
39 %    5^3     6 8       1 page    @   5 x 5 x 5 x 2   = 250
40 %
41 %    pages K
42 %      columns K'
43 %        vert Y
44 %          horiz M     } M-C-K grid
45 %            vert' C   } M-C-K grid
46
47 /debug false def
48 %/debug true def
49
50 /paperx 595 def
51 /papery 842 def
52
53 /margin 18 def
54
55 /printareax paperx margin 2 mul sub def
56 /printareay papery margin 2 mul sub def
57
58 /textx 20 def
59 /texty 12 def
60
61 /szox printareax textx sub def
62 /szoy printareay texty sub def
63
64 % o = outer, i = inner, f = final
65
66 /margox 2 def
67 /margoy 2 def
68
69 /margix 2 def
70 /margiy 2 def
71
72 /margby 2 def
73
74 % strid = stride
75
76 /digits [ (0) (1) (2) (3) (4) (5) (6) (7) (8) (9)
77           (a) (b) (c) (d) (e) (f) ] def
78
79 /cctexty 8 def
80 /ccfont /Helvetica findfont cctexty scalefont def
81
82 /Helvetica findfont texty scalefont setfont
83
84 /ifdebug { debug exch if } def
85
86 /klist_get {
87     klist
88         blackx
89         blacky  knx mul add
90         get
91 } def
92 /kentry_x {
93     textx
94     magentax stridox mul  add
95     blackx   stridix mul  add
96     
97 } def
98 /kentry_y {
99     blacky  neg kmy add  stridiy mul
100     cyany   neg  gm add  stridoy mul  add
101 } def 
102
103 /cmy_xy2val {
104     maxval gm div  mul  round cvi
105 } def
106
107 /maxvalshow {
108                 (/) show
109                 maxval (_) cvs show
110 } def
111
112 /someyellow {
113     
114     /gn     gm    1 add   def
115     /kmx    knx   1 sub   def
116     /kmy    kny   1 sub   def
117
118     /stridox  gridox  gn  div  def
119     /stridoy  gridoy  gn  div  def
120
121     /szix  stridox  margox sub  def
122     /sziy  stridoy  margoy sub  def
123
124     /stridix  szix  knx  div def
125     /stridiy  sziy  kny  div def
126
127     /szfx  stridix  margix sub  def
128     /szfy  stridiy  margiy sub  def
129
130     0 1 gm {            /cyany    exch def
131     0 1 kmy {           /blacky   exch def
132
133     0 1 gm {            /magentax exch def
134     0 1 kmx {           /blackx   exch def
135
136     gsave
137         szfy setlinewidth
138         kentry_x kentry_y translate
139
140                 cyany           gm div
141                  magentax       gm div
142                  yellowval      maxval div
143                  klist_get maxval div
144  { 4 copy } ifdebug
145
146                  setcmykcolor
147
148                 0  szfy +0.5 mul  moveto
149                 szfx 0 rlineto stroke
150
151  { gsave
152     /Helvetica findfont 6.5 scalefont setfont
153       0
154         1 1 4 {
155             index
156             0.5 ge {
157                 pop 1
158             } if
159         } for
160         setgray
161         0 1 3 {
162             6.5 mul  0 exch  moveto
163             20 string cvs   show
164         } for
165  grestore } ifdebug
166
167
168
169       cyany 0 le  blacky 0 le  and {  % top row
170           0  setgray
171           0  stridiy margoy add  translate
172           0 0 moveto
173           text_u
174       } if
175
176     grestore
177
178     } for
179     } for
180
181       gsave
182         0  kentry_y  translate
183         0 0 moveto
184         text_l
185       grestore
186
187     } for
188     } for
189
190     gsave
191       0  printareay texty sub  translate
192       0 0 moveto  text_ul
193     grestore
194
195 } def
196
197 /start_page {
198     margin margin translate
199 } def
200 start_page
201
202 /finish_page {
203     0 setgray
204
205     showpage
206     start_page
207 } def
208
209 /maxval 8 def
210
211 /gm 8 def
212
213 /knx 1 def
214 /kny 3 def
215
216 /klist [ 0 1 2 ] def
217 /ylist [ 0 1 2 3 5 8 11 15 ] def
218
219 /gridox szox def
220 /gridoy szoy def
221
222 /text_yellow {
223     (Y) show
224     yellowval (_) cvs show
225 } def
226
227 /text_ul { text_yellow } def
228
229 /text_cyan {
230     (C) show
231     cyany cmy_xy2val (_) cvs show
232 } def
233 /text_magenta {
234     (M) show
235     magentax cmy_xy2val (_) cvs show
236     magentax gm ge { maxvalshow } if
237 } def
238
239 /text_l {
240      0  texty 0.25 mul  translate
241     cyany 0 le {
242         (K) show
243         klist blacky get (_) cvs show
244         0 texty moveto
245     } if
246     blacky 0 le {
247         text_cyan
248         cyany gm 2 sub ge {
249             gsave
250             ccfont setfont
251             cctexty 0.75 mul  texty -0.75 mul  translate
252             90 rotate
253             0 1 1 { /copyrighty exch def
254                0  cctexty copyrighty neg mul  moveto
255                copyright  cyany neg gm add 2 mul  copyrighty add  get
256                dup stringwidth
257                neg exch neg exch  rmoveto
258                show
259             } for
260             grestore
261         } if
262     } if
263 } def
264 /text_u {
265     text_magenta
266 } def
267
268 /ranges {
269     0 1 maxval {                /yellowval  exch def
270
271         /ytext { digits yellow get } def
272
273         someyellow
274
275     finish_page
276     } for
277 } def
278 ranges
279
280 /gm 4 def
281 /gn 5 def
282
283 /knx 2 def
284 /kny 1 def
285
286 /text_u {
287     yellowy 0 le {
288         magentax 0 le {
289             (K) show
290             klist blackx get (_) cvs show
291             blackx knx 1 sub eq {
292                 maxvalshow
293             } if
294             ( ) show
295         } if
296         blackx 0 le {
297             text_magenta
298             magentax gm ge {
299     gsave
300     ( ) show
301     ccfont setfont
302 %    stridox gn mul stridoy sub  0 translate
303     %   stridix 0.5 mul -0.25 cctexty mul  0  exch  moveto
304     0 1 1 {
305     ( ) show
306         copyright exch get
307         show
308     } for
309     grestore
310             } if
311         } if
312     } if
313 } def
314 /text_ul {
315 } def
316 /text_l {
317     0 texty 0.5 mul translate
318     cyany 0 le { 0 texty moveto text_yellow } if
319     0 0 moveto text_cyan
320 } def
321
322 /ranges2 {
323
324   /gridoy szoy   margby 4 mul sub   gn div  def
325
326   0 1 gm { /yellowy exch def
327
328     /yellowval yellowy cmy_xy2val  def
329     /text_u_p  yellowy 1 ge  def
330     gsave
331       0
332         yellowy  neg gm add   gridoy margby add  mul
333         translate
334      someyellow
335     grestore
336   } for
337
338   finish_page
339
340 } def
341
342   /text_l_p true  def  
343
344 /klist [ 3 4 ] def  ranges2
345 /klist [ 6 8 ] def  /text_l_p false def  ranges2