| 1 |
% Copyright 2019 by Till Tantau |
| 2 |
% |
| 3 |
% PS-3 shadings, image and opacity masks (fadings), transparency groups, |
| 4 |
% blend modes copyright 2020 by Alexander Grahn |
| 5 |
% |
| 6 |
% This file may be distributed and/or modified |
| 7 |
% |
| 8 |
% 1. under the LaTeX Project Public License and/or |
| 9 |
% 2. under the GNU Public License. |
| 10 |
% |
| 11 |
% See the file doc/generic/pgf/licenses/LICENSE for more details. |
| 12 |
|
| 13 |
\ProvidesFileRCS{pgfsys-dvips.def} |
| 14 |
|
| 15 |
% Driver commands for dvips |
| 16 |
|
| 17 |
\def\pgfsys@invoke#1{\special{ps\ifpgfsys@ps@boxmode\else:\fi: #1}} |
| 18 |
\def\pgfsys@outerinvoke#1{\special{ps: #1}} |
| 19 |
\def\pgf@sys@postscript@header#1{\pgfutil@insertatbegincurrentpage{\special{! #1}}} |
| 20 |
\def\pgf@sys@postscript@object#1{\special{! #1}} |
| 21 |
|
| 22 |
|
| 23 |
% |
| 24 |
% Load common postscript commands: |
| 25 |
% |
| 26 |
\input pgfsys-common-postscript.def |
| 27 |
|
| 28 |
|
| 29 |
% |
| 30 |
% dvips-specific stuff: |
| 31 |
% |
| 32 |
|
| 33 |
\def\pgfsys@beginpicture{\pgfsys@ps@boxmodefalse\special{ps: }\special{ps::[begin]}\pgfsys@invoke{pgfo}} |
| 34 |
\def\pgfsys@endpicture{\pgfsys@invoke{pgfc}\special{ps::[end]}} |
| 35 |
\def\pgfsys@hbox#1{% |
| 36 |
\pgfsys@begin@idscope% |
| 37 |
\pgfsys@invoke{pgfs}% |
| 38 |
\special{ps::[end]}% |
| 39 |
\wd#1=0pt |
| 40 |
\ht#1=0pt |
| 41 |
\dp#1=0pt |
| 42 |
\box#1 |
| 43 |
\special{ps::[begin]}% |
| 44 |
\pgfsys@invoke{pgfr}% |
| 45 |
\pgfsys@end@idscope% |
| 46 |
} |
| 47 |
\def\pgfsys@begininvisible{% |
| 48 |
\special{ps::[begin]}% |
| 49 |
\pgfsys@invoke{gsave nulldevice}% |
| 50 |
\special{ps::[end]}} |
| 51 |
\def\pgfsys@endinvisible{% |
| 52 |
\special{ps::[begin]}% |
| 53 |
\pgfsys@invoke{grestore}% |
| 54 |
\special{ps::[end]}% |
| 55 |
} |
| 56 |
\def\pgfsys@color@unstacked#1{\special{ps: \XC@usecolor{#1}}} |
| 57 |
\def\pgfsys@imagesuffixlist{.epsi:.eps:.ps:} |
| 58 |
|
| 59 |
\def\pgfsys@papersize#1#2{% |
| 60 |
\special{papersize=#1,#2}% |
| 61 |
% \expandafter\gdef\expandafter\pgfsys@atbegindocument\expandafter{\pgfsys@atbegindocument\special{papersize=#1,#2}}% |
| 62 |
} |
| 63 |
\def\pgfsys@prepare@papersize#1#2{% |
| 64 |
\expandafter\gdef\expandafter\pgfsys@atbegindocument\expandafter{\pgfsys@atbegindocument\special{papersize=#1,#2}}% |
| 65 |
} |
| 66 |
|
| 67 |
\expandafter\gdef\expandafter\pgfsys@atbegindocument\expandafter{\pgfsys@atbegindocument% |
| 68 |
\pgf@sys@postscript@header{ |
| 69 |
/pgfsc{}bind def% stroke color is empty by default |
| 70 |
/pgffc{}bind def% fill color is empty by default |
| 71 |
/pgfstr{stroke}bind def% |
| 72 |
/pgffill{fill}bind def% |
| 73 |
/pgfeofill{eofill}bind def% |
| 74 |
/pgfe{a dup 0 rlineto exch 0 exch rlineto neg 0 rlineto closepath}bind def% rectangle |
| 75 |
/pgfw{setlinewidth}bind def% setlinewidth |
| 76 |
/pgfs{save pgfpd 72 Resolution div 72 VResolution div neg scale |
| 77 |
magscale{1 DVImag div dup scale}if |
| 78 |
pgfx neg pgfy neg translate pgffoa .setopacityalpha}bind def% save |
| 79 |
/pgfr{pgfsd restore}bind def %restore |
| 80 |
userdict begin% |
| 81 |
/pgfo{pgfsd /pgfx currentpoint /pgfy exch def def @beginspecial}bind def %open |
| 82 |
/pgfc{newpath @endspecial pgfpd}bind def %close |
| 83 |
/pgfsd{globaldict /pgfdelta /delta where {pop delta} {0} ifelse put}bind def% save delta |
| 84 |
/pgfpd{/delta globaldict /pgfdelta get def}bind def % put delta |
| 85 |
/.setblendmode where {pop} {/.setblendmode{pop}def} ifelse % install .setblendmode |
| 86 |
/.setfillconstantalpha where {% |
| 87 |
pop /.setopacityalpha {.setfillconstantalpha} def% |
| 88 |
} {% |
| 89 |
/.setopacityalpha where {pop} {/.setopacityalpha {pop} def} ifelse% install .setopacityalpha (fallback) |
| 90 |
} ifelse |
| 91 |
/.pgfsetfillopacityalpha{/pgffoa exch def |
| 92 |
/.setfillconstantalpha where {pop pgffoa .setfillconstantalpha} {% |
| 93 |
/pgffill{gsave pgffoa .setopacityalpha fill 1 .setopacityalpha newpath fill grestore newpath}bind def |
| 94 |
/pgfeofill{gsave pgffoa .setopacityalpha eofill 1 .setopacityalpha newpath eofill grestore newpath}bind def% |
| 95 |
} ifelse% |
| 96 |
} bind def |
| 97 |
/.pgfsetstrokeopacityalpha{/pgfsoa exch def |
| 98 |
/.setstrokeconstantalpha where {pop pgfsoa .setstrokeconstantalpha} {% |
| 99 |
/pgfstr{gsave pgfsoa .setopacityalpha stroke grestore newpath}bind def% |
| 100 |
} ifelse% |
| 101 |
}bind def |
| 102 |
/pgffoa 1 def |
| 103 |
/pgfsoa 1 def |
| 104 |
% mandatory, transparency-related per-page operations, see |
| 105 |
% https://www.ghostscript.com/doc/current/Language.htm#Transparency |
| 106 |
% (bop-hook & eop-hook automatically executed if defined in userdict, see texdoc dvips) |
| 107 |
/.pushpdf14devicefilter where {pop |
| 108 |
[userdict /bop-hook known {userdict /bop-hook get aload pop} if |
| 109 |
{0 .pushpdf14devicefilter} aload pop] cvx userdict exch /bop-hook exch put |
| 110 |
[userdict /eop-hook known {userdict /eop-hook get aload pop} if |
| 111 |
{.poppdf14devicefilter} aload pop] cvx userdict exch /eop-hook exch put% |
| 112 |
} if |
| 113 |
% keeps printers from choking on pdfmark operator |
| 114 |
systemdict /pdfmark known not {userdict /pdfmark systemdict /cleartomark get put} if |
| 115 |
end |
| 116 |
}% |
| 117 |
} |
| 118 |
|
| 119 |
\AtBeginDocument{ % needed for plain TeX |
| 120 |
\pgfsys@atbegindocument |
| 121 |
\let\pgfsys@atbegindocument=\pgfutil@empty |
| 122 |
} |
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
% |
| 127 |
% Position tracking (needs pdftex or luatex in dvi mode) |
| 128 |
% |
| 129 |
\ifx\savepos\@undefined |
| 130 |
\ifx\pdfsavepos\@undefined |
| 131 |
\else |
| 132 |
\let\pgf@savepos\pdfsavepos |
| 133 |
\let\pgf@lastxpos\pdflastxpos |
| 134 |
\let\pgf@lastypos\pdflastypos |
| 135 |
\fi |
| 136 |
\else |
| 137 |
\let\pgf@savepos\savepos |
| 138 |
\let\pgf@lastxpos\lastxpos |
| 139 |
\let\pgf@lastypos\lastypos |
| 140 |
\fi |
| 141 |
|
| 142 |
|
| 143 |
\ifx\pgf@savepos\@undefined |
| 144 |
\else |
| 145 |
|
| 146 |
\def\pgfsys@markposition#1{% |
| 147 |
\pgf@savepos% |
| 148 |
\edef\pgf@temp{#1}% |
| 149 |
\expandafter\pgfutil@writetoaux\expandafter{% |
| 150 |
\expandafter\noexpand\expandafter\pgfsyspdfmark\expandafter{\pgf@temp}{\the\pgf@lastxpos}{\the\pgf@lastypos}}% |
| 151 |
} |
| 152 |
|
| 153 |
\def\pgfsyspdfmark#1#2#3{% |
| 154 |
\expandafter\gdef\csname pgf@sys@pdf@mark@pos@#1\endcsname{\pgfqpoint{#2sp}{#3sp}}% |
| 155 |
\pgfutil@check@rerun{#1}{{#2}{#3}}% |
| 156 |
} |
| 157 |
|
| 158 |
\def\pgfsys@getposition#1#2{% |
| 159 |
\edef\pgf@marshal{\let\noexpand#2=\expandafter\noexpand\csname pgf@sys@pdf@mark@pos@#1\endcsname}% |
| 160 |
\pgf@marshal% |
| 161 |
} |
| 162 |
|
| 163 |
\def\pgf@sys@pdf@mark@pos@pgfpageorigin{\pgfpointorigin} |
| 164 |
|
| 165 |
\fi |
| 166 |
|
| 167 |
|
| 168 |
% Path usage: |
| 169 |
\def\pgfsys@discardpath{% |
| 170 |
\ifpgfsys@@clipnext% |
| 171 |
\ifpgfsys@eorule% |
| 172 |
\pgfsysprotocol@literal{% |
| 173 |
/pgfsmaskinplace dup where {exch get}{pop false} ifelse not {eoclip} if}% |
| 174 |
\else% |
| 175 |
\pgfsysprotocol@literal{% |
| 176 |
/pgfsmaskinplace dup where {exch get}{pop false} ifelse not {clip} if}% |
| 177 |
\fi% |
| 178 |
\pgfsys@@clipnextfalse% |
| 179 |
\fi% |
| 180 |
\pgfsysprotocol@literal{newpath}} |
| 181 |
|
| 182 |
|
| 183 |
% |
| 184 |
% Blending |
| 185 |
% |
| 186 |
|
| 187 |
\def\pgfsys@blend@mode#1{% |
| 188 |
\expandafter\ifx\csname pgf@sys@pdf@bm@#1\endcsname\relax% |
| 189 |
\expandafter\let\expandafter\pgf@temp\csname pgf@sys@pdf@blend@mode@map@#1\endcsname% |
| 190 |
\expandafter\xdef\csname pgf@sys@pdf@bm@#1\endcsname{/\pgf@temp}% |
| 191 |
\ifx\pgf@temp\relax% |
| 192 |
\pgferror{Unknown blend mode '#1'}% |
| 193 |
\def\pgf@temp{Normal}% |
| 194 |
\fi% |
| 195 |
\fi% |
| 196 |
\pgfsysprotocol@literal{\csname pgf@sys@pdf@bm@#1\endcsname\space .setblendmode}% |
| 197 |
} |
| 198 |
\expandafter\def\csname pgf@sys@pdf@blend@mode@map@normal\endcsname{Normal} |
| 199 |
\expandafter\def\csname pgf@sys@pdf@blend@mode@map@multiply\endcsname{Multiply} |
| 200 |
\expandafter\def\csname pgf@sys@pdf@blend@mode@map@screen\endcsname{Screen} |
| 201 |
\expandafter\def\csname pgf@sys@pdf@blend@mode@map@overlay\endcsname{Overlay} |
| 202 |
\expandafter\def\csname pgf@sys@pdf@blend@mode@map@darken\endcsname{Darken} |
| 203 |
\expandafter\def\csname pgf@sys@pdf@blend@mode@map@lighten\endcsname{Lighten} |
| 204 |
\expandafter\def\csname pgf@sys@pdf@blend@mode@map@color dodge\endcsname{ColorDodge} |
| 205 |
\expandafter\def\csname pgf@sys@pdf@blend@mode@map@color burn\endcsname{ColorBurn} |
| 206 |
\expandafter\def\csname pgf@sys@pdf@blend@mode@map@hard light\endcsname{HardLight} |
| 207 |
\expandafter\def\csname pgf@sys@pdf@blend@mode@map@soft light\endcsname{SoftLight} |
| 208 |
\expandafter\def\csname pgf@sys@pdf@blend@mode@map@difference\endcsname{Difference} |
| 209 |
\expandafter\def\csname pgf@sys@pdf@blend@mode@map@exclusion\endcsname{Exclusion} |
| 210 |
\expandafter\def\csname pgf@sys@pdf@blend@mode@map@saturation\endcsname{Saturation} |
| 211 |
\expandafter\def\csname pgf@sys@pdf@blend@mode@map@color\endcsname{Color} |
| 212 |
\expandafter\def\csname pgf@sys@pdf@blend@mode@map@hue\endcsname{Hue} |
| 213 |
\expandafter\def\csname pgf@sys@pdf@blend@mode@map@luminosity\endcsname{Luminosity} |
| 214 |
|
| 215 |
|
| 216 |
% |
| 217 |
% Shadings |
| 218 |
% |
| 219 |
|
| 220 |
\def\pgfsys@horishading#1#2#3{% |
| 221 |
{% |
| 222 |
\pgf@parsefunc{#3}% |
| 223 |
\pgf@xb=\pgf@max |
| 224 |
\pgfmathsetlength\pgf@y{#2}% |
| 225 |
\pgf@yb=\pgf@y |
| 226 |
\pgf@sys@bp@correct{\pgf@xb}% |
| 227 |
\pgf@sys@bp@correct{\pgf@yb}% |
| 228 |
\xdef\pgfutil@tempa{\hbox to \the\pgf@max{% |
| 229 |
\noexpand\vrule width0pt height\the\pgf@y% |
| 230 |
\noexpand\pgfsys@beginpurepicture% |
| 231 |
\noexpand\pgfsys@outerinvoke{ |
| 232 |
\pgf@sys@tonumber{\pgf@yb} \pgf@sys@tonumber{\pgf@xb} 0 0 pgfe << |
| 233 |
/PatternType 2 |
| 234 |
/Shading << |
| 235 |
/ShadingType 2 |
| 236 |
/ColorSpace \pgf@shading@device\space |
| 237 |
/Domain [\pgf@pdfparseddomain] |
| 238 |
/Coords [\pgf@doma\space0 \pgf@domb\space0] |
| 239 |
/Function \pgf@pdfparsedfunction |
| 240 |
>> |
| 241 |
>> matrix makepattern setpattern fill |
| 242 |
}% |
| 243 |
\hss% |
| 244 |
\noexpand\pgfsys@endpurepicture% |
| 245 |
}}% |
| 246 |
}% |
| 247 |
\global\expandafter\let\csname @pgfshading#1!\endcsname\pgfutil@tempa% |
| 248 |
} |
| 249 |
\def\pgfsys@vertshading#1#2#3{% |
| 250 |
{% |
| 251 |
\pgf@parsefunc{#3}% |
| 252 |
\pgfmathsetlength\pgf@x{#2}% |
| 253 |
\pgf@xb=\pgf@x |
| 254 |
\pgf@yb=\pgf@max |
| 255 |
\pgf@sys@bp@correct{\pgf@xb}% |
| 256 |
\pgf@sys@bp@correct{\pgf@yb}% |
| 257 |
\xdef\pgfutil@tempa{\hbox to \the\pgf@x{% |
| 258 |
\noexpand\vrule width0pt height\the\pgf@max% |
| 259 |
\noexpand\pgfsys@beginpurepicture% |
| 260 |
\noexpand\pgfsys@outerinvoke{ |
| 261 |
\pgf@sys@tonumber{\pgf@yb} \pgf@sys@tonumber{\pgf@xb} 0 0 pgfe << |
| 262 |
/PatternType 2 |
| 263 |
/Shading << |
| 264 |
/ShadingType 2 |
| 265 |
/ColorSpace \pgf@shading@device\space |
| 266 |
/Domain [\pgf@pdfparseddomain] |
| 267 |
/Coords [0 \pgf@doma\space0 \pgf@domb] |
| 268 |
/Function \pgf@pdfparsedfunction |
| 269 |
>> |
| 270 |
>> matrix makepattern setpattern fill |
| 271 |
}% |
| 272 |
\hss% |
| 273 |
\noexpand\pgfsys@endpurepicture% |
| 274 |
}}% |
| 275 |
}% |
| 276 |
\global\expandafter\let\csname @pgfshading#1!\endcsname\pgfutil@tempa% |
| 277 |
} |
| 278 |
\def\pgfsys@radialshading#1#2#3{% |
| 279 |
{% |
| 280 |
\pgf@parsefunc{#3}% |
| 281 |
\pgf@process{#2}% |
| 282 |
\pgf@xa=\pgf@x |
| 283 |
\pgf@ya=\pgf@y |
| 284 |
\pgf@process{\pgfpoint{\pgf@max}{\pgf@max}}% |
| 285 |
\advance\pgf@xa by \pgf@x |
| 286 |
\advance\pgf@ya by \pgf@y |
| 287 |
\pgf@sys@bp@correct{\pgf@x}% |
| 288 |
\pgf@sys@bp@correct{\pgf@y}% |
| 289 |
\pgf@sys@bp@correct{\pgf@xa}% |
| 290 |
\pgf@sys@bp@correct{\pgf@ya}% |
| 291 |
\pgf@max=2\pgf@max |
| 292 |
\xdef\pgfutil@tempa{\hbox to \the\pgf@max{% |
| 293 |
\noexpand\vrule width0pt height\the\pgf@max% |
| 294 |
\noexpand\pgfsys@beginpurepicture% |
| 295 |
\noexpand\pgfsys@outerinvoke{ |
| 296 |
<< |
| 297 |
/ShadingType 3 |
| 298 |
/ColorSpace \pgf@shading@device\space |
| 299 |
/Domain [\pgf@pdfparseddomain] |
| 300 |
/Coords [\pgf@sys@tonumber{\pgf@xa} \pgf@sys@tonumber{\pgf@ya} \pgf@doma\space |
| 301 |
\pgf@sys@tonumber{\pgf@x} \pgf@sys@tonumber{\pgf@y} \pgf@domb] |
| 302 |
/Function \pgf@pdfparsedfunction |
| 303 |
/Extend [true false] |
| 304 |
>> shfill |
| 305 |
}% |
| 306 |
\hss% |
| 307 |
\noexpand\pgfsys@endpurepicture% |
| 308 |
}}% |
| 309 |
}% |
| 310 |
\global\expandafter\let\csname @pgfshading#1!\endcsname\pgfutil@tempa% |
| 311 |
} |
| 312 |
\def\pgfsys@functionalshading#1#2#3#4{% |
| 313 |
{% |
| 314 |
\pgf@process{#2}% |
| 315 |
\pgf@xa=\pgf@x |
| 316 |
\pgf@ya=\pgf@y |
| 317 |
\pgf@process{#3}% |
| 318 |
\pgf@xb=\pgf@x |
| 319 |
\pgf@yb=\pgf@y |
| 320 |
\advance\pgf@x by-\pgf@xa |
| 321 |
\advance\pgf@y by-\pgf@ya |
| 322 |
\pgf@sys@bp@correct{\pgf@xa}% |
| 323 |
\pgf@sys@bp@correct{\pgf@ya}% |
| 324 |
\pgf@sys@bp@correct{\pgf@xb}% |
| 325 |
\pgf@sys@bp@correct{\pgf@yb}% |
| 326 |
\pgf@xc=-\pgf@xa |
| 327 |
\pgf@yc=-\pgf@ya |
| 328 |
\xdef\pgfutil@tempa{% |
| 329 |
\hbox to\the\pgf@x{\vbox to\the\pgf@y{\vfil |
| 330 |
\noexpand\pgfsys@beginpurepicture% |
| 331 |
\noexpand\pgfsys@invoke{% |
| 332 |
% patch coords |
| 333 |
/pgfpatchllx \pgf@sys@tonumber{\pgf@xa} def |
| 334 |
/pgfpatchlly \pgf@sys@tonumber{\pgf@ya} def |
| 335 |
% shading patch width and height |
| 336 |
/pgfpatchX \pgf@sys@tonumber{\pgf@xb} pgfpatchllx sub def |
| 337 |
/pgfpatchY \pgf@sys@tonumber{\pgf@yb} pgfpatchlly sub def |
| 338 |
% number of samples in each direction (with samples spaced by approx. 1bp) |
| 339 |
/pgfsamplesx pgfpatchX round cvi 1 add def |
| 340 |
/pgfsamplesy pgfpatchY round cvi 1 add def |
| 341 |
% exact sample distance in each direction, in bp |
| 342 |
/pgfpatchdx pgfpatchX pgfsamplesx 1 sub div def |
| 343 |
/pgfpatchdy pgfpatchY pgfsamplesy 1 sub div def |
| 344 |
% |
| 345 |
pgfpatchllx neg pgfpatchlly neg translate |
| 346 |
/pgfproc {#4} bind def |
| 347 |
% |
| 348 |
% sampling procedure; repeatedly called by /ReusableStreamDecode filter; |
| 349 |
% on each call, /pgfsamplingproc puts one colour sample (rgb, cmyk or gray) |
| 350 |
% on the operand stack which is then consumed by the filter |
| 351 |
userdict /pgfsampleidx 0 put % internal index; updated on each call |
| 352 |
/pgfsamplingproc { |
| 353 |
pgfsampleidx pgfsamplesx pgfsamplesy mul eq { |
| 354 |
() % push empty string on the stack to signal end-of-data |
| 355 |
} { |
| 356 |
pgfcolorsample\pgf@shading@model\space % -str- |
| 357 |
pgfsampleidx pgfsamplesx mod pgfpatchdx mul pgfpatchllx add % -str- x |
| 358 |
pgfsampleidx pgfsamplesx idiv pgfpatchdy mul pgfpatchlly add % -str- x y |
| 359 |
pgfproc % -str- <colour> |
| 360 |
pgfwritesample\pgf@shading@model\space % -str- |
| 361 |
/pgfsampleidx pgfsampleidx 1 add store % (update index) |
| 362 |
} ifelse |
| 363 |
} bind def |
| 364 |
% |
| 365 |
pgfpatchY pgfpatchX pgfpatchllx pgfpatchlly pgfe << |
| 366 |
/PatternType 2 |
| 367 |
/Shading << |
| 368 |
/ShadingType 1 |
| 369 |
/Domain [0 1 0 1] |
| 370 |
/Matrix [pgfpatchX 0 0 pgfpatchY pgfpatchllx pgfpatchlly] |
| 371 |
/ColorSpace \pgf@shading@device\space |
| 372 |
/Function << |
| 373 |
/FunctionType 0 |
| 374 |
/Order 1 |
| 375 |
/Domain [0 1 0 1] |
| 376 |
/Range pgfrange\pgf@shading@model |
| 377 |
/BitsPerSample pgfchanneldepth\pgf@shading@model % bits per channel, actually |
| 378 |
/Size [pgfsamplesx pgfsamplesy] |
| 379 |
/DataSource /pgfsamplingproc load /ReusableStreamDecode filter |
| 380 |
>> |
| 381 |
>> |
| 382 |
>> matrix makepattern setpattern fill |
| 383 |
}% |
| 384 |
\noexpand\pgfsys@endpurepicture% |
| 385 |
}\hss}% |
| 386 |
}% |
| 387 |
}% |
| 388 |
\global\expandafter\let\csname @pgfshading#1!\endcsname\pgfutil@tempa% |
| 389 |
} |
| 390 |
|
| 391 |
% helpers for converting FunctionType-4 to FunctionType-0, i. e. sampled, functions; |
| 392 |
% FunctionType-4 functions are not defined in PostScript-3 |
| 393 |
% |
| 394 |
% These are the different colour models we are going to use: |
| 395 |
% +-------+-------------------+-----------+------------------+ |
| 396 |
% | model | channel depth/bit | max value | sample size/byte | |
| 397 |
% +-------+-------------------+-----------+------------------+ |
| 398 |
% | cmyk | 8 | 255 | 4 | |
| 399 |
% | rgb | 8 | 255 | 3 | |
| 400 |
% | gray | 24 | 16777215 | 3 | |
| 401 |
% +-------+-------------------+-----------+------------------+ |
| 402 |
\expandafter\gdef\expandafter\pgfsys@atbegindocument\expandafter{\pgfsys@atbegindocument% |
| 403 |
\pgf@sys@postscript@header{ |
| 404 |
% |
| 405 |
% -str- c m y k pgfwritesamplecmyk ==> -str- |
| 406 |
% -str- r g b pgfwritesamplergb ==> -str- |
| 407 |
% -str- gray pgfwritesamplegray ==> -str- |
| 408 |
% writes a single colour sample into the /pgfcolorsample* string; |
| 409 |
% colour components (c,m,y,k; r,g,b; gray) between 0.0 to 1.0 |
| 410 |
% |
| 411 |
/pgfwritesamplecmyk { |
| 412 |
4 index 0 5 index pgfcheckcolorrange 255 mul round cvi put |
| 413 |
4 index 1 4 index pgfcheckcolorrange 255 mul round cvi put |
| 414 |
4 index 2 3 index pgfcheckcolorrange 255 mul round cvi put |
| 415 |
4 index 3 2 index pgfcheckcolorrange 255 mul round cvi put |
| 416 |
pop pop pop pop |
| 417 |
} bind def |
| 418 |
% |
| 419 |
/pgfwritesamplergb { |
| 420 |
3 index 0 4 index pgfcheckcolorrange 255 mul round cvi put |
| 421 |
3 index 1 3 index pgfcheckcolorrange 255 mul round cvi put |
| 422 |
3 index 2 2 index pgfcheckcolorrange 255 mul round cvi put |
| 423 |
pop pop pop |
| 424 |
} bind def |
| 425 |
% |
| 426 |
/pgfwritesamplegray { |
| 427 |
% grayvalue between 0 and 16777215 (24 bit) |
| 428 |
pgfcheckcolorrange 16777215 mul round cvi % -str- gray24 |
| 429 |
1 index 0 2 index -16 bitshift put % high byte |
| 430 |
1 index 1 2 index 65535 and -8 bitshift put % middle byte |
| 431 |
1 index 2 2 index 255 and put % low byte |
| 432 |
pop |
| 433 |
} bind def |
| 434 |
% |
| 435 |
% <colour component> pgfcheckcolorrange ==> <something between 0.0 and 1.0> |
| 436 |
% truncates value to the allowed range (user-defined Type-4 functions may |
| 437 |
% happen to provide values outside this range) |
| 438 |
/pgfcheckcolorrange { |
| 439 |
dup 0.0 lt {pop 0.0} if |
| 440 |
dup 1.0 gt {pop 1.0} if |
| 441 |
} bind def |
| 442 |
% |
| 443 |
%colour depths per channel (bit) |
| 444 |
/pgfchanneldepthcmyk 8 def |
| 445 |
/pgfchanneldepthrgb 8 def |
| 446 |
/pgfchanneldepthgray 24 def |
| 447 |
% |
| 448 |
% allocate strings as buffers for storing a single colour sample |
| 449 |
/pgfcolorsamplecmyk 4 string def |
| 450 |
/pgfcolorsamplergb 3 string def |
| 451 |
/pgfcolorsamplegray 3 string def |
| 452 |
% |
| 453 |
%/Range array in the FunctionType 0 dictionary |
| 454 |
/pgfrangecmyk [0 1 0 1 0 1 0 1] def |
| 455 |
/pgfrangergb [0 1 0 1 0 1] def |
| 456 |
/pgfrangegray [0 1] def |
| 457 |
}% |
| 458 |
} |
| 459 |
|
| 460 |
|
| 461 |
% |
| 462 |
% Opacity masks |
| 463 |
% |
| 464 |
|
| 465 |
\def\pgfsys@fadingfrombox#1#2{% |
| 466 |
\ifcsname pgfsmaskxform@#1\endcsname |
| 467 |
\pgfwarning{Fading '#1' already defined.\MessageBreak Going to replace it with new definition}% |
| 468 |
\fi% |
| 469 |
\global\advance\pgf@objectcount\@ne% |
| 470 |
{% |
| 471 |
\pgf@x=-.5\wd#2% |
| 472 |
\pgf@y=-.5\ht#2% |
| 473 |
\advance\pgf@y by.5\dp#2% |
| 474 |
\expandafter\xdef\csname pgfsmasktrans@#1\endcsname{% |
| 475 |
\noexpand\pgftransformcm{1}{0}{0}{1}{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}}% |
| 476 |
\edef\@tempa{\noexpand\pgfutil@insertatbegincurrentpagefrombox{% |
| 477 |
% box coordinates (reference point and top) needed for ps2pdf |
| 478 |
\pgfsys@outerinvoke{currentpoint /pgf@refy exch def /pgf@refx exch def}% |
| 479 |
\hbox to 0pt {\hbox to \ifdim\ht#2>\ht\strutbox\ht#2\else\ht\strutbox\fi{\hss\pgfsys@outerinvoke{% |
| 480 |
/pgf@top pgf@refy currentpoint pop pgf@refx sub VResolution Resolution div mul sub def% |
| 481 |
}}\hss}% |
| 482 |
% lower-right box corner coordinates for viewing |
| 483 |
\hbox to 0pt {\hbox to \wd#2{\hss\pgfsys@outerinvoke{/pgf@right currentpoint pop def}}\hss}% |
| 484 |
\hbox to 0pt {\hbox to \ifdim\dp#2>\dp\strutbox\dp#2\else\dp\strutbox\fi{\hss\pgfsys@outerinvoke{% |
| 485 |
/pgf@bot pgf@refy currentpoint pop pgf@refx sub VResolution Resolution div mul add def% |
| 486 |
}}\hss}% |
| 487 |
\pgfsys@outerinvoke{gsave |
| 488 |
clippath pathbbox newpath pop pop translate |
| 489 |
systemdict /pdfmark known {% |
| 490 |
% for ps2pdf, translate box to upper-left page corner, so we have the whole clipping |
| 491 |
% path (i. e. page area) available, as outlying parts get clipped |
| 492 |
pgf@refx neg pgf@top neg translate% |
| 493 |
} {% |
| 494 |
% for viewing, however, we want to hide the box by moving it off-page; we do so by aligning |
| 495 |
% the lower-right box corner with the upper-left page corner |
| 496 |
pgf@right neg pgf@bot neg translate% |
| 497 |
} ifelse |
| 498 |
% translate origin (0,0) to the reference point |
| 499 |
gsave pgf@refx pgf@refy translate |
| 500 |
mark /_objdef {pgfsmaskxform@\the\pgf@objectcount} |
| 501 |
/BBox [clippath pathbbox newpath] /BP pdfmark grestore% |
| 502 |
}% |
| 503 |
\wd#2=0pt |
| 504 |
\ht#2=0pt |
| 505 |
\dp#2=0pt |
| 506 |
\box#2% |
| 507 |
\pgfsys@outerinvoke{mark /EP pdfmark grestore}% |
| 508 |
}}\@tempa% |
| 509 |
\expandafter\xdef\csname pgfsmaskxform@#1\endcsname{\the\pgf@objectcount}% |
| 510 |
}% |
| 511 |
} |
| 512 |
\def\pgfsys@usefading#1#2#3#4#5#6#7{% |
| 513 |
\ifcsname pgfsmaskxform@#1\endcsname% |
| 514 |
{% |
| 515 |
\pgftransformreset% |
| 516 |
\pgftransformcm{#2}{#3}{#4}{#5}{\pgfpoint{#6}{#7}}% |
| 517 |
\csname pgfsmasktrans@#1\endcsname% |
| 518 |
{% |
| 519 |
\pgflowlevelsynccm% |
| 520 |
\pgfsys@outerinvoke{% |
| 521 |
/.begintransparencymaskgroup where {pop |
| 522 |
/pgf@sys@currentcolorspace currentcolorspace def |
| 523 |
/pgf@sys@currentcolor [currentcolor] cvx def |
| 524 |
/pgf@sys@OverrideICC currentuserparams /OverrideICC get def % Chr. Liddell |
| 525 |
<</OverrideICC true>> setuserparams % of Artifex |
| 526 |
/DeviceGray setcolorspace |
| 527 |
true <</Subtype/Luminosity>> clippath pathbbox newpath .begintransparencymaskgroup |
| 528 |
gsave |
| 529 |
72 Resolution div 72 VResolution div scale |
| 530 |
1 DVImag div 1 DVImag div neg scale |
| 531 |
mark {pgfsmaskxform@\csname pgfsmaskxform@#1\endcsname} /SP pdfmark |
| 532 |
grestore |
| 533 |
0 .endtransparencymask |
| 534 |
<</OverrideICC pgf@sys@OverrideICC>> setuserparams % restore orig. settings |
| 535 |
pgf@sys@currentcolorspace setcolorspace |
| 536 |
pgf@sys@currentcolor setcolor |
| 537 |
/pgfsmaskinplace true def |
| 538 |
} if% |
| 539 |
}% |
| 540 |
}% |
| 541 |
\pgftransforminvert% |
| 542 |
\pgflowlevelsynccm% |
| 543 |
}% |
| 544 |
\else |
| 545 |
\pgferror{Undefined fading '#1'}% |
| 546 |
\fi% |
| 547 |
} |
| 548 |
\def\pgfsys@clipfading{% |
| 549 |
\pgfsyssoftpath@invokecurrentpath% |
| 550 |
\pgfsys@clipnext% |
| 551 |
\pgfsys@discardpath% |
| 552 |
} |
| 553 |
|
| 554 |
|
| 555 |
% |
| 556 |
% Transparency groups |
| 557 |
% |
| 558 |
\def\pgfsys@transparencygroupfrombox#1{% |
| 559 |
\global\advance\pgf@objectcount\@ne% |
| 560 |
\pgfsys@outerinvoke{% |
| 561 |
mark /_objdef {pgfxform@\the\pgf@objectcount} /BBox [clippath pathbbox newpath] /BP pdfmark |
| 562 |
gsave |
| 563 |
/pgf@sys@foa pgffoa def /pgf@sys@soa pgfsoa def |
| 564 |
/.setstrokeconstantalpha where |
| 565 |
{pop 1 .pgfsetfillopacityalpha 1 .pgfsetstrokeopacityalpha} if% |
| 566 |
}% |
| 567 |
\wd#1=0pt |
| 568 |
\ht#1=0pt |
| 569 |
\dp#1=0pt |
| 570 |
\hskip\pgf@picminx\box#1\hskip-\pgf@picminx |
| 571 |
\pgfsys@outerinvoke{% |
| 572 |
/pgffoa pgf@sys@foa def /pgfsoa pgf@sys@soa def |
| 573 |
grestore |
| 574 |
mark /EP pdfmark |
| 575 |
mark {pgfxform@\the\pgf@objectcount} << /Group << /S /Transparency |
| 576 |
/I \ifpgfsys@transparency@group@isolated true \else false \fi |
| 577 |
/K \ifpgfsys@transparency@group@knockout true \else false \fi >> >> /PUT pdfmark% |
| 578 |
}% |
| 579 |
\setbox#1=\hbox{\pgfsys@outerinvoke{mark {pgfxform@\the\pgf@objectcount} /SP pdfmark}}% |
| 580 |
} |
| 581 |
|
| 582 |
|
| 583 |
% |
| 584 |
% Image inclusion, adding SMask reference and image interpolation if mandated |
| 585 |
% |
| 586 |
|
| 587 |
\def\pgfsys@defineimage{% |
| 588 |
\ifx\pgf@imagewidth\pgfutil@empty\else\edef\pgf@imagewidth{width=\pgf@imagewidth,}\fi% |
| 589 |
\ifx\pgf@imageheight\pgfutil@empty\else\edef\pgf@imageheight{height=\pgf@imageheight,}\fi% |
| 590 |
\begingroup% |
| 591 |
\def\pgf@imageaddedkeys{}\def\@tempa{true}% |
| 592 |
\ifx\pgf@imageinterpolate\@tempa\def\pgf@imageaddedkeys{/Interpolate true}\fi% |
| 593 |
\ifx\pgf@imagemask\pgfutil@empty\else\edef\pgf@imageaddedkeys{\pgf@imageaddedkeys /SMask {\pgf@imagemask}}\fi% |
| 594 |
\edef\@tempa{% |
| 595 |
\ifx\pgf@imageaddedkeys\pgfutil@empty\else% |
| 596 |
\noexpand\pgfsys@outerinvoke{% |
| 597 |
save /pgfparent [(img) cvx cvn rand] cvx def %random name for current image |
| 598 |
mark /_objdef /pgfparent load /NI pdfmark |
| 599 |
% sometimes, image metadata contain embedded pdfmarks that prevent us from |
| 600 |
% writing to the image dictionary ourselves, so we disable them temporarily |
| 601 |
save /pdfmark /cleartomark load def |
| 602 |
}% |
| 603 |
\fi% |
| 604 |
\noexpand\includegraphics[\pgf@imageheight\pgf@imagewidth]{\pgf@filename}% |
| 605 |
\ifx\pgf@imageaddedkeys\pgfutil@empty\else% |
| 606 |
\noexpand\pgfsys@outerinvoke{% |
| 607 |
% empty image dummy, in case the provided file is not a valid raster image |
| 608 |
0 0 1 [1 0 0 1 0 0] {} image restore |
| 609 |
mark /pgfparent load <<\pgf@imageaddedkeys>> /PUT pdfmark restore |
| 610 |
}% |
| 611 |
\fi% |
| 612 |
}% |
| 613 |
\expandafter\endgroup% |
| 614 |
\expandafter\def\expandafter\pgf@image\expandafter{\@tempa}% |
| 615 |
} |
| 616 |
|
| 617 |
|
| 618 |
% |
| 619 |
% Image masks |
| 620 |
% |
| 621 |
|
| 622 |
\def\pgfsys@definemask{% |
| 623 |
\global\advance\pgf@objectcount\@ne% |
| 624 |
\ifx\pgf@maskmatte\pgfutil@empty% |
| 625 |
\else% |
| 626 |
\edef\pgf@maskmatte{/Matte [\pgf@maskmatte]}% |
| 627 |
\fi% |
| 628 |
\pgfsys@outerinvoke{% |
| 629 |
mark /_objdef {pgfmask\the\pgf@objectcount} /NI pdfmark |
| 630 |
1 dict begin /pdfmark /cleartomark load def |
| 631 |
}% |
| 632 |
\special{psfile=\pgf@filename\space hsize=0 vsize=0}% |
| 633 |
\pgfsys@outerinvoke{% |
| 634 |
0 0 1 [1 0 0 1 0 0] {} image |
| 635 |
end mark {pgfmask\the\pgf@objectcount} <</Decode [1 0] \pgf@maskmatte>> /PUT pdfmark |
| 636 |
}% |
| 637 |
\edef\pgf@mask{pgfmask\the\pgf@objectcount}% |
| 638 |
} |
| 639 |
|
| 640 |
\endinput |
| 641 |
|
| 642 |
%%% Local Variables: |
| 643 |
%%% mode: latex |
| 644 |
%%% End: |