| 1 |
% Copyright 2018 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 |
\ProvidesFileRCS{tikzlibraryanimations.code.tex} |
| 11 |
|
| 12 |
\usepgfmodule{animations}% |
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
% Scope syntax extension: |
| 17 |
|
| 18 |
\def\tikz@collect@scope@anims#1{% |
| 19 |
\let\tikz@scope@anims\pgfutil@empty% |
| 20 |
\let\tikz@collect@command#1% |
| 21 |
\tikz@collect@scope@anims@parse% |
| 22 |
}% |
| 23 |
\def\tikz@collect@scope@anims@parse{% |
| 24 |
\pgfutil@ifnextchar[{\tikz@collect@scope@anims@opt}{% |
| 25 |
\pgfutil@ifnextchar:{\tikz@collect@scope@anims@go}{% |
| 26 |
\tikz@collect@scope@anims@done}}%] |
| 27 |
}% |
| 28 |
\def\tikz@collect@scope@anims@done{% |
| 29 |
\expandafter\tikz@collect@command\expandafter[\tikz@scope@anims]% |
| 30 |
}% |
| 31 |
\def\tikz@collect@scope@anims@opt[{%] |
| 32 |
\expandafter\tikz@collect@command\expandafter[\tikz@scope@anims%] |
| 33 |
}% |
| 34 |
\def\tikz@collect@scope@anims@go:#1=#2{% |
| 35 |
\expandafter\def\expandafter\tikz@scope@anims\expandafter{\tikz@scope@anims animate={myself:={:{#1}={#2}}},}% |
| 36 |
\tikz@collect@scope@anims@parse% |
| 37 |
}% |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
% |
| 43 |
% The main keys: |
| 44 |
% |
| 45 |
|
| 46 |
\def\tikzanimateset{\pgfqkeys{/tikz/animate}}% |
| 47 |
\tikzanimateset{ |
| 48 |
.code={ |
| 49 |
\pgfkeys{/handlers/first char syntax=true} |
| 50 |
\pgfkeyssetvalue{/handlers/first char syntax/\expandafter\meaning\string"}{\tikz@animation@value}% |
| 51 |
\def\tikz@anim@t{0}% |
| 52 |
\def\tikz@anim@t@base{0}% |
| 53 |
\def\tikz@anim@t@current{0}% |
| 54 |
\tikzanimateset{#1} |
| 55 |
}, |
| 56 |
scope/.code=\tikz@anim@scope{#1}{}{}, |
| 57 |
sync/.code=\tikz@anim@sync@scope{#1}{}{}, |
| 58 |
entry/.code=\tikz@anim@make@entry, |
| 59 |
object/.code=\tikz@anim@set@object{#1}, |
| 60 |
attribute/.code=\tikz@anim@set@attr{#1}, |
| 61 |
id/.code=\tikz@anim@set@id{#1}, |
| 62 |
time/.code=\tikz@anim@set@time{#1}, |
| 63 |
value/.code=\tikz@anim@add{\tikz@anim@value{#1}},% |
| 64 |
remember/.code=\pgfmathadd@{\tikz@anim@t}{\tikz@anim@t@base}\global\let#1\pgfmathresult, |
| 65 |
resume/.code=\tikz@anim@resume{#1}, |
| 66 |
fork/.code={\tikz@anim@parse@time{#1}\pgfmathadd@\tikz@anim@t\tikz@anim@t@base\let\tikz@anim@t@base\pgfmathresult\def\tikz@anim@t{0}}, |
| 67 |
fork/.default = 0later, |
| 68 |
base/.style={scope={/utils/exec=\let\tikz@animation@time\tikz@anim@base@text,#1,entry}}, |
| 69 |
}% |
| 70 |
|
| 71 |
\tikzset{ |
| 72 |
make snapshot of/.code=\edef\tikz@temp{#1}\ifx\tikz@temp\pgfutil@empty\else\pgfsnapshot{#1}\fi, |
| 73 |
make snapshot after/.code=\edef\tikz@temp{#1}\ifx\tikz@temp\pgfutil@empty\else\pgfsnapshotafter{#1}\fi, |
| 74 |
make snapshot if necessary/.code=\ifpgfsysanimationsupported\else\pgfsnapshot{#1}\fi, |
| 75 |
make snapshot if necessary/.default=0s, |
| 76 |
}% |
| 77 |
|
| 78 |
\def\tikz@anim@scope#1#2#3{% |
| 79 |
{#2\tikzanimateset{#1}#3}% |
| 80 |
}% |
| 81 |
\def\tikz@anim@sync@scope#1#2#3{% |
| 82 |
{% |
| 83 |
#2% |
| 84 |
\tikzanimateset{#1}% |
| 85 |
#3% |
| 86 |
\pgfmathadd@{\tikz@anim@t}{\tikz@anim@t@base}% |
| 87 |
\expandafter% |
| 88 |
}\expandafter\pgfmathsubtract@\expandafter{\pgfmathresult}{\tikz@anim@t@base}% |
| 89 |
\tikz@anim@set@time{\pgfmathresult}% |
| 90 |
}% |
| 91 |
|
| 92 |
\def\tikz@anim@set@time#1{% |
| 93 |
\tikz@anim@parse@time{#1}% |
| 94 |
\let\tikz@anim@t@current\tikz@anim@t% |
| 95 |
\pgfmathadd@\tikz@anim@t\tikz@anim@t@base% |
| 96 |
\let\tikz@animation@time\pgfmathresult% |
| 97 |
}% |
| 98 |
|
| 99 |
\def\tikz@anim@value#1{% |
| 100 |
\def\tikz@anim@result{#1} |
| 101 |
\ifx\tikz@anim@result\pgf@special@current@text% |
| 102 |
\else% |
| 103 |
\ifx\tikz@animation@parser\relax% |
| 104 |
\else% |
| 105 |
\tikz@animation@parser{#1}% |
| 106 |
\fi% |
| 107 |
\fi% |
| 108 |
}% |
| 109 |
|
| 110 |
|
| 111 |
\def\tikz@anim@resume#1{% |
| 112 |
\pgfparsetime{#1}% |
| 113 |
\pgfmathsubtract@{\pgftimeresult}{\tikz@anim@t@base}% |
| 114 |
\tikz@anim@set@time{\pgfmathresult}% |
| 115 |
}% |
| 116 |
|
| 117 |
|
| 118 |
% The object--attribute entries are of the following forms: |
| 119 |
% |
| 120 |
% objects:attributes |
| 121 |
% objects:attributes_id |
| 122 |
% |
| 123 |
|
| 124 |
\def\tikz@animation@syntax@check#1#2{% |
| 125 |
\def\tikz@animation@rest{#1}% |
| 126 |
\expandafter\pgfutil@in@\expandafter:\expandafter{\tikz@key}% |
| 127 |
\ifpgfutil@in@% |
| 128 |
\expandafter\tikz@anim@parse@colon\tikz@key\pgf@stop% |
| 129 |
\else% |
| 130 |
#2% |
| 131 |
\fi% |
| 132 |
}% |
| 133 |
|
| 134 |
\def\tikz@anim@parse@colon#1:#2\pgf@stop{% |
| 135 |
\expandafter\tikz@anim@sync@scope\expandafter{\tikz@animation@rest}{% |
| 136 |
\tikz@anim@set@object{#1}% |
| 137 |
\pgfutil@in@_{#2}% |
| 138 |
\ifpgfutil@in@% |
| 139 |
\tikz@anim@parse@under#2\pgf@stop% |
| 140 |
\else% |
| 141 |
\tikz@anim@parse@under#2_\pgf@stop% |
| 142 |
\fi% |
| 143 |
}{\tikz@anim@make@entry}% |
| 144 |
}% |
| 145 |
|
| 146 |
\def\tikz@anim@parse@under#1_#2\pgf@stop{% |
| 147 |
\tikz@anim@set@attr{#1}% |
| 148 |
\tikz@anim@set@id{#2}% |
| 149 |
}% |
| 150 |
|
| 151 |
\def\tikz@anim@set@attr#1{% |
| 152 |
\pgfkeys@spdef\tikz@anim@a{#1}% |
| 153 |
\ifx\tikz@anim@a\pgfutil@empty% |
| 154 |
\else% |
| 155 |
\let\tikz@anim@tl@attributes\tikz@anim@a% |
| 156 |
\fi% |
| 157 |
}% |
| 158 |
|
| 159 |
\def\tikz@anim@set@id#1{% |
| 160 |
\pgfkeys@spdef\tikz@anim@a{#1}% |
| 161 |
\ifx\tikz@anim@a\pgfutil@empty% |
| 162 |
\else% |
| 163 |
\let\tikz@anim@tl@id\tikz@anim@a% |
| 164 |
\fi% |
| 165 |
}% |
| 166 |
|
| 167 |
\def\tikz@anim@set@object#1{% |
| 168 |
\pgfkeys@spdef\tikz@anim@a{#1}% |
| 169 |
\ifx\tikz@anim@a\pgfutil@empty% |
| 170 |
\else% |
| 171 |
\let\tikz@anim@tl@objects\tikz@anim@a% |
| 172 |
\fi% |
| 173 |
}% |
| 174 |
|
| 175 |
|
| 176 |
% |
| 177 |
% Parsing of values |
| 178 |
% |
| 179 |
|
| 180 |
\def\tikz@animation@value#1{% |
| 181 |
\tikz@animation@value@parser#1\pgf@stop% |
| 182 |
}% |
| 183 |
|
| 184 |
\def\tikz@animation@value@parser"#1"{% |
| 185 |
\def\tikz@animation@value@head{#1}% |
| 186 |
\pgfutil@ifnextchar\pgf@stop{\tikz@animation@value@rest=}{% |
| 187 |
\pgfutil@ifnextchar b\tikz@animation@value@rest@base\tikz@animation@value@rest% |
| 188 |
}% |
| 189 |
}% |
| 190 |
\def\tikz@animation@value@rest=#1\pgf@stop{% |
| 191 |
\tikz@anim@sync@scope{#1}{\expandafter\tikz@anim@add\expandafter{\expandafter\tikz@anim@value\expandafter{\tikz@animation@value@head}}}{\tikz@anim@make@entry}% |
| 192 |
}% |
| 193 |
|
| 194 |
\def\tikz@animation@value@rest@base base{% |
| 195 |
\tikz@anim@sync@scope{}{\let\tikz@animation@time\tikz@anim@base@text\expandafter\tikz@anim@add\expandafter{\expandafter\tikz@anim@value\expandafter{\tikz@animation@value@head}}}{\tikz@anim@make@entry}% |
| 196 |
\pgfutil@ifnextchar\pgf@stop{\tikz@animation@value@rest=}{\tikz@animation@value@rest}% |
| 197 |
}% |
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
% |
| 203 |
% The parsers |
| 204 |
% |
| 205 |
|
| 206 |
\def\tikz@anim@simple@parse#1{} % nothing to do, \def\tikz@anim@result{#1} is already done |
| 207 |
|
| 208 |
\def\tikz@anim@slant@parse#1{\pgfmathsetmacro\tikz@anim@result{atan(#1)}}% |
| 209 |
|
| 210 |
\def\tikz@anim@dashpattern@parse#1{% |
| 211 |
\pgfmathsetmacro\tikz@anim@dash@phase{\tikz@dashphase}% |
| 212 |
\def\tikz@dashpattern{}% |
| 213 |
\expandafter\tikz@scandashon\pgfutil@gobble#1o\@nil% |
| 214 |
\edef\tikz@anim@result{{\tikz@dashpattern}{\tikz@anim@dash@phase pt}}% |
| 215 |
}% |
| 216 |
\def\tikz@anim@dashoffset@parse#1{% |
| 217 |
\pgfmathparse{#1}% |
| 218 |
\edef\tikz@anim@result{{\tikz@dashpattern}{\pgfmathresult pt}}% |
| 219 |
}% |
| 220 |
\def\tikz@anim@dash@parse#1{% |
| 221 |
\tikz@anim@dash@parse@#1\pgf@stop% |
| 222 |
}% |
| 223 |
\def\tikz@anim@dash@parse@#1phase#2\pgf@stop{% |
| 224 |
\pgfmathsetmacro\tikz@anim@dash@phase{#2}% |
| 225 |
\def\tikz@dashpattern{}% |
| 226 |
\expandafter\tikz@scandashon\pgfutil@gobble#1o\@nil% |
| 227 |
\edef\tikz@anim@result{{\tikz@dashpattern}{\tikz@anim@dash@phase pt}}% |
| 228 |
}% |
| 229 |
|
| 230 |
\def\tikz@anim@xshift@parse#1{\pgfmathparse{#1}\edef\tikz@anim@result{\noexpand\pgfqpoint{\pgfmathresult pt}{0pt}}}% |
| 231 |
\def\tikz@anim@yshift@parse#1{\pgfmathparse{#1}\edef\tikz@anim@result{\noexpand\pgfqpoint{0pt}{\pgfmathresult pt}}}% |
| 232 |
|
| 233 |
\def\tikz@anim@xscale@parse#1{\pgfmathparse{#1}\edef\tikz@anim@result{\pgfmathresult,1}}% |
| 234 |
\def\tikz@anim@yscale@parse#1{\pgfmathparse{#1}\edef\tikz@anim@result{1,\pgfmathresult}}% |
| 235 |
|
| 236 |
\def\tikz@anim@shift@parse#1{\tikz@scan@one@point\tikz@anim@do@shift#1}% |
| 237 |
\def\tikz@anim@do@shift#1{\def\tikz@anim@result{#1}}% |
| 238 |
|
| 239 |
\def\tikz@anim@position@parse#1{% |
| 240 |
\begingroup% |
| 241 |
\let\tikz@transform=\relax% |
| 242 |
\pgf@xc-\pgf@pt@x% |
| 243 |
\pgf@yc-\pgf@pt@y% |
| 244 |
\pgfsettransform\tikz@anim@saved@transform% |
| 245 |
\tikz@scan@one@point\tikz@anim@do@position#1}% |
| 246 |
\def\tikz@anim@do@position#1{% |
| 247 |
\pgf@process{\pgfpointtransformed{#1}}% |
| 248 |
\advance\pgf@x by\pgf@xc% |
| 249 |
\advance\pgf@y by\pgf@yc% |
| 250 |
\xdef\tikz@anim@temp{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}% |
| 251 |
\endgroup% |
| 252 |
\let\tikz@anim@result\tikz@anim@temp% |
| 253 |
}% |
| 254 |
|
| 255 |
\def\tikz@anim@view@parse#1{\tikz@anim@view@parse@#1\pgf@stop}% |
| 256 |
\def\tikz@anim@view@parse@{% |
| 257 |
\pgfutil@ifnextchar({\tikz@scan@one@point\tikz@anim@view@parse@a}{\tikz@anim@view@node}% |
| 258 |
}% |
| 259 |
\def\tikz@anim@view@parse@a#1{% |
| 260 |
\def\tikz@anim@result{{#1}}% |
| 261 |
\pgfutil@ifnextchar r{\tikz@anim@view@parsed@rec}{\tikz@scan@one@point\tikz@anim@view@parse@b}% |
| 262 |
}% |
| 263 |
\def\tikz@anim@view@parsed@rec rectangle{\tikz@scan@one@point\tikz@anim@view@parse@b}% |
| 264 |
\def\tikz@anim@view@parse@b#1{% |
| 265 |
\expandafter\def\expandafter\tikz@anim@result\expandafter{\tikz@anim@result{#1}}% |
| 266 |
\pgfutil@ifnextchar\pgf@stop\pgfutil@gobble{\tikzerror{Wrong view syntax}}% |
| 267 |
}% |
| 268 |
\def\tikz@anim@view@node#1\pgf@stop{% |
| 269 |
\expandafter\ifx\csname pgf@sh@ns@#1\endcsname\relax% |
| 270 |
\tikzerror{Undefined node '#1'}% |
| 271 |
\else% |
| 272 |
% Compute a bounding box for the node: |
| 273 |
{% |
| 274 |
\pgf@process{\pgfpointanchor{#1}{west}}% |
| 275 |
\pgf@xa\pgf@x \pgf@ya\pgf@y |
| 276 |
\pgf@xb\pgf@x \pgf@yb\pgf@y |
| 277 |
\pgf@process{\pgfpointanchor{#1}{north}}% |
| 278 |
\ifdim\pgf@x<\pgf@xa \pgf@xa=\pgf@x\fi% |
| 279 |
\ifdim\pgf@x>\pgf@xb \pgf@xb=\pgf@x\fi% |
| 280 |
\ifdim\pgf@y<\pgf@ya \pgf@ya=\pgf@y\fi% |
| 281 |
\ifdim\pgf@y>\pgf@yb \pgf@yb=\pgf@y\fi% |
| 282 |
\pgf@process{\pgfpointanchor{#1}{south}}% |
| 283 |
\ifdim\pgf@x<\pgf@xa \pgf@xa=\pgf@x\fi% |
| 284 |
\ifdim\pgf@x>\pgf@xb \pgf@xb=\pgf@x\fi% |
| 285 |
\ifdim\pgf@y<\pgf@ya \pgf@ya=\pgf@y\fi% |
| 286 |
\ifdim\pgf@y>\pgf@yb \pgf@yb=\pgf@y\fi% |
| 287 |
\pgf@process{\pgfpointanchor{#1}{east}}% |
| 288 |
\ifdim\pgf@x<\pgf@xa \pgf@xa=\pgf@x\fi% |
| 289 |
\ifdim\pgf@x>\pgf@xb \pgf@xb=\pgf@x\fi% |
| 290 |
\ifdim\pgf@y<\pgf@ya \pgf@ya=\pgf@y\fi% |
| 291 |
\ifdim\pgf@y>\pgf@yb \pgf@yb=\pgf@y\fi% |
| 292 |
\xdef\tikz@anim@result{{\noexpand\pgfqpoint{\the\pgf@xa}{\the\pgf@ya}}{\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}}} |
| 293 |
}% |
| 294 |
\fi% |
| 295 |
}% |
| 296 |
|
| 297 |
\def\tikz@anim@path@parse#1{% |
| 298 |
{% |
| 299 |
\setbox0=\hbox{{% protect against side effects |
| 300 |
\pgfinterruptpath% |
| 301 |
\expandafter\tikz@scan@next@command#1\pgf@stop% |
| 302 |
\pgfsyssoftpath@getcurrentpath\tikz@anim@result% |
| 303 |
\pgfprocessround{\tikz@anim@result}{\tikz@anim@result}% |
| 304 |
\global\let\tikz@anim@result\tikz@anim@result% |
| 305 |
\endpgfinterruptpath% |
| 306 |
}}% |
| 307 |
}% |
| 308 |
}% |
| 309 |
|
| 310 |
% The special along parser |
| 311 |
|
| 312 |
|
| 313 |
\def\tikz@anim@along#1#2{% |
| 314 |
% Parse the path... |
| 315 |
{% |
| 316 |
\setbox0=\hbox{{% protect against side effects |
| 317 |
\pgfinterruptpath% |
| 318 |
\pgf@relevantforpicturesizefalse% |
| 319 |
\iftikz@anim@is@position% |
| 320 |
\let\tikz@transform=\relax% |
| 321 |
\pgf@x-\pgf@pt@x% |
| 322 |
\pgf@y-\pgf@pt@y% |
| 323 |
\edef\tikz@anim@along@shift{\pgf@xc\the\pgf@x\pgf@yc\the\pgf@y}% |
| 324 |
\pgfsettransformentries#1% |
| 325 |
\else% |
| 326 |
\pgftransformreset% |
| 327 |
\fi |
| 328 |
\tikz@scan@next@command#2\pgf@stop% |
| 329 |
\pgfsyssoftpath@getcurrentpath\tikz@anim@parsed@path% |
| 330 |
\pgfprocessround{\tikz@anim@parsed@path}{\tikz@anim@parsed@path}% |
| 331 |
\iftikz@anim@is@position% |
| 332 |
\tikz@anim@shift@path% |
| 333 |
\global\let\tikz@anim@parsed@path\tikz@anim@patched@path% |
| 334 |
\else% |
| 335 |
\global\let\tikz@anim@parsed@path\tikz@anim@parsed@path% |
| 336 |
\fi% |
| 337 |
\endpgfinterruptpath% |
| 338 |
}}% |
| 339 |
}% |
| 340 |
\pgfanimationset{along softpath/.expand once=\tikz@anim@parsed@path}% |
| 341 |
}% |
| 342 |
|
| 343 |
\def\tikz@anim@shift@path{% |
| 344 |
\let\tikz@anim@patched@path\pgfutil@empty% |
| 345 |
\tikz@anim@along@shift% |
| 346 |
\expandafter\tikz@anim@shift@path@\tikz@anim@parsed@path\pgf@stop% |
| 347 |
}% |
| 348 |
\def\tikz@anim@shift@path@{% |
| 349 |
\pgfutil@ifnextchar\pgf@stop\pgfutil@gobble{% |
| 350 |
\pgfutil@ifnextchar\bgroup\tikz@anim@shift@path@sub\tikz@anim@shift@path@copy}% |
| 351 |
}% |
| 352 |
\def\tikz@anim@shift@path@copy#1{% |
| 353 |
\expandafter\def\expandafter\tikz@anim@patched@path\expandafter{\tikz@anim@patched@path#1}% |
| 354 |
\tikz@anim@shift@path@% |
| 355 |
}% |
| 356 |
\def\tikz@anim@shift@path@sub#1#2{% |
| 357 |
\pgf@x#1% |
| 358 |
\pgf@y#2% |
| 359 |
\advance\pgf@x by\pgf@xc% |
| 360 |
\advance\pgf@y by\pgf@yc% |
| 361 |
\edef\tikz@temp{{\the\pgf@x}{\the\pgf@y}}% |
| 362 |
\expandafter\tikz@anim@shift@path@copy\expandafter{\tikz@temp}% |
| 363 |
}% |
| 364 |
|
| 365 |
|
| 366 |
|
| 367 |
\def\tikz@anim@parse@origin#1{% |
| 368 |
\tikz@scan@one@point\tikz@anim@parse@origin@#1\relax% |
| 369 |
}% |
| 370 |
\def\tikz@anim@parse@origin@#1{\tikz@anim@add{\pgfanimationset{origin={#1}}}}% |
| 371 |
|
| 372 |
|
| 373 |
% Internals |
| 374 |
|
| 375 |
\def\tikz@anim@tl@objects{}% |
| 376 |
\def\tikz@anim@tl@attributes{}% |
| 377 |
\def\tikz@anim@tl@id{default}% |
| 378 |
|
| 379 |
\let\tikz@anim@tl@exec@options\pgfutil@empty |
| 380 |
\let\tikz@anim@tl@early@options\pgfutil@empty |
| 381 |
|
| 382 |
\def\tikz@anim@add@early#1{\expandafter\def\expandafter\tikz@anim@tl@early@options\expandafter{\tikz@anim@tl@early@options#1}}% |
| 383 |
\def\tikz@anim@add@once@early#1{% |
| 384 |
\global\advance\tikz@anim@once@count by1\relax% |
| 385 |
\expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter\tikz@anim@tl@early@options% |
| 386 |
\expandafter\expandafter\expandafter{\expandafter\tikz@anim@tl@early@options\expandafter\tikz@anim@exec@once\expandafter{\the\tikz@anim@once@count}{#1}}% |
| 387 |
}% |
| 388 |
\def\tikz@anim@add#1{\expandafter\def\expandafter\tikz@anim@tl@exec@options\expandafter{\tikz@anim@tl@exec@options#1}}% |
| 389 |
\def\tikz@anim@add@once#1{% |
| 390 |
\global\advance\tikz@anim@once@count by1\relax% |
| 391 |
\expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter\tikz@anim@tl@exec@options% |
| 392 |
\expandafter\expandafter\expandafter{\expandafter\tikz@anim@tl@exec@options\expandafter\tikz@anim@exec@once\expandafter{\the\tikz@anim@once@count}{#1}}% |
| 393 |
}% |
| 394 |
\newcount\tikz@anim@once@count% |
| 395 |
\def\tikz@anim@exec@once#1#2{% |
| 396 |
\expandafter\ifx\csname tikz@anim@once@#1\endcsname\pgf@stop% |
| 397 |
\else% |
| 398 |
\expandafter\let\csname tikz@anim@once@#1\endcsname\pgf@stop% |
| 399 |
#2% |
| 400 |
\fi% |
| 401 |
}% |
| 402 |
|
| 403 |
\newif\iftikz@anim@do@entry |
| 404 |
|
| 405 |
\def\tikz@anim@make@entry{% |
| 406 |
\tikz@anim@do@entrytrue% |
| 407 |
\ifx\tikz@anim@tl@objects\pgfutil@empty\tikz@anim@do@entryfalse\fi% |
| 408 |
\ifx\tikz@anim@tl@attributes\pgfutil@empty\tikz@anim@do@entryfalse\fi% |
| 409 |
\ifx\tikz@anim@tl@exec@options\pgfutil@empty\ifx\tikz@anim@tl@early@options\pgfutil@empty\tikz@anim@do@entryfalse\fi\fi% |
| 410 |
\iftikz@anim@do@entry% |
| 411 |
\foreach\tikz@anim@tl@object in\tikz@anim@tl@objects{% |
| 412 |
\expandafter\tikzanimationattributesset\expandafter{\tikz@anim@tl@attributes}% |
| 413 |
}% |
| 414 |
\fi% |
| 415 |
}% |
| 416 |
|
| 417 |
\def\tikzanimationattributesset#1{\pgfqkeys{/tikz/animate/attributes}{#1}}% |
| 418 |
|
| 419 |
\tikzanimationattributesset{ |
| 420 |
.unknown/.code={ |
| 421 |
\let\tikz@anim@attribute@name\pgfkeyscurrentname |
| 422 |
\expandafter\let\expandafter\pgf@temp\csname tikz@anim@def@pgf@attr@\tikz@anim@attribute@name\endcsname% |
| 423 |
\ifx\pgf@temp\relax% |
| 424 |
\tikzerror{Unknown animation attribute '\tikz@anim@attribute@name'}% |
| 425 |
\else% |
| 426 |
\expandafter\tikz@timeline@config\expandafter\tikz@anim@tl@object\expandafter\tikz@anim@attribute@name\expandafter\tikz@anim@tl@id\expandafter{\tikz@anim@configs}% |
| 427 |
\edef\pgf@marshal{\noexpand\tikz@timeline@entry{\tikz@anim@tl@object}{\tikz@anim@attribute@name}{\tikz@anim@tl@id}}% |
| 428 |
\expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter\pgf@marshal\expandafter\expandafter\expandafter{\expandafter\pgf@marshal\expandafter{\tikz@anim@tl@early@options}}% |
| 429 |
\expandafter\expandafter\expandafter\pgf@marshal\expandafter\expandafter\expandafter{\expandafter\expandafter\expandafter\tikz@anim@entry\expandafter\expandafter\expandafter{\expandafter\tikz@anim@tl@exec@options\expandafter\def\expandafter\tikz@animation@time\expandafter{\tikz@animation@time}}}% |
| 430 |
\fi% |
| 431 |
} |
| 432 |
}% |
| 433 |
\let\tikz@anim@configs\pgfutil@empty |
| 434 |
|
| 435 |
\def\tikz@anim@entry#1{% |
| 436 |
% Reset splines and value: |
| 437 |
\let\tikz@anim@result\pgfutil@empty% |
| 438 |
\pgf@anim@reset@linear% |
| 439 |
#1% |
| 440 |
\ifx\tikz@anim@result\pgfutil@empty% |
| 441 |
\else% |
| 442 |
\ifx\tikz@animation@time\pgfutil@empty% |
| 443 |
\else% |
| 444 |
\ifx\tikz@animation@time\tikz@anim@base@text% |
| 445 |
\expandafter\pgf@anim@base\expandafter{\tikz@anim@result}% |
| 446 |
\else% |
| 447 |
\expandafter\expandafter\expandafter\pgf@anim@entry% |
| 448 |
\expandafter\expandafter\expandafter{\expandafter\tikz@animation@time\expandafter}\expandafter{\tikz@anim@result}% |
| 449 |
\fi% |
| 450 |
\fi% |
| 451 |
\fi% |
| 452 |
}% |
| 453 |
\let\tikz@animation@time\pgfutil@empty% |
| 454 |
\def\tikz@anim@base@text{base}% |
| 455 |
|
| 456 |
\tikzanimateset{ |
| 457 |
.unknown/.code={% |
| 458 |
\let\tikz@key\pgfkeyscurrentname% |
| 459 |
\tikz@animation@syntax@check{#1}{\tikz@anim@options{#1}}% |
| 460 |
} |
| 461 |
}% |
| 462 |
|
| 463 |
|
| 464 |
\def\tikz@anim@options#1{ |
| 465 |
\let\tikz@anim@key\pgfkeyscurrentname% |
| 466 |
\pgfqkeys{/tikz/animate/options}{\tikz@anim@key/.try={#1}}% |
| 467 |
\ifpgfkeyssuccess% |
| 468 |
\else% |
| 469 |
\def\tikz@anim@unparsed@value{#1}% |
| 470 |
\expandafter\tikz@anim@time@test\tikz@anim@key\pgf@stop% |
| 471 |
\fi% |
| 472 |
}% |
| 473 |
|
| 474 |
\tikzanimateset{ |
| 475 |
options/.cd, |
| 476 |
name/.code=\tikz@anim@add{\pgfanimationset{name={#1}}}, |
| 477 |
forever/.code=\tikz@anim@add{\pgfanimationset{freeze at end}}, |
| 478 |
freeze/.code=\tikz@anim@add{\pgfanimationset{freeze at end}}, |
| 479 |
restart/.code=\tikz@anim@add{\pgfanimationset{restart={#1}}}, |
| 480 |
repeats/.code=\tikz@anim@add{\pgfanimationset{repeats={#1}}}, |
| 481 |
repeats/.default=, |
| 482 |
repeat/.code=\tikz@anim@add{\pgfanimationset{repeats={#1}}}, |
| 483 |
repeat/.default=, |
| 484 |
begin/.code=\tikz@anim@add@once{\pgfanimationset{begin={#1}}}, |
| 485 |
end/.code=\tikz@anim@add@once{\pgfanimationset{end={#1}}}, |
| 486 |
begin on/.code=\tikz@anim@event{begin}{#1}, |
| 487 |
end on/.code=\tikz@anim@event{end}{#1}, |
| 488 |
begin snapshot/.code=\tikz@anim@add{\pgfanimationset{begin snapshot={#1}}}, |
| 489 |
origin/.code=\tikz@anim@parse@origin{#1}, |
| 490 |
transform/.code=\tikz@anim@add{\pgfanimationset{transform={\let\tikz@transform\relax\tikzset{#1}}}}, |
| 491 |
along/.code=\tikz@anim@handle@along#1\pgf@stop, |
| 492 |
entry control/.code=\tikz@anim@add{\pgfanimationset{entry control={#1}}}, |
| 493 |
exit control/.code=\tikz@anim@add{\pgfanimationset{exit control={#1}}}, |
| 494 |
stay/.code=\tikz@anim@add{\pgfanimationset{stay}}, |
| 495 |
jump/.code=\tikz@anim@add{\pgfanimationset{jump}}, |
| 496 |
ease/.style={ |
| 497 |
entry control={1-(#1)}{1}, |
| 498 |
exit control={#1}{0} |
| 499 |
}, |
| 500 |
ease/.default=0.5, |
| 501 |
ease in/.style={ |
| 502 |
entry control={1-(#1)}{1}, |
| 503 |
}, |
| 504 |
ease in/.default=0.5, |
| 505 |
ease out/.style={ |
| 506 |
exit control={#1}{0}, |
| 507 |
}, |
| 508 |
ease out/.default=0.5, |
| 509 |
arrows/.code=\tikz@anim@add@early{\pgfanimationset{arrows={#1}}}, |
| 510 |
shorten >/.code=\tikz@anim@add@early{\pgfanimationset{shorten >={#1}}}, |
| 511 |
shorten </.code=\tikz@anim@add@early{\pgfanimationset{snorten <={#1}}}, |
| 512 |
}% |
| 513 |
\newif\iftikz@anim@along |
| 514 |
|
| 515 |
\def\tikz@anim@t{0}% |
| 516 |
|
| 517 |
\def\tikz@anim@handle@along#1{% |
| 518 |
\pgfutil@ifnextchar s{\tikz@anim@handle@sloped{#1}}{\tikz@anim@handle@upright{#1}}% |
| 519 |
}% |
| 520 |
\def\tikz@anim@handle@sloped#1sloped{% |
| 521 |
\pgfgettransform\tikz@anim@trans@pre% |
| 522 |
\expandafter\tikz@anim@add@once% |
| 523 |
\expandafter{% |
| 524 |
\expandafter\tikz@anim@along\expandafter{\tikz@anim@trans@pre}{#1}% |
| 525 |
\pgfsysanimkeycanvastransform{% |
| 526 |
\pgf@xc\pgf@pt@x% |
| 527 |
\pgf@yc\pgf@pt@y% |
| 528 |
\pgftransformreset% |
| 529 |
\pgf@pt@x\pgf@xc% |
| 530 |
\pgf@pt@y\pgf@yc% |
| 531 |
{\pgflowlevelsynccm}% |
| 532 |
}{\pgftransforminvert\pgflowlevelsynccm}% |
| 533 |
\pgfanimationset{rotate along=true}% |
| 534 |
}% |
| 535 |
\def\tikz@anim@configs{\tikz@anim@alongtrue}% |
| 536 |
\tikz@anim@handle@in% |
| 537 |
}% |
| 538 |
\def\tikz@anim@handle@upright#1upright{% |
| 539 |
\pgfgettransform\tikz@anim@trans@pre% |
| 540 |
\expandafter\tikz@anim@add@once% |
| 541 |
\expandafter{% |
| 542 |
\expandafter\tikz@anim@along\expandafter{\tikz@anim@trans@pre}{#1}% |
| 543 |
\pgfsysanimkeycanvastransform{}{}% |
| 544 |
}% |
| 545 |
\def\tikz@anim@configs{\tikz@anim@alongtrue}% |
| 546 |
\tikz@anim@handle@in% |
| 547 |
}% |
| 548 |
\def\tikz@anim@handle@in{% |
| 549 |
\pgfutil@ifnextchar i{\tikz@anim@handle@in@yes}{\tikz@anim@handle@in@no}% |
| 550 |
}% |
| 551 |
\def\tikz@anim@handle@in@no\pgf@stop{}% |
| 552 |
\def\tikz@anim@handle@in@yes in#1\pgf@stop{% |
| 553 |
\tikzanimateset{scope={time=0,value=0,entry,time=#1,value=1,entry}}% |
| 554 |
}% |
| 555 |
|
| 556 |
|
| 557 |
|
| 558 |
\def\tikz@anim@event#1#2{% |
| 559 |
{% |
| 560 |
% evaluate #2 once to determine the id now |
| 561 |
\let\pgf@anim@id\pgfutil@empty% |
| 562 |
\pgfqkeys{/pgf/animation/events}{#2}% |
| 563 |
\expandafter}% |
| 564 |
\expandafter\def\expandafter\tikz@anim@temp@id\expandafter{\pgf@anim@id}% |
| 565 |
\ifx\tikz@anim@temp@id\pgfutil@empty% |
| 566 |
\def\tikz@temp{#1 on={of id=\tikz@anim@current@id,#2}}% |
| 567 |
\else |
| 568 |
\expandafter\tikz@anim@event@setter\expandafter{\tikz@anim@temp@id}{#1}{#2}% |
| 569 |
\fi% |
| 570 |
\expandafter\tikz@anim@add@once\expandafter{\expandafter\pgfanimationset\expandafter{\tikz@temp}}% |
| 571 |
}% |
| 572 |
\def\tikz@anim@event@setter#1#2#3{% |
| 573 |
\def\tikz@temp{#2 on={#3,of id=#1}}% |
| 574 |
}% |
| 575 |
|
| 576 |
\def\tikz@anim@time@test#1#2\pgf@stop{% |
| 577 |
\edef\tikz@temp{\meaning#1}% |
| 578 |
\expandafter\ifx\csname tikz@anim@test@\tikz@temp\endcsname\relax% |
| 579 |
\tikzerror{I do not know the timing key '#1#2' to which you passed '\tikz@anim@unparsed@value'}% |
| 580 |
\else% |
| 581 |
\expandafter\tikz@anim@sync@scope\expandafter{\tikz@anim@unparsed@value}{\tikz@anim@set@time{#1#2}}{\tikz@anim@make@entry}% |
| 582 |
\fi% |
| 583 |
}% |
| 584 |
|
| 585 |
\def\tikz@anim@parse@time#1{% |
| 586 |
\pgfutil@in@{later\pgf@stop}{#1\pgf@stop}% |
| 587 |
\ifpgfutil@in@% |
| 588 |
\tikz@anim@parse@later#1\pgf@stop% |
| 589 |
\else% |
| 590 |
\pgfparsetime{#1}\let\tikz@anim@t\pgftimeresult% |
| 591 |
\fi% |
| 592 |
}% |
| 593 |
\def\tikz@anim@parse@later#1later\pgf@stop{% |
| 594 |
\pgfparsetime{#1+\tikz@anim@t@current}\let\tikz@anim@t\pgftimeresult% |
| 595 |
}% |
| 596 |
|
| 597 |
\expandafter\let\csname tikz@anim@test@the character 0\endcsname\pgfutil@empty |
| 598 |
\expandafter\let\csname tikz@anim@test@the character 1\endcsname\pgfutil@empty |
| 599 |
\expandafter\let\csname tikz@anim@test@the character 2\endcsname\pgfutil@empty |
| 600 |
\expandafter\let\csname tikz@anim@test@the character 3\endcsname\pgfutil@empty |
| 601 |
\expandafter\let\csname tikz@anim@test@the character 4\endcsname\pgfutil@empty |
| 602 |
\expandafter\let\csname tikz@anim@test@the character 5\endcsname\pgfutil@empty |
| 603 |
\expandafter\let\csname tikz@anim@test@the character 6\endcsname\pgfutil@empty |
| 604 |
\expandafter\let\csname tikz@anim@test@the character 7\endcsname\pgfutil@empty |
| 605 |
\expandafter\let\csname tikz@anim@test@the character 8\endcsname\pgfutil@empty |
| 606 |
\expandafter\let\csname tikz@anim@test@the character 9\endcsname\pgfutil@empty |
| 607 |
\expandafter\let\csname tikz@anim@test@the character -\endcsname\pgfutil@empty |
| 608 |
\expandafter\let\csname tikz@anim@test@the character +\endcsname\pgfutil@empty |
| 609 |
\expandafter\let\csname tikz@anim@test@the character .\endcsname\pgfutil@empty |
| 610 |
\expandafter\let\csname tikz@anim@test@the character (\endcsname\pgfutil@empty |
| 611 |
|
| 612 |
|
| 613 |
|
| 614 |
|
| 615 |
|
| 616 |
% Configure an animation attribute |
| 617 |
% |
| 618 |
% #1 = tikz attribute name |
| 619 |
% #2 = configuration |
| 620 |
% |
| 621 |
% Description: |
| 622 |
% |
| 623 |
% Sets up internals for the tikz attribute. |
| 624 |
|
| 625 |
\def\tikzanimationdefineattribute#1#2{% |
| 626 |
\expandafter\def\csname tikz@anim@def@pgf@attr@#1\endcsname{#1}% |
| 627 |
\expandafter\let\csname tikz@anim@def@no@node@#1\endcsname\pgfutil@empty |
| 628 |
\expandafter\let\csname tikz@anim@def@is@node@#1\endcsname\pgfutil@empty |
| 629 |
\expandafter\let\csname tikz@anim@def@code@#1\endcsname\pgfutil@empty |
| 630 |
\expandafter\let\csname tikz@anim@def@parser@#1\endcsname\tikz@anim@simple@parse |
| 631 |
\def\tikz@anim@attr{#1}% |
| 632 |
\pgfkeys{/tikz/animate/@attrdef/.cd,#2}% |
| 633 |
}% |
| 634 |
|
| 635 |
\pgfkeys{/tikz/animate/@attrdef/.cd, |
| 636 |
pgf attribute name/.code=\expandafter\def\csname tikz@anim@def@pgf@attr@\tikz@anim@attr\endcsname{#1}, |
| 637 |
pgf attribute name scope/.code=\expandafter\def\csname tikz@anim@def@pgf@attr@@scope@\tikz@anim@attr\endcsname{#1}, |
| 638 |
pgf attribute name node/.code=\expandafter\def\csname tikz@anim@def@pgf@attr@@node@\tikz@anim@attr\endcsname{#1}, |
| 639 |
scope type/.code=\expandafter\def\csname tikz@anim@def@no@node@\tikz@anim@attr\endcsname{#1}, |
| 640 |
node type/.code=\expandafter\def\csname tikz@anim@def@is@node@\tikz@anim@attr\endcsname{#1}, |
| 641 |
code/.code=\expandafter\def\csname tikz@anim@def@code@\tikz@anim@attr\endcsname{#1}, |
| 642 |
setup/.code=\expandafter\def\csname tikz@anim@def@setup@\tikz@anim@attr\endcsname{#1}, |
| 643 |
parser/.code=\expandafter\def\csname tikz@anim@def@parser@\tikz@anim@attr\endcsname{#1}, |
| 644 |
}% |
| 645 |
|
| 646 |
|
| 647 |
% Configure an animation attribute list |
| 648 |
% |
| 649 |
% #1 = tikz attribute list name |
| 650 |
% #2 = list of tikz attributes |
| 651 |
% |
| 652 |
% Description: |
| 653 |
% |
| 654 |
% Sets up internals for the tikz attribute. |
| 655 |
|
| 656 |
\def\tikzanimationdefineattributelist#1#2{% |
| 657 |
\tikzanimationattributesset{#1/.style={#2}}% |
| 658 |
}% |
| 659 |
|
| 660 |
|
| 661 |
|
| 662 |
|
| 663 |
% Definition of the tikz attributes |
| 664 |
|
| 665 |
|
| 666 |
\tikzanimationdefineattributelist{color}{@color,text}% |
| 667 |
\tikzanimationdefineattribute{@color}{pgf attribute name=color,node type=.background}% |
| 668 |
\tikzanimationdefineattribute{dash pattern}{pgf attribute name=dash,parser=dashpattern, node type=.background}% |
| 669 |
\tikzanimationdefineattribute{dash phase}{pgf attribute name=dash,parser=dashoffset, node type=.background}% |
| 670 |
\tikzanimationdefineattribute{dash}{parser=dash, node type=.background}% |
| 671 |
\tikzanimationdefineattribute{draw opacity}{pgf attribute name=stroke opacity}% |
| 672 |
\tikzanimationdefineattribute{draw}{pgf attribute name=stroke, node type=.background}% |
| 673 |
\tikzanimationdefineattribute{fill opacity}{}% |
| 674 |
\tikzanimationdefineattribute{fill}{node type=.background}% |
| 675 |
\tikzanimationdefineattribute{line width}{node type=.background}% |
| 676 |
\tikzanimationdefineattribute{path}{pgf attribute name=softpath, scope type=.path, node type=.background.path, parser=path}% |
| 677 |
\tikzanimationdefineattribute{opacity}{}% |
| 678 |
\tikzanimationdefineattribute{position}{% |
| 679 |
pgf attribute name=\iftikz@anim@along motion\else translate\fi, |
| 680 |
parser=\iftikz@anim@along simple\else position\fi, |
| 681 |
setup=\tikz@anim@position@setup, |
| 682 |
}% |
| 683 |
\tikzanimationdefineattribute{rotate}{}% |
| 684 |
\tikzanimationdefineattribute{scale}{}% |
| 685 |
\tikzanimationdefineattribute{shift}{ |
| 686 |
pgf attribute name=\iftikz@anim@along motion\else translate\fi, |
| 687 |
parser=\iftikz@anim@along simple\else shift\fi |
| 688 |
}% |
| 689 |
\tikzanimationdefineattribute{stage}{}% |
| 690 |
\tikzanimationdefineattribute{text opacity}{pgf attribute name=fill opacity, node type=.text, pgf attribute name scope=none}% |
| 691 |
\tikzanimationdefineattribute{text}{pgf attribute name=color, node type=.text, pgf attribute name scope=none}% |
| 692 |
\tikzanimationdefineattribute{view}{scope type=.view, parser=view}% |
| 693 |
\tikzanimationdefineattribute{visible}{}% |
| 694 |
\tikzanimationdefineattribute{xshift}{pgf attribute name=translate, parser=xshift}% |
| 695 |
\tikzanimationdefineattribute{xscale}{pgf attribute name=scale, parser=xscale}% |
| 696 |
\tikzanimationdefineattribute{xskew}{}% |
| 697 |
\tikzanimationdefineattribute{xslant}{pgf attribute name=xskew, parser=slant}% |
| 698 |
\tikzanimationdefineattribute{yshift}{pgf attribute name=translate, parser=yshift}% |
| 699 |
\tikzanimationdefineattribute{yskew}{}% |
| 700 |
\tikzanimationdefineattribute{yslant}{pgf attribute name=yskew, parser=slant}% |
| 701 |
\tikzanimationdefineattribute{yscale}{pgf attribute name=scale, parser=yscale}% |
| 702 |
|
| 703 |
|
| 704 |
\def\tikz@anim@position@setup{% |
| 705 |
\pgfgettransform\tikz@anim@saved@transform% |
| 706 |
\expandafter\def\expandafter\tikz@temp\expandafter{% |
| 707 |
\expandafter\def\expandafter\tikz@anim@saved@transform\expandafter{\tikz@anim@saved@transform}% |
| 708 |
\pgfsysanimkeycanvastransform{}{}% |
| 709 |
\tikz@anim@is@positiontrue% |
| 710 |
}% |
| 711 |
\expandafter\expandafter\expandafter\def% |
| 712 |
\expandafter\expandafter\expandafter\tikz@anim@initial@options% |
| 713 |
\expandafter\expandafter\expandafter{\expandafter\tikz@temp\tikz@anim@initial@options}% |
| 714 |
}% |
| 715 |
\newif\iftikz@anim@is@position |
| 716 |
|
| 717 |
|
| 718 |
% The TikZ animation callbacks |
| 719 |
% |
| 720 |
% Description: |
| 721 |
% |
| 722 |
% The callbacks called by tikz.code.tex whenever an object is |
| 723 |
% created. These callbacks will add the accumulated animation code. |
| 724 |
|
| 725 |
\def\tikz@anim@id@hook{% |
| 726 |
\expandafter\ifx\csname tikz@anim@att@\tikz@id@name\endcsname\relax% |
| 727 |
% No named animation: |
| 728 |
% Now, check for auto animation: |
| 729 |
\expandafter\ifx\csname tikz@anim@att@\tikz@auto@id\endcsname\relax% |
| 730 |
\else% |
| 731 |
% Auto animation% |
| 732 |
\ifx\tikz@id@name\pgfutil@empty% Id set? |
| 733 |
% No, so set it |
| 734 |
\def\tikz@id@name{@auto}% |
| 735 |
\fi% |
| 736 |
\pgfidrefnextuse\tikz@anim@current@id\tikz@id@name% |
| 737 |
\csname tikz@anim@att@\tikz@auto@id\endcsname% |
| 738 |
\expandafter\global\expandafter\let\csname tikz@anim@att@\tikz@auto@id\endcsname\relax% |
| 739 |
\fi% |
| 740 |
\else% |
| 741 |
% Named animation: |
| 742 |
\pgfidrefnextuse\tikz@anim@current@id\tikz@id@name% |
| 743 |
\csname tikz@anim@att@\tikz@id@name\endcsname% |
| 744 |
\csname tikz@anim@att@\tikz@auto@id\endcsname% and unnamed animation |
| 745 |
\expandafter\global\expandafter\let\csname tikz@anim@att@\tikz@id@name\endcsname\relax% |
| 746 |
\expandafter\global\expandafter\let\csname tikz@anim@att@\tikz@auto@id\endcsname\relax% |
| 747 |
\fi% |
| 748 |
}% |
| 749 |
|
| 750 |
% Add hook: |
| 751 |
\expandafter\def\expandafter\tikz@id@hook\expandafter{\tikz@id@hook\tikz@anim@id@hook}% |
| 752 |
|
| 753 |
|
| 754 |
|
| 755 |
% Attaches an animation to a named object (named in tikz) |
| 756 |
% |
| 757 |
% #1 = name of the object. If equal to the special text "myself", the |
| 758 |
% next created object is meant. |
| 759 |
% #2 = Animation code. When this code is executed, the following |
| 760 |
% things will be setup: |
| 761 |
% |
| 762 |
% \iftikz@is@node will be set to true or false |
| 763 |
% depending on whether the name references a node. |
| 764 |
% |
| 765 |
% \tikz@id@name will be set to the name of the object, |
| 766 |
% typically #1, except when #1 was ".", in this case another |
| 767 |
% name may have been used by the user, which will be used |
| 768 |
% instead. |
| 769 |
% |
| 770 |
% Description: |
| 771 |
% |
| 772 |
% After the call, the next time an object named #1 is created in TikZ |
| 773 |
% (using name=#1), the code #2 will be executed inside a scope to |
| 774 |
% create an animation of the object. |
| 775 |
|
| 776 |
\def\tikzanimationattachto#1#2{% |
| 777 |
{% |
| 778 |
\def\tikz@anim@name{#1}% |
| 779 |
\ifx\tikz@anim@name\pgfutil@empty% |
| 780 |
\tikzerror{Trying to attach an animation to an unnamed object. This should not happen.}% |
| 781 |
\else% |
| 782 |
\expandafter\ifx\csname tikz@anim@att@\tikz@anim@name\endcsname\relax% |
| 783 |
\expandafter\gdef\csname tikz@anim@att@\tikz@anim@name\endcsname{#2}% |
| 784 |
\else% |
| 785 |
\expandafter\let\expandafter\tikz@temp\csname tikz@anim@att@\tikz@anim@name\endcsname% |
| 786 |
\expandafter\def\expandafter\tikz@temp\expandafter{\tikz@temp#2}% |
| 787 |
\expandafter\global\expandafter\let\csname tikz@anim@att@\tikz@anim@name\endcsname\tikz@temp% |
| 788 |
\fi% |
| 789 |
\fi% |
| 790 |
}% |
| 791 |
}% |
| 792 |
\def\tikz@auto@id{myself}% |
| 793 |
\expandafter\let\csname tikz@anim@att@\tikz@auto@id\endcsname\relax% |
| 794 |
|
| 795 |
|
| 796 |
% Add config code to a timeline |
| 797 |
% |
| 798 |
% #1 = The object (may be "myself") |
| 799 |
% #2 = The attribute (see pgfanimateattribute) |
| 800 |
% #3 = Timeline sequence identifier |
| 801 |
% #4 = code |
| 802 |
% |
| 803 |
% Description: |
| 804 |
% |
| 805 |
% This commands adds the code to the timeline configuration, which is |
| 806 |
% code that gets executed before the rest of entries of the timeline |
| 807 |
% are executed. |
| 808 |
|
| 809 |
\def\tikz@timeline@config#1#2#3#4{% |
| 810 |
\expandafter\def\expandafter\tikz@temp\expandafter{\csname tikz@a@conf@#1@#2@#3\endcsname}% |
| 811 |
\expandafter\ifx\tikz@temp\relax% |
| 812 |
\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\gdef\expandafter\expandafter\expandafter\tikz@temp\expandafter\expandafter\expandafter{\expandafter\expandafter\expandafter\global\expandafter\let\tikz@temp\relax}% |
| 813 |
\fi% |
| 814 |
\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\gdef\expandafter\expandafter\expandafter\tikz@temp\expandafter\expandafter\expandafter{\tikz@temp#4}% |
| 815 |
}% |
| 816 |
|
| 817 |
|
| 818 |
|
| 819 |
% Add a timeline entry |
| 820 |
% |
| 821 |
% #1 = The object (may be "myself") |
| 822 |
% #2 = The attribute (see pgfanimateattribute) |
| 823 |
% #3 = Timeline sequence identifier |
| 824 |
% #4 = early code |
| 825 |
% #5 = later code |
| 826 |
% |
| 827 |
% Description: |
| 828 |
% |
| 829 |
% This command stores an option with a timeline of an object. For each |
| 830 |
% object--attribute--identifier tuple a timeline can be created, for |
| 831 |
% which the values of #4 and #5 are collected. Later on, \pgfanimateattribute |
| 832 |
% will be called for the pgf attribute associated with tikz attribute, |
| 833 |
% the type associated with it and initial code, followed by the |
| 834 |
% accumulated values of #4 and then the accumulated values of #5. |
| 835 |
|
| 836 |
\def\tikz@timeline@entry#1#2#3#4#5{% |
| 837 |
% First, does the object have an animation already attached? |
| 838 |
\expandafter\ifx\csname tikz@a@tlo@#1\endcsname\relax% |
| 839 |
% No, first entry! |
| 840 |
% Create call: |
| 841 |
\edef\pgf@marshal{\noexpand\tikzanimationattachto{#1}{\expandafter\noexpand\csname tikz@a@tlo@#1\endcsname}}% |
| 842 |
\pgf@marshal% |
| 843 |
\expandafter\gdef\csname tikz@a@tlo@#1\endcsname{\tikz@anim@cleanup{#1}}% |
| 844 |
\fi% |
| 845 |
% Second, does the timeline exist? |
| 846 |
\expandafter\ifx\csname tikz@a@tlc@#1@#2@#3\endcsname\relax% |
| 847 |
% No, first entry! |
| 848 |
\def\tikz@anim@initial@early@options{#4}% |
| 849 |
\def\tikz@anim@initial@options{#5}% |
| 850 |
\csname tikz@anim@def@setup@#2\endcsname% |
| 851 |
% Create timeline... |
| 852 |
\expandafter\global\expandafter\let\csname tikz@a@tlc@#1@#2@#3\endcsname\tikz@anim@initial@options% |
| 853 |
\expandafter\global\expandafter\let\csname tikz@a@tld@#1@#2@#3\endcsname\tikz@anim@initial@early@options% |
| 854 |
% ...and add to calls |
| 855 |
\expandafter\let\expandafter\pgf@temp\csname tikz@a@tlo@#1\endcsname% |
| 856 |
\expandafter\def\expandafter\pgf@temp@name\expandafter{\tikz@anim@create{#1}{#2}{#3}}% |
| 857 |
\expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter\pgf@temp\expandafter\expandafter\expandafter{\expandafter\pgf@temp\pgf@temp@name}% |
| 858 |
\expandafter\global\expandafter\let\csname tikz@a@tlo@#1\endcsname\pgf@temp% |
| 859 |
\else% |
| 860 |
% Add to timeline: |
| 861 |
\expandafter\let\expandafter\pgf@temp\csname tikz@a@tld@#1@#2@#3\endcsname% |
| 862 |
\expandafter\def\expandafter\pgf@temp\expandafter{\pgf@temp#4}% |
| 863 |
\expandafter\global\expandafter\let\csname tikz@a@tld@#1@#2@#3\endcsname\pgf@temp% |
| 864 |
\expandafter\let\expandafter\pgf@temp\csname tikz@a@tlc@#1@#2@#3\endcsname% |
| 865 |
\expandafter\def\expandafter\pgf@temp\expandafter{\pgf@temp#5}% |
| 866 |
\expandafter\global\expandafter\let\csname tikz@a@tlc@#1@#2@#3\endcsname\pgf@temp% |
| 867 |
\fi% |
| 868 |
}% |
| 869 |
|
| 870 |
|
| 871 |
\def\tikz@anim@cleanup#1{% |
| 872 |
\expandafter\global\expandafter\let\csname tikz@a@tlo@#1\endcsname\relax% |
| 873 |
}% |
| 874 |
|
| 875 |
\def\tikz@anim@create#1#2#3{% |
| 876 |
\csname tikz@a@conf@#1@#2@#3\endcsname% |
| 877 |
\iftikz@is@node% |
| 878 |
\expandafter\let\expandafter\tikz@temp\csname tikz@anim@def@pgf@attr@@node@#2\endcsname% |
| 879 |
\else% |
| 880 |
\expandafter\let\expandafter\tikz@temp\csname tikz@anim@def@pgf@attr@@scope@#2\endcsname% |
| 881 |
\fi% |
| 882 |
\ifx\tikz@temp\relax% |
| 883 |
\expandafter\let\expandafter\tikz@temp\csname tikz@anim@def@pgf@attr@#2\endcsname% |
| 884 |
\fi% |
| 885 |
\expandafter\pgfanimateattributecode\expandafter{\tikz@temp}{% |
| 886 |
\iftikz@is@node% |
| 887 |
\edef\tikz@anim@whom{\tikz@id@name\csname tikz@anim@def@is@node@#2\endcsname}% |
| 888 |
\else% |
| 889 |
\edef\tikz@anim@whom{\tikz@id@name\csname tikz@anim@def@no@node@#2\endcsname}% |
| 890 |
\fi% |
| 891 |
\pgfanimationset{whom=\tikz@anim@whom}% |
| 892 |
\expandafter\let\expandafter\tikz@animation@parser\csname tikz@anim@\csname tikz@anim@def@parser@#2\endcsname @parse\endcsname% |
| 893 |
\csname tikz@anim@def@code@#2\endcsname% |
| 894 |
\csname tikz@a@tld@#1@#2@#3\endcsname% |
| 895 |
\csname tikz@a@tlc@#1@#2@#3\endcsname% |
| 896 |
}% |
| 897 |
\expandafter\global\expandafter\let\csname tikz@a@tlc@#1@#2@#3\endcsname\relax% |
| 898 |
\expandafter\global\expandafter\let\csname tikz@a@tld@#1@#2@#3\endcsname\relax% |
| 899 |
}% |
| 900 |
|
| 901 |
|
| 902 |
|
| 903 |
|
| 904 |
\endinput |