| 1 |
% \iffalse meta-comment |
| 2 |
%<=*COPYRIGHT> |
| 3 |
%% Copyright (C) 2011 by Martin Scharrer <[email protected]> |
| 4 |
%% --------------------------------------------------------------------------- |
| 5 |
%% This work may be distributed and/or modified under the |
| 6 |
%% conditions of the LaTeX Project Public License, either version 1.3 |
| 7 |
%% of this license or (at your option) any later version. |
| 8 |
%% The latest version of this license is in |
| 9 |
%% http://www.latex-project.org/lppl.txt |
| 10 |
%% and version 1.3 or later is part of all distributions of LaTeX |
| 11 |
%% version 2005/12/01 or later. |
| 12 |
%% |
| 13 |
%% This work has the LPPL maintenance status `maintained'. |
| 14 |
%% |
| 15 |
%% The Current Maintainer of this work is Martin Scharrer. |
| 16 |
%% |
| 17 |
%% This work consists of the files storebox.dtx and storebox.ins |
| 18 |
%% and the derived filebase storebox.sty and storebox-pgf.sty. |
| 19 |
%% |
| 20 |
%<=/COPYRIGHT> |
| 21 |
% \fi |
| 22 |
% |
| 23 |
% \iffalse |
| 24 |
%<*driver> |
| 25 |
\ProvidesFile{storebox.dtx}[% |
| 26 |
%<=*DATE> |
| 27 |
2011/12/21 |
| 28 |
%<=/DATE> |
| 29 |
%<=*VERSION> |
| 30 |
v1.3a |
| 31 |
%<=/VERSION> |
| 32 |
DTX file for storebox] |
| 33 |
\documentclass{ydoc} |
| 34 |
\GetFileInfo{storebox.dtx} |
| 35 |
\usepackage{storebox}[\filedate] |
| 36 |
\EnableCrossrefs |
| 37 |
\CodelineIndex |
| 38 |
\RecordChanges |
| 39 |
\begin{document} |
| 40 |
\DocInput{\jobname.dtx} |
| 41 |
\PrintChanges |
| 42 |
\PrintIndex |
| 43 |
\end{document} |
| 44 |
%</driver> |
| 45 |
% \fi |
| 46 |
% |
| 47 |
% \CheckSum{680} |
| 48 |
% |
| 49 |
% \CharacterTable |
| 50 |
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z |
| 51 |
% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z |
| 52 |
% Digits \0\1\2\3\4\5\6\7\8\9 |
| 53 |
% Exclamation \! Double quote \" Hash (number) \# |
| 54 |
% Dollar \$ Percent \% Ampersand \& |
| 55 |
% Acute accent \' Left paren \( Right paren \) |
| 56 |
% Asterisk \* Plus \+ Comma \, |
| 57 |
% Minus \- Point \. Solidus \/ |
| 58 |
% Colon \: Semicolon \; Less than \< |
| 59 |
% Equals \= Greater than \> Question mark \? |
| 60 |
% Commercial at \@ Left bracket \[ Backslash \\ |
| 61 |
% Right bracket \] Circumflex \^ Underscore \_ |
| 62 |
% Grave accent \` Left brace \{ Vertical bar \| |
| 63 |
% Right brace \} Tilde \~} |
| 64 |
% |
| 65 |
% |
| 66 |
% \changes{v0.99}{2011/08/05}{Converted to DTX file.} |
| 67 |
% \changes{v1.0}{2011/09/22}{First release.} |
| 68 |
% \changes{v1.1}{2011/10/21}{Fixed issue with \env{storebox} environment with new \pkg{collectbox} version.} |
| 69 |
% \changes{v1.2}{2011/12/19}{Added PDF resources argument to support transparent material.} |
| 70 |
% \changes{v1.3}{2011/12/20}{Added patch for PDF pdftex driver to fully support transparent material and shadings.} |
| 71 |
% \changes{v1.3a}{2011/12/21}{Made the use of \cs{immediate} optional so that unused storeboxes are not written to the PDF.} |
| 72 |
% |
| 73 |
% \DoNotIndex{\newcommand,\newenvironment} |
| 74 |
% |
| 75 |
% \GetFileInfo{storebox.dtx} |
| 76 |
% \author{Martin Scharrer} |
| 77 |
% \email{[email protected]} |
| 78 |
% \ifdefined\repository |
| 79 |
% \repository{https://bitbucket.org/martin_scharrer/storebox} |
| 80 |
% \fi |
| 81 |
% |
| 82 |
% \maketitle |
| 83 |
% |
| 84 |
% \begin{abstract}\noindent |
| 85 |
% This package allows the placement of identical content multiple times in a document while only storing it once in the output file. |
| 86 |
% At the moment only \LaTeX\ compilers with native PDF output are supported (|pdflatex| or |lualatex|). |
| 87 |
% For other \LaTeX\ compilers a fallback to |\savebox| is implemented. |
| 88 |
% \end{abstract} |
| 89 |
% |
| 90 |
% \section{Introduction} |
| 91 |
% \LaTeX{} provides box registers to save content and use it later in the document once or multiple times (or none at all). |
| 92 |
% However, the box content is then written every time to the output file. |
| 93 |
% The PDF file format provides a way to store material as object and reference it later. A similar technique is theoretically |
| 94 |
% possible for PostScript output (but not yet implemented). This has the benefit that the content is really only stored once |
| 95 |
% in the output file. However, if file compression is used for the final output file the size benefit might be very small |
| 96 |
% if the content is only reused a low number of times. |
| 97 |
% |
| 98 |
% This package provides ``store boxes'' which have the same user interface like normal \LaTeX{} ``save boxes'', but only |
| 99 |
% store the content once in the output file even if it is used several times. |
| 100 |
% At the moment only PDF output is supported (i.e.\ \texttt{pdflatex} and \texttt{lualatex}). |
| 101 |
% If the stored content is not used in the document after all it is not written to the PDF except if the \opt{immediate} option was used. |
| 102 |
% For any other \TeX{} and output format the package simply falls back to use the normal savebox equivalents. |
| 103 |
% |
| 104 |
% \section{Known issues} |
| 105 |
% There are some known side effects with advanced graphic elements, namely transparencies and shadings. |
| 106 |
% These elements require special driver code which adds the required PDF instructions. For TikZ/PGF drawings this is done |
| 107 |
% by the |pdftex| driver of TikZ/PGF. However, due to a |
| 108 |
% \href{https://sourceforge.net/tracker/?func=detail&atid=752792&aid=3462542&group_id=142562}{bug in this driver} |
| 109 |
% transparent material is not supported, but shown fully opaque if the storebox also holds PDF shadings. |
| 110 |
% This affects \file{pgfsys-pdftex.def} in v1.26 from 2009/05/22 and earlier versions. |
| 111 |
% Since \pkg{storebox} v1.3 from 2011/12/20 a set of patches for the PGF |pdftex| driver is loaded (as support package \pkg{storebox-pgf}), |
| 112 |
% so that both transparencies and shadings are supported together. The patches are not loaded if a new version of the driver is detected. |
| 113 |
% Please report all issues with this patches to the \pkg{storebox} author, not to the TikZ/PGF authors. |
| 114 |
% |
| 115 |
% \section{Options} |
| 116 |
% The package allows to enable and disable the storebox feature. Normally this is selected automatically dependent if PDF output is used (using \pkg{ifpdf}). |
| 117 |
% It also provides two options \opt{enable} and \opt{disable} to explicitly switch the storebox feature on or off. |
| 118 |
% The \opt{disable} option is useful to see the resulting file size difference. |
| 119 |
% The usage of the \opt{enable} option should not be required and will lead to errors if used with unsupported \TeX{} formats. |
| 120 |
% |
| 121 |
% Two further complementary options \opt{delayed} (default) and \opt{immediate} are provided. |
| 122 |
% They control if a storebox (i.e.\ the underlying \Macro\pdfxform) is written to the PDF immediately or only after it gets referenced, i.e.\ is inserted into the document using |
| 123 |
% \Macro\usestorebox. With \opt{immediate} the storebox is always written into the PDF, even if it is not used. By default \opt{delayed} is used, but |
| 124 |
% it is possible that \opt{immediate} is required if \Macro\storebox is used inside other \Macro\pdfxform\relax's, e.g.\ inside certain TikZ/PGF nodes. |
| 125 |
% If any graphic issues occur in a document the \opt{immediate} option should first be tested before sending any bug reports. |
| 126 |
% |
| 127 |
% \Needspace*{3cm} |
| 128 |
% \section{Macros} |
| 129 |
% |
| 130 |
% \DescribeMacro{\newstorebox}{<\textbackslash boxname>} |
| 131 |
% Because storeboxes are stored as PDF objects and not as \TeX\ box registers |
| 132 |
% it is not required to allocate a register for them. However, in fall-back mode |
| 133 |
% the used control sequence \meta{\textbackslash boxname} must be defined as savebox. |
| 134 |
% This macro defines \meta{\textbackslash boxname} simply as \Macro\relax\relax (just as precaution) and is equal to |
| 135 |
% \Macro\newsavebox in fall-back mode. |
| 136 |
% |
| 137 |
% |
| 138 |
% \DescribeMacro{\storebox}{<\textbackslash boxname>}{<content>} |
| 139 |
% This stores the \meta{content} as \meta{\textbackslash boxname} (which is actually just a numeric reference) for later use. |
| 140 |
% The \pkg{collectbox} package is used to collect the \meta{content} as box and not as macro argument and therefore it can |
| 141 |
% contain verbatim and other special material. The braces can also be written in their explicit form \Macro\bgroup and \Macro\egroup |
| 142 |
% and then split in two different macros or across the begin and end of an environment. |
| 143 |
% It is possible to use \Macro\storebox multiple times with the same \meta{\textbackslash boxname}. This will create |
| 144 |
% a new PDF object without affected the old one. |
| 145 |
% In fall-back mode this macro is functional equal to \Macro\savebox\relax (but then still uses \pkg{collectbox}). |
| 146 |
% |
| 147 |
% |
| 148 |
% \DescribeEnv[<content>]{storebox}{<\textbackslash boxname>} |
| 149 |
% This is the environment version of \Macro\storebox. Special care is taken to allow for an identical name. |
| 150 |
% In fall-back mode this macro is equal to the \env{lrbox} environment. |
| 151 |
% |
| 152 |
% |
| 153 |
% \DescribeMacro{\usestorebox}{<\textbackslash boxname>} |
| 154 |
% This macro typesets the stored content at the current position (as horizontal box in horizontal mode). |
| 155 |
% This is realized by adding a PDF reference to the stored content. |
| 156 |
% In fall-back mode this macro is equal to \Macro\usebox. |
| 157 |
% |
| 158 |
% |
| 159 |
% \DescribeMacro{\ifstorebox} |
| 160 |
% This if-switch is set to \emph{true} if \Macro\storebox was successfully defined as intended |
| 161 |
% but to \emph{false} if the \Macro\savebox fall-back was used. |
| 162 |
% |
| 163 |
% \clearpage |
| 164 |
% \section{Example} |
| 165 |
% \begin{lstlisting}[gobble=2,language={[latex]tex},numbers=none] |
| 166 |
% \documentclass{article} |
| 167 |
% |
| 168 |
% \usepackage{storebox} |
| 169 |
% |
| 170 |
% \newstorebox{\mybox} % Not really required for PDF output |
| 171 |
% \begin{document} |
| 172 |
% |
| 173 |
% \storebox{\mybox}{\verb+Supports verbatim #$\empty+} |
| 174 |
% |
| 175 |
% \usestorebox{\mybox} |
| 176 |
% \usestorebox{\mybox} |
| 177 |
% |
| 178 |
% \storebox\mybox\bgroup |
| 179 |
% Can also be split |
| 180 |
% \verb+\empty+ |
| 181 |
% \egroup |
| 182 |
% |
| 183 |
% \usestorebox{\mybox} |
| 184 |
% \usestorebox{\mybox} |
| 185 |
% |
| 186 |
% \begin{storebox}{\mybox} |
| 187 |
% Or used as environment |
| 188 |
% (then will ignore leading and trailing spaces) |
| 189 |
% \end{storebox} |
| 190 |
% |
| 191 |
% \usestorebox{\mybox} |
| 192 |
% \usestorebox{\mybox} |
| 193 |
% |
| 194 |
% \end{document} |
| 195 |
% \end{lstlisting} |
| 196 |
% |
| 197 |
% \setcounter{lstnumber}{1} |
| 198 |
% \StopEventually{} |
| 199 |
% |
| 200 |
% \clearpage |
| 201 |
% \section{Implementation} |
| 202 |
% |
| 203 |
% \iffalse |
| 204 |
%<*storebox.sty> |
| 205 |
% \fi |
| 206 |
% \begin{macrocode} |
| 207 |
%<!COPYRIGHT> |
| 208 |
\ProvidesPackage{storebox}[% |
| 209 |
%<!DATE> |
| 210 |
%<!VERSION> |
| 211 |
%<*DRIVER> |
| 212 |
2099/01/01 develop |
| 213 |
%</DRIVER> |
| 214 |
Store and reuse boxes in a file size efficient way] |
| 215 |
% \end{macrocode} |
| 216 |
% |
| 217 |
% \begin{macrocode} |
| 218 |
\DeclareOption{disable}{\let\ifstorebox\iffalse} |
| 219 |
\DeclareOption{enable}{\let\ifstorebox\iftrue} |
| 220 |
\DeclareOption{immediate}{\let\storebox@immediate\immediate} |
| 221 |
\DeclareOption{delayed}{\let\storebox@immediate\relax} |
| 222 |
\ExecuteOptions{delayed} |
| 223 |
\ProcessOptions* |
| 224 |
\expandafter\ifx\csname ifstorebox\endcsname\relax |
| 225 |
\RequirePackage{ifpdf} |
| 226 |
\expandafter\let\csname ifstorebox\expandafter\endcsname\csname ifpdf\endcsname |
| 227 |
\fi |
| 228 |
% \end{macrocode} |
| 229 |
% |
| 230 |
% \begin{macrocode} |
| 231 |
\RequirePackage{collectbox}[2011/08/04] |
| 232 |
% \end{macrocode} |
| 233 |
% |
| 234 |
% \begin{macro}{\storebox} |
| 235 |
% \begin{macrocode} |
| 236 |
\newcommand*\storebox{% |
| 237 |
\begingroup |
| 238 |
\def\@tempa{storebox}% |
| 239 |
\ifx\@currenvir\@tempa |
| 240 |
\endgroup |
| 241 |
\expandafter\@storebox@env |
| 242 |
\else |
| 243 |
\endgroup |
| 244 |
\expandafter\@storebox |
| 245 |
\fi |
| 246 |
} |
| 247 |
% \end{macrocode} |
| 248 |
% \end{macro} |
| 249 |
% |
| 250 |
% |
| 251 |
% \begin{macrocode} |
| 252 |
\ifstorebox |
| 253 |
% \end{macrocode} |
| 254 |
% |
| 255 |
% \begin{macro}{\@storebox} |
| 256 |
% Macro version: |
| 257 |
% \begin{macrocode} |
| 258 |
\def\@storebox#1{% |
| 259 |
\begingroup |
| 260 |
\@collectboxto\collectedbox{% |
| 261 |
\storebox@immediate\pdfxform resources {\the\pdfpageresources}\collectedbox |
| 262 |
\endgroup\mathchardef#1=\pdflastxform |
| 263 |
}% |
| 264 |
} |
| 265 |
% \end{macrocode} |
| 266 |
% \end{macro} |
| 267 |
% |
| 268 |
% |
| 269 |
% \begin{macro}{\@storebox@env} |
| 270 |
% Environment version. Code adapted from \env{lrbox} environment. The group added by \Macro\begin and \Macro\end must |
| 271 |
% be specially handled to allow for a local assignment. |
| 272 |
% \begin{macrocode} |
| 273 |
\def\@storebox@env#1{% |
| 274 |
\edef\@tempa{% |
| 275 |
\setbox\collectedbox\hbox\bgroup% |
| 276 |
\def\noexpand\the@storebox{\noexpand#1}% |
| 277 |
}% |
| 278 |
\@tempa |
| 279 |
\begingroup |
| 280 |
\aftergroup\@storebox@env@end |
| 281 |
\@endpefalse |
| 282 |
\color@setgroup |
| 283 |
\begingroup |
| 284 |
\def\@currenvir{storebox\empty}% |
| 285 |
\ignorespaces |
| 286 |
} |
| 287 |
% \end{macrocode} |
| 288 |
% \end{macro} |
| 289 |
% |
| 290 |
% \begin{macro}{\endstorebox} |
| 291 |
% \begin{macrocode} |
| 292 |
\def\endstorebox{% |
| 293 |
\unskip |
| 294 |
\endgroup |
| 295 |
\color@endgroup |
| 296 |
} |
| 297 |
% \end{macrocode} |
| 298 |
% \end{macro} |
| 299 |
% |
| 300 |
% |
| 301 |
% |
| 302 |
% \begin{macro}{\@storebox@env@end} |
| 303 |
% This ends the box assignment and stores the box as PDF xform. |
| 304 |
% Then the given control sequence is set to the xform number. |
| 305 |
% \begin{macrocode} |
| 306 |
\def\@storebox@env@end{% |
| 307 |
\edef\@tempa{% |
| 308 |
\egroup |
| 309 |
\immediate\pdfxform resources {\the\pdfpageresources}\collectedbox |
| 310 |
\endgroup |
| 311 |
\mathchardef\expandafter\noexpand\the@storebox=\pdflastxform |
| 312 |
}% |
| 313 |
\@tempa |
| 314 |
} |
| 315 |
% \end{macrocode} |
| 316 |
% \end{macro} |
| 317 |
% |
| 318 |
% |
| 319 |
% \begin{macro}{\newstorebox} |
| 320 |
% \begin{macrocode} |
| 321 |
\newcommand*\newstorebox[1]{% |
| 322 |
\@ifdefinable{#1}{\let#1\relax}% |
| 323 |
} |
| 324 |
% \end{macrocode} |
| 325 |
% \end{macro} |
| 326 |
% |
| 327 |
% \begin{macro}{\usestorebox} |
| 328 |
% \begin{macrocode} |
| 329 |
\newcommand*\usestorebox[1]{% |
| 330 |
\mbox{\pdfrefxform#1}% |
| 331 |
} |
| 332 |
% \end{macrocode} |
| 333 |
% \end{macro} |
| 334 |
% |
| 335 |
% Load PGF driver patches if required: |
| 336 |
% \begin{macrocode} |
| 337 |
\AtBeginDocument{% |
| 338 |
\@ifpackageloaded{pgf}{\RequirePackage{storebox-pgf}{}}% |
| 339 |
} |
| 340 |
% \end{macrocode} |
| 341 |
% |
| 342 |
% \begin{macrocode} |
| 343 |
\else |
| 344 |
% \end{macrocode} |
| 345 |
% |
| 346 |
% |
| 347 |
% \begin{macro}{\@storebox} |
| 348 |
% Macro version: |
| 349 |
% \begin{macrocode} |
| 350 |
\def\@storebox#1{\@collectboxto{#1}{}} |
| 351 |
% \end{macrocode} |
| 352 |
% \end{macro} |
| 353 |
% |
| 354 |
% |
| 355 |
% \begin{macro}{\@storebox@env} |
| 356 |
% \begin{macrocode} |
| 357 |
\def\@storebox@env{% |
| 358 |
\edef\@currenvir{\@currenvir\noexpand\noexpand\noexpand\empty}% |
| 359 |
\lrbox |
| 360 |
} |
| 361 |
% \end{macrocode} |
| 362 |
% \end{macro} |
| 363 |
% |
| 364 |
% |
| 365 |
% \begin{macro}{\endstorebox} |
| 366 |
% \begin{macrocode} |
| 367 |
\def\endstorebox{% |
| 368 |
\endlrbox |
| 369 |
\edef\@currenvir{\@currenvir}% |
| 370 |
} |
| 371 |
% \end{macrocode} |
| 372 |
% \end{macro} |
| 373 |
% |
| 374 |
% \begin{macro}{\newsavebox} |
| 375 |
% \begin{macrocode} |
| 376 |
\@ifdefinable\newstorebox{% |
| 377 |
\let\newstorebox\newsavebox |
| 378 |
} |
| 379 |
% \end{macrocode} |
| 380 |
% \end{macro} |
| 381 |
% |
| 382 |
% \begin{macro}{\usestorebox} |
| 383 |
% \begin{macrocode} |
| 384 |
\@ifdefinable\usestorebox{% |
| 385 |
\let\usestorebox\usebox |
| 386 |
} |
| 387 |
% \end{macrocode} |
| 388 |
% \end{macro} |
| 389 |
% |
| 390 |
% \begin{macrocode} |
| 391 |
\fi |
| 392 |
% \end{macrocode} |
| 393 |
% |
| 394 |
|
| 395 |
% \iffalse |
| 396 |
%</storebox.sty> |
| 397 |
% \fi |
| 398 |
% |
| 399 |
% |
| 400 |
% \subsection{PGF patches} |
| 401 |
% |
| 402 |
% \iffalse |
| 403 |
%<*storebox-pgf.sty> |
| 404 |
% \fi |
| 405 |
% \begin{macrocode} |
| 406 |
%% This support package contains patches for the file 'pgfsys-pdftex.def' file from |
| 407 |
%% the TikZ/PGF bundle. All patches code is copyright by the TikZ/PGF authors |
| 408 |
%% and is used in this file according to the LPPL license. |
| 409 |
%% Please see the copyright and license notices in the 'pgfsys-pdftex.def' file. |
| 410 |
%% |
| 411 |
%% The rest of the code of this file is under the following copyright and licence: |
| 412 |
%% |
| 413 |
%<!COPYRIGHT> |
| 414 |
\ProvidesPackage{storebox-pgf}[% |
| 415 |
%<!DATE> |
| 416 |
%<!VERSION> |
| 417 |
%<*DRIVER> |
| 418 |
2099/01/01 develop |
| 419 |
%</DRIVER> |
| 420 |
Patches for PGF to support transparency and shadings inside storeboxes] |
| 421 |
% \end{macrocode} |
| 422 |
% |
| 423 |
% \begin{macrocode} |
| 424 |
\begingroup |
| 425 |
\let\on@line\@gobble |
| 426 |
% |
| 427 |
% \end{macrocode} |
| 428 |
% |
| 429 |
% \begin{macrocode} |
| 430 |
\@ifl@ter{def}{pgfsys-pdftex}{2009/05/23}{% |
| 431 |
\PackageInfo{storebox-pgf}{Newer version of 'pgfsys-pdftex.def' found.\MessageBreak No patches applied.}% |
| 432 |
\endgroup |
| 433 |
\endinput |
| 434 |
}{}% |
| 435 |
% \end{macrocode} |
| 436 |
% |
| 437 |
% \begin{macro}{\storebox@patch} |
| 438 |
% \begin{macrocode} |
| 439 |
\def\storebox@patch#1#2#3#4{% |
| 440 |
\ifx#1\@undefined |
| 441 |
\PackageInfo{storebox-pgf}{Macro \string#1\space not defined.\MessageBreak No patch applied.}% |
| 442 |
\else |
| 443 |
\def\@tempa#2{#3}% |
| 444 |
\ifx#1\@tempa |
| 445 |
\PackageInfo{storebox-pgf}{Patching macro \string#1.}% |
| 446 |
\gdef#1#2{#4}% |
| 447 |
\else |
| 448 |
\PackageInfo{storebox-pgf}{Macro \string#1\space with unknown definition.\MessageBreak No patch applied.}% |
| 449 |
\fi |
| 450 |
\fi |
| 451 |
} |
| 452 |
% \end{macrocode} |
| 453 |
% \end{macro} |
| 454 |
% |
| 455 |
% \begin{macrocode} |
| 456 |
\storebox@patch\pgfsys@horishading{#1#2#3}{% |
| 457 |
{% |
| 458 |
\pgf@parsefunc{#3}% |
| 459 |
\pgfmathparse{#2}% |
| 460 |
\setbox\pgfutil@tempboxa=\hbox to\pgf@max{\vbox to\pgfmathresult pt{\vfil\pgfsys@invoke{/Sh sh}}\hfil}% |
| 461 |
\pgf@process{\pgfpoint{\pgf@max}{#2}}% |
| 462 |
\pdfxform resources {% |
| 463 |
/Shading << /Sh << /ShadingType 2 |
| 464 |
/ColorSpace /DeviceRGB |
| 465 |
/Domain [\pgf@pdfparseddomain] |
| 466 |
/Coords [\pgf@doma\space0 \pgf@domb\space0] |
| 467 |
/Function \pgf@pdfparsedfunction |
| 468 |
/Extend [false false] >> >>}\pgfutil@tempboxa% << |
| 469 |
\expandafter\xdef\csname @pgfshading#1!\endcsname{\leavevmode\noexpand\pdfrefxform\the\pdflastxform}% |
| 470 |
}% |
| 471 |
}{% |
| 472 |
{% |
| 473 |
\pgf@parsefunc{#3}% |
| 474 |
\pgfmathparse{#2}% |
| 475 |
\setbox\pgfutil@tempboxa=\hbox to\pgf@max{\vbox to\pgfmathresult pt{\vfil\pgfsys@invoke{/Sh sh}}\hfil}% |
| 476 |
\pgf@process{\pgfpoint{\pgf@max}{#2}}% |
| 477 |
\immediate\pdfxform resources {% |
| 478 |
/Shading << /Sh << /ShadingType 2 |
| 479 |
/ColorSpace /DeviceRGB |
| 480 |
/Domain [\pgf@pdfparseddomain] |
| 481 |
/Coords [\pgf@doma\space0 \pgf@domb\space0] |
| 482 |
/Function \pgf@pdfparsedfunction |
| 483 |
/Extend [false false] >> >>}\pgfutil@tempboxa% << |
| 484 |
\expandafter\xdef\csname @pgfshading#1!\endcsname{\leavevmode\noexpand\pdfrefxform\the\pdflastxform}% |
| 485 |
}% |
| 486 |
} |
| 487 |
% \end{macrocode} |
| 488 |
% |
| 489 |
% \begin{macrocode} |
| 490 |
\storebox@patch\pgfsys@vertshading{#1#2#3}{% |
| 491 |
{% |
| 492 |
\pgf@parsefunc{#3}% |
| 493 |
\pgfmathparse{#2}% |
| 494 |
\setbox\pgfutil@tempboxa=\hbox to\pgfmathresult pt{\vbox to\pgf@max{\vfil\pgfsys@invoke{/Sh sh}}\hfil}% |
| 495 |
\pgf@process{\pgfpoint{#2}{\pgf@max}}% |
| 496 |
\pdfxform resources {% |
| 497 |
/Shading << /Sh << /ShadingType 2 |
| 498 |
/ColorSpace /DeviceRGB |
| 499 |
/Domain [\pgf@pdfparseddomain] |
| 500 |
/Coords [0 \pgf@doma\space0 \pgf@domb] |
| 501 |
/Function \pgf@pdfparsedfunction |
| 502 |
/Extend [false false] >> >>}\pgfutil@tempboxa% << |
| 503 |
\expandafter\xdef\csname @pgfshading#1!\endcsname{\leavevmode\noexpand\pdfrefxform\the\pdflastxform}% |
| 504 |
}% |
| 505 |
}{% |
| 506 |
{% |
| 507 |
\pgf@parsefunc{#3}% |
| 508 |
\pgfmathparse{#2}% |
| 509 |
\setbox\pgfutil@tempboxa=\hbox to\pgfmathresult pt{\vbox to\pgf@max{\vfil\pgfsys@invoke{/Sh sh}}\hfil}% |
| 510 |
\pgf@process{\pgfpoint{#2}{\pgf@max}}% |
| 511 |
\immediate\pdfxform resources {% |
| 512 |
/Shading << /Sh << /ShadingType 2 |
| 513 |
/ColorSpace /DeviceRGB |
| 514 |
/Domain [\pgf@pdfparseddomain] |
| 515 |
/Coords [0 \pgf@doma\space0 \pgf@domb] |
| 516 |
/Function \pgf@pdfparsedfunction |
| 517 |
/Extend [false false] >> >>}\pgfutil@tempboxa% << |
| 518 |
\expandafter\xdef\csname @pgfshading#1!\endcsname{\leavevmode\noexpand\pdfrefxform\the\pdflastxform}% |
| 519 |
}% |
| 520 |
} |
| 521 |
% \end{macrocode} |
| 522 |
% |
| 523 |
% \begin{macrocode} |
| 524 |
\storebox@patch\pgfsys@radialshading{#1#2#3}{% |
| 525 |
{% |
| 526 |
\pgf@parsefunc{#3}% |
| 527 |
\setbox\pgfutil@tempboxa=\hbox to2\pgf@max{\vbox to2\pgf@max{\vfil\pgfsys@invoke{/Sh sh}}\hfil}% |
| 528 |
\pgf@process{#2}% |
| 529 |
\pgf@xa=\pgf@x% |
| 530 |
\pgf@ya=\pgf@y% |
| 531 |
\pgf@process{\pgfpoint{\pgf@max}{\pgf@max}}% |
| 532 |
\advance\pgf@xa by \pgf@x% |
| 533 |
\advance\pgf@ya by \pgf@y% |
| 534 |
\pgf@sys@bp@correct{\pgf@x}% |
| 535 |
\pgf@sys@bp@correct{\pgf@y}% |
| 536 |
\pgf@sys@bp@correct{\pgf@xa}% |
| 537 |
\pgf@sys@bp@correct{\pgf@ya}% |
| 538 |
\pdfxform resources {% |
| 539 |
/Shading << /Sh << /ShadingType 3 |
| 540 |
/ColorSpace /DeviceRGB |
| 541 |
/Domain [\pgf@pdfparseddomain] |
| 542 |
/Coords [\pgf@sys@tonumber{\pgf@xa} \pgf@sys@tonumber{\pgf@ya} \pgf@doma\space \pgf@sys@tonumber{\pgf@x} \pgf@sys@tonumber{\pgf@y} \pgf@domb] |
| 543 |
/Function \pgf@pdfparsedfunction |
| 544 |
/Extend [true false] >> >>}\pgfutil@tempboxa% << |
| 545 |
\expandafter\xdef\csname @pgfshading#1!\endcsname{\leavevmode\noexpand\pdfrefxform\the\pdflastxform}% |
| 546 |
}% |
| 547 |
}{% |
| 548 |
{% |
| 549 |
\pgf@parsefunc{#3}% |
| 550 |
\setbox\pgfutil@tempboxa=\hbox to2\pgf@max{\vbox to2\pgf@max{\vfil\pgfsys@invoke{/Sh sh}}\hfil}% |
| 551 |
\pgf@process{#2}% |
| 552 |
\pgf@xa=\pgf@x% |
| 553 |
\pgf@ya=\pgf@y% |
| 554 |
\pgf@process{\pgfpoint{\pgf@max}{\pgf@max}}% |
| 555 |
\advance\pgf@xa by \pgf@x% |
| 556 |
\advance\pgf@ya by \pgf@y% |
| 557 |
\pgf@sys@bp@correct{\pgf@x}% |
| 558 |
\pgf@sys@bp@correct{\pgf@y}% |
| 559 |
\pgf@sys@bp@correct{\pgf@xa}% |
| 560 |
\pgf@sys@bp@correct{\pgf@ya}% |
| 561 |
\immediate\pdfxform resources {% |
| 562 |
/Shading << /Sh << /ShadingType 3 |
| 563 |
/ColorSpace /DeviceRGB |
| 564 |
/Domain [\pgf@pdfparseddomain] |
| 565 |
/Coords [\pgf@sys@tonumber{\pgf@xa} \pgf@sys@tonumber{\pgf@ya} \pgf@doma\space \pgf@sys@tonumber{\pgf@x} \pgf@sys@tonumber{\pgf@y} \pgf@domb] |
| 566 |
/Function \pgf@pdfparsedfunction |
| 567 |
/Extend [true false] >> >>}\pgfutil@tempboxa% << |
| 568 |
\expandafter\xdef\csname @pgfshading#1!\endcsname{\leavevmode\noexpand\pdfrefxform\the\pdflastxform}% |
| 569 |
}% |
| 570 |
}% |
| 571 |
% \end{macrocode} |
| 572 |
% |
| 573 |
% \begin{macrocode} |
| 574 |
\storebox@patch\pgfsys@functionalshading{#1#2#3#4}{% |
| 575 |
{% |
| 576 |
\pgf@process{#2}% |
| 577 |
\pgf@xa=\pgf@x% |
| 578 |
\pgf@ya=\pgf@y% |
| 579 |
\pgf@process{#3}% |
| 580 |
\pgf@xb=\pgf@x% |
| 581 |
\pgf@yb=\pgf@y% |
| 582 |
\advance\pgf@x by-\pgf@xa% |
| 583 |
\advance\pgf@y by-\pgf@ya% |
| 584 |
\setbox\pgfutil@tempboxa=\hbox to\pgf@x{\vbox to\pgf@y{\vfil\pgfsys@invoke{/Sh sh}}\hfil}% |
| 585 |
\pgf@sys@bp@correct{\pgf@xa}% |
| 586 |
\pgf@sys@bp@correct{\pgf@ya}% |
| 587 |
\pgf@sys@bp@correct{\pgf@xb}% |
| 588 |
\pgf@sys@bp@correct{\pgf@yb}% |
| 589 |
\pgf@xc=-\pgf@xa% |
| 590 |
\pgf@yc=-\pgf@ya% |
| 591 |
% Now build the function |
| 592 |
\pdfobj |
| 593 |
stream |
| 594 |
attr |
| 595 |
{ |
| 596 |
/FunctionType 4 |
| 597 |
/Domain [\pgf@sys@tonumber{\pgf@xa}\space\pgf@sys@tonumber{\pgf@xb}\space\pgf@sys@tonumber{\pgf@ya}\space\pgf@sys@tonumber{\pgf@yb}] |
| 598 |
/Range [0 1 0 1 0 1] |
| 599 |
} |
| 600 |
{{#4}}% |
| 601 |
\edef\pgf@temp@num{\the\pdflastobj}% |
| 602 |
\pdfxform resources {% |
| 603 |
/Shading << /Sh << /ShadingType 1 |
| 604 |
/ColorSpace /DeviceRGB |
| 605 |
/Matrix [1 0 0 1 \pgf@sys@tonumber{\pgf@xc}\space\pgf@sys@tonumber{\pgf@yc}] |
| 606 |
/Domain [\pgf@sys@tonumber{\pgf@xa}\space\pgf@sys@tonumber{\pgf@xb}\space\pgf@sys@tonumber{\pgf@ya}\space\pgf@sys@tonumber{\pgf@yb}] |
| 607 |
/Function \pgf@temp@num\space 0 R |
| 608 |
>> >>}\pgfutil@tempboxa% << |
| 609 |
\expandafter\xdef\csname @pgfshading#1!\endcsname{% |
| 610 |
\leavevmode% |
| 611 |
\noexpand\pdfrefxform\the\pdflastxform% |
| 612 |
\noexpand\pdfrefobj\pgf@temp@num% |
| 613 |
}% |
| 614 |
}% |
| 615 |
}{% |
| 616 |
{% |
| 617 |
\pgf@process{#2}% |
| 618 |
\pgf@xa=\pgf@x% |
| 619 |
\pgf@ya=\pgf@y% |
| 620 |
\pgf@process{#3}% |
| 621 |
\pgf@xb=\pgf@x% |
| 622 |
\pgf@yb=\pgf@y% |
| 623 |
\advance\pgf@x by-\pgf@xa% |
| 624 |
\advance\pgf@y by-\pgf@ya% |
| 625 |
\setbox\pgfutil@tempboxa=\hbox to\pgf@x{\vbox to\pgf@y{\vfil\pgfsys@invoke{/Sh sh}}\hfil}% |
| 626 |
\pgf@sys@bp@correct{\pgf@xa}% |
| 627 |
\pgf@sys@bp@correct{\pgf@ya}% |
| 628 |
\pgf@sys@bp@correct{\pgf@xb}% |
| 629 |
\pgf@sys@bp@correct{\pgf@yb}% |
| 630 |
\pgf@xc=-\pgf@xa% |
| 631 |
\pgf@yc=-\pgf@ya% |
| 632 |
% Now build the function |
| 633 |
\pdfobj |
| 634 |
stream |
| 635 |
attr |
| 636 |
{ |
| 637 |
/FunctionType 4 |
| 638 |
/Domain [\pgf@sys@tonumber{\pgf@xa}\space\pgf@sys@tonumber{\pgf@xb}\space\pgf@sys@tonumber{\pgf@ya}\space\pgf@sys@tonumber{\pgf@yb}] |
| 639 |
/Range [0 1 0 1 0 1] |
| 640 |
} |
| 641 |
{{#4}}% |
| 642 |
\edef\pgf@temp@num{\the\pdflastobj}% |
| 643 |
\immediate\pdfxform resources {% |
| 644 |
/Shading << /Sh << /ShadingType 1 |
| 645 |
/ColorSpace /DeviceRGB |
| 646 |
/Matrix [1 0 0 1 \pgf@sys@tonumber{\pgf@xc}\space\pgf@sys@tonumber{\pgf@yc}] |
| 647 |
/Domain [\pgf@sys@tonumber{\pgf@xa}\space\pgf@sys@tonumber{\pgf@xb}\space\pgf@sys@tonumber{\pgf@ya}\space\pgf@sys@tonumber{\pgf@yb}] |
| 648 |
/Function \pgf@temp@num\space 0 R |
| 649 |
>> >>}\pgfutil@tempboxa% << |
| 650 |
\expandafter\xdef\csname @pgfshading#1!\endcsname{% |
| 651 |
\leavevmode% |
| 652 |
\noexpand\pdfrefxform\the\pdflastxform% |
| 653 |
\noexpand\pdfrefobj\pgf@temp@num% |
| 654 |
}% |
| 655 |
}% |
| 656 |
} |
| 657 |
% \end{macrocode} |
| 658 |
% |
| 659 |
% \begin{macrocode} |
| 660 |
\storebox@patch\pgfsys@fadingfrombox{#1#2}{% |
| 661 |
{% |
| 662 |
\pgf@sys@pdf@check@resources% |
| 663 |
\pgf@x=-.5\wd#2% |
| 664 |
\pgf@y=-.5\ht#2% |
| 665 |
\advance\pgf@y by.5\dp#2% |
| 666 |
\expandafter\xdef\csname pgfsmasktrans@#1\endcsname{% |
| 667 |
\noexpand\pgftransformcm{1}{0}{0}{1}{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}}% |
| 668 |
\pdfxform resources { \pgf@sys@pdf@possible@resources } #2% |
| 669 |
\expandafter\xdef\csname pgfsmaskxform@#1\endcsname{\the\pdflastxform}% |
| 670 |
}% |
| 671 |
}{% |
| 672 |
{% |
| 673 |
\pgf@sys@pdf@check@resources% |
| 674 |
\pgf@x=-.5\wd#2% |
| 675 |
\pgf@y=-.5\ht#2% |
| 676 |
\advance\pgf@y by.5\dp#2% |
| 677 |
\expandafter\xdef\csname pgfsmasktrans@#1\endcsname{% |
| 678 |
\noexpand\pgftransformcm{1}{0}{0}{1}{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}}% |
| 679 |
\immediate\pdfxform resources { \pgf@sys@pdf@possible@resources } #2% |
| 680 |
\expandafter\xdef\csname pgfsmaskxform@#1\endcsname{\the\pdflastxform}% |
| 681 |
}% |
| 682 |
} |
| 683 |
\storebox@patch\pgfsys@transparencygroupfrombox{#1}{% |
| 684 |
\pgf@sys@pdf@check@resources% |
| 685 |
\pdfxform |
| 686 |
attr { /Group << /S /Transparency >> } %<< |
| 687 |
resources { \pgf@sys@pdf@possible@resources } |
| 688 |
#1% |
| 689 |
\setbox#1=\hbox{\pdfrefxform\pdflastxform}% |
| 690 |
}{% |
| 691 |
\pgf@sys@pdf@check@resources% |
| 692 |
\immediate\pdfxform |
| 693 |
attr { /Group << /S /Transparency >> } %<< |
| 694 |
resources { \pgf@sys@pdf@possible@resources } |
| 695 |
#1% |
| 696 |
\setbox#1=\hbox{\pdfrefxform\pdflastxform}% |
| 697 |
} |
| 698 |
\endgroup |
| 699 |
% \end{macrocode} |
| 700 |
% |
| 701 |
% \iffalse |
| 702 |
%</storebox-pgf.sty> |
| 703 |
% \fi |
| 704 |
% |
| 705 |
% \Finale |
| 706 |
\endinput |