| 1 |
%D \module |
| 2 |
%D [ file=supp-mpe, |
| 3 |
%D version=1999.07.10, |
| 4 |
%D title=\CONTEXT\ Support Macros, |
| 5 |
%D subtitle=METAPOST Special Extensions, |
| 6 |
%D author=Hans Hagen, |
| 7 |
%D date=\currentdate, |
| 8 |
%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] |
| 9 |
%C |
| 10 |
%C This module is part of the \CONTEXT\ macro||package and is |
| 11 |
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for |
| 12 |
%C details. |
| 13 |
|
| 14 |
% fuzzy and complicating is the fact that we need to support |
| 15 |
% context as well as mptopdf, so we cannot fall back on the |
| 16 |
% special drivers and color module (although there may be |
| 17 |
% good reasons to use a smaller context instead); also, |
| 18 |
% shading is handled here while it should move to the special |
| 19 |
% driver - to do! |
| 20 |
|
| 21 |
%D This module is still experimental and deals with some |
| 22 |
%D extensions to \METAPOST. When using \POSTSCRIPT\ output, |
| 23 |
%D these extensions can be supplied by means of proper |
| 24 |
%D preamble definitions, but when producing \PDF\ we have to |
| 25 |
%D set up the appropriate datastructures ourselves. It acts as |
| 26 |
%D a plug in into \type {supp-pdf}. As soon as we need more |
| 27 |
%D extensions, we will generalize these macro. Some |
| 28 |
%D definitions will move to the special drivers. |
| 29 |
|
| 30 |
%D For usage in plain \TEX, say something: |
| 31 |
%D |
| 32 |
%D \starttyping |
| 33 |
%D \input supp-pdf |
| 34 |
%D \input supp-mpe |
| 35 |
%D |
| 36 |
%D \MPcmykcolorstrue |
| 37 |
%D \MPspotcolorstrue |
| 38 |
%D \makeMPintoPDFobject\plusone |
| 39 |
%D \stoptyping |
| 40 |
|
| 41 |
\ifx\writestatus\undefined |
| 42 |
\immediate\write16{[Loading MPS to PDF extensions.]} |
| 43 |
\else |
| 44 |
\writestatus{loading}{ConTeXt Support Macros / MPS extensions} |
| 45 |
\fi |
| 46 |
|
| 47 |
%D We implement extensions by using the \METAPOST\ special |
| 48 |
%D mechanism. Opposite to \TEX's specials, the \METAPOST\ ones |
| 49 |
%D are flushed before or after the graphic data, but thereby |
| 50 |
%D are no longer connected to a position. |
| 51 |
%D |
| 52 |
%D We implement specials by overloading the \type {fill} |
| 53 |
%D operator. By counting the fills, we can let the converter |
| 54 |
%D treat the appropriate fill in a special way. The |
| 55 |
%D specification of the speciality can have two forms, |
| 56 |
%D determined by the setting of a boolean variable: |
| 57 |
%D |
| 58 |
%D \starttyping |
| 59 |
%D _inline_specials_ := false ; % comment like code (default) |
| 60 |
%D _inline_specials_ := true ; % command like code |
| 61 |
%D \stoptyping |
| 62 |
%D |
| 63 |
%D When the specification is embedded as comment, it looks |
| 64 |
%D like: |
| 65 |
%D |
| 66 |
%D \starttyping |
| 67 |
%D %%MetaPostSpecial <size> <data> <number> <identifier> |
| 68 |
%D \stoptyping |
| 69 |
%D |
| 70 |
%D The in||line alternative is more tuned for \POSTSCRIPT, |
| 71 |
%D since it permits us to define a macro \type {special}. |
| 72 |
%D |
| 73 |
%D \starttyping |
| 74 |
%D inline : <data> <number> <identifier> <size> special |
| 75 |
%D \stoptyping |
| 76 |
%D |
| 77 |
%D The \type {identifier} determines what to do, and the data |
| 78 |
%D can be used to accomplish this. A type~2 shading function |
| 79 |
%D has identifier~2. Alltogether, the number of parameters is |
| 80 |
%D specified in \type {size}. The \type {number} is the number |
| 81 |
%D of the fill that needs the special treatment. For a type~2 |
| 82 |
%D and~3 shaded fill, the datablock contains the following |
| 83 |
|
| 84 |
%D data: |
| 85 |
%D |
| 86 |
%D \starttyping |
| 87 |
%D from to n inner_r g b x y outer_r g b x y |
| 88 |
%D from to n inner_r g b x y radius outer_r g b x y radius |
| 89 |
%D \stoptyping |
| 90 |
%D |
| 91 |
%D The implementation below saves the data on the stack in |
| 92 |
%D a way similar to the macros in \type {supp-pdf.tex}, and |
| 93 |
%D just overload a few already defined handlers. That way, |
| 94 |
%D the existing macros are still generic. \footnote {Actually, |
| 95 |
%D the macros here are just as generic.} |
| 96 |
%D |
| 97 |
%D Currently the only extension concerns shading, which is |
| 98 |
%D accomplished by handling yet another value of \type |
| 99 |
%D {\finiMPpath}. The recource disctionary is stored and |
| 100 |
%D later picked up by the general \CONTEXT\ figure inclusion |
| 101 |
%D macros. |
| 102 |
|
| 103 |
\unprotect |
| 104 |
|
| 105 |
%D The \type {%%MetaPostSpecials: version.revision signal} line |
| 106 |
%D triggers this module into handling color specifications kind |
| 107 |
%D of special. We need this safeguard for non||special |
| 108 |
%D usage. |
| 109 |
|
| 110 |
\chardef\MPspecialversion = 0 % specials when >1 |
| 111 |
\chardef\MPspecialrevision = 0 % specials when >1 |
| 112 |
\chardef\MPspecialsignal = 0 % passed on by graphic |
| 113 |
|
| 114 |
\chardef\inlineMPspecials = 1 % only needed for stack resetting |
| 115 |
|
| 116 |
%D This macro handles the special definitions that are |
| 117 |
%D passed as comment. |
| 118 |
|
| 119 |
\def\dohandleMPspecialcomment#1 |
| 120 |
{\setMPargument{#1}% |
| 121 |
\advance\scratchcounter \minusone |
| 122 |
\ifcase\scratchcounter |
| 123 |
\handleMPspecialcommand |
| 124 |
\donetrue |
| 125 |
\doresetMPstack |
| 126 |
\let\handleMPsequence\dohandleMPsequence |
| 127 |
\expandafter\handleMPsequence |
| 128 |
\else |
| 129 |
\expandafter\dohandleMPspecialcomment |
| 130 |
\fi} |
| 131 |
|
| 132 |
\def\handleMPspecialcomment #1 % number of arguments |
| 133 |
{\doresetMPstack |
| 134 |
\scratchcounter#1\relax |
| 135 |
\ifcase\scratchcounter % when zero, inline shading is used |
| 136 |
\chardef\inlineMPspecials\plusone |
| 137 |
\let\handleMPsequence\dohandleMPsequence |
| 138 |
\expandafter\handleMPsequence |
| 139 |
\else |
| 140 |
\chardef\inlineMPspecials\zerocount |
| 141 |
\expandafter\dohandleMPspecialcomment |
| 142 |
\fi} |
| 143 |
|
| 144 |
%D When defined inline, we use another macro to handle the |
| 145 |
%D definitions. Actually, this macro is called by the |
| 146 |
%D previous ones. |
| 147 |
|
| 148 |
\def\handleMPspecialcommand |
| 149 |
{\ifcase\inlineMPspecials\or |
| 150 |
\advance\nofMParguments \minusone % pop the size |
| 151 |
\fi |
| 152 |
\ifundefined\MPspecial |
| 153 |
\message{[unknown \MPspecial]}% |
| 154 |
\else |
| 155 |
\csname\MPspecial\endcsname |
| 156 |
\fi |
| 157 |
\ifcase\inlineMPspecials |
| 158 |
\doresetMPstack % 0 |
| 159 |
\else |
| 160 |
\resetMPstack % 1 |
| 161 |
\fi} |
| 162 |
|
| 163 |
%D This macro triggers special support. Currently, the |
| 164 |
%D version and revision number are not used. Any version number |
| 165 |
%D greater than zero will enable special support. |
| 166 |
|
| 167 |
\newconditional\manyMPspecials % \settrue\manyMPspecials |
| 168 |
|
| 169 |
\def\handleMPspecialscomment #1.#2 #3 % version.revision signal #4=div=1000|10000 |
| 170 |
{\doresetMPstack |
| 171 |
\chardef\MPspecialversion #1% |
| 172 |
\chardef\MPspecialrevision#2% |
| 173 |
\chardef\MPspecialsignal #3% |
| 174 |
\let\handleMPsequence\dohandleMPsequence |
| 175 |
\ifnum#1=\plusone |
| 176 |
\expandafter\handleMPsequence |
| 177 |
\else |
| 178 |
\expandafter\handleMPspecialscommentx |
| 179 |
\fi} |
| 180 |
|
| 181 |
\def\handleMPspecialscommentx #1 % version 2 |
| 182 |
% {\doifelsedoifelse{#1}{10000}{\settrue\manyMPspecials}{\setfalse\manyMPspecials}% local |
| 183 |
{\ifnum10000=0#1\relax |
| 184 |
\settrue \manyMPspecials |
| 185 |
\else |
| 186 |
\setfalse\manyMPspecials |
| 187 |
\fi |
| 188 |
\setMPextensions |
| 189 |
\handleMPsequence} |
| 190 |
|
| 191 |
% one can say (in meta-ini): |
| 192 |
% |
| 193 |
% \prependtoks |
| 194 |
% _special_div_ := 1000\ifconditional\manyMPspecials0\fi ; |
| 195 |
% \to \MPextensions |
| 196 |
|
| 197 |
%D In case of \PDF, we need to prepare resourcs. |
| 198 |
|
| 199 |
\newtoks\MPstartresources |
| 200 |
\newtoks\MPstopresources |
| 201 |
|
| 202 |
\def\startMPresources |
| 203 |
{\the\MPstartresources |
| 204 |
\ifx\currentPDFresources\empty\else |
| 205 |
\message{[unused resources]}% |
| 206 |
\fi |
| 207 |
\global\let\currentPDFresources\empty} |
| 208 |
|
| 209 |
\def\stopMPresources |
| 210 |
{\let\currentPDFresources\empty |
| 211 |
\the\MPstopresources} |
| 212 |
|
| 213 |
%D Since colors are not subjected to transformations, we can |
| 214 |
%D only use colors as signal. In our case, we use a dummy colored |
| 215 |
%D path with a red color component of \type {0.n}, so \type |
| 216 |
%D {0.001} is the first path and \type {0.010} the tenth. Since |
| 217 |
%D \METAPOST strips trailing zeros, we have to padd the string. |
| 218 |
|
| 219 |
\newif\ifMPcmykcolors |
| 220 |
\newif\ifMPspotcolors |
| 221 |
|
| 222 |
\ifx\normalhandleMPrgbcolor\undefined % in case we reload this module |
| 223 |
|
| 224 |
\let\normalhandleMPrgbcolor \handleMPrgbcolor |
| 225 |
\let\normalhandleMPcmykcolor\handleMPcmykcolor |
| 226 |
\let\normalhandleMPgraycolor\handleMPgraycolor |
| 227 |
\let\normalhandleMPspotcolor\handleMPspotcolor |
| 228 |
|
| 229 |
\fi |
| 230 |
|
| 231 |
%D When we are using \CONTEXT, we will fall back to the |
| 232 |
%D better color conversion routines. This also has the advantage |
| 233 |
%D that we don't have to parse and convert the file. In this |
| 234 |
%D alternative, \type {\!MP} is not (yet) supported. Because |
| 235 |
%D we can (for efficiency reasons) turn off strokecolor, |
| 236 |
%D something we cannot do in \METAPOST\ converted code. |
| 237 |
|
| 238 |
\newif\ifPDFMPstrokecolor \PDFMPstrokecolortrue |
| 239 |
|
| 240 |
%D [This code should move to meta-ini.] |
| 241 |
|
| 242 |
\ifCONTEXT % we can use this for a better xgstate handling |
| 243 |
|
| 244 |
\def\checkPDFMPstrokecolor |
| 245 |
{\ifPDFMPstrokecolor \PDFstrokecolortrue \fi} |
| 246 |
|
| 247 |
\def\normalhandleMPrgbcolor |
| 248 |
{{\checkPDFMPstrokecolor\execcolorR\gMPa1:\gMPa2:\gMPa3:0:0\od}} |
| 249 |
|
| 250 |
\def\normalhandleMPcmykcolor |
| 251 |
{{\checkPDFMPstrokecolor\execcolorC\gMPa1:\gMPa2:\gMPa3:\gMPa4:0:0\od}} |
| 252 |
|
| 253 |
\def\normalhandleMPgraycolor |
| 254 |
{{\checkPDFMPstrokecolor\execcolorS\gMPa1:0:0\od}} |
| 255 |
|
| 256 |
% \def\normalhandleMPspotcolor |
| 257 |
% {{\checkPDFMPstrokecolor\execcolorP\gMPa1:\gMPa2:0:0\od}} |
| 258 |
|
| 259 |
\def\normalhandleMPspotcolor % ??? |
| 260 |
{{\checkPDFMPstrokecolor\execcolorP\gMPa1:\gMPa2:\gMPa3:\gMPa4:0:0\od}} |
| 261 |
|
| 262 |
\fi |
| 263 |
|
| 264 |
% In the previous macros we use the special drivers. A more |
| 265 |
% direct approach would have been: |
| 266 |
% |
| 267 |
% \def\doPDFstartrgbcolormode#1#2#3% |
| 268 |
% {\PDFcode{#1 #2 #3 rg #1 #2 #3 RG}} |
| 269 |
% |
| 270 |
% \def\doPDFstartcmykcolormode#1#2#3#4% |
| 271 |
% {\PDFcode{#1 #2 #3 #4 k #1 #2 #3 #4 K}} |
| 272 |
% |
| 273 |
% \def\doPDFstartgraycolormode#1% |
| 274 |
% {\PDFcode{#1 g #1 G}} |
| 275 |
% |
| 276 |
% \appendtoks |
| 277 |
% \let\dostartrgbcolormode \doPDFstartrgbcolormode |
| 278 |
% \let\dostartcmykcolormode\doPDFstartcmykcolormode |
| 279 |
% \let\dostartgraycolormode\doPDFstartgraycolormode |
| 280 |
% \to \everyMPtoPDFconversion |
| 281 |
|
| 282 |
%D Now we can handle special color signals. We only do this |
| 283 |
%D when special are detected. |
| 284 |
|
| 285 |
% \def\MPrgbnumber#1{\expandafter\doMPrgbnumber#1000.0000\relax} |
| 286 |
% \def\doMPrgbnumber#1.#2#3#4#5\relax{#2#3#4} |
| 287 |
|
| 288 |
%D We cannot use \type {\everyMPtoPDFconversion} because in \MPTOPDF\ |
| 289 |
%D we don't have the \type {\appendtoks} macro available. |
| 290 |
|
| 291 |
\def\setMPextensions |
| 292 |
{\ifconditional\manyMPspecials |
| 293 |
\def\MPrgbnumber##1{\expandafter\doMPrgbnumber##10000.00000\relax}% |
| 294 |
\def\doMPrgbnumber##1.##2##3##4##5##6\relax{##2##3##4##5}% |
| 295 |
\else |
| 296 |
\def\MPrgbnumber##1{\expandafter\doMPrgbnumber##1000.0000\relax}% |
| 297 |
\def\doMPrgbnumber##1.##2##3##4##5\relax{##2##3##4}% |
| 298 |
\fi} |
| 299 |
|
| 300 |
%D The naive case looks like: |
| 301 |
%D |
| 302 |
%D \starttyping |
| 303 |
%D \def\handleMPrgbcolor% |
| 304 |
%D {\setMPcolor |
| 305 |
%D \ifcase\MPspecialversion |
| 306 |
%D \resetMPcolor\normalhandleMPrgbcolor |
| 307 |
%D \else\ifnum\MPrgbnumber\lastMPrvalue=\MPspecialsignal |
| 308 |
%D % consider it to be a signal |
| 309 |
%D \else |
| 310 |
%D \resetMPcolor\normalhandleMPrgbcolor |
| 311 |
%D \fi\fi} |
| 312 |
%D \stoptyping |
| 313 |
%D |
| 314 |
%D However, since we want \CMYK\ support, we will use the |
| 315 |
%D following implementation: |
| 316 |
|
| 317 |
% \def\setMPcolor |
| 318 |
% {\edef\lastMPrvalue{\gMPa1}% |
| 319 |
% \edef\lastMPgvalue{\gMPa2}% |
| 320 |
% \edef\lastMPbvalue{\gMPa3}} |
| 321 |
% |
| 322 |
% speed up (hardly called, so no let is needed) |
| 323 |
|
| 324 |
\def\setMPcolor |
| 325 |
{\edef\lastMPrvalue{\csname\@@MP01\endcsname}% |
| 326 |
\edef\lastMPgvalue{\csname\@@MP02\endcsname}% |
| 327 |
\edef\lastMPbvalue{\csname\@@MP03\endcsname}} |
| 328 |
|
| 329 |
\def\zeroMPrgbvalue{0.0} |
| 330 |
|
| 331 |
\def\resetMPcolor |
| 332 |
{\let\lastMPrvalue\zeroMPrgbvalue |
| 333 |
\let\lastMPgvalue\zeroMPrgbvalue |
| 334 |
\let\lastMPbvalue\zeroMPrgbvalue} |
| 335 |
|
| 336 |
\resetMPcolor |
| 337 |
|
| 338 |
\def\@@MPSK{@MPSK@} |
| 339 |
\def\@@MPSP{@MPSP@} |
| 340 |
|
| 341 |
\def\interceptMPcmykcolor % todo : \ifMPcmykcolors |
| 342 |
{\ifcase\MPrgbnumber\lastMPgvalue |
| 343 |
% cannot happen |
| 344 |
\or |
| 345 |
% 1 == cmyk color spec |
| 346 |
\ifMPcmykcolors \dointerceptMPcmykcolor \fi |
| 347 |
\or |
| 348 |
% 2 == spot color |
| 349 |
\ifMPspotcolors \dointerceptMPspotcolor \fi |
| 350 |
\or |
| 351 |
% 3 == rgb transparency |
| 352 |
\invokeMPtransparencyspecial |
| 353 |
\or |
| 354 |
% 4 == cmyk transparency |
| 355 |
\ifMPcmykcolors \invokeMPtransparencyspecial \fi |
| 356 |
\or |
| 357 |
% 5 == spot transparency |
| 358 |
\ifMPspotcolors \invokeMPtransparencyspecial \fi |
| 359 |
\else |
| 360 |
% \writestatus{MPtoPDF}{unknown direct special}% |
| 361 |
\fi} |
| 362 |
|
| 363 |
% ifcsname |
| 364 |
|
| 365 |
\def\dointerceptMPcmykcolor |
| 366 |
{\revokeMPtransparencyspecial |
| 367 |
\@EA\ifx\csname\@@MPSK\number\MPrgbnumber\lastMPbvalue\endcsname\relax\else |
| 368 |
\@EA\@EA\@EA\setMPcmyk\csname\@@MPSK\number\MPrgbnumber\lastMPbvalue\endcsname |
| 369 |
\normalhandleMPcmykcolor |
| 370 |
\fi} |
| 371 |
|
| 372 |
\def\dointerceptMPspotcolor |
| 373 |
{\revokeMPtransparencyspecial |
| 374 |
\@EA\ifx\csname\@@MPSP\number\MPrgbnumber\lastMPbvalue\endcsname\relax\else |
| 375 |
\@EA\@EA\@EA\setMPspot\csname\@@MPSP\number\MPrgbnumber\lastMPbvalue\endcsname |
| 376 |
\normalhandleMPspotcolor |
| 377 |
\fi} |
| 378 |
|
| 379 |
\def\handleMPrgbcolor |
| 380 |
{\resetMPcolor |
| 381 |
\ifcase\MPspecialversion |
| 382 |
\normalhandleMPrgbcolor |
| 383 |
\else |
| 384 |
\setMPcolor |
| 385 |
\ifnum\MPrgbnumber\lastMPrvalue=\MPspecialsignal\relax |
| 386 |
\interceptMPcmykcolor |
| 387 |
\else |
| 388 |
\revokeMPtransparencyspecial |
| 389 |
\normalhandleMPrgbcolor |
| 390 |
\fi |
| 391 |
\fi} |
| 392 |
|
| 393 |
\def\handleMPgraycolor |
| 394 |
{\resetMPcolor |
| 395 |
\ifcase\MPspecialversion \else \revokeMPtransparencyspecial \fi |
| 396 |
\normalhandleMPgraycolor} |
| 397 |
|
| 398 |
\def\handleMPcmykcolor |
| 399 |
{\resetMPcolor |
| 400 |
\ifcase\MPspecialversion \else \revokeMPtransparencyspecial \fi |
| 401 |
\normalhandleMPcmykcolor} |
| 402 |
|
| 403 |
%D Specials are define and recalled using: |
| 404 |
|
| 405 |
\def\MPspecial |
| 406 |
{MP special \gMPs\nofMParguments} |
| 407 |
|
| 408 |
\def\defineMPspecial#1#2% |
| 409 |
{\setvalue{MP special #1}{#2}} |
| 410 |
|
| 411 |
%D The path processing macro is slightly extended. |
| 412 |
|
| 413 |
\newtoks \invokeMPspecials |
| 414 |
|
| 415 |
\def\finishMPpath |
| 416 |
{\PDFcode |
| 417 |
{\ifcase\finiMPpath W n\or S\or f\or B\else W n\fi |
| 418 |
\extraMPpathcode}} |
| 419 |
|
| 420 |
\def\processMPpath |
| 421 |
{\checkMPpath % ! |
| 422 |
\ifcase\nofMPsegments\else |
| 423 |
\let\extraMPpathcode\empty |
| 424 |
\ifcase\MPspecialversion\else |
| 425 |
\ifnum\MPrgbnumber\lastMPrvalue=\MPspecialsignal |
| 426 |
\ifnum\MPrgbnumber\lastMPgvalue>10 % really needed |
| 427 |
\scratchcounter\MPrgbnumber\lastMPbvalue |
| 428 |
\edef\currentMPspecial{\the\scratchcounter}% |
| 429 |
\let\previousMPcolorspec\currentMPcolorspec |
| 430 |
\edef\currentMPcolorspec{\lastMPrvalue\lastMPgvalue\lastMPbvalue}% |
| 431 |
\ifx\previousMPcolorspec\currentMPcolorspec \else |
| 432 |
\revokeMPtransparencyspecial |
| 433 |
\fi |
| 434 |
\ifnum\finiMPpath=2 % to outer level |
| 435 |
\the\invokeMPspecials |
| 436 |
\fi |
| 437 |
\fi |
| 438 |
\fi |
| 439 |
\fi |
| 440 |
\flushMPpath |
| 441 |
\closeMPpath |
| 442 |
\finishMPpath |
| 443 |
\fi |
| 444 |
\let\handleMPsequence\dohandleMPsequence |
| 445 |
\resetMPstack |
| 446 |
\nofMPsegments0 |
| 447 |
\handleMPsequence} |
| 448 |
|
| 449 |
%D Shading is an example of a more advanced graphic feature, |
| 450 |
%D but users will seldom encounter those complications. Here |
| 451 |
%D we only show a few simple examples, but many other |
| 452 |
%D alternatives are possible by setting up the functions built |
| 453 |
%D in \PDF\ in the appropriate way. |
| 454 |
%D |
| 455 |
%D Shading has to do with interpolation between two or more |
| 456 |
%D points or user supplied ranges. In \PDF, the specifications |
| 457 |
%D of a shade has to be encapsulated in objects and passed on |
| 458 |
%D as resources. This is a \PDF\ level 1.3. feature. One can |
| 459 |
%D simulate three dimensional shades as well and define simple |
| 460 |
%D functions using a limited set of \POSTSCRIPT\ primitives. |
| 461 |
%D Given the power of \METAPOST\ and these \PDF\ features, we |
| 462 |
%D can achieve superb graphic effects. |
| 463 |
%D |
| 464 |
%D Since everything is hidden in \TEX\ and \METAPOST\ graphics, |
| 465 |
%D we can stick to high level \CONTEXT\ command, as shown in |
| 466 |
%D the following exmples. |
| 467 |
%D |
| 468 |
%D \startbuffer |
| 469 |
%D \startuniqueMPgraphic{CircularShade} |
| 470 |
%D path p ; p := unitsquare xscaled \overlaywidth yscaled \overlayheight ; |
| 471 |
%D circular_shade(p,0,.2red,.9red) ; |
| 472 |
%D \stopuniqueMPgraphic |
| 473 |
%D |
| 474 |
%D \startuniqueMPgraphic{LinearShade} |
| 475 |
%D path p ; p := unitsquare xscaled \overlaywidth yscaled \overlayheight ; |
| 476 |
%D linear_shade(p,0,.2blue,.9blue) ; |
| 477 |
%D \stopuniqueMPgraphic |
| 478 |
%D |
| 479 |
%D \startuniqueMPgraphic{DuotoneShade} |
| 480 |
%D path p ; p := unitsquare xscaled \overlaywidth yscaled \overlayheight ; |
| 481 |
%D linear_shade(p,2,.5green,.5red) ; |
| 482 |
%D \stopuniqueMPgraphic |
| 483 |
%D \stopbuffer |
| 484 |
%D |
| 485 |
%D \typebuffer |
| 486 |
%D |
| 487 |
%D \getbuffer |
| 488 |
%D |
| 489 |
%D These graphics can be hooked into the overlay mechanism, |
| 490 |
%D which is available in many commands. |
| 491 |
%D |
| 492 |
%D \startbuffer |
| 493 |
%D \defineoverlay[demo 1][\uniqueMPgraphic{CircularShade}] |
| 494 |
%D \defineoverlay[demo 2][\uniqueMPgraphic {LinearShade}] |
| 495 |
%D \defineoverlay[demo 3][\uniqueMPgraphic {DuotoneShade}] |
| 496 |
%D \stopbuffer |
| 497 |
%D |
| 498 |
%D \typebuffer |
| 499 |
%D |
| 500 |
%D \getbuffer |
| 501 |
%D |
| 502 |
%D These backgrounds can for instance be applied to \type |
| 503 |
%D {\framed}: |
| 504 |
%D |
| 505 |
%D \startbuffer |
| 506 |
%D \setupframed[width=3cm,height=2cm,frame=off] |
| 507 |
%D \startcombination[3*1] |
| 508 |
%D {\framed[background=demo 1]{\bfd \white Demo 1}} {} |
| 509 |
%D {\framed[background=demo 2]{\bfd \white Demo 2}} {} |
| 510 |
%D {\framed[background=demo 3]{\bfd \white Demo 3}} {} |
| 511 |
%D \stopcombination |
| 512 |
%D \stopbuffer |
| 513 |
%D |
| 514 |
%D \typebuffer |
| 515 |
%D |
| 516 |
%D \startlinecorrection |
| 517 |
%D \getbuffer |
| 518 |
%D \stoplinecorrection |
| 519 |
%D |
| 520 |
%D There are a few more alternatives, determined by the second |
| 521 |
%D parameter passed to \type {circular_shade} and alike. |
| 522 |
%D |
| 523 |
%D \def\SomeShade#1#2#3#4#5% |
| 524 |
%D {\startuniqueMPgraphic{Shade-#1} |
| 525 |
%D width := \overlaywidth ; |
| 526 |
%D height := \overlayheight ; |
| 527 |
%D path p ; p := unitsquare xscaled width yscaled height ; |
| 528 |
%D #2_shade(p,#3,#4,#5) ; |
| 529 |
%D \stopuniqueMPgraphic |
| 530 |
%D \defineoverlay[Shade-#1][\uniqueMPgraphic{Shade-#1}]% |
| 531 |
%D \framed[backgroundachtergrond=Shade-#1,width=2cm,height=2cm,frame=off]{}} |
| 532 |
%D |
| 533 |
%D \startlinecorrection |
| 534 |
%D \startcombination[5*1] |
| 535 |
%D {\SomeShade{10}{circular}{0}{.3blue}{.9blue}} {circular 0} |
| 536 |
%D {\SomeShade{11}{circular}{1}{.3blue}{.9blue}} {circular 1} |
| 537 |
%D {\SomeShade{12}{circular}{2}{.3blue}{.9blue}} {circular 2} |
| 538 |
%D {\SomeShade{13}{circular}{3}{.3blue}{.9blue}} {circular 3} |
| 539 |
%D {\SomeShade{14}{circular}{4}{.3blue}{.9blue}} {circular 4} |
| 540 |
%D \stopcombination |
| 541 |
%D \stoplinecorrection |
| 542 |
%D |
| 543 |
%D \blank |
| 544 |
%D |
| 545 |
%D \startlinecorrection |
| 546 |
%D \startcombination[5*1] |
| 547 |
%D {\SomeShade{20}{circular}{0}{.9green}{.3green}} {circular 0} |
| 548 |
%D {\SomeShade{21}{circular}{1}{.9green}{.3green}} {circular 1} |
| 549 |
%D {\SomeShade{22}{circular}{2}{.9green}{.3green}} {circular 2} |
| 550 |
%D {\SomeShade{23}{circular}{3}{.9green}{.3green}} {circular 3} |
| 551 |
%D {\SomeShade{24}{circular}{4}{.9green}{.3green}} {circular 4} |
| 552 |
%D \stopcombination |
| 553 |
%D \stoplinecorrection |
| 554 |
%D |
| 555 |
%D \blank |
| 556 |
%D |
| 557 |
%D \startlinecorrection |
| 558 |
%D \startcombination[4*1] |
| 559 |
%D {\SomeShade{30}{linear}{0}{.3red}{.9red}} {linear 0} |
| 560 |
%D {\SomeShade{31}{linear}{1}{.3red}{.9red}} {linear 1} |
| 561 |
%D {\SomeShade{32}{linear}{2}{.3red}{.9red}} {linear 2} |
| 562 |
%D {\SomeShade{33}{linear}{3}{.3red}{.9red}} {linear 3} |
| 563 |
%D \stopcombination |
| 564 |
%D \stoplinecorrection |
| 565 |
%D |
| 566 |
%D These macros closely cooperate with the \METAPOST\ module |
| 567 |
%D \type {mp-spec.mp}, which is part of the \CONTEXT\ |
| 568 |
%D distribution. |
| 569 |
%D |
| 570 |
%D The low level (\PDF) implementation is based on the \TEX\ |
| 571 |
%D based \METAPOST\ to \PDF\ converter. Shading is supported |
| 572 |
%D by overloading the \type {fill} operator as implemented |
| 573 |
%D earlier. In \PDF\ type~2 and~3 shading functions are |
| 574 |
%D specified in terms of: |
| 575 |
%D |
| 576 |
%D \starttabulate[|Tl|l|] |
| 577 |
%D \NC /Domain \NC sort of meeting range \NC \NR |
| 578 |
%D \NC /C0 \NC inner shade \NC \NR |
| 579 |
%D \NC /C1 \NC outer shade \NC \NR |
| 580 |
%D \NC /N \NC smaller values, bigger inner circles \NC \NR |
| 581 |
%D \stoptabulate |
| 582 |
|
| 583 |
\newcount\currentPDFshade % 0 % global (document wide) counter |
| 584 |
\let\currentMPshades\empty |
| 585 |
|
| 586 |
\def\startMPshading#1% |
| 587 |
{\edef\currentMPspecial{\gMPs{#1}}} |
| 588 |
|
| 589 |
\def\stopMPshading |
| 590 |
{\global\advance\currentPDFshade \plusone |
| 591 |
\setxvalue{obj:Sh:\currentMPspecial}% |
| 592 |
{/Sh\the\currentPDFshade\space\the\pdflastobj\space0 R }% |
| 593 |
\setxvalue{mps:Sh:\currentMPspecial}% |
| 594 |
{\the\currentPDFshade}} |
| 595 |
|
| 596 |
\appendtoks |
| 597 |
\global\let\currentMPshades\empty |
| 598 |
\to \MPstartresources |
| 599 |
|
| 600 |
\appendtoks |
| 601 |
\ifx\currentMPshades\empty \else |
| 602 |
\xdef\currentPDFresources{\currentPDFresources |
| 603 |
/Shading <<\currentMPshades>>}% |
| 604 |
\fi |
| 605 |
\to \MPstopresources |
| 606 |
|
| 607 |
\def\invokeMPshadespecial |
| 608 |
{\ifundefined{mps:Sh:\currentMPspecial}\else |
| 609 |
\edef\currentMPshade{\getvalue{obj:Sh:\currentMPspecial}}% |
| 610 |
\doifinstringelse\currentMPshade\currentMPshades \donothing |
| 611 |
{\xdef\currentMPshades{\currentMPshades\currentMPshade}}% |
| 612 |
\def\extraMPpathcode{/Sh\getvalue{mps:Sh:\currentMPspecial} sh Q}% |
| 613 |
\chardef\finiMPpath\zerocount |
| 614 |
\PDFcode{q /Pattern cs}% |
| 615 |
\fi} |
| 616 |
|
| 617 |
\appendtoks \invokeMPshadespecial \to \invokeMPspecials |
| 618 |
|
| 619 |
%D We need to convert the \CMYK\ specials into colors, because |
| 620 |
%D we have to do it twice, we define a macro. |
| 621 |
|
| 622 |
% \def\checkMPshadingcolor#1#2#3#4#5% |
| 623 |
% {\edef\tempMPrvalue{\csname\@@MP0#1\endcsname}% |
| 624 |
% \edef\tempMPgvalue{\csname\@@MP0#2\endcsname}% |
| 625 |
% \edef\tempMPbvalue{\csname\@@MP0#3\endcsname}% |
| 626 |
% \edef#5% |
| 627 |
% {\ifx\tempMPrvalue\tempMPgvalue |
| 628 |
% \ifx\tempMPrvalue\tempMPbvalue |
| 629 |
% \ifx\tempMPgvalue\tempMPbvalue |
| 630 |
% \tempMPbvalue |
| 631 |
% \fi |
| 632 |
% \fi |
| 633 |
% \fi}% |
| 634 |
% \edef#4% todo : spotcolors |
| 635 |
% {\ifnum\MPrgbnumber\tempMPrvalue=\MPspecialsignal\space |
| 636 |
% \ifMPcmykcolors\getvalue{\@@MPSK\number\MPrgbnumber\tempMPbvalue}\fi |
| 637 |
% \fi}} |
| 638 |
|
| 639 |
\def\checkMPshadingcolor#1#2#3#4#5% |
| 640 |
{\edef\tempMPrvalue{\csname\@@MP0#1\endcsname}% |
| 641 |
\edef\tempMPgvalue{\csname\@@MP0#2\endcsname}% |
| 642 |
\edef\tempMPbvalue{\csname\@@MP0#3\endcsname}% |
| 643 |
\global\let\MPresolvedspace\MPgrayspace |
| 644 |
\global\let\MPresolvedcolor\!!zerocount |
| 645 |
\ifnum\MPrgbnumber\tempMPrvalue=\MPspecialsignal\relax |
| 646 |
\ifcase\MPrgbnumber\tempMPgvalue |
| 647 |
\or % 1 = cmyk |
| 648 |
\ifMPcmykcolors |
| 649 |
\expanded{\resolveMPcmykcolor\getvalue{\@@MPSK\number\MPrgbnumber\tempMPbvalue}}\end |
| 650 |
\fi |
| 651 |
\or % 2 = spot |
| 652 |
\ifMPspotcolors |
| 653 |
\expanded{\resolveMPspotcolor\getvalue{\@@MPSP\number\MPrgbnumber\tempMPbvalue}}\end |
| 654 |
\fi |
| 655 |
\or |
| 656 |
% 3 = rgb transparency |
| 657 |
% to do |
| 658 |
\or |
| 659 |
% 4 == cmyk transparency |
| 660 |
% \ifMPcmykcolors |
| 661 |
% to do |
| 662 |
% \fi |
| 663 |
\or |
| 664 |
% 5 == spot transparency |
| 665 |
% \ifMPspotcolors |
| 666 |
% to do |
| 667 |
% \fi |
| 668 |
\fi |
| 669 |
\else |
| 670 |
\ifx\tempMPrvalue\tempMPgvalue |
| 671 |
\ifx\tempMPrvalue\tempMPbvalue |
| 672 |
\expanded{\resolveMPgraycolor\tempMPbvalue}\end |
| 673 |
\else |
| 674 |
\expanded{\resolveMPrgbcolor\tempMPrvalue\space\tempMPgvalue\space\tempMPbvalue}\end |
| 675 |
\fi |
| 676 |
\else |
| 677 |
\expanded{\resolveMPrgbcolor\tempMPrvalue\space\tempMPgvalue\space\tempMPbvalue}\end |
| 678 |
\fi |
| 679 |
\fi |
| 680 |
\let#4\MPresolvedcolor |
| 681 |
\let#5\MPresolvedspace} |
| 682 |
|
| 683 |
%D We also need to make sure that we have two \RGB\ or |
| 684 |
%D \CMYK colors, since we have to set the colorspace. |
| 685 |
|
| 686 |
\def\setMPshadingcolors#1#2#3#4#5#6% color space |
| 687 |
{\checkMPshadingcolor{#1}{#2}{#3}\MPshadeAc\MPshadeAs |
| 688 |
\checkMPshadingcolor{#4}{#5}{#6}\MPshadeBc\MPshadeBs |
| 689 |
\ifx\MPshadeAs\MPshadeBs |
| 690 |
\let\MPshadeA\MPshadeAc |
| 691 |
\let\MPshadeB\MPshadeBc |
| 692 |
\let\MPshadeC\MPshadeAs |
| 693 |
\else\ifx\MPshadeAs\MPgrayspace |
| 694 |
\ifx\MPshadeBs\MPrgbspace |
| 695 |
\edef\MPshadeA{\MPshadeAc\space\MPshadeAc\space\MPshadeAc}% |
| 696 |
\else |
| 697 |
\negatecolorcomponent\MPshadeAc |
| 698 |
\edef\MPshadeA{0 0 0 \MPshadeAc}% |
| 699 |
\fi |
| 700 |
\let\MPshadeB\MPshadeBc |
| 701 |
\let\MPshadeC\MPshadeBs |
| 702 |
\else\ifx\MPshadeBs\MPgrayspace |
| 703 |
\let\MPshadeA\MPshadeAc |
| 704 |
\ifx\MPshadeAs\MPrgbspace |
| 705 |
\edef\MPshadeB{\MPshadeBc\space\MPshadeBc\space\MPshadeBc}% |
| 706 |
\else |
| 707 |
\negatecolorcomponent\MPshadeBc |
| 708 |
\edef\MPshadeB{0 0 0 \MPshadeBc}% |
| 709 |
\fi |
| 710 |
\let\MPshadeC\MPshadeAs |
| 711 |
\else |
| 712 |
% different color spaces |
| 713 |
\def\MPshadeA{1}% |
| 714 |
\def\MPshadeB{1}% |
| 715 |
\let\MPshadeC\MPgrayspace |
| 716 |
\fi\fi\fi} |
| 717 |
|
| 718 |
\let\MPshadeA\MPcmykWhite |
| 719 |
\let\MPshadeB\MPcmykBlack |
| 720 |
\let\MPshadeC\MPgrayspace |
| 721 |
|
| 722 |
%D The reason why this macro is a bit complicates is that we |
| 723 |
%D handle black and white situations (otherwise we would have |
| 724 |
%D to use \CMYK\ b/w in case of a \CMYK\ shade). |
| 725 |
|
| 726 |
%D Here are the special handlers: |
| 727 |
|
| 728 |
\defineMPspecial{30} |
| 729 |
{\startMPshading{14}% type 2 |
| 730 |
\setMPshadingcolors{4}{5}{6}{9}{10}{11}% |
| 731 |
\immediate\pdfobj |
| 732 |
{<</FunctionType 2 |
| 733 |
/Domain [\gMPs1 \gMPs2] |
| 734 |
/C0 [\MPshadeA] |
| 735 |
/C1 [\MPshadeB] |
| 736 |
/N \gMPs3>>}% |
| 737 |
\immediate\pdfobj |
| 738 |
{<</ShadingType 2 |
| 739 |
/ColorSpace /\MPshadeC\space |
| 740 |
/Function \the\pdflastobj\space 0 R |
| 741 |
/Coords [\gMPs7 \gMPs8 \gMPs{12} \gMPs{13}] |
| 742 |
/Extend [true true]>>}% |
| 743 |
\stopMPshading} |
| 744 |
|
| 745 |
\defineMPspecial{31} |
| 746 |
{\startMPshading{16}% type 3 |
| 747 |
\setMPshadingcolors{4}{5}{6}{10}{11}{12}% |
| 748 |
\immediate\pdfobj |
| 749 |
{<</FunctionType 2 |
| 750 |
/Domain [\gMPs1 \gMPs2] |
| 751 |
/C0 [\MPshadeA] |
| 752 |
/C1 [\MPshadeB] |
| 753 |
/N \gMPs3>>}% |
| 754 |
\immediate\pdfobj |
| 755 |
{<</ShadingType 3 |
| 756 |
/ColorSpace /\MPshadeC\space |
| 757 |
/Function \the\pdflastobj\space 0 R |
| 758 |
/Coords [\gMPs7 \gMPs8 \gMPs9 \gMPs{13} \gMPs{14} \gMPs{15}] |
| 759 |
/Extend [true true]>>}% |
| 760 |
\stopMPshading} |
| 761 |
|
| 762 |
%D Figure inclusion is kind of strange to \METAPOST, but when |
| 763 |
%D Santiago Muelas started discussing this with me, I was able |
| 764 |
%D to cook up a solution using specials. |
| 765 |
|
| 766 |
\def\invokeMPfigurespecial% |
| 767 |
{\getvalue{mps:gr:\currentMPspecial}} % or \relax |
| 768 |
|
| 769 |
\appendtoks \invokeMPfigurespecial \to \invokeMPspecials |
| 770 |
|
| 771 |
\defineMPspecial{10} |
| 772 |
{\setxvalue{mps:gr:\gMPs8}% |
| 773 |
{\noexpand\handleMPfigurespecial |
| 774 |
{\gMPs1}{\gMPs2}{\gMPs3}{\gMPs4}{\gMPs5}{\gMPs6}{\gMPs7}% |
| 775 |
\noexpand\setxvalue{mps:gr:\gMPs8}{}}} |
| 776 |
|
| 777 |
% \def\handleMPfigurespecial#1#2#3#4#5#6#7% |
| 778 |
% {\vbox to 0pt |
| 779 |
% {\vss |
| 780 |
% \hbox to 0pt |
| 781 |
% {\pdfliteral{q #1 #2 #3 #4 #5 #6 cm}% |
| 782 |
% \pdfimage width 1bp height 1bp {#7}% maybe 10 is better |
| 783 |
% \pdfliteral{Q}% |
| 784 |
% \hss}}} |
| 785 |
% |
| 786 |
% better, since xform reuse |
| 787 |
|
| 788 |
\def\handleMPfigurespecial#1#2#3#4#5#6#7% todo : combine with ext fig |
| 789 |
{\vbox to \zeropoint |
| 790 |
{\vss |
| 791 |
\hbox to \zeropoint |
| 792 |
{\ifcase\pdfoutput\or % will be hooked into the special driver |
| 793 |
\doiffileelse{#7} |
| 794 |
{\doifundefinedelse{mps:x:#7} |
| 795 |
{\immediate\pdfximage\!!width\onebasepoint\!!height\onebasepoint{#7}% |
| 796 |
\setxvalue{mps:x:#7}{\pdfrefximage\the\pdflastximage}}% |
| 797 |
{\message{[reusing figure #7]}}% |
| 798 |
\PDFcode{q #1 #2 #3 #4 #5 #6 cm}% |
| 799 |
\rlap{\getvalue{mps:x:#7}}% |
| 800 |
\PDFcode{Q}} |
| 801 |
{\message{[unknown figure #7]}}% |
| 802 |
\fi |
| 803 |
\hss}}} |
| 804 |
|
| 805 |
%D An example of using both special features is the |
| 806 |
%D following. |
| 807 |
%D |
| 808 |
%D \starttyping |
| 809 |
%D \startMPpage |
| 810 |
%D externalfigure "hakker1b.png" scaled 22cm rotated 10 shifted (-2cm,0cm); |
| 811 |
%D externalfigure "hakker1b.png" scaled 10cm rotated -10 ; |
| 812 |
%D externalfigure "hakker1b.png" scaled 7cm rotated 45 shifted (8cm,12cm) ; |
| 813 |
%D path p ; p := unitcircle xscaled 15cm yscaled 20cm; |
| 814 |
%D path q ; q := p rotatedaround(center p,90) ; |
| 815 |
%D path r ; r := buildcycle(p,q) ; clip currentpicture to r ; |
| 816 |
%D path s ; s := boundingbox currentpicture enlarged 5mm ; |
| 817 |
%D picture c ; c := currentpicture ; currentpicture := nullpicture ; |
| 818 |
%D circular_shade(s,0,.2red,.9red) ; |
| 819 |
%D addto currentpicture also c ; |
| 820 |
%D \stopMPpage |
| 821 |
%D \stoptyping |
| 822 |
|
| 823 |
%D This is some experimental hyperlink driver that I wrote |
| 824 |
%D for Mark Wicks. |
| 825 |
|
| 826 |
\defineMPspecial{20} |
| 827 |
{\setxvalue{mps:hl:\gMPs6}% |
| 828 |
{\noexpand\handleMPhyperlink |
| 829 |
{\gMPs1}{\gMPs2}{\gMPs3}{\gMPs4}{\gMPs5}% |
| 830 |
\noexpand\setxvalue{mps:hl:\gMPs6}{}}} |
| 831 |
|
| 832 |
\def\handleMPhyperlink#1#2#3#4#5% |
| 833 |
{%\ifcase\pdfoutput\or |
| 834 |
\setbox\scratchbox\hbox |
| 835 |
{\setbox\scratchbox\null |
| 836 |
\scratchdimen#1\onebasepoint\scratchdimen-\scratchdimen |
| 837 |
\advance\scratchdimen#3\onebasepoint |
| 838 |
\wd\scratchbox\scratchdimen |
| 839 |
\scratchdimen#2\onebasepoint\scratchdimen-\scratchdimen |
| 840 |
\advance\scratchdimen#4\onebasepoint |
| 841 |
\ht\scratchbox\scratchdimen |
| 842 |
\incolorfalse |
| 843 |
\gotobox{\box\scratchbox}[#5]}% |
| 844 |
\setbox\scratchbox\hbox |
| 845 |
{\scratchdimen\MPxoffset\onebasepoint\advance\scratchdimen#1\onebasepoint |
| 846 |
\hskip\scratchdimen |
| 847 |
\scratchdimen\MPyoffset\onebasepoint\advance\scratchdimen#2\onebasepoint |
| 848 |
\raise\scratchdimen\box\scratchbox}% |
| 849 |
\smashbox\scratchbox |
| 850 |
\box\scratchbox |
| 851 |
}%\fi} |
| 852 |
|
| 853 |
\def\invokeMPhyperlinkspecial% |
| 854 |
{\getvalue{mps:hl:\currentMPspecial}} % or \relax |
| 855 |
|
| 856 |
\appendtoks \invokeMPhyperlinkspecial \to \invokeMPspecials |
| 857 |
|
| 858 |
%D Special number~1 is dedicated to \CMYK\ support. If you |
| 859 |
%D want to know why: look at this: |
| 860 |
%D |
| 861 |
%D \startbuffer[mp] |
| 862 |
%D fill fullcircle xyscaled (3cm,1cm) withcolor \MPcolor{test} ; |
| 863 |
%D \stopbuffer |
| 864 |
%D |
| 865 |
%D \startbuffer[cmyk] |
| 866 |
%D \startcombination[4*1] |
| 867 |
%D {\definecolor[test][c=1,y=.3,k=.3] \processMPbuffer[mp]} {c=1 y=.3 k=.3} |
| 868 |
%D {\definecolor[test][c=.9,y=.15] \processMPbuffer[mp]} {c=.9 y=.15} |
| 869 |
%D {\definecolor[test][c=.25,y=.8] \processMPbuffer[mp]} {c=.25 y=.8} |
| 870 |
%D {\definecolor[test][c=.45,y=.1] \processMPbuffer[mp]} {c=.45 y=.1} |
| 871 |
%D \stopcombination |
| 872 |
%D \stopbuffer |
| 873 |
%D |
| 874 |
%D \placefigure |
| 875 |
%D {\CMYK\ support disabled, |
| 876 |
%D conversion to \RGB.} |
| 877 |
%D {\setupcolors[cmyk=nee,state=start]\getbuffer[cmyk]} |
| 878 |
%D |
| 879 |
%D \placefigure |
| 880 |
%D {\CMYK\ support enabled, |
| 881 |
%D no support in \METAPOST.} |
| 882 |
%D {\setupcolors[cmyk=ja,mpcmyk=nee,state=start]\getbuffer[cmyk]} |
| 883 |
%D |
| 884 |
%D \placefigure |
| 885 |
%D {\CMYK\ support enabled, |
| 886 |
%D no conversion to \RGB, |
| 887 |
%D support in \METAPOST} |
| 888 |
%D {\setupcolors[cmyk=ja,state=start]\getbuffer[cmyk]} |
| 889 |
|
| 890 |
\defineMPspecial{1} |
| 891 |
{\ifMPcmykcolors |
| 892 |
\setxvalue{\@@MPSK\gMPs1}{\gMPs2 \gMPs3 \gMPs4 \gMPs5 }% |
| 893 |
\fi} |
| 894 |
|
| 895 |
\def\setMPcmyk#1 #2 #3 #4 % |
| 896 |
{\setvalue{\@@MP01}{#1}% |
| 897 |
\setvalue{\@@MP02}{#2}% |
| 898 |
\setvalue{\@@MP03}{#3}% |
| 899 |
\setvalue{\@@MP04}{#4}} |
| 900 |
|
| 901 |
%\defineMPspecial{2} |
| 902 |
% {\ifMPspotcolors |
| 903 |
% \setxvalue{\@@MPSP\gMPs1}{\gMPs2 \gMPs3 }% |
| 904 |
% \fi} |
| 905 |
|
| 906 |
% \defineMPspecial{2} |
| 907 |
% {\ifMPspotcolors |
| 908 |
% \setxvalue{\@@MPSP\gMPs1}{\gMPs2 \gMPs3 }% |
| 909 |
% \checkMPspot{\gMPs2}{\gMPs3}% |
| 910 |
% \fi} |
| 911 |
% |
| 912 |
% \def\setMPspot#1 #2 % |
| 913 |
% {\setvalue{\@@MP01}{#1}% |
| 914 |
% \setvalue{\@@MP02}{#2}} |
| 915 |
% |
| 916 |
% \def\checkMPspot#1#2% |
| 917 |
% {\expanded{\resolveMPspotcolor#1 #2}\end |
| 918 |
% \ifx\MPspotspace\MPresolvedspace |
| 919 |
% \edef\MPspotspacespec{/\MPspotspace\space}% |
| 920 |
% \doifinstringelse\MPspotspacespec\currentMPcolorspaces |
| 921 |
% \donothing\registerMPcolorspace |
| 922 |
% \fi} |
| 923 |
|
| 924 |
\defineMPspecial{2} |
| 925 |
{\ifMPspotcolors |
| 926 |
\setxvalue{\@@MPSP\gMPs1}{\gMPs2 \gMPs3 \gMPs4 \gMPs5 }% space is essential |
| 927 |
\checkMPspot{\gMPs2}{\gMPs3}{\gMPs4}{\gMPs5}% |
| 928 |
\fi} |
| 929 |
|
| 930 |
\def\setMPspot#1 #2 #3 #4 % |
| 931 |
{\setvalue{\@@MP01}{#1}% |
| 932 |
\setvalue{\@@MP02}{#2}% |
| 933 |
\setvalue{\@@MP03}{#3}% |
| 934 |
\setvalue{\@@MP04}{#4}} |
| 935 |
|
| 936 |
\def\checkMPspot#1#2#3#4% |
| 937 |
{\expanded{\resolveMPspotcolor#1 #2 #3 #4}\end |
| 938 |
\ifx\MPspotspace\MPresolvedspace |
| 939 |
\edef\MPspotspacespec{/\MPspotspace\space}% |
| 940 |
\doifinstringelse\MPspotspacespec\currentMPcolorspaces |
| 941 |
\donothing\registerMPcolorspace |
| 942 |
\fi} |
| 943 |
|
| 944 |
%D This special (number 50) passes positions to a tex file. |
| 945 |
%D This method uses a two||pass approach an (mis|)|used the |
| 946 |
%D context positioning macros. In \type {core-pos} we will |
| 947 |
%D implement the low level submacro needed. |
| 948 |
%D |
| 949 |
%D \startbuffer |
| 950 |
%D \definelayer[test] |
| 951 |
%D |
| 952 |
%D \setlayer |
| 953 |
%D [test] |
| 954 |
%D [x=\MPx{somepos-1},y=\MPy{somepos-1}] |
| 955 |
%D {Whatever we want here!} |
| 956 |
%D |
| 957 |
%D \setlayer |
| 958 |
%D [test] |
| 959 |
%D [x=\MPx{somepos-2},y=\MPy{somepos-2}] |
| 960 |
%D {Whatever we need there!} |
| 961 |
%D |
| 962 |
%D \startuseMPgraphic{oeps} |
| 963 |
%D draw fullcircle scaled 6cm withcolor red ; |
| 964 |
%D register ("somepos-1",1cm,2cm,center currentpicture) ; |
| 965 |
%D register ("somepos-2",4cm,3cm,(-1cm,-2cm)) ; |
| 966 |
%D \stopuseMPgraphic |
| 967 |
%D |
| 968 |
%D \framed[background=test,offset=overlay]{\useMPgraphic{oeps}} |
| 969 |
%D \stopbuffer |
| 970 |
%D |
| 971 |
%D \typebuffer |
| 972 |
%D |
| 973 |
%D Here the width and height are not realy used, but one can |
| 974 |
%D imagine situations where tex has to work with values |
| 975 |
%D calculated by \METAPOST. |
| 976 |
%D |
| 977 |
%D \startlinecorrection |
| 978 |
%D \getbuffer |
| 979 |
%D \stoplinecorrection |
| 980 |
%D |
| 981 |
%D Later we will implement a more convenient macro: |
| 982 |
%D |
| 983 |
%D \starttyping |
| 984 |
%D \setMPlayer [test] [somepos-1] {Whatever we want here!} |
| 985 |
%D \setMPlayer [test] [somepos-2] {Whatever we need there!} |
| 986 |
%D \stoptyping |
| 987 |
|
| 988 |
\ifx\dosavepositionwhd\undefined |
| 989 |
\let\dosavepositionwhd\gobblesevenarguments |
| 990 |
\fi |
| 991 |
|
| 992 |
\defineMPspecial{50} % x y width height label |
| 993 |
{\bgroup |
| 994 |
\scratchdimen\MPllx\onebasepoint\scratchdimen-\scratchdimen |
| 995 |
% \scratchdimen-\MPllx\onebasepoint % moet ook werken |
| 996 |
\advance\scratchdimen\gMPs1\onebasepoint |
| 997 |
\edef\x{\number\scratchdimen}% |
| 998 |
\scratchdimen\gMPs2\onebasepoint |
| 999 |
\scratchdimen-\scratchdimen |
| 1000 |
\advance\scratchdimen\MPury\onebasepoint |
| 1001 |
\edef\y{\number\scratchdimen}% |
| 1002 |
\scratchdimen\gMPs3\onebasepoint |
| 1003 |
\edef\w{\number\scratchdimen}% |
| 1004 |
\scratchdimen\gMPs4\onebasepoint |
| 1005 |
\edef\h{\number\scratchdimen}% |
| 1006 |
\dosavepositionwhd{\gMPs5}0\x\y\w\h0% |
| 1007 |
\egroup} |
| 1008 |
|
| 1009 |
%D Transparency support used specials 60 (rgb) and 61 |
| 1010 |
%D (cmyk). |
| 1011 |
%D |
| 1012 |
%D \startbuffer |
| 1013 |
%D u := 2cm ; path p ; p := fullcircle scaled u shifted (u/4,0); |
| 1014 |
%D |
| 1015 |
%D fill p rotated 90 withcolor transparent(1,.5,yellow) ; |
| 1016 |
%D fill p rotated 210 withcolor transparent(1,.5,green) ; |
| 1017 |
%D fill p rotated 330 withcolor transparent(1,.5,blue) ; |
| 1018 |
%D \stopbuffer |
| 1019 |
%D |
| 1020 |
%D \typebuffer |
| 1021 |
%D |
| 1022 |
%D \startlinecorrection \processMPbuffer \stoplinecorrection |
| 1023 |
%D |
| 1024 |
%D One can also communicate colors between \CONTEXT\ and |
| 1025 |
%D \METAPOST: |
| 1026 |
%D |
| 1027 |
%D \startbuffer |
| 1028 |
%D \definecolor[tcyan] [c=1,k=.2,t=.5] |
| 1029 |
%D \definecolor[tmagenta][m=1,k=.2,t=.5] |
| 1030 |
%D \definecolor[tyellow] [y=1,k=.2,t=.5] |
| 1031 |
%D \stopbuffer |
| 1032 |
%D |
| 1033 |
%D \typebuffer \getbuffer |
| 1034 |
%D |
| 1035 |
%D \startbuffer |
| 1036 |
%D u := 2cm ; path p ; p := fullcircle scaled u shifted (u/4,0); |
| 1037 |
%D |
| 1038 |
%D fill p rotated 90 withcolor \MPcolor{tcyan} ; |
| 1039 |
%D fill p rotated 210 withcolor \MPcolor{tmagenta} ; |
| 1040 |
%D fill p rotated 330 withcolor \MPcolor{tyellow} ; |
| 1041 |
%D \stopbuffer |
| 1042 |
%D |
| 1043 |
%D \startlinecorrection \processMPbuffer \stoplinecorrection |
| 1044 |
%D |
| 1045 |
%D We save all the three components needed in one macro, |
| 1046 |
%D just to save hash space. |
| 1047 |
|
| 1048 |
\def\@@MPST{@MPST@} |
| 1049 |
|
| 1050 |
\def\assignMPStransparency#1#2#3% |
| 1051 |
{\edef\PDFtransparencyidentifier{#1}% |
| 1052 |
\edef\PDFtransparencyreference {#2}% |
| 1053 |
\edef\PDFtransparencycolorspecs{#3}} |
| 1054 |
|
| 1055 |
% \def\PDFtransparencyspec |
| 1056 |
% {\ifx\MPresolvedspace\MPgrayspace |
| 1057 |
% \MPresolvedcolor\space g \MPresolvedcolor\space G% |
| 1058 |
% \else\ifx\MPresolvedspace\MPrgbspace |
| 1059 |
% \MPresolvedcolor\space rg \MPresolvedcolor\space RG% |
| 1060 |
% \else\ifx\MPresolvedspace\MPcmykspace |
| 1061 |
% \MPresolvedcolor\space k \MPresolvedcolor\space K% |
| 1062 |
% \else\ifx\MPresolvedspace\empty\else |
| 1063 |
% /\MPresolvedspace\space cs \MPresolvedcolor\space sc |
| 1064 |
% /\MPresolvedspace\space CS \MPresolvedcolor\space SC% |
| 1065 |
% \fi\fi\fi\fi} |
| 1066 |
|
| 1067 |
\def\PDFtransparencyspec % todo |
| 1068 |
{\ifx\MPresolvedspace\MPgrayspace |
| 1069 |
\MPresolvedcolor\space g |
| 1070 |
\MPresolvedcolor\space G% |
| 1071 |
\else\ifx\MPresolvedspace\MPrgbspace |
| 1072 |
\MPresolvedcolor\space rg |
| 1073 |
\MPresolvedcolor\space RG% |
| 1074 |
\else\ifx\MPresolvedspace\MPcmykspace |
| 1075 |
\MPresolvedcolor\space k |
| 1076 |
\MPresolvedcolor\space K% |
| 1077 |
\else\ifx\MPresolvedspace\empty\else |
| 1078 |
/\MPresolvedspace\space cs |
| 1079 |
/\MPresolvedspace\space CS |
| 1080 |
\PDFgetspotcolorspec\MPresolvedcolor |
| 1081 |
\fi\fi\fi\fi} |
| 1082 |
|
| 1083 |
\defineMPspecial{3} % rgb |
| 1084 |
{\edef\currentMPspecial{\gMPs6}% |
| 1085 |
\presetPDFtransparency{\gMPs1}{\gMPs2}% |
| 1086 |
\expanded{\resolveMPrgbcolor\gMPs3 \gMPs4 \gMPs5}\end |
| 1087 |
\setevalue{\@@MPST\currentMPspecial}% was \setxvalue, bug ! |
| 1088 |
{\noexpand\assignMPStransparency |
| 1089 |
{\PDFtransparencyidentifier}% |
| 1090 |
{\PDFtransparencyreference}% |
| 1091 |
{\PDFtransparencyspec}}} |
| 1092 |
|
| 1093 |
\defineMPspecial{4} % cmyk |
| 1094 |
{\edef\currentMPspecial{\gMPs7}% |
| 1095 |
\presetPDFtransparency{\gMPs1}{\gMPs2}% |
| 1096 |
\expanded{\resolveMPcmykcolor\gMPs3 \gMPs4 \gMPs5 \gMPs6}\end |
| 1097 |
\setevalue{\@@MPST\currentMPspecial}% was \setxvalue, bug ! |
| 1098 |
{\noexpand\assignMPStransparency |
| 1099 |
{\PDFtransparencyidentifier}% |
| 1100 |
{\PDFtransparencyreference}% |
| 1101 |
{\PDFtransparencyspec}}} |
| 1102 |
|
| 1103 |
% \defineMPspecial{5} % spot |
| 1104 |
% {\edef\currentMPspecial{\gMPs5}% |
| 1105 |
% \presetPDFtransparency{\gMPs1}{\gMPs2}% |
| 1106 |
% \checkMPspot{\gMPs3}{\gMPs4}% |
| 1107 |
% \setevalue{\@@MPST\currentMPspecial}% was \setxvalue, bug ! |
| 1108 |
% {\noexpand\assignMPStransparency |
| 1109 |
% {\PDFtransparencyidentifier}% |
| 1110 |
% {\PDFtransparencyreference}% |
| 1111 |
% {\PDFtransparencyspec}}} |
| 1112 |
|
| 1113 |
\defineMPspecial{5} % spot |
| 1114 |
{\edef\currentMPspecial{\gMPs7}% |
| 1115 |
\presetPDFtransparency{\gMPs1}{\gMPs2}% |
| 1116 |
\checkMPspot{\gMPs3}{\gMPs4}{\gMPs5}{\gMPs6}% |
| 1117 |
\setevalue{\@@MPST\currentMPspecial}% was \setxvalue, bug ! |
| 1118 |
{\noexpand\assignMPStransparency |
| 1119 |
{\PDFtransparencyidentifier}% |
| 1120 |
{\PDFtransparencyreference}% |
| 1121 |
{\PDFtransparencyspec}}} |
| 1122 |
|
| 1123 |
% beware: for the moment only supported in pdftex; needs a cleanup! |
| 1124 |
|
| 1125 |
\def\registerMPcolorspace |
| 1126 |
{\doifobjectreferencefoundelse{PDFCS}\MPspotspace |
| 1127 |
{\doPDFgetobjectreference{PDFCS}\MPspotspace\PDFobjectreference |
| 1128 |
\xdef\currentMPcolorspaces |
| 1129 |
{\currentMPcolorspaces\MPspotspacespec\PDFobjectreference\space}} |
| 1130 |
\donothing} |
| 1131 |
|
| 1132 |
%D We need to add resource specifications! |
| 1133 |
|
| 1134 |
\appendtoks |
| 1135 |
\global\let\currentMPcolorspaces\empty |
| 1136 |
\to \MPstartresources |
| 1137 |
|
| 1138 |
\appendtoks |
| 1139 |
\ifx\currentMPcolorspaces\empty \else |
| 1140 |
\xdef\currentPDFresources{\currentPDFresources |
| 1141 |
/ColorSpace <<\currentMPcolorspaces>>}% |
| 1142 |
\fi |
| 1143 |
\to \MPstopresources |
| 1144 |
|
| 1145 |
%D For efficiency reasons, we fall back on the allocation |
| 1146 |
%D mechanisms already present. For use within \MPTOPDF, we |
| 1147 |
%D provide a fall back routine. |
| 1148 |
|
| 1149 |
\let\currentMPtransparencies\empty |
| 1150 |
|
| 1151 |
% \def\invokeMPtransparencyspecial |
| 1152 |
% {\doifdefined{\@@MPST\currentMPspecial} |
| 1153 |
% {\getvalue{\@@MPST\currentMPspecial}% |
| 1154 |
% \doifinstringelse |
| 1155 |
% {\PDFtransparencyidentifier}{\currentMPtransparencies} |
| 1156 |
% {} |
| 1157 |
% {\xdef\currentMPtransparencies |
| 1158 |
% {\currentMPtransparencies |
| 1159 |
% \PDFtransparencyidentifier\space |
| 1160 |
% \PDFtransparencyreference\space}}% |
| 1161 |
% \def\extraMPpathcode{ Q}% |
| 1162 |
% \PDFcode{q |
| 1163 |
% \PDFtransparencycolorspecs\space |
| 1164 |
% \PDFtransparencyidentifier\space gs}}} |
| 1165 |
|
| 1166 |
% this one triggers a new graphic state |
| 1167 |
|
| 1168 |
\def\invokeMPtransparencyspecial |
| 1169 |
{\scratchcounter\MPrgbnumber\lastMPbvalue |
| 1170 |
\edef\currentMPspecial{\the\scratchcounter}% |
| 1171 |
\ifundefined{\@@MPST\currentMPspecial}\else |
| 1172 |
\getvalue{\@@MPST\currentMPspecial}% |
| 1173 |
\doifinstringelse\PDFtransparencyidentifier\currentMPtransparencies |
| 1174 |
\donothing\registerMPtransparencyresource % slow |
| 1175 |
\PDFcode |
| 1176 |
{\PDFtransparencycolorspecs\space |
| 1177 |
\PDFtransparencyidentifier\space gs}% |
| 1178 |
% potential optimization |
| 1179 |
% \setevalue{\@@MPST\currentMPspecial}% |
| 1180 |
% {\PDFcode |
| 1181 |
% {\PDFtransparencycolorspecs\space |
| 1182 |
% \PDFtransparencyidentifier\space gs}}% |
| 1183 |
% \getvalue{\@@MPST\currentMPspecial}% |
| 1184 |
\let\revokeMPtransparencyspecial\dorevokeMPtransparencyspecial |
| 1185 |
\fi} |
| 1186 |
|
| 1187 |
% this one does a reset |
| 1188 |
|
| 1189 |
\let\revokeMPtransparencyspecial\relax |
| 1190 |
|
| 1191 |
\appendtoks |
| 1192 |
\revokeMPtransparencyspecial |
| 1193 |
\to \MPstopresources |
| 1194 |
|
| 1195 |
\def\dorevokeMPtransparencyspecial % only called if state is set |
| 1196 |
{\ifx\PDFtransparencyresetidentifier\empty\else |
| 1197 |
\doifinstringelse\PDFtransparencyresetidentifier\currentMPtransparencies |
| 1198 |
\donothing\registerMPtransparencyresetresource |
| 1199 |
\PDFcode{\PDFtransparencyresetidentifier\space gs}% |
| 1200 |
% potential optimization |
| 1201 |
% \def\dorevokeMPtransparencyspecial |
| 1202 |
% {\PDFcode |
| 1203 |
% {\PDFtransparencycolorspecs\space |
| 1204 |
% \PDFtransparencyidentifier\space gs}}% |
| 1205 |
\let\dorevokeMPtransparencyspecial\dodorevokeMPtransparencyspecial |
| 1206 |
\let\revokeMPtransparencyspecial\relax % invoke sets it |
| 1207 |
\fi} |
| 1208 |
|
| 1209 |
% and this one a simplified reset |
| 1210 |
|
| 1211 |
% \def\dodorevokeMPtransparencyspecial % used after first invocation |
| 1212 |
% {\getvalue{\@@MPST0}% |
| 1213 |
% \PDFcode{\PDFtransparencyidentifier\space gs}} |
| 1214 |
|
| 1215 |
\def\dodorevokeMPtransparencyspecial % used after first invocation |
| 1216 |
{\PDFcode{\PDFtransparencyresetidentifier\space gs}% |
| 1217 |
\let\revokeMPtransparencyspecial\relax} % invoke sets it |
| 1218 |
|
| 1219 |
% add a resource entry |
| 1220 |
|
| 1221 |
\def\registerMPtransparencyresource |
| 1222 |
{\xdef\currentMPtransparencies |
| 1223 |
{\currentMPtransparencies |
| 1224 |
\PDFtransparencyidentifier\space |
| 1225 |
\PDFtransparencyreference\space}} |
| 1226 |
|
| 1227 |
\def\registerMPtransparencyresetresource |
| 1228 |
{\xdef\currentMPtransparencies |
| 1229 |
{\currentMPtransparencies |
| 1230 |
\PDFtransparencyresetidentifier\space |
| 1231 |
\PDFtransparencyresetreference\space}} |
| 1232 |
|
| 1233 |
\appendtoks \invokeMPtransparencyspecial \to \invokeMPspecials |
| 1234 |
|
| 1235 |
\ifCONTEXT \else |
| 1236 |
|
| 1237 |
\def\@@MPSTN{@MPSTN@} |
| 1238 |
\def\@@MPSTO{@MPSTO@} |
| 1239 |
|
| 1240 |
\newcount\PDFcurrenttransparency |
| 1241 |
|
| 1242 |
\let\PDFtransparencyresetidentifier\empty |
| 1243 |
\let\PDFtransparencyresetreference \empty |
| 1244 |
|
| 1245 |
\let\PDFtransparencyidentifier\empty |
| 1246 |
\let\PDFtransparencyreference \empty |
| 1247 |
|
| 1248 |
\def\initializePDFtransparency |
| 1249 |
{\global\let\initializePDFtransparency\relax |
| 1250 |
\presetPDFtransparency{1}{1}% |
| 1251 |
\xdef\PDFtransparencyresetidentifier{/Tr0}% |
| 1252 |
\xdef\PDFtransparencyresetreference{\the\pdflastobj\space 0 R}} |
| 1253 |
|
| 1254 |
\def\presetPDFtransparency#1#2% |
| 1255 |
{\initializePDFtransparency |
| 1256 |
\@EA\ifx\csname\@@MPSTO#1:#2\endcsname\relax |
| 1257 |
\global\advance\PDFcurrenttransparency \plusone |
| 1258 |
\immediate\pdfobj{\PDFtransparencydictionary{#1}{#2}{}}% |
| 1259 |
\setxvalue{\@@MPSTN#1:#2}{\the\PDFcurrenttransparency}% |
| 1260 |
\setxvalue{\@@MPSTO#1:#2}{\the\pdflastobj}% |
| 1261 |
\fi |
| 1262 |
\edef\PDFtransparencyidentifier{/Tr\getvalue{\@@MPSTN#1:#2}}% |
| 1263 |
\edef\PDFtransparencyreference{\getvalue{\@@MPSTO#1:#2} 0 R}} |
| 1264 |
|
| 1265 |
\def\PDFtransparencydictionary#1#2#3% type fraction extras |
| 1266 |
{<</Type /ExtGState |
| 1267 |
/ca #2 /CA #2 |
| 1268 |
/BM /\ifcase#1 Normal\or Normal\or Multiply\or Screen\or |
| 1269 |
Overlay\or SoftLight\or HardLight\or ColorDodge\or |
| 1270 |
ColorBurn\or Darken\or Lighten\or Difference\or |
| 1271 |
Exclusion\or Hue\or Saturation\or Color\or |
| 1272 |
Luminosity\else Compatible\fi |
| 1273 |
#3>>} |
| 1274 |
|
| 1275 |
\fi |
| 1276 |
|
| 1277 |
\appendtoks |
| 1278 |
\global\let\currentMPtransparencies\empty |
| 1279 |
\to \MPstartresources |
| 1280 |
|
| 1281 |
\appendtoks |
| 1282 |
\ifx\currentMPtransparencies\empty \else |
| 1283 |
\xdef\currentPDFresources{\currentPDFresources |
| 1284 |
/ExtGState <<\currentMPtransparencies>>}% |
| 1285 |
\fi |
| 1286 |
\to \MPstopresources |
| 1287 |
|
| 1288 |
%D In all cases, we need to keep track of the resources |
| 1289 |
%D used. |
| 1290 |
|
| 1291 |
%D A few auxiliary macros: |
| 1292 |
|
| 1293 |
\def\MPgrayspace{DeviceGray} |
| 1294 |
\def\MPrgbspace {DeviceRGB} |
| 1295 |
\def\MPcmykspace{DeviceCMYK} |
| 1296 |
\let\MPspotspace\MPgrayspace |
| 1297 |
|
| 1298 |
\def\MPcmykBlack{0 0 0 0} |
| 1299 |
\def\MPcmykWhite{0 0 0 1} |
| 1300 |
|
| 1301 |
\ifCONTEXT |
| 1302 |
|
| 1303 |
\def\startMPcolorresolve |
| 1304 |
{\bgroup |
| 1305 |
\def\dostartgraycolormode##1% |
| 1306 |
{\global\let\MPresolvedspace\MPgrayspace |
| 1307 |
\xdef\MPresolvedcolor{##1}}% |
| 1308 |
\def\dostartrgbcolormode ##1##2##3% |
| 1309 |
{\global\let\MPresolvedspace\MPrgbspace |
| 1310 |
\xdef\MPresolvedcolor{##1 ##2 ##3}}% |
| 1311 |
\def\dostartcmykcolormode##1##2##3##4% |
| 1312 |
{\global\let\MPresolvedspace\MPcmykspace |
| 1313 |
\xdef\MPresolvedcolor{##1 ##2 ##3 ##4}}% |
| 1314 |
\def\dostartspotcolormode##1##2% |
| 1315 |
{\global\let\MPspotspace\empty |
| 1316 |
\xdef\MPresolvedspace{##1}% |
| 1317 |
\xdef\MPresolvedcolor{##2}% |
| 1318 |
\global\let\MPspotspace\MPresolvedspace}% signal |
| 1319 |
\dostartgraycolormode\!!zerocount} % kind of hackery initialization |
| 1320 |
|
| 1321 |
\let\stopMPcolorresolve\egroup |
| 1322 |
|
| 1323 |
\def\resolveMPrgbcolor#1 #2 #3\end |
| 1324 |
{\startMPcolorresolve |
| 1325 |
\execcolorR#1:#2:#3:0:0\od |
| 1326 |
\stopMPcolorresolve} |
| 1327 |
|
| 1328 |
\def\resolveMPcmykcolor#1 #2 #3 #4\end |
| 1329 |
{\startMPcolorresolve |
| 1330 |
\execcolorC#1:#2:#3:#4:0:0\od |
| 1331 |
\stopMPcolorresolve} |
| 1332 |
|
| 1333 |
\def\resolveMPgraycolor#1\end |
| 1334 |
{\startMPcolorresolve |
| 1335 |
\execcolorS#1:0:0\od |
| 1336 |
\stopMPcolorresolve} |
| 1337 |
|
| 1338 |
% \def\resolveMPspotcolor#1 #2\end |
| 1339 |
% {\startMPcolorresolve |
| 1340 |
% \execcolorP#1:#2:0:0\od |
| 1341 |
% \stopMPcolorresolve} |
| 1342 |
|
| 1343 |
\def\resolveMPspotcolor#1 #2 #3 #4\end |
| 1344 |
{\startMPcolorresolve |
| 1345 |
\ifnum#2>\plusone |
| 1346 |
\checkmultitonecolor{#1}% |
| 1347 |
\fi |
| 1348 |
\execcolorP#1:#2:#3:#4:0:0\od |
| 1349 |
\stopMPcolorresolve} |
| 1350 |
|
| 1351 |
\else |
| 1352 |
|
| 1353 |
\def\resolveMPspotcolor#1 #2\end |
| 1354 |
{\global\let\MPresolvedspace\MPgrayspace |
| 1355 |
\xdef\MPresolvedcolor{0}} |
| 1356 |
|
| 1357 |
\def\resolveMPrgbcolor#1 #2 #3\end |
| 1358 |
{\global\let\MPresolvedspace\MPrgbspace |
| 1359 |
\xdef\MPresolvedcolor{#1 #2 #3}} |
| 1360 |
|
| 1361 |
\def\resolveMPcmykcolor#1 #2 #3 #4\end |
| 1362 |
{\global\let\MPresolvedspace\MPcmykspace |
| 1363 |
\xdef\MPresolvedcolor{#1 #2 #3 #4}} |
| 1364 |
|
| 1365 |
\def\resolveMPgraycolor#1\end |
| 1366 |
{\global\let\MPresolvedspace\MPgrayspace |
| 1367 |
\xdef\MPresolvedcolor{#1}} % should be inverted |
| 1368 |
|
| 1369 |
\fi |
| 1370 |
|
| 1371 |
\protect \endinput |