| 1 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2 |
% CMYK-HAX.TEX: |
| 3 |
% E This is a set of TeX macros supporting color separation and |
| 4 |
% substitution using TeX/PostScript environment. Needs DVIPS and |
| 5 |
% COLORDVI from standard DVIPS distribution. |
| 6 |
% |
| 7 |
% P Zestaw makr TeX-owo-PostScript-owych do tworzenia wyci/ag/ow barwnych |
| 8 |
% i podmiany kolor/ow. Wsp/o/lpracuje ze sterownikiem DVIPS |
| 9 |
% i zestawem makr COLORDVI (ze standardowej dystrybucji DVIPS-a); |
| 10 |
% |
| 11 |
% AUTHORS' COORDINATES: |
| 12 |
% BOP s.c. |
| 13 |
% ul. Piastowska 70, 80-363 Gda\'nsk, Poland |
| 14 |
% tel./fax +48 58 553-46-59 |
| 15 |
% email: [email protected] |
| 16 |
% |
| 17 |
% VERSION 0.75, 15.06.2000 |
| 18 |
% Public domain |
| 19 |
% |
| 20 |
% HISTORY: |
| 21 |
% E version released during the GUST annual meeting Bacho\TeX'95. |
| 22 |
% P wersja udost/epniona podczas Bacho\TeX'95. |
| 23 |
% VERSION 0.51, 5 V 1995: |
| 24 |
% E macro \CMYKinit added (it places necessary def's in a PS prolog). |
| 25 |
% P dodane zosta/lo makro inicjalizacyjne `\CMYKinit', |
| 26 |
% kt/ore umieszcza w prologu PS u/zywane definicje. |
| 27 |
% VERSION 0.52, 27 VI 1995: |
| 28 |
% E the `currentpoint' fault in case of empty current path; now `currentpoint' |
| 29 |
% is called by the `stopped' command, which makes an error action |
| 30 |
% availlable. |
| 31 |
% P `currentpoint' generowa/l b/l/ad gdy bie/z/aca /scie/zki by/la pusta; |
| 32 |
% obecnie `currentpoint' jest wykonywane przez `stopped', |
| 33 |
% co daje mo/zliwo/s/c zareagowania na b/l/ad. |
| 34 |
% VERSION 0.53, 23 VII 1996: |
| 35 |
% E 1. the constant `epsilon=0.005' entered to do approximed |
| 36 |
% color comparations. |
| 37 |
% 2. \PSscreen became a \special. |
| 38 |
% P 1. wprowadzono sta/l/a `epsilon=0.005', kt/ora jest dok/ladno/sci/a |
| 39 |
% por/ownania kolor/ow. |
| 40 |
% 2. \PSscreen by/l dot/ad makrem TeX-owym o tre/sci PS-owej |
| 41 |
% sensowne jest, aby sta/l si/e \specialem |
| 42 |
% VERSION 0.54, 8 XI 1996 r. |
| 43 |
% E `show' redefinition allows the text outlining. |
| 44 |
% P redefinicja `show' umo/zliwia ju/z dok/ladanie obw/odki do tekst/ow. |
| 45 |
% VERSION 0.60, 11 IV 1997: |
| 46 |
% E processing of CMYK bitmaps enabled |
| 47 |
% P umo/zliwienie przetwarzania bitmap CMYK |
| 48 |
% VERSION 0.61, 11.VIII.1997 |
| 49 |
% E `adddownstroke' added (stroke under fill) |
| 50 |
% P dodano `adddownstroke' (rysowan/a pod fillem) |
| 51 |
% VERSION 0.62, 24.IX.1997 |
| 52 |
% E `setscreen' gets all parameters |
| 53 |
% P `setscreen' zyskuje wszystkie parametry podawane explicite |
| 54 |
% nie korzysta si/e z warto/sci `currentscreen' |
| 55 |
% VERSION 0.64, 9.VII.1999 |
| 56 |
% E bitmap color separation added, delblack (also for imagemask), |
| 57 |
% additional 5-th all-white bitmap separation (\BITinit and /to_sep_bitmap true def /hax_sep 4 def) |
| 58 |
% additional 6-th all-black bitmap separation (\BITinit and /to_sep_bitmap true def /hax_sep 5 def) |
| 59 |
% P do/l/aczono rozbarwianie bitmap, delblack (tak/ze dla imagemask), |
| 60 |
% 5. bia/ly wyci/ag z bitmap (\BITinit oraz /to_sep_bitmap true def /hax_sep 4 def) |
| 61 |
% 6. czarny wyci/ag z bitmap (\BITinit oraz /to_sep_bitmap true def /hax_sep 5 def) |
| 62 |
% VERSION 0.65, 6.VIII.1999 |
| 63 |
% E 5-th and 6-th bitmap separation were improved (`pop' added |
| 64 |
% in the case of not-dictionary images) |
| 65 |
% P poprawka w 5. i 6. wyci/agu bitmap (dodano `pop' w bitmapach |
| 66 |
% nies/lownikowych) |
| 67 |
% VERSION 0.66, 13.IX.1999 |
| 68 |
% E indexed color bitmaps support (for `colormap') |
| 69 |
% P obs/luga bitmap paletowych (do `colormap') |
| 70 |
% VERSION 0.67, 21.01.2000 |
| 71 |
% E support for multisource `colorimage' -- only CMYK separations |
| 72 |
% P obs/luga wersji wielo/xr/od/lowej polecenia `colorimage' |
| 73 |
% -- na razie tylko CMYK i tylko separacja |
| 74 |
% VERSION 0.68, 16.03.2000 |
| 75 |
% E \projectCMYK calls setcmykcolor explicite |
| 76 |
% P \projectCMYK wywo/luje explicite setcmykcolor |
| 77 |
% VERSION 0.70, 27.03.2000 |
| 78 |
% E image, colorimage and imagemask operators are transferred to |
| 79 |
% their dictionary form and we support them almost completly; |
| 80 |
% limitations: we support only bitmaps with |
| 81 |
% ImageType = 1, in one of Device Color Spaces, |
| 82 |
% when BitsPerComponent = 1 (other values of BitsPerComponent |
| 83 |
% we allow for imagemask, of corse, and for DeviceGray model -- |
| 84 |
% without color substitution, unfortunately) |
| 85 |
% P oparatory image, colorimage oraz imagemask przeniesione do wersji |
| 86 |
% s/lownikowej i prawie kompletnie obs/lu/zone; |
| 87 |
% ograniczenia: obs/lugujemy tylko bitmapy, dla kt/orych |
| 88 |
% ImageType = 1, model barw nale/zy do klasy Device Color Spaces, |
| 89 |
% BitsPerComponent = 8 (inne warto/sci BitsPerComponent dopuszczamy |
| 90 |
% oczywi/scie dla imagemask oraz w przypadku modelu DeviceGray -- |
| 91 |
% wtedy jednak nie potrafimy podmienia/c kolor/ow) |
| 92 |
% VERSION 0.71, 10.04.2000 |
| 93 |
% E 3 bugs fixed: |
| 94 |
% 1) we already support MultipleDataSources in ImageDict |
| 95 |
% 2) it was a superfluous pop in merge_multi3 |
| 96 |
% 3) 1 level of redefinition setcmykcolor (hax_setcmykcolor) added |
| 97 |
% P usuni/eto 3 pluskwy w obs/ludze image: |
| 98 |
% 1) ju/z obs/luguje si/e MultipleDataSources w ImageDict |
| 99 |
% 2) by/l zb/edny pop w merge_multi3 |
| 100 |
% 3) dodano 1 poziom redefinicji setcmykcolor (hax_setcmykcolor) |
| 101 |
% VERSION 0.73, 28.04.2000 |
| 102 |
% E 1) \sepbitmapfalse turns bitmap separation off, |
| 103 |
% \sepbitmaptrue turns bitmap separation on |
| 104 |
% 2) missing ImageDict parameter added before ori_image |
| 105 |
% P 1) \sepbitmapfalse wy/l/acza rozbarwianie bitmap, |
| 106 |
% \sepbitmaptrue przywraca rozbarwianie bitmap |
| 107 |
% 2) dodano brakuj/acy parametr ImageDict przed ori_image |
| 108 |
% VERSION 0.74, 11.05.2000 |
| 109 |
% E Bug in \delblacktrue handling has been fixed; |
| 110 |
% the colors created from black with changecolor can be separated now. |
| 111 |
% P Poprawiona pluskwa w obs/ludze \delblacktrue; |
| 112 |
% mo/zliwe staje si/e rozbarwianie kolor/ow powsta/lych z podmiany |
| 113 |
% koloru czarnego. |
| 114 |
% VERSION 0.75, 15.06.2000 |
| 115 |
% E \convertbitmaptrue turns on conversion of RGB bitmaps to CMYK, |
| 116 |
% to allow them to be separated |
| 117 |
% \convertbitmapfalse truns conversion off, by default, RGB bitmaps |
| 118 |
% are neither converted nor separated |
| 119 |
% P \convertbitmaptrue w/l/acza konwersj/e bitmap RGB do modelu CMYK, |
| 120 |
% co umo/zliwia ich rozbarwianie |
| 121 |
% \convertbitmapfalse wy/l/acza konwersj/e bitmap RGB do modelu CMYK, |
| 122 |
% co uniemo/zliwia ich rozbarwianie; domy/slnie bitmapy RGB nie s/a |
| 123 |
% ani konwertowane, ani rozbarwiane |
| 124 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 125 |
% |
| 126 |
\edef\slashcatcode {\the\catcode`\/} |
| 127 |
\catcode`\/12 |
| 128 |
% |
| 129 |
\def\CMYKinit {\special {! userdict begin |
| 130 |
% |
| 131 |
/ori_setcmykcolor where {pop} {/ori_setcmykcolor /setcmykcolor load def} ifelse |
| 132 |
/ori_setrgbcolor where {pop} {/ori_setrgbcolor /setrgbcolor load def} ifelse |
| 133 |
/ori_setgray where {pop} {/ori_setgray /setgray load def} ifelse |
| 134 |
/ori_colorimage where {pop} {/ori_colorimage /colorimage load def} ifelse |
| 135 |
/ori_image where {pop} {/ori_image /image load def} ifelse |
| 136 |
/ori_imagemask where {pop} {/ori_imagemask /imagemask load def} ifelse |
| 137 |
/ori_fill where {pop} {/ori_fill /fill load def} ifelse |
| 138 |
/ori_eofill where {pop} {/ori_eofill /eofill load def} ifelse |
| 139 |
/ori_stroke where {pop} {/ori_stroke /stroke load def} ifelse |
| 140 |
/ori_show where {pop} {/ori_show /show load def} ifelse |
| 141 |
/hax_setcmykcolor /ori_setcmykcolor load def |
| 142 |
% |
| 143 |
/maybe_black { |
| 144 |
4 copy |
| 145 |
1 sub abs epsilon le exch |
| 146 |
0 sub abs epsilon le and exch |
| 147 |
0 sub abs epsilon le and exch |
| 148 |
0 sub abs epsilon le and |
| 149 |
/if_delblack exch def |
| 150 |
} def |
| 151 |
% |
| 152 |
/my_fill {userdict begin if_delblack {newpath} {ori_fill} ifelse end} def |
| 153 |
/my_eofill {userdict begin if_delblack {newpath} {ori_eofill} ifelse end} def |
| 154 |
/my_stroke {userdict begin if_delblack {newpath} {ori_stroke} ifelse end} def |
| 155 |
/my_show {userdict begin if_delblack {false charpath currentpoint newpath moveto} {ori_show} ifelse end} def |
| 156 |
% |
| 157 |
/eofill {userdict begin my_eofill end} def |
| 158 |
/fill {userdict begin my_fill end} def |
| 159 |
/stroke {userdict begin my_stroke end} def |
| 160 |
/show {userdict begin my_show end} def |
| 161 |
% |
| 162 |
/setcmykcolor {userdict begin |
| 163 |
/k_ exch def /y_ exch def /m_ exch def /c_ exch def |
| 164 |
c_ m_ y_ k_ hax_setcmykcolor end} def |
| 165 |
/setgray {ori_setgray currentcmykcolor setcmykcolor} def |
| 166 |
/setrgbcolor {ori_setrgbcolor currentcmykcolor setcmykcolor} def |
| 167 |
% |
| 168 |
/hax_image { |
| 169 |
dup type cvlit /dicttype eq { |
| 170 |
/ImageDict exch def |
| 171 |
currentcolorspace dup length 1 eq % only Device color spaces |
| 172 |
ImageDict /ImageType get 1 eq and {% and ImageType 1 are supported |
| 173 |
0 get |
| 174 |
dup /DeviceRGB eq {/ncomp 3 def} if |
| 175 |
dup /DeviceGray eq {/ncomp 1 def} if |
| 176 |
/DeviceCMYK eq {/ncomp 4 def} if |
| 177 |
ImageDict /BitsPerComponent get 8 ne % only gray image separations |
| 178 |
/ncomp 1 ne and {/ncomp 0 def} if % allowed if sample is not a byte |
| 179 |
} {pop /ncomp 0 def} ifelse |
| 180 |
} { |
| 181 |
false 1 makeimagedict |
| 182 |
} ifelse |
| 183 |
ncomp 0 eq {ImageDict ori_image} {hax_image_} ifelse |
| 184 |
} def |
| 185 |
% |
| 186 |
/hax_colorimage { |
| 187 |
makeimagedict |
| 188 |
hax_image_ |
| 189 |
} def |
| 190 |
% |
| 191 |
/makeimagedict { |
| 192 |
dup /ncomp exch def |
| 193 |
dup 4 eq {/DeviceCMYK setcolorspace} if |
| 194 |
dup 3 eq {/DeviceRGB setcolorspace} if |
| 195 |
1 eq {/DeviceGray setcolorspace} if |
| 196 |
/ImageDict 7 dict def ImageDict begin |
| 197 |
{/MultipleDataSources true def |
| 198 |
ncomp array astore} if % store multi source in array |
| 199 |
/DataSource exch def |
| 200 |
/ImageMatrix exch def |
| 201 |
/BitsPerComponent exch def |
| 202 |
/Height exch def |
| 203 |
/Width exch def |
| 204 |
/Decode [ncomp {0 1} repeat] def |
| 205 |
/ImageType 1 def |
| 206 |
end |
| 207 |
} def |
| 208 |
% |
| 209 |
/data_str 65532 string def % very long |
| 210 |
/data_str_ 8192 string def |
| 211 |
/merge_multi4 { |
| 212 |
ImageDict /DataSource get aload pop |
| 213 |
dup type cvlit /filetype eq { |
| 214 |
/fdatsrck exch def |
| 215 |
/fdatsrcy exch def |
| 216 |
/fdatsrcm exch def |
| 217 |
/fdatsrcc exch def |
| 218 |
/datasrck {fdatsrck data_str_ readstring pop} def |
| 219 |
/datasrcy {fdatsrcy data_str_ readstring pop} def |
| 220 |
/datasrcm {fdatsrcm data_str_ readstring pop} def |
| 221 |
/datasrcc {fdatsrcc data_str_ readstring pop} def |
| 222 |
} { |
| 223 |
/datasrck exch def |
| 224 |
/datasrcy exch def |
| 225 |
/datasrcm exch def |
| 226 |
/datasrcc exch def |
| 227 |
} ifelse |
| 228 |
ImageDict /DataSource { |
| 229 |
data_str |
| 230 |
0 datasrcc {3 copy put pop 4 add} forall pop |
| 231 |
1 datasrcm {3 copy put pop 4 add} forall pop |
| 232 |
2 datasrcy {3 copy put pop 4 add} forall pop |
| 233 |
3 datasrck {3 copy put pop 4 add} forall |
| 234 |
3 sub 0 exch getinterval |
| 235 |
} put |
| 236 |
} def |
| 237 |
% |
| 238 |
/merge_multi3 { |
| 239 |
ImageDict /DataSource get aload pop |
| 240 |
dup type cvlit /filetype eq { |
| 241 |
/fdatsrcb exch def |
| 242 |
/fdatsrcg exch def |
| 243 |
/fdatsrcr exch def |
| 244 |
/datasrcb {fdatsrcb data_str_ readstring pop} def |
| 245 |
/datasrcg {fdatsrcg data_str_ readstring pop} def |
| 246 |
/datasrcr {fdatsrcr data_str_ readstring pop} def |
| 247 |
} { |
| 248 |
/datasrcb exch def |
| 249 |
/datasrcg exch def |
| 250 |
/datasrcr exch def |
| 251 |
} ifelse |
| 252 |
ImageDict /DataSource { |
| 253 |
data_str |
| 254 |
0 datasrcr {3 copy put pop 3 add} forall pop |
| 255 |
1 datasrcg {3 copy put pop 3 add} forall pop |
| 256 |
2 datasrcb {3 copy put pop 3 add} forall |
| 257 |
2 sub 0 exch getinterval |
| 258 |
} put |
| 259 |
} def |
| 260 |
% |
| 261 |
/i_Str 3 string def |
| 262 |
/O_Str 4 string def |
| 263 |
/UCR {0.5 mul} def |
| 264 |
/BG {0.7 mul} def |
| 265 |
/min {1 index 1 index le {pop} {exch pop} ifelse} def |
| 266 |
/max {1 index 1 index ge {pop} {exch pop} ifelse} def |
| 267 |
% |
| 268 |
/RGBtoCMYK {% RGB pixel is on the stack |
| 269 |
% RGB --> CMYK conversion (Red Book p. 306) |
| 270 |
dup 0 get R_scale mul R_shift add /c_i exch def |
| 271 |
dup 1 get G_scale mul G_shift add /m_i exch def |
| 272 |
2 get B_scale mul B_shift add /y_i exch def |
| 273 |
/k_i c_i m_i y_i min min def |
| 274 |
O_Str |
| 275 |
dup 0 255 0 c_i k_i UCR sub cvi max min put |
| 276 |
dup 1 255 0 m_i k_i UCR sub cvi max min put |
| 277 |
dup 2 255 0 y_i k_i UCR sub cvi max min put |
| 278 |
dup 3 255 0 k_i BG cvi max min put |
| 279 |
} def |
| 280 |
% |
| 281 |
/RGBtoCMYKfilter { |
| 282 |
ImageDict /Decode get aload pop % use Decode for RGB -> CMYK conversion |
| 283 |
2 copy sub /B_scale exch def pop 255 mul 255 exch sub /B_shift exch def |
| 284 |
2 copy sub /G_scale exch def pop 255 mul 255 exch sub /G_shift exch def |
| 285 |
2 copy sub /R_scale exch def pop 255 mul 255 exch sub /R_shift exch def |
| 286 |
/rtc_file ImageDict /DataSource get def |
| 287 |
ImageDict /DataSource {rtc_file i_Str readstring {RGBtoCMYK} if} |
| 288 |
0 () /SubFileDecode filter put |
| 289 |
/DeviceCMYK setcolorspace /ncomp 4 def |
| 290 |
ImageDict /Decode [0 1 0 1 0 1 0 1] put |
| 291 |
} def |
| 292 |
% |
| 293 |
/sep_str 8192 string def |
| 294 |
/SEP_CMYK { |
| 295 |
0 |
| 296 |
hax_sep 4 3 index length 1 sub { |
| 297 |
2 index exch get |
| 298 |
3 copy put pop |
| 299 |
1 add |
| 300 |
} for |
| 301 |
dup 0 ne {0 exch getinterval}{pop pop ()} ifelse |
| 302 |
} def |
| 303 |
% |
| 304 |
/SEPfilters { |
| 305 |
ncomp 4 eq { |
| 306 |
hax_sep 3 le { |
| 307 |
/sepproc /SEP_CMYK load def |
| 308 |
ImageDict begin /Decode [ |
| 309 |
Decode hax_sep 2 mul 1 add get |
| 310 |
Decode hax_sep 2 mul get |
| 311 |
] def end |
| 312 |
} { |
| 313 |
/sepproc {dup length 4 idiv 0 exch getinterval} def |
| 314 |
} ifelse |
| 315 |
/sep_file ImageDict /DataSource get def |
| 316 |
ImageDict /DataSource {sep_file sep_str readstring pop sepproc} 0 () |
| 317 |
/SubFileDecode filter put |
| 318 |
/DeviceGray setcolorspace |
| 319 |
} {% ncomp 1 eq |
| 320 |
hax_sep 3 ne {ImageDict /Decode [ 1 1 ] put} if |
| 321 |
} ifelse |
| 322 |
hax_sep 4 eq {ImageDict /Decode [ 1 1 ] put} if |
| 323 |
hax_sep 5 eq {ImageDict /Decode [ 0 0 ] put} if |
| 324 |
} def |
| 325 |
% |
| 326 |
/change_str 12288 string def % must be a multiplicity of 3 and 4 |
| 327 |
/CHANGEfilter { |
| 328 |
/change_file ImageDict /DataSource get def |
| 329 |
ImageDict /DataSource { |
| 330 |
change_file change_str readstring pop |
| 331 |
0 ncomp 2 index length ncomp sub { |
| 332 |
1 index exch 2 copy ncomp |
| 333 |
getinterval changebits putinterval |
| 334 |
} for |
| 335 |
} 0 () /SubFileDecode filter put |
| 336 |
} def |
| 337 |
% |
| 338 |
/hax_image_ { |
| 339 |
ImageDict /MultipleDataSources known { |
| 340 |
ImageDict /MultipleDataSources get { |
| 341 |
ImageDict /MultipleDataSources false put |
| 342 |
ImageDict /DataSource get length |
| 343 |
dup 4 eq {merge_multi4} if |
| 344 |
dup 3 eq {merge_multi3} if |
| 345 |
1 eq {ImageDict begin /DataSource DataSource aload pop def end} if |
| 346 |
} if |
| 347 |
} if |
| 348 |
ImageDict begin |
| 349 |
/DataSource dup load Width BitsPerComponent mul 7 add 8 idiv |
| 350 |
Height ncomp mul mul () /SubFileDecode filter def |
| 351 |
end |
| 352 |
to_change_bitmap {CHANGEfilter} if |
| 353 |
ncomp 3 eq to_convert_bitmap and {RGBtoCMYKfilter} if |
| 354 |
ncomp 3 ne to_sep_bitmap and {SEPfilters} if |
| 355 |
ImageDict ori_image |
| 356 |
} def |
| 357 |
% |
| 358 |
/zero_data_str 65532 string def % length of the data_str |
| 359 |
/hax_imagemask { |
| 360 |
if_delblack { |
| 361 |
dup type cvlit /dicttype eq { |
| 362 |
/ImageDict exch def |
| 363 |
} { |
| 364 |
/ImageDict 7 dict def ImageDict begin |
| 365 |
/DataSource exch def |
| 366 |
/ImageMatrix exch def |
| 367 |
/Decode exch {[1 0]} {[0 1]} ifelse def |
| 368 |
/Height exch def |
| 369 |
/Width exch def |
| 370 |
/BitsPerComponent 1 def |
| 371 |
/ImageType 1 def |
| 372 |
end |
| 373 |
} ifelse |
| 374 |
ImageDict begin |
| 375 |
/DataSource load Width 7 add 8 idiv Height mul |
| 376 |
() /SubFileDecode filter |
| 377 |
end /mask_file exch def |
| 378 |
ImageDict /DataSource { |
| 379 |
zero_data_str 0 mask_file data_str readstring pop length getinterval |
| 380 |
} 0 () /SubFileDecode filter put |
| 381 |
ImageDict /Decode [1 0] put |
| 382 |
ImageDict ori_imagemask |
| 383 |
} {ori_imagemask} ifelse |
| 384 |
} def |
| 385 |
% |
| 386 |
/truebp {0 matrix defaultmatrix matrix currentmatrix |
| 387 |
matrix invertmatrix matrix concatmatrix dtransform |
| 388 |
dup mul exch dup mul add sqrt} def |
| 389 |
/truein {72 mul truebp} def |
| 390 |
/truept {72.27 div truein} def |
| 391 |
/truesp {65536 div truept} def |
| 392 |
/truedd {1238 mul 1157 div truept} def |
| 393 |
/truecc {12 mul truedd} def |
| 394 |
/truemm {25.4 div truein} def |
| 395 |
/truecm {10 mul truemm} def |
| 396 |
% |
| 397 |
/epsilon 0.005 def |
| 398 |
/if_delblack false def |
| 399 |
/to_change_bitmap false def |
| 400 |
/to_convert_bitmap false def |
| 401 |
/to_sep_bitmap false def |
| 402 |
% |
| 403 |
currentcmykcolor setcmykcolor |
| 404 |
% |
| 405 |
end % userdict |
| 406 |
}}% \special \CMYKinit |
| 407 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 408 |
\def\PSbegingroup {\begingroup \special{ps: save }} |
| 409 |
\def\PSendgroup {\special{ps: restore }\endgroup} |
| 410 |
% |
| 411 |
\def\forcolor #1{\def\thecolor{#1}} |
| 412 |
\def\checkcolor {\thecolor\space count 4 lt {(Not CMYK ) print} if |
| 413 |
% k_ eq exch y_ eq and exch m_ eq and exch c_ eq and |
| 414 |
% comparison of colours with a predefined accurracy (epsilon): |
| 415 |
k_ sub abs epsilon le exch |
| 416 |
y_ sub abs epsilon le and exch |
| 417 |
m_ sub abs epsilon le and exch |
| 418 |
c_ sub abs epsilon le and } |
| 419 |
% |
| 420 |
\def\changefill #1{% |
| 421 |
\edef\changefills{\changefills \checkcolor |
| 422 |
{#1 hax_setcmykcolor} if }} |
| 423 |
\def\changestroke #1{% |
| 424 |
\edef\changestrokes{\changestrokes \checkcolor |
| 425 |
{#1 hax_setcmykcolor} if }} |
| 426 |
\def\changecolor #1{% |
| 427 |
\edef\changecolors{\changecolors \checkcolor |
| 428 |
{#1 hax_setcmykcolor} if }} |
| 429 |
\def\addfill #1{% |
| 430 |
\edef\addfills{\addfills \checkcolor {addfill} if }% |
| 431 |
\edef\changefills{\changefills \checkcolor |
| 432 |
{#1 hax_setcmykcolor} if }} |
| 433 |
\def\adddownstroke #1{% |
| 434 |
\edef\addstrokes{\addstrokes \checkcolor {adddownstroke} if }% |
| 435 |
\edef\changestrokes{\changestrokes \checkcolor |
| 436 |
{#1 hax_setcmykcolor} if }} |
| 437 |
\def\addstroke #1{% |
| 438 |
\edef\addstrokes{\addstrokes \checkcolor {addstroke} if }% |
| 439 |
\edef\changestrokes{\changestrokes \checkcolor |
| 440 |
{#1 hax_setcmykcolor} if }} |
| 441 |
\def\addcolor #1{\addstroke{#1}\addfill{#1}} |
| 442 |
\def\delfill {% |
| 443 |
\edef\delfills{\delfills \checkcolor {delfill} if }} |
| 444 |
\def\delstroke {% |
| 445 |
\edef\delstrokes{\delstrokes \checkcolor {delstroke} if }} |
| 446 |
\def\delcolor {% |
| 447 |
\edef\delcolors{\delcolors \checkcolor {delfill delstroke} if }} |
| 448 |
\def\strokehook #1{% |
| 449 |
\edef\strokehooks{\strokehooks \checkcolor {#1} if }} |
| 450 |
\def\fillhook #1{% |
| 451 |
\edef\fillhooks{\fillhooks \checkcolor {#1} if }} |
| 452 |
\def\strokeup {% |
| 453 |
\edef\changestrokes{\changestrokes \checkcolor {upstroke} if }} |
| 454 |
\def\fillup {% |
| 455 |
\edef\changestrokes{\changestrokes \checkcolor {upfill} if }} |
| 456 |
% |
| 457 |
\def\forbitmap #1{\def\thebitcolor{<#1>}} |
| 458 |
\def\checkbitcolor {dup \thebitcolor\space eq } |
| 459 |
% |
| 460 |
\def\changebitmap #1{% |
| 461 |
\edef\changebits{\changebits \checkbitcolor {pop <#1>} if }} |
| 462 |
% |
| 463 |
\def\setCMYKchange{% |
| 464 |
\edef\changestrokes{}% |
| 465 |
\edef\changefills{}% |
| 466 |
\edef\changecolors{}% |
| 467 |
\edef\addstrokes{}% |
| 468 |
\edef\addfills{}% |
| 469 |
\edef\delstrokes{}% |
| 470 |
\edef\delfills{}% |
| 471 |
\edef\delcolors{}% |
| 472 |
\edef\strokehooks{}% |
| 473 |
\edef\fillhooks{}% |
| 474 |
\edef\changebits{}% |
| 475 |
} |
| 476 |
% |
| 477 |
\def\fillinitials{% |
| 478 |
/to_fill true def |
| 479 |
/to_stroke false def |
| 480 |
/to_upstroke false def |
| 481 |
} |
| 482 |
\def\strokeinitials{% |
| 483 |
/to_fill false def |
| 484 |
/to_stroke true def |
| 485 |
/to_upstroke true def |
| 486 |
} |
| 487 |
% |
| 488 |
\def\useCMYKchange{% |
| 489 |
\special{ps: |
| 490 |
userdict begin |
| 491 |
/addfill {/to_fill true def} def |
| 492 |
/delfill {/to_fill false def} def |
| 493 |
/upfill {/to_upstroke false def} def |
| 494 |
/addstroke {/to_stroke true def upstroke} def |
| 495 |
/adddownstroke {/to_stroke true def upfill} def |
| 496 |
/delstroke {/to_stroke false def} def |
| 497 |
/upstroke {/to_upstroke true def} def |
| 498 |
/current_point {{currentpoint} stopped {0 0} if} def |
| 499 |
% |
| 500 |
/do_stroke { |
| 501 |
to_stroke {gsave \changestrokes \strokehooks my_stroke grestore} if |
| 502 |
} def |
| 503 |
% |
| 504 |
/eofill { |
| 505 |
userdict begin |
| 506 |
\fillinitials \delfills \delcolors \addstrokes |
| 507 |
current_point |
| 508 |
to_upstroke {} {do_stroke} ifelse |
| 509 |
to_fill {gsave \changefills \fillhooks my_eofill grestore} if |
| 510 |
to_upstroke {do_stroke} if |
| 511 |
newpath moveto |
| 512 |
end |
| 513 |
} def |
| 514 |
% |
| 515 |
/fill { |
| 516 |
userdict begin |
| 517 |
\fillinitials \delfills \delcolors \addstrokes |
| 518 |
current_point |
| 519 |
to_upstroke {} {do_stroke} ifelse |
| 520 |
to_fill {gsave \changefills \fillhooks my_fill grestore} if |
| 521 |
to_upstroke {do_stroke} if |
| 522 |
newpath moveto |
| 523 |
end |
| 524 |
} def |
| 525 |
% |
| 526 |
/stroke { |
| 527 |
userdict begin |
| 528 |
\strokeinitials \delstrokes \delcolors \addfills |
| 529 |
current_point |
| 530 |
to_upstroke {} {do_stroke} ifelse |
| 531 |
to_fill {gsave \changefills \fillhooks my_eofill grestore} if |
| 532 |
to_upstroke {do_stroke} if |
| 533 |
newpath moveto |
| 534 |
end |
| 535 |
} def |
| 536 |
% |
| 537 |
/show { |
| 538 |
userdict begin |
| 539 |
\fillinitials \delfills \delcolors \addstrokes |
| 540 |
to_upstroke {} {dup false gsave charpath do_stroke grestore} ifelse |
| 541 |
to_fill {dup gsave my_show grestore} {} ifelse |
| 542 |
to_upstroke {dup false gsave charpath do_stroke grestore} if |
| 543 |
false charpath current_point newpath moveto |
| 544 |
end |
| 545 |
} def |
| 546 |
% |
| 547 |
/setcmykcolor { |
| 548 |
userdict begin |
| 549 |
/k_ exch def /y_ exch def /m_ exch def /c_ exch def |
| 550 |
c_ m_ y_ k_ hax_setcmykcolor \changecolors |
| 551 |
end |
| 552 |
} def |
| 553 |
% |
| 554 |
currentcmykcolor setcmykcolor |
| 555 |
end}% |
| 556 |
\ifx\changebits\empty\else |
| 557 |
\BITinit |
| 558 |
\special{ps: |
| 559 |
userdict begin |
| 560 |
/to_change_bitmap true def |
| 561 |
/changebits {\changebits} def |
| 562 |
end}% |
| 563 |
\fi |
| 564 |
} |
| 565 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 566 |
\def\cyan {1 0 0 0} |
| 567 |
\def\magenta {0 1 0 0} |
| 568 |
\def\yellow {0 0 1 0} |
| 569 |
\def\black {0 0 0 1} |
| 570 |
\def\white {0 0 0 0} |
| 571 |
% |
| 572 |
\def\ScreenFrequency {150} |
| 573 |
\def\Cangle {15} |
| 574 |
\def\Mangle {75} |
| 575 |
\def\Yangle {0} |
| 576 |
\def\Kangle {45} |
| 577 |
% |
| 578 |
\def\PSscreen #1{\ifx\ScreenFrequency\empty |
| 579 |
\special{ps: currentscreen exch pop #1 exch setscreen}% |
| 580 |
\else |
| 581 |
\special{ps: |
| 582 |
/dot_spot {dup mul exch dup mul add 1 exch sub 2 div} def |
| 583 |
\ScreenFrequency\space #1 {dot_spot} setscreen |
| 584 |
}\fi} |
| 585 |
% |
| 586 |
\newif\ifdelblack \delblackfalse |
| 587 |
\newif\ifbitmapsep \bitmapseptrue |
| 588 |
% |
| 589 |
\def\sepbitmaptrue{% |
| 590 |
\bitmapseptrue |
| 591 |
\BITinit |
| 592 |
\special{ps: |
| 593 |
userdict begin |
| 594 |
/to_sep_bitmap true def |
| 595 |
end}} |
| 596 |
% |
| 597 |
\def\sepbitmapfalse{% |
| 598 |
\bitmapsepfalse |
| 599 |
\special{ps: |
| 600 |
userdict begin |
| 601 |
/to_sep_bitmap false def |
| 602 |
end}} |
| 603 |
% |
| 604 |
\def\convertbitmaptrue{% |
| 605 |
\BITinit |
| 606 |
\special{ps: |
| 607 |
userdict begin |
| 608 |
/to_convert_bitmap true def |
| 609 |
end}} |
| 610 |
% |
| 611 |
\def\convertbitmapfalse{% |
| 612 |
\special{ps: |
| 613 |
userdict begin |
| 614 |
/to_convert_bitmap false def |
| 615 |
end}} |
| 616 |
% |
| 617 |
\def\BITinit{\special{ps: |
| 618 |
userdict begin |
| 619 |
/image /hax_image load def |
| 620 |
/colorimage /hax_colorimage load def |
| 621 |
/imagemask /hax_imagemask load def |
| 622 |
end}} |
| 623 |
% |
| 624 |
\def\projectCMYK #1{% |
| 625 |
\edef\projectcolor{#1}% |
| 626 |
\ifx\projectcolor\cyan |
| 627 |
\special{ps: |
| 628 |
userdict begin |
| 629 |
/hax_sep 0 def |
| 630 |
/hax_setcmykcolor {\ifdelblack maybe_black \fi pop pop pop 1 exch sub ori_setgray} def |
| 631 |
end |
| 632 |
}% |
| 633 |
\PSscreen\Cangle |
| 634 |
\else \ifx\projectcolor\magenta |
| 635 |
\special{ps: |
| 636 |
userdict begin |
| 637 |
/hax_sep 1 def |
| 638 |
/hax_setcmykcolor {\ifdelblack maybe_black \fi pop pop exch pop 1 exch sub ori_setgray} def |
| 639 |
end |
| 640 |
}% |
| 641 |
\PSscreen\Mangle |
| 642 |
\else \ifx\projectcolor\yellow |
| 643 |
\special{ps: |
| 644 |
userdict begin |
| 645 |
/hax_sep 2 def |
| 646 |
/hax_setcmykcolor {\ifdelblack maybe_black \fi pop exch pop exch pop 1 exch sub ori_setgray} def |
| 647 |
end |
| 648 |
}% |
| 649 |
\PSscreen\Yangle |
| 650 |
\else \ifx\projectcolor\black |
| 651 |
\special{ps: |
| 652 |
userdict begin |
| 653 |
/hax_sep 3 def |
| 654 |
/hax_setcmykcolor {exch pop exch pop exch pop 1 exch sub ori_setgray} def |
| 655 |
end |
| 656 |
}% |
| 657 |
\PSscreen\Kangle |
| 658 |
\fi \fi \fi \fi |
| 659 |
\ifbitmapsep\sepbitmaptrue\fi |
| 660 |
\special{ps: currentcmykcolor setcmykcolor}% |
| 661 |
} |
| 662 |
% |
| 663 |
\def\CMYKlabels #1{{#1% #1 is a font csname |
| 664 |
\Cyan{CYAN} |
| 665 |
\Magenta{MAGENTA} |
| 666 |
\Yellow{YELLOW} |
| 667 |
\Black{BLACK}}} |
| 668 |
% |
| 669 |
\ifx\notCMYKinit\undefined\CMYKinit\fi |
| 670 |
% |
| 671 |
\catcode`\/\slashcatcode |
| 672 |
% |
| 673 |
\endinput |