| 1 |
%! |
| 2 |
% Colour separation. |
| 3 |
% Ask dvips to do 4 pages. In bop-hook, cycle |
| 4 |
% round CMYK color spaces. |
| 5 |
% |
| 6 |
% Sebastian Rahtz 30.9.93 |
| 7 |
% checked 7.1.94 |
| 8 |
% from Green Book, and Kunkel Graphic Design with PostScript |
| 9 |
% (Green Book Listing 9-5, on page 153.) |
| 10 |
% |
| 11 |
/seppages 0 def |
| 12 |
userdict begin |
| 13 |
/Min {% 3 items on stack |
| 14 |
2 copy lt { pop }{ exch pop } ifelse |
| 15 |
2 copy lt { pop }{ exch pop } ifelse |
| 16 |
} def |
| 17 |
/SetGray { |
| 18 |
1 exch sub systemdict begin adjustdot setgray end |
| 19 |
} def |
| 20 |
/sethsbcolor {systemdict begin |
| 21 |
sethsbcolor currentrgbcolor end |
| 22 |
userdict begin setrgbcolor end}def |
| 23 |
|
| 24 |
/ToCMYK |
| 25 |
% Red book p 305 |
| 26 |
{ |
| 27 |
% subtract each colour from 1 |
| 28 |
3 { 1 exch sub 3 1 roll } repeat |
| 29 |
% define percent of black undercolor |
| 30 |
% find minimum (k) |
| 31 |
3 copy Min |
| 32 |
% remove undercolor |
| 33 |
blackUCR sub |
| 34 |
dup 0 lt {pop 0} if |
| 35 |
/percent_UCR exch def |
| 36 |
% |
| 37 |
% subtract that from each colour |
| 38 |
% |
| 39 |
3 { percent_UCR sub 3 1 roll } repeat |
| 40 |
% work out black itself |
| 41 |
percent_UCR 1.25 mul % 1 exch sub |
| 42 |
% stack should now have C M Y K |
| 43 |
} def |
| 44 |
% |
| 45 |
% crop marks |
| 46 |
% |
| 47 |
/cX 18 def |
| 48 |
/CM{gsave TR 0 cX neg moveto 0 cX lineto stroke |
| 49 |
cX neg 0 moveto cX 0 lineto stroke grestore}def |
| 50 |
% |
| 51 |
/bop-hook{cX dup TR |
| 52 |
% |
| 53 |
% which page are we producing |
| 54 |
% |
| 55 |
seppages 1 add |
| 56 |
/seppages exch def |
| 57 |
seppages 5 eq { /seppages 1 def } if |
| 58 |
seppages 1 eq { |
| 59 |
/ColourName (CYAN) def |
| 60 |
CYAN setupcolor |
| 61 |
/WhichColour 3 def } if |
| 62 |
seppages 2 eq { |
| 63 |
/ColourName (MAGENTA) def |
| 64 |
MAGENTA setupcolor |
| 65 |
/WhichColour 2 def } if |
| 66 |
seppages 3 eq { |
| 67 |
/ColourName (YELLOW) def |
| 68 |
YELLOW setupcolor |
| 69 |
/WhichColour 1 def } if |
| 70 |
seppages 4 eq { |
| 71 |
/ColourName (BLACK) def |
| 72 |
BLACK setupcolor |
| 73 |
/WhichColour 0 def } if |
| 74 |
% |
| 75 |
% crop marks |
| 76 |
% |
| 77 |
gsave .3 setlinewidth |
| 78 |
3 -7 moveto |
| 79 |
/Helvetica findfont 6 scalefont setfont |
| 80 |
ColourName show |
| 81 |
0 0 CM |
| 82 |
vsize cX 2 mul sub dup hsize cX 2 mul sub dup isls{4 2 roll}if 0 CM |
| 83 |
exch CM 0 |
| 84 |
exch CM |
| 85 |
grestore 0 cX -2 mul TR isls |
| 86 |
{cX -2 mul 0 TR}if |
| 87 |
} def end |
| 88 |
% |
| 89 |
/separations 48 dict def |
| 90 |
separations begin |
| 91 |
/cmykprocs [ %def |
| 92 |
% cyan |
| 93 |
{ pop pop pop SetGray } |
| 94 |
% magenta |
| 95 |
{ pop pop exch pop SetGray } |
| 96 |
% yellow |
| 97 |
{ pop 3 1 roll pop pop SetGray } |
| 98 |
% black |
| 99 |
{ 4 1 roll pop pop pop SetGray } |
| 100 |
] def |
| 101 |
/rgbprocs [ %def |
| 102 |
% cyan |
| 103 |
{ ToCMYK pop pop pop SetGray } |
| 104 |
% magenta |
| 105 |
{ ToCMYK pop pop exch pop SetGray } |
| 106 |
% yellow |
| 107 |
{ ToCMYK pop 3 1 roll pop pop SetGray } |
| 108 |
% black |
| 109 |
{ ToCMYK 4 1 roll pop pop pop SetGray } |
| 110 |
] def |
| 111 |
/testprocs [ %def |
| 112 |
% cyan |
| 113 |
{ ToCMYK pop pop pop } |
| 114 |
% magenta |
| 115 |
{ ToCMYK pop pop exch pop } |
| 116 |
% yellow |
| 117 |
{ ToCMYK pop 3 1 roll pop pop } |
| 118 |
% black |
| 119 |
{ ToCMYK 4 1 roll pop pop pop } |
| 120 |
] def |
| 121 |
/screenangles [ %def |
| 122 |
105 % cyan |
| 123 |
75 % magenta |
| 124 |
0 % yellow |
| 125 |
45 % black |
| 126 |
] def |
| 127 |
end % separations |
| 128 |
|
| 129 |
% setupcolortakes 0, 1, 2, or 3 as its argument, |
| 130 |
% for cyan, magenta, yellow, and black. |
| 131 |
/CYAN 0 def /MAGENTA 1 def |
| 132 |
/YELLOW 2 def /BLACK 3 def |
| 133 |
/setupcolor{ %def |
| 134 |
userdict begin |
| 135 |
dup separations /cmykprocs get exch get |
| 136 |
/setcmykcolor exch def |
| 137 |
dup separations /rgbprocs get exch get |
| 138 |
/setrgbcolor exch def |
| 139 |
dup separations /testprocs get exch get |
| 140 |
/testrgbcolor exch def |
| 141 |
separations /screenangles get exch get |
| 142 |
currentscreen |
| 143 |
exch pop 3 -1 roll exch |
| 144 |
setscreen |
| 145 |
/setscreen { pop pop pop } def |
| 146 |
% |
| 147 |
% redefine setgray so that it only shows on the black separation |
| 148 |
% |
| 149 |
/setgray { |
| 150 |
WhichColour 0 eq |
| 151 |
{systemdict begin adjustdot setgray end} |
| 152 |
{pop systemdict begin 1 setgray end} |
| 153 |
ifelse}def |
| 154 |
end |
| 155 |
} bind def |
| 156 |
|
| 157 |
% |
| 158 |
% from Kunkel |
| 159 |
% |
| 160 |
/adjustdot { dup 0 eq { } { dup 1 exch sub .1 mul add} ifelse } def |
| 161 |
% |
| 162 |
% redefine existing operators |
| 163 |
% |
| 164 |
% Percent of undercolor removal |
| 165 |
/magentaUCR .3 def |
| 166 |
/yellowUCR .07 def |
| 167 |
/blackUCR .4 def |
| 168 |
% |
| 169 |
% Correct yellow and magenta |
| 170 |
/correctMY {rgb2cym |
| 171 |
1 index yellowUCR mul sub 3 1 roll |
| 172 |
1 index magentaUCR mul sub 3 1 roll |
| 173 |
3 1 roll rgb2cym}def |
| 174 |
% |
| 175 |
%(bluely green ) = |
| 176 |
%CYAN setupcolor |
| 177 |
%.1 .4 .5 testrgbcolor = |
| 178 |
%MAGENTA setupcolor |
| 179 |
%.1 .4 .5 testrgbcolor = |
| 180 |
%YELLOW setupcolor |
| 181 |
%.1 .4 .5 testrgbcolor = |
| 182 |
%BLACK setupcolor |
| 183 |
%.1 .4 .5 testrgbcolor = |
| 184 |
%quit |