| 1 |
% Copyright 2019 by Till Tantau |
| 2 |
% |
| 3 |
% This file may be distributed and/or modified |
| 4 |
% |
| 5 |
% 1. under the LaTeX Project Public License and/or |
| 6 |
% 2. under the GNU Public License. |
| 7 |
% |
| 8 |
% See the file doc/generic/pgf/licenses/LICENSE for more details. |
| 9 |
|
| 10 |
\ProvidesPackageRCS{pgfsys.code.tex} |
| 11 |
|
| 12 |
|
| 13 |
% Load key mechanism |
| 14 |
\ifdefined\pgfkeysloaded\else |
| 15 |
\input pgfkeys.code.tex |
| 16 |
\fi |
| 17 |
|
| 18 |
% "pgf" is a family |
| 19 |
\pgfkeys{/pgf/.is family} |
| 20 |
\def\pgfset{\pgfqkeys{/pgf}} |
| 21 |
|
| 22 |
% This if is needed *very* early |
| 23 |
\newif\ifpgfpicture |
| 24 |
|
| 25 |
|
| 26 |
% |
| 27 |
% The following conversion functions are used to convert from TeX |
| 28 |
% dimensions to postscript/pdf points. |
| 29 |
% |
| 30 |
{\catcode`\p=12\catcode`\t=12\gdef\Pgf@geT#1pt{#1}} |
| 31 |
|
| 32 |
\def\pgf@sys@tonumber#1{\expandafter\Pgf@geT\the#1} |
| 33 |
|
| 34 |
\def\pgf@sys@bp@correct#1{#1=0.99627#1} |
| 35 |
|
| 36 |
\def\pgf@sys@bp#1{% |
| 37 |
{% |
| 38 |
\pgf@x=#1\relax% |
| 39 |
\pgf@x=0.99627\pgf@x% |
| 40 |
\edef\temp{\expandafter\Pgf@geT\the\pgf@x\space}% |
| 41 |
\pgfutil@toks@\expandafter\expandafter\expandafter{\expandafter\pgfsysprotocol@currentprotocol\temp}% |
| 42 |
\xdef\pgfsysprotocol@currentprotocol{\the\pgfutil@toks@}% |
| 43 |
}% |
| 44 |
} |
| 45 |
\def\pgf@sys@pt#1{% |
| 46 |
{% |
| 47 |
\pgf@x=#1\relax% |
| 48 |
\edef\temp{\expandafter\Pgf@geT\the\pgf@x\space}% |
| 49 |
\pgfutil@toks@\expandafter\expandafter\expandafter{\expandafter\pgfsysprotocol@currentprotocol\temp}% |
| 50 |
\xdef\pgfsysprotocol@currentprotocol{\the\pgfutil@toks@}% |
| 51 |
}% |
| 52 |
} |
| 53 |
|
| 54 |
|
| 55 |
% internal dimensions that are always present when pgsys is loaded. |
| 56 |
\newdimen\pgf@x |
| 57 |
\newdimen\pgf@y |
| 58 |
\newdimen\pgf@xa |
| 59 |
\newdimen\pgf@ya |
| 60 |
\newdimen\pgf@xb |
| 61 |
\newdimen\pgf@yb |
| 62 |
\newdimen\pgf@xc |
| 63 |
\newdimen\pgf@yc |
| 64 |
\newdimen\pgf@xd |
| 65 |
\newdimen\pgf@yd |
| 66 |
|
| 67 |
\newwrite\w@pgf@writea |
| 68 |
\newread\r@pgf@reada |
| 69 |
\let\pgfutil@inputcheck=\r@pgf@reada |
| 70 |
|
| 71 |
% internal counters that are always present when pgfsys is loaded |
| 72 |
\newcount\c@pgf@counta |
| 73 |
\newcount\c@pgf@countb |
| 74 |
\newcount\c@pgf@countc |
| 75 |
\newcount\c@pgf@countd |
| 76 |
|
| 77 |
\newtoks\t@pgf@toka |
| 78 |
\newtoks\t@pgf@tokb |
| 79 |
\newtoks\t@pgf@tokc |
| 80 |
|
| 81 |
% Ensure that math registers are the same (math is broken in case it |
| 82 |
% is loaded first) |
| 83 |
\let\pgfmath@x\pgf@x |
| 84 |
\let\pgfmath@xa\pgf@xa |
| 85 |
\let\pgfmath@xb\pgf@xb |
| 86 |
\let\pgfmath@xc\pgf@xc |
| 87 |
|
| 88 |
\let\pgfmath@y\pgf@y |
| 89 |
\let\pgfmath@ya\pgf@ya |
| 90 |
\let\pgfmath@yb\pgf@yb |
| 91 |
\let\pgfmath@yc\pgf@yc |
| 92 |
|
| 93 |
\let\c@pgfmath@counta\c@pgf@counta |
| 94 |
\let\c@pgfmath@countb\c@pgf@countb |
| 95 |
\let\c@pgfmath@countc\c@pgf@countc |
| 96 |
\let\c@pgfmath@countd\c@pgf@countd |
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
% In the following dummy definitions of the pgf system commands are |
| 103 |
% given. The individual drivers must overwrite these definitions, |
| 104 |
% preferably all of them. If some system command is used that has not |
| 105 |
% been overwritten, the command fails with a warning. |
| 106 |
% |
| 107 |
% In some cases, some pgf system commands are just shorthands for a |
| 108 |
% series of more complicated commands. In this case, a default |
| 109 |
% implementation is given in this file, but a driver may choose to |
| 110 |
% overwrite this default implementation with a more efficient |
| 111 |
% version. For example, a closestroke is the same as a closepath |
| 112 |
% followed by a stroking, but in pdf there is a special shorthand for |
| 113 |
% this. So, the pdf driver overwrites \pgfsys@closestroke, while the |
| 114 |
% postscript driver does not. |
| 115 |
% |
| 116 |
% The commands for which default implementations are available are |
| 117 |
% given at the end. |
| 118 |
|
| 119 |
\def\pgf@sys@fail#1{% |
| 120 |
\expandafter\ifx\csname pgf@sys@fail@#1\endcsname\pgfutil@empty% |
| 121 |
\else% |
| 122 |
\expandafter\global\expandafter\let\csname pgf@sys@fail@#1\endcsname=\pgfutil@empty% |
| 123 |
\pgfwarning{Your graphic driver \pgfsysdriver\space does not support #1. This warning is given only once}% |
| 124 |
\fi% |
| 125 |
} |
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
% |
| 130 |
% Invocation commands |
| 131 |
% |
| 132 |
|
| 133 |
\def\pgfsys@invoke{\pgf@sys@fail{invoking specials}} |
| 134 |
% This command is used whenever some literal text needs to be inserted |
| 135 |
% into the resulting .pdf, .ps, or .dvi file. Note that most |
| 136 |
% \pgfsys@xxxx commands will not directly call this command, but, |
| 137 |
% rather, use the protocolling mechanism to record their literal |
| 138 |
% text. It is then left to the discretion of the protocolling |
| 139 |
% mechanism to insert the literal text at some appropriate, later |
| 140 |
% time. |
| 141 |
% |
| 142 |
% This command should only be called when \pgfsys@beginpicture has |
| 143 |
% been called previously and when the picture has not been suspended |
| 144 |
% using \pgfsys@beginhbox. |
| 145 |
|
| 146 |
\def\pgfsys@outerinvoke{\pgfsys@invoke} |
| 147 |
% This command can be used to insert protocolled graphic commands |
| 148 |
% outside any picture. This is extremely dangerous, but sometimes |
| 149 |
% useful. By default, this command does the same as inside pictures. |
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
% |
| 154 |
% |
| 155 |
% Path construction commands |
| 156 |
% |
| 157 |
% |
| 158 |
|
| 159 |
\def\pgfsys@moveto#1#2{\pgf@sys@fail{path constructions}} |
| 160 |
% This command is used to start a path at a specific point (#1,#2) |
| 161 |
% or to move the current point of the current path to (#1,#2) |
| 162 |
% without drawing anything upon stroking (the current path is |
| 163 |
% `interrupted'). |
| 164 |
% |
| 165 |
% The arguments must be dimensions (like |10pt|). |
| 166 |
% |
| 167 |
% Example: |
| 168 |
% |
| 169 |
% \pgfsys@moveto{10pt}{10pt} |
| 170 |
% \pgfsys@lineto{0pt}{0pt} |
| 171 |
% \pgfsys@stroke |
| 172 |
% |
| 173 |
% This will draw a line from (10pt,10pt) to the origin of the picture. |
| 174 |
|
| 175 |
\def\pgfsys@lineto#1#2{\pgf@sys@fail{path constructions}} |
| 176 |
% Continue the current path to (#1,#2) with a line. |
| 177 |
|
| 178 |
\def\pgfsys@curveto#1#2#3#4#5#6{\pgf@sys@fail{path constructions}} |
| 179 |
% Continue the current path with a bezier curve to (#5,#6). The |
| 180 |
% control points of the curve are at (#1,#2) and (#3,#4). |
| 181 |
|
| 182 |
\def\pgfsys@rect#1#2#3#4{\pgf@sys@fail{path constructions}} |
| 183 |
% Append a rectangle to the current path whose lower left corner is at |
| 184 |
% (#1,#2) and whose width/height is given by (#3,#4). |
| 185 |
% |
| 186 |
% This command can be `mapped back' to moveto and lineto commands, but |
| 187 |
% it is included since pdf has a special, quick version of this command. |
| 188 |
|
| 189 |
\def\pgfsys@closepath{\pgf@sys@fail{path constructions}} |
| 190 |
% Close the current path. This results in joining the current point of |
| 191 |
% the path with the point specified by the last moveto |
| 192 |
% operation. Typically, this is preferable over using lineto to the |
| 193 |
% last point specified by a moveto, since the line starting at this |
| 194 |
% point and the line ending at this point will be smoothly joined by |
| 195 |
% closepath. |
| 196 |
% |
| 197 |
% Example: |
| 198 |
% |
| 199 |
% \pgfsys@moveto{0}{0} |
| 200 |
% \pgfsys@lineto{10}{10} |
| 201 |
% \pgfsys@lineto{0}{10} |
| 202 |
% \pgfsys@closepath |
| 203 |
% \pgfsys@stroke |
| 204 |
% |
| 205 |
% versus |
| 206 |
% |
| 207 |
% \pgfsys@moveto{0}{0} |
| 208 |
% \pgfsys@lineto{10}{10} |
| 209 |
% \pgfsys@lineto{0}{10} |
| 210 |
% \pgfsys@lineto{0}{0} |
| 211 |
% \pgfsys@stroke |
| 212 |
% |
| 213 |
% The difference between the above will be that in the second triangle |
| 214 |
% the corner at the origin will be wrong; it will just be the overlay |
| 215 |
% of two lines going in different directions, not a sharp pointed |
| 216 |
% corner. |
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
% |
| 224 |
% |
| 225 |
% Stroking and filling commands |
| 226 |
% |
| 227 |
% |
| 228 |
|
| 229 |
\def\pgfsys@stroke{\pgf@sys@fail{path usage}} |
| 230 |
% Stroke the current path (as if it were drawn with a pen). A number |
| 231 |
% of so-called graphic state parameters influence this, which can be |
| 232 |
% set in different ways: |
| 233 |
% |
| 234 |
% - linewidth |
| 235 |
% The `thickness' of the line. A width of 0 is the thinnest width |
| 236 |
% renderable on the device. On a high-resolution printer this may |
| 237 |
% become invisible and should be avoided. A good choice is 0.4pt, |
| 238 |
% which is the default. |
| 239 |
% |
| 240 |
% - stroke color |
| 241 |
% This special color is used for stroking. If it is not set, the |
| 242 |
% current color is used. |
| 243 |
% |
| 244 |
% - cap |
| 245 |
% The cap describes how the endings of lines a drawn. A round cap |
| 246 |
% adds a little half circle to these endings. A butt cap ends the |
| 247 |
% lines exactly at the end (or start) point without anything |
| 248 |
% added. A rectangular cap ends the lines like the butt cap, but the |
| 249 |
% lines protrude over the endpoint by the line thickness. (See also |
| 250 |
% the pdf or postscript manual). If the path has been closed, no cap |
| 251 |
% is drawn. |
| 252 |
% |
| 253 |
% - join |
| 254 |
% This describes how a bend (a join) in a path is rendered. A round |
| 255 |
% join draws bends using small arcs. A bevel join just draws the two |
| 256 |
% lines and then fills the join minimally so that it becomes |
| 257 |
% convex. A miter join extends the lines so that they form a single |
| 258 |
% sharp corner, but only up to a certain miter limit. (See the pdf |
| 259 |
% or postscript manual once more). |
| 260 |
% |
| 261 |
% - dash |
| 262 |
% The line may be dashed according to a dashing pattern. |
| 263 |
% |
| 264 |
% - clipping area |
| 265 |
% If a clipping area is established, only those parts of the path |
| 266 |
% that are inside the clipping area will be drawn. |
| 267 |
% |
| 268 |
% In addition to stroking a path, the path may also be used for |
| 269 |
% clipping after it has been stroked. This will happen if the |
| 270 |
% \pgfsys@clipnext is used prior to this command, see there for |
| 271 |
% details. |
| 272 |
|
| 273 |
\def\pgfsys@fill{\pgf@sys@fail{path usage}} |
| 274 |
% This command fills the area surrounded by the current path. If the |
| 275 |
% path has not yet been closed, it is closed prior to filling. The |
| 276 |
% path itself is not stroked. For self-intersecting paths or paths |
| 277 |
% consisting of multiple parts, the nonzero winding number rule is |
| 278 |
% used to determine whether a point is inside or outside the |
| 279 |
% path, except if \ifpgfsys@eorule holds -- in which case the even-odd |
| 280 |
% rule should be used. (See the pdf or postscript manual for details.) |
| 281 |
% |
| 282 |
% The following graphic state parameters influence the filling: |
| 283 |
% |
| 284 |
% - fill color |
| 285 |
% If the fill color is not especially set, the current color is |
| 286 |
% used. |
| 287 |
% |
| 288 |
% - clipping area |
| 289 |
% If a clipping area is established, only those parts of the filling |
| 290 |
% area that are inside the clipping area will be drawn. |
| 291 |
% |
| 292 |
% In addition to filling the path, the path will also be used for |
| 293 |
% clipping if \pgfsys@clipnext is used prior to this command. |
| 294 |
|
| 295 |
\def\pgfsys@fillstroke{\pgf@sys@fail{path usage}} |
| 296 |
% First, the path is filled, then the path is stroked. If the fill and |
| 297 |
% stroke colors are the same (or if they are not specified and the |
| 298 |
% current color is used), this yields almost the same as a |
| 299 |
% \pgfsys@fill. However, due to the line thickness of the stroked |
| 300 |
% path, the fillstroked area will be slightly larger. |
| 301 |
% |
| 302 |
% In addition to stroking and filling the path, the path will also be |
| 303 |
% used for clipping if \pgfsys@clipnext is used prior to this command. |
| 304 |
|
| 305 |
\def\pgfsys@clipnext{\pgf@sys@fail{path usage}} |
| 306 |
% This command should be issued after a path has been constructed, but |
| 307 |
% before it has been stroked and/or filled or discarded. When the |
| 308 |
% command is used, the next stroking/filling/discarding command will |
| 309 |
% first be executed normally. Then, afterwards, the just-used path |
| 310 |
% will be used for subsequent clipping. If there has already been a |
| 311 |
% clipping region, this region is intersected with the new clipping |
| 312 |
% path (the clipping cannot get bigger). The nonzero winding number |
| 313 |
% rule is used to determine whether a point is inside or outside the |
| 314 |
% clipping area or the even-odd rule, depending on whether |
| 315 |
% \ifpgfsys@eorule holds. |
| 316 |
|
| 317 |
\def\pgfsys@discardpath{\pgf@sys@fail{path usage}} |
| 318 |
% Normally, this command should `throw away' the current path. |
| 319 |
% However, after \pgfsys@clipnext has been called, the current path |
| 320 |
% should subsequently be used for clipping. See \pgfsys@clipnext for |
| 321 |
% details. |
| 322 |
|
| 323 |
\def\pgfsys@closestroke{\pgfsys@closepath\pgfsys@stroke} |
| 324 |
% This command should have the same effect as first closing the path |
| 325 |
% and then stroking it. |
| 326 |
|
| 327 |
\newif\ifpgfsys@eorule |
| 328 |
% Decides, whether even-odd filling and clipping is |
| 329 |
% to be used or normal the non-zero winding number rule. See the |
| 330 |
% pdf-documentation for details on what these rules are. |
| 331 |
|
| 332 |
|
| 333 |
|
| 334 |
|
| 335 |
% |
| 336 |
% |
| 337 |
% Stroking options |
| 338 |
% |
| 339 |
% |
| 340 |
\def\pgfsys@setlinewidth#1{\pgf@sys@fail{setting the line width}} |
| 341 |
% Sets the width of lines, when stroked, to #1, which must be a TeX |
| 342 |
% dimension (as text). |
| 343 |
|
| 344 |
\def\pgfsys@buttcap{\pgf@sys@fail{setting the line cap}} |
| 345 |
% Sets the cap to a butt cap. See \pgfsys@stroke. |
| 346 |
|
| 347 |
\def\pgfsys@roundcap{\pgf@sys@fail{setting the line cap}} |
| 348 |
% Sets the cap to a round cap. See \pgfsys@stroke. |
| 349 |
|
| 350 |
\def\pgfsys@rectcap{\pgf@sys@fail{setting the line cap}} |
| 351 |
% Sets the cap to a rectangular cap. See \pgfsys@stroke. |
| 352 |
|
| 353 |
\def\pgfsys@miterjoin{\pgf@sys@fail{setting the line join}} |
| 354 |
% Sets the join to a miter join. See \pgfsys@stroke. |
| 355 |
|
| 356 |
\def\pgfsys@setmiterlimit#1{\pgf@sys@fail{setting the line cap}} |
| 357 |
% Sets the miter limit of lines to #1. See the pdf or postscript |
| 358 |
% documentation. |
| 359 |
|
| 360 |
\def\pgfsys@roundjoin{\pgf@sys@fail{setting the line cap}} |
| 361 |
% Sets the join to a round join. See \pgfsys@stroke. |
| 362 |
|
| 363 |
\def\pgfsys@beveljoin{\pgf@sys@fail{setting the line cap}} |
| 364 |
% Sets the join to a bevel join. See \pgfsys@stroke. |
| 365 |
|
| 366 |
\def\pgfsys@setdash#1#2{\pgf@sys@fail{setting the dashing pattern}} |
| 367 |
% Sets the dashing pattern. #1 should be a list of lengths separated by |
| 368 |
% commas. #2 should be a single dimension. |
| 369 |
% |
| 370 |
% The list of values in #1 is used to determine the lengths of the |
| 371 |
% `on' phases of the dashing and of the `off' phases. For example, if |
| 372 |
% #1 is `3pt,4pt', then the dashing pattern is `3pt on followed by 4pt |
| 373 |
% off, followed by 3pt on, followed by 4pt off, and so on'. A pattern |
| 374 |
% of `.5pt,4pt,3pt,1.5pt' means `.5pt on, 4pt off, 3pt on, 1.5pt off, .5pt on, |
| 375 |
% ...'. If the number of entries is odd, the last one is used twice, |
| 376 |
% so `3pt' means `3pt on, 3pt off, 3pt on, 3pt off,...'. An empty list |
| 377 |
% means `always on'. |
| 378 |
% |
| 379 |
% The second argument determines the `phase' of the pattern. For |
| 380 |
% example, for a pattern of `3pt,4pt' and a phase of `1pt', the pattern |
| 381 |
% would start: `2pt on, 4pt off, 3pt on, 4pt off, 3pt on, 4pt off...'. |
| 382 |
|
| 383 |
|
| 384 |
|
| 385 |
|
| 386 |
|
| 387 |
% |
| 388 |
% |
| 389 |
% Color stuff |
| 390 |
% |
| 391 |
% |
| 392 |
|
| 393 |
\def\pgfsys@color@rgb@stroke#1#2#3{\pgf@sys@fail{color}} |
| 394 |
% Sets the color used for stroking operations to the given rgb tuple |
| 395 |
% (numbers between 0 and 1). |
| 396 |
% |
| 397 |
% Example: Make stroked text dark red: \pgfsys@color@rgb@stroke{0.5}{0}{0} |
| 398 |
% |
| 399 |
% The special stroking color is only used if the stroking color has |
| 400 |
% been set since the last \pgfutil@color command. Thus, each \pgfutil@color command |
| 401 |
% should reset both the stroking and filling colors. |
| 402 |
|
| 403 |
\def\pgfsys@color@rgb@fill#1#2#3{\pgf@sys@fail{color}} |
| 404 |
% Sets the color used for filling operations to the given rgb tuple |
| 405 |
% (numbers between 0 and 1). This color may be different from the |
| 406 |
% stroking color. |
| 407 |
|
| 408 |
\def\pgfsys@color@rgb#1#2#3{\pgfsys@color@rgb@stroke{#1}{#2}{#3}\pgfsys@color@rgb@fill{#1}{#2}{#3}} |
| 409 |
% Sets the color used for filling and stroking operations. This is a |
| 410 |
% ``low-level'' version of the \pgfutil@color command. It is currently only |
| 411 |
% used by the plain tex version to support colors. |
| 412 |
|
| 413 |
\def\pgfsys@color@cmyk@stroke#1#2#3#4{\pgf@sys@fail{color}} |
| 414 |
% Sets the color used for stroking operations to the given cymk tuple |
| 415 |
% (numbers between 0 and 1). |
| 416 |
|
| 417 |
\def\pgfsys@color@cmyk@fill#1#2#3#4{\pgf@sys@fail{color}} |
| 418 |
% Sets the color used for filling operations to the given cymk tuple |
| 419 |
% (numbers between 0 and 1). |
| 420 |
|
| 421 |
\def\pgfsys@color@cmyk#1#2#3#4{\pgfsys@color@cmyk@stroke{#1}{#2}{#3}{#4}\pgfsys@color@cmyk@fill{#1}{#2}{#3}{#4}} |
| 422 |
% Sets the color used for filling and stroking operations. |
| 423 |
|
| 424 |
\def\pgfsys@color@cmy@stroke#1#2#3{\pgf@sys@fail{color}} |
| 425 |
% Sets the color used for stroking operations to the given cym tuple |
| 426 |
% (numbers between 0 and 1). |
| 427 |
|
| 428 |
\def\pgfsys@color@cmy@fill#1#2#3{\pgf@sys@fail{color}} |
| 429 |
% Sets the color used for filling operations to the given cym tuple |
| 430 |
% (numbers between 0 and 1). |
| 431 |
|
| 432 |
\def\pgfsys@color@cmy#1#2#3{\pgfsys@color@cmy@stroke{#1}{#2}{#3}\pgfsys@color@cmy@fill{#1}{#2}{#3}} |
| 433 |
% Sets the color used for filling and stroking operations. |
| 434 |
|
| 435 |
\def\pgfsys@color@gray@stroke#1{\pgf@sys@fail{color}} |
| 436 |
% Sets the color used for stroking operations to the given gray level |
| 437 |
% (number between 0 and 1). |
| 438 |
|
| 439 |
\def\pgfsys@color@gray@fill#1{\pgf@sys@fail{color}} |
| 440 |
% Sets the color used for filling operations to the given gray level |
| 441 |
% (number between 0 and 1). |
| 442 |
|
| 443 |
\def\pgfsys@color@gray#1{\pgfsys@color@gray@stroke{#1}\pgfsys@color@gray@fill{#1}} |
| 444 |
% Sets the color used for filling and stroking operations. |
| 445 |
|
| 446 |
\newif\ifpgfsys@color@reset@inorder |
| 447 |
% This if decides whether the color resetting of the |
| 448 |
% \pgfsys@color@reset command may assume that all color commands are |
| 449 |
% given ``in order.'' This means that this command will not be called, |
| 450 |
% say, at the beginning of a box that is later inserted at a point |
| 451 |
% where a fill color was actively set. This may allow the command to |
| 452 |
% produce more compact code when it ``knows'' that no special fill or |
| 453 |
% stroke color has been set. |
| 454 |
\pgfsys@color@reset@inordertrue |
| 455 |
|
| 456 |
|
| 457 |
\def\pgfsys@color@reset{} |
| 458 |
% This command will be called when the \pgfutil@color command is used. It |
| 459 |
% should purge any internal settings of stroking and filling |
| 460 |
% color. After this call, till the next use of a command like |
| 461 |
% \pgfsys@color@rgb@fill, the current color installed by the \pgfutil@color |
| 462 |
% command should be used. |
| 463 |
|
| 464 |
\def\pgfsys@color@unstacked#1{} |
| 465 |
% This slightly obscure command causes the color stack to be |
| 466 |
% tricked. When called, this command should set the current color to |
| 467 |
% #1 without causing any change in the color stack. |
| 468 |
|
| 469 |
\def\pgfsys@text@to@black@hook{} |
| 470 |
% Another slightly obscure command that allows tikz to hack into |
| 471 |
% dvisvgm's color management inside text nodes. The problem is that |
| 472 |
% the color "black" is special for dvisvgm. |
| 473 |
|
| 474 |
|
| 475 |
|
| 476 |
% |
| 477 |
% |
| 478 |
% Coordinate system transformations |
| 479 |
% |
| 480 |
% |
| 481 |
|
| 482 |
\def\pgfsys@transformcm#1#2#3#4#5#6{\pgf@sys@fail{transformations}} |
| 483 |
% Perform a concatenation of the low-level current transformation |
| 484 |
% matrix with the matrix given by the values #1 to #6. The |
| 485 |
% transformation matrix is a transformation on a homogeneous |
| 486 |
% 2D-coordinate system. See the pdf or postscript manual for details. |
| 487 |
|
| 488 |
\def\pgfsys@transformshift#1#2{\pgfsys@transformcm{1}{0}{0}{1}{#1}{#2}} |
| 489 |
% This command will change the origin of the low-level coordinate |
| 490 |
% system to (#1,#2). |
| 491 |
|
| 492 |
\def\pgfsys@transformxyscale#1#2{\pgfsys@transformcm{#1}{0}{0}{#2}{0bp}{0bp}} |
| 493 |
% This command will scale the low-level coordinate system (and |
| 494 |
% everything that is drawn) by a factor of #1 in x-directed and #2 in |
| 495 |
% y-direction. Note that this applies to everything, including |
| 496 |
% lines. So a scaled line will have a different width and may even |
| 497 |
% have a different width when going along the x-axis and when going |
| 498 |
% along the y-axis, if the scaling is different in these directions. |
| 499 |
|
| 500 |
\def\pgfsys@viewboxmeet#1#2#3#4#5#6#7#8{\pgfsys@beginscope\pgf@sys@default@viewbox@impl{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}{<}} |
| 501 |
% Consider the two rectangles R with lower left corner |
| 502 |
% (#5,#6) and upper right (#7,#8) and S with lower left corner |
| 503 |
% (#1,#2) and upper right (#3,#4). Now, consider the transformation |
| 504 |
% that scales and translates R so that the result T has the same |
| 505 |
% center as S and has maximal size while still being inside S. This |
| 506 |
% transformation gets installed in a new graphics group, which must be |
| 507 |
% ended with a corresponding \pgfsys@endviewbox. |
| 508 |
|
| 509 |
\def\pgfsys@viewboxslice#1#2#3#4#5#6#7#8{\pgfsys@beginscope\pgf@sys@default@viewbox@impl{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}{>}} |
| 510 |
% Works like \pgfsys@viewboxmeet, but R3 will have minimal size so |
| 511 |
% that in contains all of R2. |
| 512 |
|
| 513 |
\def\pgfsys@endviewbox{\pgfsys@endscope} |
| 514 |
% Ends a viewbox scope started by either of the previous two commands. |
| 515 |
|
| 516 |
|
| 517 |
\def\pgf@sys@default@viewbox@impl#1#2#3#4#5#6#7#8#9{{% |
| 518 |
\pgf@x#1% |
| 519 |
\pgf@y#2% |
| 520 |
\pgf@xa#3% |
| 521 |
\pgf@ya#4% |
| 522 |
\advance\pgf@xa by-\pgf@x% |
| 523 |
\advance\pgf@ya by-\pgf@y% |
| 524 |
\pgfmathdivide@{\pgf@sys@tonumber\pgf@xa}{\pgf@sys@tonumber\pgf@ya}% |
| 525 |
\let\aspectr\pgfmathresult% |
| 526 |
\pgf@xb#5% |
| 527 |
\pgf@yb#6% |
| 528 |
\pgf@xc#7% |
| 529 |
\pgf@yc#8% |
| 530 |
\advance\pgf@xc by-\pgf@xb% |
| 531 |
\advance\pgf@yc by-\pgf@yb% |
| 532 |
\pgfmathdivide@{\pgf@sys@tonumber\pgf@xc}{\pgf@sys@tonumber\pgf@yc}% |
| 533 |
\let\aspects\pgfmathresult% |
| 534 |
\ifdim\aspectr pt#9\aspects pt% |
| 535 |
\pgfmathdivide@{\pgf@sys@tonumber\pgf@xa}{\pgf@sys@tonumber\pgf@xc}% |
| 536 |
\else% |
| 537 |
\pgfmathdivide@{\pgf@sys@tonumber\pgf@ya}{\pgf@sys@tonumber\pgf@yc}% |
| 538 |
\fi% |
| 539 |
\advance\pgf@x by.5\pgf@xa% |
| 540 |
\advance\pgf@xb by.5\pgf@xc% |
| 541 |
\advance\pgf@y by.5\pgf@ya% |
| 542 |
\advance\pgf@yb by.5\pgf@yc% |
| 543 |
\pgfsys@transformcm{\pgfmathresult}{0}{0}{\pgfmathresult}{\pgf@x}{\pgf@y}% |
| 544 |
\pgfsys@transformcm{1}{0}{0}{1}{-\pgf@xb}{-\pgf@yb}% |
| 545 |
}% |
| 546 |
} |
| 547 |
|
| 548 |
|
| 549 |
|
| 550 |
|
| 551 |
% |
| 552 |
% |
| 553 |
% Graphic state saving and restoring. |
| 554 |
% |
| 555 |
% |
| 556 |
|
| 557 |
\def\pgfsys@beginscope{\pgf@sys@fail{scoping}} |
| 558 |
% Saves the current graphic state on a graphic state stack. All |
| 559 |
% changes to the graphic state parameters mentioned for \pgfsys@stroke |
| 560 |
% and \pgfsys@fill will be local to the current graphic state and will |
| 561 |
% the old values will be restored after endscope is used. |
| 562 |
% |
| 563 |
% WARNING: pdf and postscript differ with respect to the question of |
| 564 |
% whether the current path is part of the graphic state or not. For |
| 565 |
% this reason, you should never use this command unless the path is |
| 566 |
% currently empty. For example, it might be a good idea to use |
| 567 |
% discardpath prior to calling this command. |
| 568 |
|
| 569 |
\def\pgfsys@endscope{\pgf@sys@fail{scoping}} |
| 570 |
% Restores the last saved graphic state. |
| 571 |
|
| 572 |
\def\pgfsys@begin@idscope{% |
| 573 |
\begingroup% |
| 574 |
\edef\pgf@sys@cacheref{\pgfsys@id@refcurrent}% |
| 575 |
\expandafter\let\expandafter\pgfsys@beg@save\csname pgf@sys@att@beg@\pgf@sys@cacheref\endcsname% |
| 576 |
\expandafter\let\expandafter\pgfsys@end@save\csname pgf@sys@att@end@\pgf@sys@cacheref\endcsname% |
| 577 |
\ifx\pgfsys@beg@save\relax% |
| 578 |
\ifx\pgfsys@end@save\relax% |
| 579 |
\else% |
| 580 |
\pgfsys@call@save% |
| 581 |
\fi% |
| 582 |
\else% |
| 583 |
\pgfsys@call@save% |
| 584 |
\fi% |
| 585 |
\pgfsys@invalidate@currentid% |
| 586 |
\begingroup% |
| 587 |
} |
| 588 |
% Starts an "id scope" where the current value of \pgfsys@use@id and |
| 589 |
% \pgfsys@use@type is used. If the combination has been used before, |
| 590 |
% nothing happens. Otherwise, depending of the driver, a graphic |
| 591 |
% scope may or may not be created. To ensure that a graphic scope is |
| 592 |
% created, use \pgfsys@beginscope additionally. |
| 593 |
|
| 594 |
\def\pgfsys@call@save{% |
| 595 |
\pgfsys@beginscope% |
| 596 |
\pgfsys@beg@save% |
| 597 |
\expandafter\global\expandafter\let\csname pgf@sys@att@beg@\pgfsys@id@refcurrent\endcsname\relax% |
| 598 |
\expandafter\global\expandafter\let\csname pgf@sys@att@end@\pgfsys@id@refcurrent\endcsname\relax% |
| 599 |
} |
| 600 |
|
| 601 |
\def\pgfsys@end@idscope{ |
| 602 |
\endgroup% |
| 603 |
\ifx\pgfsys@beg@save\relax% |
| 604 |
\ifx\pgfsys@end@save\relax% |
| 605 |
\else% |
| 606 |
\pgfsys@call@end% |
| 607 |
\fi% |
| 608 |
\else% |
| 609 |
\pgfsys@call@end% |
| 610 |
\fi% |
| 611 |
\endgroup |
| 612 |
} |
| 613 |
% Ends an id scope. |
| 614 |
|
| 615 |
\def\pgfsys@call@end{% |
| 616 |
\pgfsys@end@save% |
| 617 |
\pgfsys@endscope% |
| 618 |
} |
| 619 |
|
| 620 |
|
| 621 |
\def\pgfsys@begin@text{} |
| 622 |
% Inside a text box you should not use graphics command. However, TikZ |
| 623 |
% needs to insert some color commands at the beginnings of text |
| 624 |
% boxes. For most drivers, this is not a problem; except for SVG, |
| 625 |
% where every change of the graphics state opens a scope and needs a |
| 626 |
% closing scope. This command should be used at the beginning of text |
| 627 |
% boxes containing such color commands and the matching |
| 628 |
% \pgfsys@end@text at the end. If the box does not contain commands |
| 629 |
% that change the graphics state, this command is not needed. |
| 630 |
|
| 631 |
\def\pgfsys@end@text{} |
| 632 |
% Closes a \pgfsys@begin@text. |
| 633 |
|
| 634 |
|
| 635 |
|
| 636 |
% |
| 637 |
% |
| 638 |
% Id management (all of these commands have a default implementation |
| 639 |
% any typically need not be redefined by a driver) |
| 640 |
% |
| 641 |
% |
| 642 |
|
| 643 |
% The id count |
| 644 |
\newcount\pgf@sys@id@count |
| 645 |
|
| 646 |
\def\pgfsys@new@id#1{% |
| 647 |
\edef#1{pgf\the\pgf@sys@id@count}% |
| 648 |
\global\advance\pgf@sys@id@count by1\relax% |
| 649 |
} |
| 650 |
% Creates a new id and stores it in the macro #1. |
| 651 |
|
| 652 |
\def\pgfsys@use@id#1{% |
| 653 |
\edef\pgf@sys@id@current@id{#1}% |
| 654 |
\let\pgfsys@current@type\pgfutil@empty% |
| 655 |
} |
| 656 |
\let\pgf@sys@id@current@id\pgfutil@empty |
| 657 |
% Sets the id to be used for the next graphic object (group, box, or |
| 658 |
% path). The type is reset to be empty. #1 must be a macro name that |
| 659 |
% has previously been set using \pgfsys@new@id. |
| 660 |
% |
| 661 |
% Each combination of id and type can be used only once, on a second |
| 662 |
% use nothing happens. |
| 663 |
|
| 664 |
\def\pgfsys@clear@id{% |
| 665 |
\let\pgf@sys@id@current@id\pgfutil@empty% |
| 666 |
} |
| 667 |
% Clears the current id, so nothing can be referenced. |
| 668 |
|
| 669 |
\def\pgfsys@use@type#1{% |
| 670 |
\edef\pgfsys@current@type{#1}% |
| 671 |
\pgfsys@register@type\pgfsys@current@type% |
| 672 |
} |
| 673 |
\let\pgfsys@current@type\pgfutil@empty |
| 674 |
% Sets the type to be used for the next graphic object. |
| 675 |
|
| 676 |
\def\pgfsys@append@type#1{% |
| 677 |
\ifx\pgfsys@current@type\pgfutil@empty% |
| 678 |
\pgfsys@use@type{#1}% |
| 679 |
\else% |
| 680 |
\pgfsys@use@type{\pgfsys@current@type.#1}% |
| 681 |
\fi% |
| 682 |
} |
| 683 |
% Appends something to the current type |
| 684 |
|
| 685 |
\def\pgfsys@register@type#1{% |
| 686 |
\expandafter\let\expandafter\pgf@sys@temp\csname pgf@sys@reg@type@#1\endcsname% |
| 687 |
\ifx\pgf@sys@temp\relax% |
| 688 |
{% |
| 689 |
\c@pgf@counta\pgf@sys@type@count\relax% |
| 690 |
\global\advance\c@pgf@counta by1\relax% |
| 691 |
\edef\pgf@sys@type@count{\the\c@pgf@counta}% |
| 692 |
\expandafter\xdef\csname pgf@sys@reg@type@#1\endcsname{y\the\c@pgf@counta}% |
| 693 |
}% |
| 694 |
\fi% |
| 695 |
} |
| 696 |
% Registers a type with the system. Must be called before any use of |
| 697 |
% the type |
| 698 |
\def\pgf@sys@reg@type@{} |
| 699 |
\def\pgf@sys@reg@type@background{b} |
| 700 |
\def\pgf@sys@reg@type@path{p} |
| 701 |
\def\pgf@sys@reg@type@text{t} |
| 702 |
\expandafter\def\csname pgf@sys@reg@[email protected]\endcsname{bp} |
| 703 |
\def\pgf@sys@type@count{0} |
| 704 |
|
| 705 |
\def\pgfsys@push@type{% |
| 706 |
\expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter\pgf@sys@typestack% |
| 707 |
\expandafter\expandafter\expandafter{\expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter\pgfsys@current@type% |
| 708 |
\expandafter\expandafter\expandafter{\expandafter\pgfsys@current@type\expandafter}% |
| 709 |
\expandafter\def\expandafter\pgf@sys@typestack\expandafter{\pgf@sys@typestack}}% |
| 710 |
} |
| 711 |
\let\pgf@sys@typestack\pgfutil@empty |
| 712 |
% Pushes the current type onto a global stack. This is useful for |
| 713 |
% temporarily changing the type without creating \TeX scopes. |
| 714 |
|
| 715 |
\def\pgfsys@pop@type{\pgf@sys@typestack} |
| 716 |
% Pops the last id from the stack. |
| 717 |
|
| 718 |
\def\pgfsys@id@ref#1#2{#1\csname pgf@sys@reg@type@#2\endcsname} |
| 719 |
% Expands to a text that can be inserted as a reference. #1 must be a |
| 720 |
% reference created \pgfsys@new@id, #2 must be a type that has been |
| 721 |
% registered using \pgfsys@id@register@type. |
| 722 |
|
| 723 |
\def\pgfsys@id@refcurrent{\pgfsys@id@ref{\pgf@sys@id@current@id}{\pgfsys@current@type}} |
| 724 |
% Expands to a text that can be inserted as a reference to the current |
| 725 |
% id-type pair in use. |
| 726 |
|
| 727 |
\def\pgfsys@invalidate@currentid{% |
| 728 |
\expandafter\global\expandafter\let\csname pgf@sys@id@keylist@\pgfsys@id@refcurrent\endcsname\pgfutil@empty% |
| 729 |
} |
| 730 |
% Mark the current id-type pair as used. |
| 731 |
|
| 732 |
\def\pgfsys@attach@to@id#1#2#3#4{% |
| 733 |
\pgfsys@register@type{#2}% |
| 734 |
\expandafter\def\expandafter\pgf@sys@tempbeg\expandafter{\csname pgf@sys@att@beg@\pgfsys@id@ref{#1}{#2}\endcsname}% |
| 735 |
\expandafter\def\expandafter\pgf@sys@tempend\expandafter{\csname pgf@sys@att@end@\pgfsys@id@ref{#1}{#2}\endcsname}% |
| 736 |
\expandafter\ifx\pgf@sys@tempbeg\relax% |
| 737 |
\expandafter\let\pgf@sys@tempbeg\pgfutil@empty% |
| 738 |
\fi% |
| 739 |
\expandafter\ifx\pgf@sys@tempend\relax% |
| 740 |
\expandafter\let\pgf@sys@tempend\pgfutil@empty% |
| 741 |
\fi% |
| 742 |
\expandafter\let\expandafter\pgf@sys@tempbeg@cont\pgf@sys@tempbeg% |
| 743 |
\expandafter\let\expandafter\pgf@sys@tempend@cont\pgf@sys@tempend% |
| 744 |
\expandafter\expandafter\expandafter\gdef\expandafter\pgf@sys@tempbeg\expandafter{\pgf@sys@tempbeg@cont#3}% |
| 745 |
\def\pgf@sys@temp{#4}% |
| 746 |
\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\gdef\expandafter\expandafter\expandafter\pgf@sys@tempend\expandafter\expandafter\expandafter{\expandafter\pgf@sys@temp\pgf@sys@tempend@cont}% |
| 747 |
} |
| 748 |
% Attaches some code to an id-type pair so that when the id's scope |
| 749 |
% gets created, #3 is added at the beginning and #4 is added at the |
| 750 |
% end. |
| 751 |
|
| 752 |
\def\pgfsys@if@fresh@id#1#2#3#4{% |
| 753 |
\edef\pgf@sys@temp{#1}% |
| 754 |
\ifx\pgf@sys@temp\pgfutil@empty% empty id always counts as "has been used" |
| 755 |
#4% |
| 756 |
\else% |
| 757 |
\pgfsys@register@type{#2}% |
| 758 |
\expandafter\ifx\csname pgf@sys@id@keylist@\pgfsys@id@ref{#1}{#2}\endcsname\pgfutil@empty% |
| 759 |
% has already been used! |
| 760 |
#4% |
| 761 |
\else% |
| 762 |
#3% |
| 763 |
\fi% |
| 764 |
\fi% |
| 765 |
} |
| 766 |
% Checks whether a given id-type pair #1-#2 has not been used, yet. If |
| 767 |
% so, #3 is executed, otherwise #4. |
| 768 |
|
| 769 |
\def\pgfsys@if@fresh@currentid#1#2{% |
| 770 |
\ifx\pgf@sys@id@current@id\pgfutil@empty% empty id always counts as "has been used" |
| 771 |
#2% |
| 772 |
\else% |
| 773 |
\expandafter\ifx\csname pgf@sys@id@keylist@\pgfsys@id@refcurrent\endcsname\pgfutil@empty% |
| 774 |
% has already been used! |
| 775 |
#2% |
| 776 |
\else% |
| 777 |
#1% |
| 778 |
\fi% |
| 779 |
\fi% |
| 780 |
} |
| 781 |
% Checks whether the current id-type pair in use has not been used, |
| 782 |
% yet. If so, #1 is executed, otherwise #2. |
| 783 |
|
| 784 |
|
| 785 |
|
| 786 |
|
| 787 |
% |
| 788 |
% |
| 789 |
% Special commands |
| 790 |
% |
| 791 |
% |
| 792 |
|
| 793 |
\def\pgfsys@imagesuffixlist{} |
| 794 |
% A list of suffixes, separated by `:', that will be tried when |
| 795 |
% searching for an image. |
| 796 |
|
| 797 |
|
| 798 |
|
| 799 |
% |
| 800 |
% |
| 801 |
% Transparency |
| 802 |
% |
| 803 |
% |
| 804 |
|
| 805 |
\def\pgfsys@opacity#1{\pgfsys@stroke@opacity{#1}\pgfsys@fill@opacity{#1}} |
| 806 |
% Ideally, this should sets the opacity of all operations, treating |
| 807 |
% the group as a transparency group with 1 meaning fully opaque, 0 |
| 808 |
% meaning fully transparent. Since most drivers do not support this, |
| 809 |
% the fallback is to set the stroke and fill opacity at the same |
| 810 |
% time. This is not quite the same, however. |
| 811 |
|
| 812 |
\def\pgfsys@stroke@opacity#1{\pgf@sys@fail{opacity}} |
| 813 |
% Sets the opacity of stroking operations. 1 means fully opaque, 0 |
| 814 |
% means fully transparent. |
| 815 |
|
| 816 |
\def\pgfsys@fill@opacity#1{\pgf@sys@fail{opacity}} |
| 817 |
% Sets the opacity of filling operations. 1 means fully opaque, 0 |
| 818 |
% means fully transparent. |
| 819 |
|
| 820 |
\def\pgfsys@transparencygroupfrombox#1{\pgf@sys@fail{transparency groups}} |
| 821 |
% This takes a TeX box and converts it into a transparency |
| 822 |
% group. This means that any transparency settings apply to the box as |
| 823 |
% a whole. For instance, if a box contains two overlapping black |
| 824 |
% circles and you draw them normally with 50% transparency, then the |
| 825 |
% overlap will be darker than the rest. By comparison, if the circles |
| 826 |
% are part of a transparency group, the overlap will get the same |
| 827 |
% color as the rest. |
| 828 |
% |
| 829 |
% The following settings modify the behaviour of a transparency group: |
| 830 |
|
| 831 |
\newif\ifpgfsys@transparency@group@isolated |
| 832 |
\newif\ifpgfsys@transparency@group@knockout |
| 833 |
|
| 834 |
|
| 835 |
\def\pgfsys@blend@mode#1{\pgf@sys@fail{blend mode}} |
| 836 |
% Sets the current blend mode. See the PDF specification for details |
| 837 |
% on blend modes. |
| 838 |
|
| 839 |
|
| 840 |
\def\pgfsys@definemask{\pgf@sys@fail{image masks}} |
| 841 |
% This command declares a mask for usage with images. It works similar |
| 842 |
% to \pgfsys@defineimage: Certain macros are set when the command is |
| 843 |
% called. The result should be to set the macro \pgf@mask to a pdf |
| 844 |
% object count that can subsequently be used as a soft mask. The |
| 845 |
% following macros will be set when this command is invoked: |
| 846 |
% |
| 847 |
% - \pgf@filename |
| 848 |
% File name of the mask to be defined. |
| 849 |
% |
| 850 |
% - \pgf@maskmatte |
| 851 |
% The so-called matte of the mask (see the pdf documentation for |
| 852 |
% details). The matte is a color specification consisting of 1, 3 or |
| 853 |
% 4 numbers between 0 and 1. The number of numbers depends on the |
| 854 |
% number of color channels in the image (not in the mask!). It will |
| 855 |
% be assumed that the image has been preblended with this color. |
| 856 |
|
| 857 |
\def\pgfsys@fadingfrombox#1#2{\pgf@sys@fail{fadings}} |
| 858 |
% Declares an fading named #1. The parameter #2 must be a |
| 859 |
% box. Its contents luminosity determines the opacity of the resulting |
| 860 |
% mask. |
| 861 |
|
| 862 |
\def\pgfsys@usefading#1#2#3#4#5#6#7{\pgf@sys@fail{fadings}} |
| 863 |
% Installs a previously declared fading #1 in the current graphics |
| 864 |
% state. Parameters #2 to #7 specify a transformation cm that should |
| 865 |
% be applied to the mask before it is used. |
| 866 |
|
| 867 |
\def\pgfsys@clipfading{} |
| 868 |
% This default implementation is a no-op for all drivers except `dvips' |
| 869 |
% where we have to set the clipping path _before_ installing the fading (used in |
| 870 |
% \pgfsetfadingforcurrentpath, \pgfsetfadingforcurrentpathstroked commands of |
| 871 |
% the basic layer) |
| 872 |
|
| 873 |
|
| 874 |
% |
| 875 |
% |
| 876 |
% Shading commands |
| 877 |
% |
| 878 |
% |
| 879 |
|
| 880 |
\def\pgfsys@horishading#1#2#3{\pgf@sys@fail{shadings}\pgf@sys@noshading{#1}} |
| 881 |
% Declares a horizontal shading for later use. The effect of this |
| 882 |
% command should be the definition of a macro called `@pgfshading#1!' |
| 883 |
% (or \csname @pdfshading#1!\endcsname, to be precise). When invoked, |
| 884 |
% this new macro should insert a shading at the current position. |
| 885 |
% |
| 886 |
% #1 is the name of the shading, which is also used in the output |
| 887 |
% macro name. #2 is the height of the shading and must be given as a |
| 888 |
% TeX dimension like `2cm' or `10pt'. #3 is a shading color |
| 889 |
% specification as specified in the pgfuserguide. The shading |
| 890 |
% specification implicitly fixes the width of the shading. |
| 891 |
% |
| 892 |
% When `@pgfshading#1!' is invoked, it should insert a box of height |
| 893 |
% #2 and the width implicit in the shading declaration. |
| 894 |
|
| 895 |
\def\pgfsys@vertshading#1#2#3{\pgf@sys@fail{shadings}\pgf@sys@noshading{#1}} |
| 896 |
% Like horishading, only for vertical shadings. This time, the height |
| 897 |
% of the shading is implicit in #3 and the width is given as #2. |
| 898 |
|
| 899 |
\def\pgfsys@radialshading#1#2#3{\pgf@sys@fail{shadings}\pgf@sys@noshading{#1}} |
| 900 |
% Declares a radial shading. Like the previous macros, this command |
| 901 |
% should setup the macro `@pgfshading#1!', which upon invocation |
| 902 |
% should insert a radial shading whose size is implicit in #3. |
| 903 |
% |
| 904 |
% The parameter #2 is a pgf point specification if the starting point |
| 905 |
% of the shading. See the pgfuserguide for details. |
| 906 |
|
| 907 |
\def\pgfsys@functionalshading#1#2#3#4{\pgf@sys@fail{shadings (functional)}\pgf@sys@noshading{#1}} |
| 908 |
% Declares a shading using a PostScript-like function that provides a |
| 909 |
% color for each point. Like the previous macros, this command |
| 910 |
% should setup the macro `@pgfshading#1!' so that it will produce a |
| 911 |
% box containing the desired shading. |
| 912 |
% |
| 913 |
% Parameter #1 is the name of the shading. Parameter #4 is a |
| 914 |
% Postscript-like function (type 4 function of the PDF specification) |
| 915 |
% as described in Section 3.9.4 of the PDF Specification version 1.7. |
| 916 |
% Parameter #2 and #3 are pgf point specifications that specifies the |
| 917 |
% lower left and upper right coordinate. |
| 918 |
% |
| 919 |
% When function #4 is evaluated, the coordinate of the current |
| 920 |
% point will be on the (virtual) PostScript stack in bp units. After |
| 921 |
% the function has been evaluated, the stack should consist of three |
| 922 |
% numbers (not integers! - the Apple PDF renderer is broken in this |
| 923 |
% regard, so add cvr's at the end if needed) that represent the red, |
| 924 |
% green, and blue components of the color. |
| 925 |
% |
| 926 |
% A buggy #4 will result is *totally unpredictable chaos* during |
| 927 |
% rendering. |
| 928 |
|
| 929 |
\def\pgf@sys@noshading#1{\expandafter\global\expandafter\let\csname @pgfshading#1!\endcsname=\pgfutil@empty} |
| 930 |
|
| 931 |
|
| 932 |
|
| 933 |
|
| 934 |
% |
| 935 |
% |
| 936 |
% Pattern stuff |
| 937 |
% |
| 938 |
% |
| 939 |
|
| 940 |
\def\pgfsys@declarepattern#1#2#3#4#5#6#7#8#9{\pgf@sys@fail{patterns}} |
| 941 |
% This command declares a new colored or uncolored pattern. Uncolored |
| 942 |
% patterns have no inherent color, the color is provided when they are |
| 943 |
% set. Colored patterns have an inherent color. |
| 944 |
% #1 = name of the pattern (must be a plain suffix for use in |
| 945 |
% postscript/pdf/etc.) |
| 946 |
% #2 to #5 = four coordinates describing the corners of a bounding box |
| 947 |
% of pattern cells |
| 948 |
% #6 = x-step |
| 949 |
% #7 = y-step |
| 950 |
% #8 = pattern code |
| 951 |
% #9 = 0 if uncolored pattern, 1 if colored pattern. |
| 952 |
|
| 953 |
\def\pgfsys@setpatternuncolored#1#2#3#4{\pgf@sys@fail{patterns}} |
| 954 |
% Sets an uncolored pattern #1 as filling color. The numbers #2, #3, |
| 955 |
% #4 must be an rgb-value to be used as the color of the pattern. |
| 956 |
|
| 957 |
\def\pgfsys@setpatterncolored#1{\pgf@sys@fail{patterns}} |
| 958 |
% Sets an colored pattern #1 as filling color. |
| 959 |
|
| 960 |
|
| 961 |
|
| 962 |
|
| 963 |
|
| 964 |
% |
| 965 |
% |
| 966 |
% Animations |
| 967 |
% |
| 968 |
% |
| 969 |
|
| 970 |
|
| 971 |
\newif\ifpgfsysanimationsupported |
| 972 |
% Will be set to true by a driver when animations are supported. Note |
| 973 |
% that snapshots are always supported. |
| 974 |
|
| 975 |
|
| 976 |
\def\pgfsys@animate#1{\pgf@sys@fail{animations}} |
| 977 |
% Adds an animation of the attribute #1 to the current scope. |
| 978 |
% The configuration of the animation (like start times, etc.) is taken |
| 979 |
% from the current values of the animation keys, which are configured |
| 980 |
% using calls to \pgfsys@animation@..., which setup an animation |
| 981 |
% key for the local scope. This means that you typically setup these |
| 982 |
% keys in a scope and at the end of the scope call \pgfsys@animate. |
| 983 |
% |
| 984 |
% Some keys accumulate (like begin or keytime), most do not. In those |
| 985 |
% cases, the last call overrides the previous one. |
| 986 |
% |
| 987 |
% Not all value types make sense or are allowed, it depends on the |
| 988 |
% specific \pgfsys@animate call. |
| 989 |
% |
| 990 |
% Example: |
| 991 |
% |
| 992 |
% { |
| 993 |
% \pgfsys@animation@offset{10}{begin}% |
| 994 |
% \pgfsys@animation@event{}{click}{1}{begin}% |
| 995 |
% \pgfsys@animation@time{5}{1}{1}{0}{0} |
| 996 |
% \pgfsys@animation@val@scalar{1} |
| 997 |
% \pgfsys@animation@time{8}{1}{1}{0}{0} |
| 998 |
% \pgfsys@animation@val@scalar{0.5} |
| 999 |
% \pgfsys@animation@sum% |
| 1000 |
% \pgfsys@animate{fillopacity}% |
| 1001 |
% } |
| 1002 |
% |
| 1003 |
% When a driver does not support a specific attribute #1, it should |
| 1004 |
% issue a \pgf@sys@fail. Typical attributes are things like "opacity" |
| 1005 |
% or "linewidth" or "dash". |
| 1006 |
% |
| 1007 |
% The following values are permissible for "#1": |
| 1008 |
% |
| 1009 |
% "opacity" adds an animation of the opacity. |
| 1010 |
% Type: scalar |
| 1011 |
% |
| 1012 |
% "fillopacity" adds an animation of the fill opacity. |
| 1013 |
% Type: scalar |
| 1014 |
% |
| 1015 |
% "strokeopacity" adds an animation of the stroke opacity. |
| 1016 |
% Type: scalar |
| 1017 |
% |
| 1018 |
% "visibility" adds an animation of the visibility. |
| 1019 |
% Type: text ("visible" or "hidden") |
| 1020 |
% |
| 1021 |
% "linewidth" adds an animation of the line width. |
| 1022 |
% Type: dimension |
| 1023 |
% |
| 1024 |
% "dash" adds an animation of the dash. |
| 1025 |
% Type: dash |
| 1026 |
% |
| 1027 |
% "translate" adds an animation of the transformation. |
| 1028 |
% Type: translate |
| 1029 |
% |
| 1030 |
% "scale" adds an animation of the transformation. |
| 1031 |
% Type: scale |
| 1032 |
% |
| 1033 |
% "rotate" adds an animation of the transformation. |
| 1034 |
% Type: scalar |
| 1035 |
% |
| 1036 |
% "skewx" adds an animation of the transformation. |
| 1037 |
% Type: scalar |
| 1038 |
% |
| 1039 |
% "skewy" adds an animation of the transformation. |
| 1040 |
% Type: scalar |
| 1041 |
% |
| 1042 |
% "motion" adds a movement along a path. |
| 1043 |
% Type: motion |
| 1044 |
% |
| 1045 |
% "strokecolor" adds an animation of the stroke color. |
| 1046 |
% Type: color |
| 1047 |
% |
| 1048 |
% "fillcolor" adds an animation of the fill color. |
| 1049 |
% Type: color |
| 1050 |
% |
| 1051 |
% "viewbox" adds an animation of the view box. |
| 1052 |
% Type: view box |
| 1053 |
% |
| 1054 |
% "path" adds an animation of the path to the path specified by |
| 1055 |
% \pgfsys@animation@whom |
| 1056 |
% Type: path |
| 1057 |
% |
| 1058 |
% "syncbase" adds a sync base to the animation. A sync base does not animate |
| 1059 |
% anything by itself, but other animations can begin and end relative |
| 1060 |
% to it. |
| 1061 |
% |
| 1062 |
% "none" suppresses the animation |
| 1063 |
% Type: any |
| 1064 |
|
| 1065 |
|
| 1066 |
|
| 1067 |
|
| 1068 |
% Animation timing : |
| 1069 |
% |
| 1070 |
% You specify an animation using a timeline. A timeline consists of a |
| 1071 |
% sequence of times together with values for these times. The times |
| 1072 |
% must be given in increasing order. You use the command |
| 1073 |
% \pgfsys@animation@time to specify a time and |
| 1074 |
% \pgfsys@animation@val@... to specify a value. The time must be |
| 1075 |
% specified first, the time--value is created when the value command is |
| 1076 |
% used. |
| 1077 |
% |
| 1078 |
% Times are given in seconds (so 0.01 is one hundredth of a second). |
| 1079 |
% |
| 1080 |
% The animation's timeline will start with the first time mentioned |
| 1081 |
% (not necessarily zero and not necessarily a positive value) and ends |
| 1082 |
% with the last value. The duration is the difference between these |
| 1083 |
% two values. |
| 1084 |
|
| 1085 |
\def\pgfsys@animation@restart@always{} |
| 1086 |
% Specifies that the animation can always restart |
| 1087 |
|
| 1088 |
\def\pgfsys@animation@restart@never{} |
| 1089 |
% Specifies that the animation should never restart |
| 1090 |
|
| 1091 |
\def\pgfsys@animation@restart@whennotactive{} |
| 1092 |
% Specifies that the animation should only restart when it is not active |
| 1093 |
|
| 1094 |
\def\pgfsys@animation@repeat#1{} |
| 1095 |
% #1 must be a number |
| 1096 |
|
| 1097 |
\def\pgfsys@animation@repeat@indefinite{} |
| 1098 |
% Repeats forever |
| 1099 |
|
| 1100 |
\def\pgfsys@animation@repeat@dur#1{} |
| 1101 |
% #1 must be a clock value |
| 1102 |
|
| 1103 |
\def\pgfsys@animation@freezeatend{} |
| 1104 |
% Specifies that the last value of the animation remains in force at |
| 1105 |
% the end |
| 1106 |
|
| 1107 |
\def\pgfsys@animation@removeatend{} |
| 1108 |
% Specifies that the effect of the animation is removed at the end |
| 1109 |
|
| 1110 |
\def\pgfsys@animation@time#1#2#3#4#5{} |
| 1111 |
% Specifies a time together with spline control points for the entry |
| 1112 |
% and the exit to this time. The value #1 is a time in seconds (so 60 |
| 1113 |
% means 1 minute, 0.001 means one millisecond). The values #2 and #3 |
| 1114 |
% specify the control point of the spline *entering* the time point, |
| 1115 |
% while the values #4 and #5 specify the control point of the spline |
| 1116 |
% *leaving* the time point. They are all dimensionless values between |
| 1117 |
% 0 and 1. For a linear animation, set the first two to 1 and the last |
| 1118 |
% two to 0. |
| 1119 |
% |
| 1120 |
% Example: |
| 1121 |
% \pgfsys@animation@time{5}{1}{1}{0.25}{0.1} |
| 1122 |
% \pgfsys@animation@val@scalar{80} |
| 1123 |
% \pgfsys@animation@time{8}{.75}{1}{0}{0} |
| 1124 |
% \pgfsys@animation@val@scalar{90} |
| 1125 |
% |
| 1126 |
% In SVG, this will create the following entries: |
| 1127 |
% begin = +5s |
| 1128 |
% duration = 3s |
| 1129 |
% keyTimes = 0;1 |
| 1130 |
% values = 80;90 |
| 1131 |
% keySpline = 0.25 0.1 0.75 1 |
| 1132 |
% |
| 1133 |
% For the key spline, note that the entry spline controls of the first |
| 1134 |
% time and the exit spline controls of the last point are dropped. |
| 1135 |
% |
| 1136 |
% |
| 1137 |
% When the exit spline takes the special values #4="stay" and #5="0", |
| 1138 |
% the attribute's value "stays" until the next value for the next time |
| 1139 |
% (it "jumps" to the next value then). This corresponds, roughly, to |
| 1140 |
% an "infinite" #4. |
| 1141 |
% |
| 1142 |
% Similarly, when the entry spline takes the special value #2="jump" |
| 1143 |
% and #3="1", the value immediately jumps from the previous value to |
| 1144 |
% the next value when the previous value was "created". |
| 1145 |
|
| 1146 |
\def\pgfsys@stay@text{{stay}{0}} |
| 1147 |
\def\pgfsys@jump@text{{jump}{1}} |
| 1148 |
|
| 1149 |
\def\pgfsys@animation@base{} |
| 1150 |
% Think of this command as setting the value of the attribute in the |
| 1151 |
% timeline before the timeline starts. Normally, an animation only |
| 1152 |
% influences the timeline while the animation is running (which may be |
| 1153 |
% forever) and before and after the animation is running, the |
| 1154 |
% attribute's value is not modified by the animation (so, it is just |
| 1155 |
% inherited from the surrounding scope). When a base value is set, |
| 1156 |
% while the animation is not running, this value is used. For most |
| 1157 |
% attributes you can achieve the same effect by surrounding the |
| 1158 |
% to-be-animated object by a scope and setting the value there, but |
| 1159 |
% using bases is often more convenient and, for instance for the |
| 1160 |
% visibility attribute, it is necessary to use a base. |
| 1161 |
% |
| 1162 |
% Note that when a backend driver does not support animations, base |
| 1163 |
% values will not be depicted unless a snapshot is used explicitly. |
| 1164 |
|
| 1165 |
\def\pgfsys@animation@offset#1#2{} |
| 1166 |
% #1 must be a value in seconds, #2 is the target "begin" or "end" to |
| 1167 |
% which this offset is appended. |
| 1168 |
|
| 1169 |
\def\pgfsys@animation@syncbegin#1#2#3#4{} |
| 1170 |
% #1 is the id of a sync base (obtained by |
| 1171 |
% \pgfsys@new@id), #2 is the id type (or empty), #3 is an optional |
| 1172 |
% offset, #4 is the target. |
| 1173 |
|
| 1174 |
\def\pgfsys@animation@syncend#1#2#3#4{} |
| 1175 |
% Like the previous command. |
| 1176 |
|
| 1177 |
\def\pgfsys@animation@event#1#2#3#4#5{} |
| 1178 |
% #1 is the optional id of another element (obtained by |
| 1179 |
% \pgfsys@new@id), #2 is the optional type of the id, #3 is an event |
| 1180 |
% name, #4 is an optional offset, #5 is the target. |
| 1181 |
|
| 1182 |
\def\pgfsys@animation@repeat@event#1#2#3#4#5{} |
| 1183 |
% #1 is the optional id of another element, #2 is the type, #3 is a |
| 1184 |
% repeat count, and #4 is an optional offset, #5 is the target. |
| 1185 |
|
| 1186 |
\def\pgfsys@animation@accesskey#1#2#3{} |
| 1187 |
% #1 is a character, #2 is an optional offset, #3 is the target. |
| 1188 |
|
| 1189 |
\def\pgf@sys@begin@text{begin} |
| 1190 |
|
| 1191 |
|
| 1192 |
% Accumulation |
| 1193 |
|
| 1194 |
\def\pgfsys@animation@accumulate{} |
| 1195 |
% Corresponds to accumulate="sum" in SVG |
| 1196 |
|
| 1197 |
\def\pgfsys@animation@noaccumulate{} |
| 1198 |
% Corresponds to accumulate="none" in SVG |
| 1199 |
|
| 1200 |
|
| 1201 |
% Targeting |
| 1202 |
|
| 1203 |
\def\pgfsys@animation@whom#1#2{} |
| 1204 |
% Sets the target of the animation. #1 must be an id previously |
| 1205 |
% created using \pgfsys@new@id and #2 must be empty or a type |
| 1206 |
% previously created using \pgfsys@new@id@type |
| 1207 |
|
| 1208 |
|
| 1209 |
% Attribute definitions |
| 1210 |
|
| 1211 |
\def\pgfsys@animation@rotatealong{} |
| 1212 |
% Applicable only to motion animations. Indicates that the |
| 1213 |
% to-be-animated group should be rotated automatically so that it |
| 1214 |
% points along the path as time progresses. |
| 1215 |
|
| 1216 |
\def\pgfsys@animation@norotatealong{} |
| 1217 |
% Corresponds to rotate="0" |
| 1218 |
|
| 1219 |
\def\pgfsys@animation@movealong#1{} |
| 1220 |
% Applicable only to motion animations. #1 is a softpath along which |
| 1221 |
% the movement will be done. |
| 1222 |
|
| 1223 |
\def\pgfsys@animation@tip@markers#1#2{} |
| 1224 |
% Applicable only to path animations. #1 and #2 are markers (declared |
| 1225 |
% using \pgfsys@marker@declare) that store marker symbols to be added |
| 1226 |
% at the start and at the end of the to-be-animated path. If empty, no |
| 1227 |
% markers are added. |
| 1228 |
|
| 1229 |
\def\pgfsys@animation@canvas@transform#1#2{} |
| 1230 |
% #1 is some code that may call \pgfsys@transformcm at most once. It |
| 1231 |
% will be executed when a canvas transformation animation is |
| 1232 |
% installed for a scope id. #2 is some further codes that may also |
| 1233 |
% call \pgfsys@transformcm at most once. It will be installed right |
| 1234 |
% after the animation. |
| 1235 |
% |
| 1236 |
% Typically, #1 is some pgf coordinate shift followed by |
| 1237 |
% {\pgflowlevelsynccm} and #2 is \pgftransforminvert followed by |
| 1238 |
% \pgflowlevelsynccm. |
| 1239 |
|
| 1240 |
|
| 1241 |
|
| 1242 |
% Values |
| 1243 |
|
| 1244 |
\def\pgfsys@animation@val@current{} |
| 1245 |
% The current value of the attribute. At least with SVG, this can only |
| 1246 |
% be used for the first value and, then, only if there is only one |
| 1247 |
% other value. |
| 1248 |
|
| 1249 |
\def\pgfsys@animation@val@text#1{} |
| 1250 |
% #1 should be some text. |
| 1251 |
|
| 1252 |
\def\pgfsys@animation@val@scalar#1{} |
| 1253 |
% #1 should be a single value. |
| 1254 |
|
| 1255 |
\def\pgfsys@animation@val@dimension#1{} |
| 1256 |
% #1 must be a dimension. |
| 1257 |
|
| 1258 |
\def\pgfsys@animation@val@color@rgb#1#2#3{} |
| 1259 |
% #1,#2,#3 must be an rgb tuple |
| 1260 |
|
| 1261 |
\def\pgfsys@animation@val@color@cmyk#1#2#3#4{} |
| 1262 |
% #1,#2,#3,#4 must be an cmyk tuple |
| 1263 |
|
| 1264 |
\def\pgfsys@animation@val@color@cmy#1#2#3{} |
| 1265 |
% #1,#2,#3 must be an cmy tuple |
| 1266 |
|
| 1267 |
\def\pgfsys@animation@val@color@gray#1{} |
| 1268 |
% #1 must be a gray value |
| 1269 |
|
| 1270 |
\def\pgfsys@animation@val@path#1{} |
| 1271 |
% #1 must consist of path-construction tokens (as returned by the |
| 1272 |
% softpath layer) |
| 1273 |
|
| 1274 |
\def\pgfsys@animation@val@translate#1#2{} |
| 1275 |
% #1,#2 must be dimensions |
| 1276 |
|
| 1277 |
\def\pgfsys@animation@val@scale#1#2{} |
| 1278 |
% #1,#2 must be dimensionless |
| 1279 |
|
| 1280 |
\def\pgfsys@animation@val@viewbox#1#2#3#4{} |
| 1281 |
% #1,#2 describe the lower left, #3,#4 the upper right corner of the |
| 1282 |
% view box. |
| 1283 |
|
| 1284 |
\def\pgfsys@animation@val@dash#1#2{} |
| 1285 |
% #1,#2 have the syntax of \pgfsys@setdash. |
| 1286 |
|
| 1287 |
|
| 1288 |
|
| 1289 |
% |
| 1290 |
% |
| 1291 |
% Markers |
| 1292 |
% |
| 1293 |
% |
| 1294 |
|
| 1295 |
\def\pgfsys@marker@declare#1#2{% |
| 1296 |
{% |
| 1297 |
\pgfpicturetrue% |
| 1298 |
\pgfsysprotocol@getcurrentprotocol\pgfsys@marker@temp% |
| 1299 |
\pgfsysprotocol@setcurrentprotocol\pgfutil@empty% |
| 1300 |
\pgfsysprotocol@bufferedtrue% |
| 1301 |
\pgfsys@beginscope% |
| 1302 |
#2% |
| 1303 |
\pgfsys@endscope% |
| 1304 |
\xdef#1{\the\pgf@sys@id@count}% |
| 1305 |
\expandafter\expandafter\expandafter\global\expandafter\pgfsysprotocol@getcurrentprotocol\csname pgf@sys@marker@prot@#1\endcsname% |
| 1306 |
\pgfsys@marker@declare@% courtesy hook |
| 1307 |
\pgfsysprotocol@setcurrentprotocol\pgfsys@marker@temp% |
| 1308 |
\global\advance\pgf@sys@id@count by1\relax% |
| 1309 |
}% |
| 1310 |
} |
| 1311 |
\let\pgfsys@marker@declare@\relax |
| 1312 |
% Declares a new marker symbol whose code is in #2. #1 should be a |
| 1313 |
% macro name, which will be set to a unique |
| 1314 |
% value by which the marker can be referenced later on. #2 should be |
| 1315 |
% code that, when executed, produces recordable code. |
| 1316 |
|
| 1317 |
\def\pgfsys@marker@use#1{% |
| 1318 |
\pgfsysprotocol@literal{\csname pgf@sys@marker@prot@#1\endcsname}% |
| 1319 |
} |
| 1320 |
% Draws the marker symbol not at the end of a path, but simply with |
| 1321 |
% the current transformation matrix |
| 1322 |
|
| 1323 |
|
| 1324 |
|
| 1325 |
|
| 1326 |
|
| 1327 |
|
| 1328 |
% |
| 1329 |
% |
| 1330 |
% RDF |
| 1331 |
% |
| 1332 |
% |
| 1333 |
|
| 1334 |
\def\pgfsys@rdf@about#1{\pgf@sys@fail{rdf}} |
| 1335 |
% Adds the rdf attribute "about" with value #1 to the next |
| 1336 |
% idscope. The RDF-spec says: "a SafeCURIEorCURIEorIRI, used for |
| 1337 |
% stating what the data is about (a 'subject' in RDF terminology);" |
| 1338 |
|
| 1339 |
\def\pgfsys@rdf@content#1{\pgf@sys@fail{rdf}} |
| 1340 |
% Adds the rdf attribute content with value #1 to the next |
| 1341 |
% idscope. The RDF-spec says: "a CDATA string, for supplying |
| 1342 |
% machine-readable content for a literal (a 'literal object', in RDF |
| 1343 |
% terminology);" |
| 1344 |
|
| 1345 |
\def\pgfsys@rdf@datatype#1{\pgf@sys@fail{rdf}} |
| 1346 |
% Adds the rdf attribute datatype with value #1 to the next |
| 1347 |
% idscope. The RDF-spec says: "a TERMorCURIEorAbsIRI representing a |
| 1348 |
% datatype, to express the datatype of a literal;" |
| 1349 |
|
| 1350 |
\def\pgfsys@rdf@href#1{\pgf@sys@fail{rdf}} |
| 1351 |
% Adds the rdf attribute href with value #1 to the next idscope |
| 1352 |
% The RDF-spec says: "a traditionally navigable IRI for |
| 1353 |
% expressing the partner resource of a relationship (a 'resource |
| 1354 |
% object', in RDF terminology);" |
| 1355 |
|
| 1356 |
\def\pgfsys@rdf@inlist{\pgf@sys@fail{rdf}} |
| 1357 |
% Adds the rdf attribute inlist to the next idscope. The |
| 1358 |
% RDF-spec says: "An attribute used to indicate that the object |
| 1359 |
% associated with a rel or property attribute on the same element is |
| 1360 |
% to be added to the list for that predicate. The value of this |
| 1361 |
% attribute must be ignored. Presence of this attribute causes a list |
| 1362 |
% to be created if it does not already exist." |
| 1363 |
|
| 1364 |
\def\pgfsys@rdf@prefix#1{\pgf@sys@fail{rdf}} |
| 1365 |
% Adds #1 to the list of the rdf prefix attribute to the next |
| 1366 |
% idscope. Can be called several times, in which case all values of #1 |
| 1367 |
% are concatenated with whitespaces. The RDF-spec says: "a white space |
| 1368 |
% separated list of prefix-name IRI pairs of the form NCName ':' ' '+ |
| 1369 |
% xsd:anyURI" |
| 1370 |
|
| 1371 |
\def\pgfsys@rdf@property#1{\pgf@sys@fail{rdf}} |
| 1372 |
% Adds #1 to the list of the rdf property attribute to the next |
| 1373 |
% idscope. Can be called repeatedly. The RDF-spec says: "a white space |
| 1374 |
% separated list of TERMorCURIEorAbsIRIs, used for expressing |
| 1375 |
% relationships between a subject and either a resource object if |
| 1376 |
% given or some literal text (also a 'predicate');" |
| 1377 |
|
| 1378 |
\def\pgfsys@rdf@rel#1{\pgf@sys@fail{rdf}} |
| 1379 |
% Adds #1 to the list of the rdf rel attribute to the next |
| 1380 |
% next idscope. Can be called repeatedly. The |
| 1381 |
% RDF-spec says: "a white space separated list of |
| 1382 |
% TERMorCURIEorAbsIRIs, used for expressing relationships between two |
| 1383 |
% resources ('predicates' in RDF terminology);" |
| 1384 |
|
| 1385 |
\def\pgfsys@rdf@resource#1{\pgf@sys@fail{rdf}} |
| 1386 |
% Adds the rdf attribute resource with value #1 to the next idscope. The |
| 1387 |
% RDF-spec says: "a SafeCURIEorCURIEorIRI for expressing the partner |
| 1388 |
% resource of a relationship that is not intended to be navigable |
| 1389 |
% (e.g., a 'clickable' link) (also an 'object');" |
| 1390 |
|
| 1391 |
\def\pgfsys@rdf@rev#1{\pgf@sys@fail{rdf}} |
| 1392 |
% Adds #1 to the list of the rdf rev attribute to the next |
| 1393 |
% idscope. Can be called repeatedly. The |
| 1394 |
% RDF-spec says: "a white space separated list of |
| 1395 |
% TERMorCURIEorAbsIRIs, used for expressing reverse relationships |
| 1396 |
% between two resources (also 'predicates'); |
| 1397 |
|
| 1398 |
\def\pgfsys@rdf@src#1{\pgf@sys@fail{rdf}} |
| 1399 |
% Adds an rdf attribute src with value #1 to the next idscope. The |
| 1400 |
% RDF-spec says: "an IRI for expressing the partner resource of a |
| 1401 |
% relationship when the resource is embedded (also a 'resource |
| 1402 |
% object');" |
| 1403 |
|
| 1404 |
\def\pgfsys@rdf@typeof#1{\pgf@sys@fail{rdf}} |
| 1405 |
% Adds #1 to the list of the rdf typeof attribute to the next |
| 1406 |
% idscope. Can be called repeatedly. The |
| 1407 |
% RDF-spec says: "a white space separated list of TERMorCURIEorAbsIRIs |
| 1408 |
% that indicate the RDF type(s) to associate with a subject;" |
| 1409 |
|
| 1410 |
\def\pgfsys@rdf@vocab#1{\pgf@sys@fail{rdf}} |
| 1411 |
% Adds an rdf attribute vocab with value #1 to the next idscope. The |
| 1412 |
% RDF-spec says: "an IRI that defines the mapping to use when a TERM |
| 1413 |
% is referenced in an attribute value. See General Use of Terms in |
| 1414 |
% Attributes and the section on Vocabulary Expansion." |
| 1415 |
|
| 1416 |
|
| 1417 |
|
| 1418 |
% |
| 1419 |
% |
| 1420 |
% Page size stuff |
| 1421 |
% |
| 1422 |
% |
| 1423 |
|
| 1424 |
\def\pgfsys@papersize#1#2{\pgf@sys@fail{papersize}} |
| 1425 |
% This command sets the paper size in a portable way. It tries to do |
| 1426 |
% so "locally" for the current page, but what really happens depends |
| 1427 |
% strongly on the driver. For instance, dvips will use whatever is |
| 1428 |
% used with the first call to this command that is part of the |
| 1429 |
% shipped-out document and will ignore all other uses. In contrast, |
| 1430 |
% pdftex will use the current value of the papersize for each page |
| 1431 |
% and, additionally, setting the papersize is local to the current TeX |
| 1432 |
% group. |
| 1433 |
% #1 = width |
| 1434 |
% #2 = height |
| 1435 |
|
| 1436 |
\def\pgfsys@global@papersize#1#2{\pgfsys@papersize{#1}{#2}} |
| 1437 |
% This command does the same as the papersize command, only for |
| 1438 |
% drivers that support this, \global is used to set the papersize. |
| 1439 |
% #1 = width |
| 1440 |
% #2 = height |
| 1441 |
|
| 1442 |
\def\pgfsys@prepare@papersize#1#2{\pgfsys@papersize{#1}{#2}} |
| 1443 |
% Like \pgfsys@papersize, this prepares the paper size in a portable |
| 1444 |
% way -- but it is supposed to be a preparation step before the |
| 1445 |
% document has started. Drivers may decide to postpone the action |
| 1446 |
% until the document has started. |
| 1447 |
% |
| 1448 |
% The root cause why I added this method is that image externalization |
| 1449 |
% seems to suffer from the fact that some drivers need a "prepared" |
| 1450 |
% routine whereas others must not have a prepared routine and have to |
| 1451 |
% apply the action right-away. This method is the solution for image |
| 1452 |
% externalization. |
| 1453 |
% #1 = width |
| 1454 |
% #2 = height |
| 1455 |
|
| 1456 |
\ifx\paperheight\@undefined |
| 1457 |
\def\pgfsys@thepageheight{\the\vsize} % this is wrong, but I do not |
| 1458 |
% know how to compute the page height |
| 1459 |
% in plain tex. |
| 1460 |
\def\pgfsys@thepagewidth{\the\hsize} |
| 1461 |
\else |
| 1462 |
\def\pgfsys@thepageheight{\paperheight} |
| 1463 |
\def\pgfsys@thepagewidth{\paperwidth} |
| 1464 |
\fi |
| 1465 |
|
| 1466 |
|
| 1467 |
% |
| 1468 |
% |
| 1469 |
% Position tracking commands |
| 1470 |
% |
| 1471 |
% |
| 1472 |
|
| 1473 |
% Marks the current position on the page. This position can later be |
| 1474 |
% referenced using \pgfsys@getposition |
| 1475 |
\def\pgfsys@markposition#1{\pgf@sys@fail{marking the current position}} |
| 1476 |
|
| 1477 |
% Sets #2 to a pgfpoint macro that returns the position #1 is |
| 1478 |
% returned in a coordinate system where the x-axis goes right and the |
| 1479 |
% y-axis goes up. The origin of this coordinate system may or may not |
| 1480 |
% lie in the lower left corner; you should shift the coordinate system |
| 1481 |
% to the position "pgfpageorigin" to make sure that the origin is at |
| 1482 |
% the lower left corner. Typically, getting this position |
| 1483 |
% requires two runs of TeX. On the first run, the macro will be set to |
| 1484 |
% \relax, indicating that the position is not available. |
| 1485 |
% |
| 1486 |
% If #1 is set to the special position "pgfpageorigin", the position |
| 1487 |
% of the the lower left page corner is returned. |
| 1488 |
|
| 1489 |
\def\pgfsys@getposition#1#2{\let#2=\relax} |
| 1490 |
|
| 1491 |
|
| 1492 |
|
| 1493 |
% |
| 1494 |
% |
| 1495 |
% Commands having a default implementation. These commands only need |
| 1496 |
% not be implemented by drivers if this results in a better |
| 1497 |
% performance. |
| 1498 |
% |
| 1499 |
% |
| 1500 |
|
| 1501 |
|
| 1502 |
\def\pgfsys@shadingoutsidepgfpicture#1{% |
| 1503 |
#1% |
| 1504 |
} |
| 1505 |
% This command gets the definition of a shading (@pgfshadingxxxx!) as |
| 1506 |
% an argument and should insert this shading into the normal text. |
| 1507 |
% |
| 1508 |
% This command has a default implementation. |
| 1509 |
|
| 1510 |
|
| 1511 |
\def\pgfsys@shadinginsidepgfpicture#1{% |
| 1512 |
\pgf@makehbox{#1}% |
| 1513 |
\setbox\pgf@hbox=\hbox{\hskip-.5\wd\pgf@hbox\lower.5\ht\pgf@hbox\hbox{\box\pgf@hbox}}% |
| 1514 |
\pgfqbox{\pgf@hbox}% |
| 1515 |
} |
| 1516 |
% This command works like \pgfsys@shadingoutsidepgfpicture, only it is |
| 1517 |
% called when a shading should be inserted inside a picture. This |
| 1518 |
% command should insert the shading centered on the origin (which will |
| 1519 |
% typically have been low-level translated somewhere else.) |
| 1520 |
% |
| 1521 |
% This command has a default implementation. |
| 1522 |
|
| 1523 |
|
| 1524 |
\def\pgfsys@hbox#1{% |
| 1525 |
\pgfsys@begin@idscope% |
| 1526 |
\pgfsys@beginscope% |
| 1527 |
\setbox#1=\hbox{\box#1}% |
| 1528 |
\wd#1=0pt% |
| 1529 |
\ht#1=0pt% |
| 1530 |
\dp#1=0pt% |
| 1531 |
\box#1% |
| 1532 |
\pgfsys@endscope% |
| 1533 |
\pgfsys@end@idscope% |
| 1534 |
} |
| 1535 |
% Called to insert a TeX hbox into a pgfpicture. |
| 1536 |
|
| 1537 |
\def\pgfsys@hboxsynced#1{% |
| 1538 |
\pgfsys@beginscope\pgflowlevelsynccm\pgfsys@hbox#1\pgfsys@endscope% |
| 1539 |
}% |
| 1540 |
% Called to insert box #1 into a pgfpicture, but with the current |
| 1541 |
% coordinate transformation matrix synced with the canvas |
| 1542 |
% transformation matrix and surrounded by a scope. |
| 1543 |
% |
| 1544 |
% In essence, this command does the same as if you first said |
| 1545 |
% \pgflowlevelsynccm and then \pgfsys@hbox#1. However, a |
| 1546 |
% ``TeX-translation'' is used for the translation part of the |
| 1547 |
% transformation cm. This will ensure that hyperlinks ``survive'' at |
| 1548 |
% least translations. |
| 1549 |
|
| 1550 |
\def\pgfsys@pictureboxsynced#1{% |
| 1551 |
{% |
| 1552 |
\setbox0=\hbox{\pgfsys@beginpicture\box#1\pgfsys@endpicture}% |
| 1553 |
\pgfsys@hboxsynced0% |
| 1554 |
}% |
| 1555 |
} |
| 1556 |
% Basically, this should do the same as doing a (scoped) low level sync |
| 1557 |
% followed by inserting the box #1 directly into the output |
| 1558 |
% stream. However, the default implementation uses \pgfsys@hboxsynced |
| 1559 |
% in conjunction with \pgfsys@beginpicture to ensure that, if |
| 1560 |
% possible, hyperlinks survive in pdfs. Drivers that are sensitive to |
| 1561 |
% picture-in-picture scopes should replace this implementation by |
| 1562 |
% \pgfsys@beginscope\pgflowlevelsynccm\box#1\pgfsys@endscope |
| 1563 |
|
| 1564 |
\def\pgfsys@beginpicture{} |
| 1565 |
% Called at the beginning of a pgfpicture. Used to setup things. |
| 1566 |
|
| 1567 |
\def\pgfsys@endpicture{} |
| 1568 |
% Called at the end of a pgfpicture. |
| 1569 |
|
| 1570 |
\def\pgfsys@typesetpicturebox#1{% |
| 1571 |
\pgf@ya=\pgf@shift@baseline\relax% |
| 1572 |
\advance\pgf@ya by-\pgf@picminy\relax% |
| 1573 |
% |
| 1574 |
% |
| 1575 |
\advance\pgf@picmaxy by-\pgf@picminy\relax% maxy is now the height |
| 1576 |
\advance\pgf@picmaxx by-\pgf@picminx\relax% maxx is now the width |
| 1577 |
\setbox#1=\hbox{\hskip-\pgf@picminx\lower\pgf@picminy\box#1}% |
| 1578 |
\ht#1=\pgf@picmaxy% |
| 1579 |
\wd#1=\pgf@picmaxx% |
| 1580 |
\dp#1=0pt% |
| 1581 |
\leavevmode% |
| 1582 |
\pgf@xa=\pgf@trimleft@final\relax \ifdim\pgf@xa=0pt \else\kern\pgf@xa\fi |
| 1583 |
\raise-\pgf@ya\box#1% |
| 1584 |
\pgf@xa=\pgf@trimright@final\relax \ifdim\pgf@xa=0pt \else\kern\pgf@xa\fi |
| 1585 |
} |
| 1586 |
% Called after a picture has been typeset in box #1. This |
| 1587 |
% command should insert the box into the normal TeX code. The box #1 |
| 1588 |
% will still be a ``raw'' box that contains only the \special's. The |
| 1589 |
% job of this command is to resize and shift this box according to the |
| 1590 |
% baseline shift and the size of the box. |
| 1591 |
% |
| 1592 |
% This command has a default implementation. |
| 1593 |
|
| 1594 |
\def\pgfsys@beginpurepicture{\pgfsys@beginpicture} |
| 1595 |
% This version of the beginpicture command can be used for pictures |
| 1596 |
% that are guaranteed not to contain any hboxes. In this case, a |
| 1597 |
% driver might provide a more compact version of the command. |
| 1598 |
|
| 1599 |
\def\pgfsys@endpurepicture{\pgfsys@endpicture} |
| 1600 |
% Called at the end of a ``pure'' pgfpicture. |
| 1601 |
|
| 1602 |
\def\pgfsys@defineimage{% |
| 1603 |
\ifx\pgf@imagewidth\pgfutil@empty\else\edef\pgf@imagewidth{width=\pgf@imagewidth,}\fi% |
| 1604 |
\ifx\pgf@imageheight\pgfutil@empty\else\edef\pgf@imageheight{height=\pgf@imageheight,}\fi% |
| 1605 |
\ifx\pgf@imagepage\pgfutil@empty\else\edef\pgf@imagepage{page=\pgf@imagepage,}\fi% |
| 1606 |
\edef\pgf@image{\noexpand\includegraphics[\pgf@imageheight\pgf@imagewidth]{\pgf@filename}}% |
| 1607 |
} |
| 1608 |
% Called, when an image should be defined. |
| 1609 |
% |
| 1610 |
% This command does not take any parameters. Instead, certain macros |
| 1611 |
% will be preinstalled with appropriate values when this command is |
| 1612 |
% invoked. These are: |
| 1613 |
% |
| 1614 |
% - \pgf@filename |
| 1615 |
% File name of the image to be defined. |
| 1616 |
% |
| 1617 |
% - \pgf@imagewidth |
| 1618 |
% Will be set to the desired (scaled) width of the image. |
| 1619 |
% |
| 1620 |
% - \pgf@imageheight |
| 1621 |
% Will be set to the desired (scaled) height of the image. |
| 1622 |
% |
| 1623 |
% If this macro and also the height macro are empty, the image |
| 1624 |
% should have its `natural' size. |
| 1625 |
% |
| 1626 |
% If exactly only of them is specified, the undefined value the |
| 1627 |
% image is scaled so that the aspect ratio is kept. |
| 1628 |
% |
| 1629 |
% If both are set, the image is scaled in both directions |
| 1630 |
% independently, possibly changing the aspect ratio. |
| 1631 |
% |
| 1632 |
% |
| 1633 |
% The following macros presumable mostly make sense for drivers that |
| 1634 |
% can handle pdf: |
| 1635 |
% |
| 1636 |
% - \pgf@imagepage |
| 1637 |
% The desired page number to be extracted from a multi-page |
| 1638 |
% `image'. |
| 1639 |
% |
| 1640 |
% - \pgf@imagemask |
| 1641 |
% If set, it will be set to `/SMask x 0 R', where x is the pdf |
| 1642 |
% object number of a soft mask to be applied to the image. |
| 1643 |
% |
| 1644 |
% - \pgf@imageinterpolate |
| 1645 |
% If set, it will be set to `/Interpolate true' or `/Interpolate |
| 1646 |
% false', indicating whether the image should be interpolated in |
| 1647 |
% pdf. |
| 1648 |
% |
| 1649 |
% |
| 1650 |
% The command should now setup the macro \pgf@image such that calling |
| 1651 |
% this macro will result in typesetting the image. Thus, \pgf@image is |
| 1652 |
% the `return value' of the command. |
| 1653 |
|
| 1654 |
|
| 1655 |
\def\pgfsys@defobject#1#2#3#4{% |
| 1656 |
\pgfsysprotocol@getcurrentprotocol\pgfsys@temp% |
| 1657 |
{% |
| 1658 |
\pgfpicturetrue% |
| 1659 |
\pgfsysprotocol@setcurrentprotocol\pgfutil@empty% |
| 1660 |
\pgfsysprotocol@bufferedtrue% |
| 1661 |
\pgfsys@beginscope% |
| 1662 |
#4% |
| 1663 |
\pgfsys@endscope% |
| 1664 |
\pgfsysprotocol@getcurrentprotocol\pgfsys@@temp% |
| 1665 |
\expandafter\global\expandafter\let\csname #1\endcsname=\pgfsys@@temp% |
| 1666 |
}% |
| 1667 |
\pgfsysprotocol@setcurrentprotocol\pgfsys@temp% |
| 1668 |
} |
| 1669 |
% Declares an object for later use. The idea is that the object can be |
| 1670 |
% precached in some way and then be rendered more quickly when used |
| 1671 |
% several times. For example, an arrow head might be defined and |
| 1672 |
% prerendered in this way. |
| 1673 |
% |
| 1674 |
% The parameter #1 is the name for later use. #2 and #3 are pgf points |
| 1675 |
% specifying a bounding box for the object. #4 is the code for the |
| 1676 |
% object. The code may only contain protocolable code. |
| 1677 |
|
| 1678 |
|
| 1679 |
\def\pgfsys@useobject#1#2{% |
| 1680 |
\pgfsysprotocol@getcurrentprotocol\pgfsys@temp% |
| 1681 |
{% |
| 1682 |
\pgfsysprotocol@setcurrentprotocol\pgfutil@empty% |
| 1683 |
\pgfsysprotocol@bufferedfalse% |
| 1684 |
#2% |
| 1685 |
\expandafter\pgfsysprotocol@setcurrentprotocol\csname #1\endcsname% |
| 1686 |
\pgfsysprotocol@invokecurrentprotocol% |
| 1687 |
}% |
| 1688 |
\pgfsysprotocol@setcurrentprotocol\pgfsys@temp% |
| 1689 |
} |
| 1690 |
% Renders a previously declared object. The first parameter is the |
| 1691 |
% name of the object. The second parameter is extra code that |
| 1692 |
% should be executed right *before* the object is rendered. Typically, |
| 1693 |
% this will be some transformation code. |
| 1694 |
|
| 1695 |
|
| 1696 |
\def\pgfsys@begininvisible{\pgfsys@transformcm{1}{0}{0}{1}{2000bp}{2000bp}} |
| 1697 |
% Between this command and the closing endinvisible, all output should |
| 1698 |
% be suppressed. Nothing should be drawn at all, which includes all |
| 1699 |
% paths, images and shadings. This command typically should not open a |
| 1700 |
% graphic scope. |
| 1701 |
|
| 1702 |
\def\pgfsys@endinvisible{\pgfsys@transformcm{1}{0}{0}{1}{-2000bp}{-2000bp}} |
| 1703 |
% Ends the invisibility section, unless invisibility blocks have been |
| 1704 |
% nested. In this case, only the `last' one restores visibility. |
| 1705 |
|
| 1706 |
\def\pgfsys@begininvisiblescope{\pgfsys@beginscope\pgfsys@begininvisible} |
| 1707 |
% Works like pgfsys@begininvisible, but it may open a graphics scope. |
| 1708 |
|
| 1709 |
\def\pgfsys@endinvisiblescope{\pgfsys@endinvisible\pgfsys@endscope} |
| 1710 |
% Closes the invisibility scope. |
| 1711 |
|
| 1712 |
|
| 1713 |
\def\pgfsys@atbegindocument{} |
| 1714 |
% This command will be executed at the begin of the document. If for |
| 1715 |
% whatever reason this is not done, you may wish to execute this |
| 1716 |
% command yourself. It will setup certain specials that need to be |
| 1717 |
% inserted into the resulting .pdf/.ps/.xxx file. |
| 1718 |
|
| 1719 |
|
| 1720 |
% String comparison |
| 1721 |
\ifdefined\pdfstrcmp |
| 1722 |
\let\pgfsys@strcmp\pdfstrcmp |
| 1723 |
\else\ifdefined\strcmp |
| 1724 |
\let\pgfsys@strcmp\strcmp |
| 1725 |
\else\ifdefined\directlua |
| 1726 |
\directlua{ |
| 1727 |
local lft = lua.get_functions_table() |
| 1728 |
lft[\string#lft+1] = function() |
| 1729 |
local lhs = token.scan_string() |
| 1730 |
local rhs = token.scan_string() |
| 1731 |
if lhs < rhs then |
| 1732 |
tex.sprint(-2, "-1") |
| 1733 |
elseif lhs == rhs then |
| 1734 |
tex.sprint(-2, "0") |
| 1735 |
else |
| 1736 |
tex.sprint(-2, "1") |
| 1737 |
end |
| 1738 |
end |
| 1739 |
token.set_lua("pgfsys@strcmp", \string#lft, "global") |
| 1740 |
} |
| 1741 |
\else |
| 1742 |
\def\pgfsys@strcmp#1#2{\pgf@sys@fail{string comparison}}% |
| 1743 |
\fi\fi\fi |
| 1744 |
|
| 1745 |
|
| 1746 |
% Discern the driver: |
| 1747 |
|
| 1748 |
% Default driver: |
| 1749 |
\ifx\pgfsysdriver\@undefined |
| 1750 |
\pgfutil@guessdriver |
| 1751 |
\fi |
| 1752 |
|
| 1753 |
\input pgf.cfg |
| 1754 |
|
| 1755 |
\immediate\write-1{Driver file for pgf: \pgfsysdriver} |
| 1756 |
\pgfutil@InputIfFileExists{\pgfsysdriver}{}{% |
| 1757 |
\pgferror{Driver file ``\pgfsysdriver'' not found.}} |
| 1758 |
|
| 1759 |
|
| 1760 |
|
| 1761 |
% This will insert always-present-specials at the beginning of the |
| 1762 |
% code. |
| 1763 |
\AtBeginDocument{ |
| 1764 |
\pgfsys@atbegindocument |
| 1765 |
\let\pgfsys@atbegindocument=\pgfutil@empty |
| 1766 |
} |
| 1767 |
|
| 1768 |
|
| 1769 |
|
| 1770 |
% Read aux file in plain and context mode: |
| 1771 |
|
| 1772 |
\pgfutil@aux@read@hook |
| 1773 |
|
| 1774 |
|
| 1775 |
\endinput |