chiark / gitweb /
preview png, actually make it a png
[pandemic-rising-tide.git] / cmyk.ps
diff --git a/cmyk.ps b/cmyk.ps
index b0e595c20b87e4424445e4165d4746fb2658ce9c..73ecfda27ed6ae408ed30407cf03fb61d7905b6d 100644 (file)
--- a/cmyk.ps
+++ b/cmyk.ps
@@ -1,5 +1,52 @@
 %!
 
+/copyright [
+    (cmyk.{ps,pdf})
+    (v0.1)
+    (Copyright 2019)
+    (Ian Jackson)
+    (GNU AGPL v3+)
+    (NO WARRANTY)
+] def
+
+%    cmyk printer sample test
+%
+%    Copyright (C) 2019 Ian Jackson
+%
+%    This program is free software: you can redistribute it and/or modify
+%    it under the terms of the GNU Affero General Public License as
+%    published by the Free Software Foundation, either version 3 of the
+%    License, or (at your option) any later version.
+%
+%    This program is distributed in the hope that it will be useful,
+%    but WITHOUT ANY WARRANTY; without even the implied warranty of
+%    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+%    GNU Affero General Public License for more details.
+%
+%    You can obtain a copy of the GNU Affero General Public License
+%    from <http://www.gnu.org/licenses/>.
+
+%    CYM     K
+%
+%    9^3     0 1 2     9 pagex   @   9 x 9 x 3       = 243
+%
+%    pages Y
+%      horiz M         } M-C-K grid
+%        vert C        } M-C-K grid
+%           veert' K   } M-C-K grid
+%
+%    5^3     3 4       1 page    @   5 x 5 x 5 x 2   = 250
+%    5^3     6 8       1 page    @   5 x 5 x 5 x 2   = 250
+%
+%    pages K
+%      columns K'
+%        vert Y
+%          horiz M     } M-C-K grid
+%            vert' C   } M-C-K grid
+
+/debug false def
+%/debug true def
+
 /paperx 595 def
 /papery 842 def
 
@@ -8,7 +55,7 @@
 /printareax paperx margin 2 mul sub def
 /printareay papery margin 2 mul sub def
 
-/textx 12 def
+/textx 20 def
 /texty 12 def
 
 /szox printareax textx sub def
 
 % o = outer, i = inner, f = final
 
-/margox 5 def
-/margoy 5 def
+/margox 2 def
+/margoy 2 def
 
 /margix 2 def
 /margiy 2 def
 
+/margby 2 def
+
 % strid = stride
 
+/digits [ (0) (1) (2) (3) (4) (5) (6) (7) (8) (9)
+          (a) (b) (c) (d) (e) (f) ] def
+
+/cctexty 8 def
+/ccfont /Helvetica findfont cctexty scalefont def
+
+/Helvetica findfont texty scalefont setfont
+
+/ifdebug { debug exch if } def
+
+/klist_get {
+    klist
+        blackx
+        blacky  knx mul add
+       get
+} def
+/kentry_x {
+    textx
+    magentax stridox mul  add
+    blackx   stridix mul  add
+    
+} def
+/kentry_y {
+    blacky  neg kmy add  stridiy mul
+    cyany   neg  gm add  stridoy mul  add
+} def 
+
+/cmy_xy2val {
+    maxval gm div  mul  round cvi
+} def
+
+/maxvalshow {
+               (/) show
+               maxval (_) cvs show
+} def
+
 /someyellow {
     
-    /n      m     1 add   def
+    /gn     gm    1 add   def
     /kmx    knx   1 sub   def
     /kmy    kny   1 sub   def
 
-    /stridox  szox  n  div  def
-    /stridoy  szoy  n  div  def
+    /stridox  gridox  gn  div  def
+    /stridoy  gridoy  gn  div  def
 
     /szix  stridox  margox sub  def
     /sziy  stridoy  margoy sub  def
     /szfx  stridix  margix sub  def
     /szfy  stridiy  margiy sub  def
 
-    margin margin translate
-    textx  0      translate
+    0 1 gm {           /cyany    exch def
+    0 1 kmy {          /blacky   exch def
 
-    0 1 m {            /magenta exch def
-    0 1 m {            /cyan    exch def
+    0 1 gm {           /magentax exch def
+    0 1 kmx {          /blackx   exch def
 
     gsave
-
-        magenta                        stridox mul
-        cyan    neg m add      stridoy mul  translate
-
         szfy setlinewidth
+        kentry_x kentry_y translate
 
-        0 1 kmx {      /blackx exch def
-        0 1 kmy {      /blacky exch def
-
-               cyan            n div
-                 magenta       n div
-                 yellow                n div
-
-                 blackx        knx div
-                 blacky  add   kny div
-                 kfact mul  kbase add
+               cyany           gm div
+                 magentax      gm div
+                 yellowval     maxval div
+                klist_get maxval div
+ { 4 copy } ifdebug
 
                  setcmykcolor
 
-                blackx                         stridix mul
-                 blacky  neg kmy add           stridiy mul
-                 szfy -0.5 mul add
-                 moveto
-
+                0  szfy +0.5 mul  moveto
                 szfx 0 rlineto stroke
 
+ { gsave
+    /Helvetica findfont 6.5 scalefont setfont
+      0
+        1 1 4 {
+           index
+           0.5 ge {
+               pop 1
+           } if
         } for
+       setgray
+        0 1 3 {
+           6.5 mul  0 exch  moveto
+           20 string cvs   show
         } for
+ grestore } ifdebug
+
+
+
+      cyany 0 le  blacky 0 le  and {  % top row
+          0  setgray
+          0  stridiy margoy add  translate
+         0 0 moveto
+         text_u
+      } if
 
     grestore
 
     } for
     } for
 
+      gsave
+        0  kentry_y  translate
+       0 0 moveto
+       text_l
+      grestore
+
+    } for
+    } for
+
+    gsave
+      0  printareay texty sub  translate
+      0 0 moveto  text_ul
+    grestore
+
+} def
+
+/start_page {
+    margin margin translate
+} def
+start_page
+
+/finish_page {
     0 setgray
 
+    showpage
+    start_page
+} def
+
+/maxval 8 def
+
+/gm 8 def
+
+/knx 1 def
+/kny 3 def
+
+/klist [ 0 1 2 ] def
+/ylist [ 0 1 2 3 5 8 11 15 ] def
+
+/gridox szox def
+/gridoy szoy def
+
+/text_yellow {
+    (Y) show
+    yellowval (_) cvs show
+} def
+
+/text_ul { text_yellow } def
+
+/text_cyan {
+    (C) show
+    cyany cmy_xy2val (_) cvs show
+} def
+/text_magenta {
+    (M) show
+    magentax cmy_xy2val (_) cvs show
+    magentax gm ge { maxvalshow } if
+} def
+
+/text_l {
+     0  texty 0.25 mul  translate
+    cyany 0 le {
+        (K) show
+        klist blacky get (_) cvs show
+       0 texty moveto
+    } if
+    blacky 0 le {
+       text_cyan
+       cyany gm 2 sub ge {
+           gsave
+           ccfont setfont
+           cctexty 0.75 mul  texty -0.75 mul  translate
+           90 rotate
+           0 1 1 { /copyrighty exch def
+              0  cctexty copyrighty neg mul  moveto
+              copyright  cyany neg gm add 2 mul  copyrighty add  get
+              dup stringwidth
+              neg exch neg exch  rmoveto
+              show
+           } for
+           grestore
+       } if
+    } if
+} def
+/text_u {
+    text_magenta
 } def
 
 /ranges {
+    0 1 maxval {               /yellowval  exch def
+
+        /ytext { digits yellow get } def
 
-    0 1 m {                    /yellow  exch def
         someyellow
 
-        /Helvetica findfont 18 scalefont setfont
-        0 0 moveto
-        (Y) show
-        yellow (___) cvs show
-        showpage
+    finish_page
     } for
+} def
+ranges
 
+/gm 4 def
+/gn 5 def
+
+/knx 2 def
+/kny 1 def
+
+/text_u {
+    yellowy 0 le {
+       magentax 0 le {
+           (K) show
+           klist blackx get (_) cvs show
+           blackx knx 1 sub eq {
+               maxvalshow
+           } if
+           ( ) show
+       } if
+       blackx 0 le {
+           text_magenta
+           magentax gm ge {
+    gsave
+    ( ) show
+    ccfont setfont
+%    stridox gn mul stridoy sub  0 translate
+    %  stridix 0.5 mul -0.25 cctexty mul  0  exch  moveto
+    0 1 1 {
+    ( ) show
+       copyright exch get
+       show
+    } for
+    grestore
+           } if
+       } if
+    } if
+} def
+/text_ul {
+} def
+/text_l {
+    0 texty 0.5 mul translate
+    cyany 0 le { 0 texty moveto text_yellow } if
+    0 0 moveto text_cyan
 } def
 
-/m 16 def
+/ranges2 {
 
-/knx 1 def
-/kny 3 def
+  /gridoy szoy   margby 4 mul sub   gn div  def
 
-/kbase 0 def
-/kfact 0.5 def
+  0 1 gm { /yellowy exch def
 
-ranges
+    /yellowval yellowy cmy_xy2val  def
+    /text_u_p  yellowy 1 ge  def
+    gsave
+      0
+        yellowy  neg gm add   gridoy margby add  mul
+        translate
+     someyellow
+    grestore
+  } for
+
+  finish_page
+
+} def
+
+  /text_l_p true  def  
+
+/klist [ 3 4 ] def  ranges2
+/klist [ 6 8 ] def  /text_l_p false def  ranges2