Debian Codegraph @

texmf-dist/tex/generic/pgf/modules/pgfmoduleanimations.code.tex

raw
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 \ProvidesFileRCS{pgfmoduleanimations.code.tex}
11
12
13 % We need the animation system abstraction:
14
15 \input pgfsysanimations.code.tex
16
17
18 % Animate an attribute over time
19 %
20 % #1 = an attribute
21 % #2 = configuration keys
22 %
23 % This command adds animation commands for the attribute given in #1
24 % of some future object to the current graphic scope. For instance,
25 % when #1 is "fill opacity" then the fill opacity of the object will
26 % change over time. The object to which the command refers is
27 % specified using a special key in #2.
28 %
29 % The keys in #2 specify how the changes occur over time. There are a
30 % number of keys that have an effect on the animation "as a whole"
31 % (like "repeats") while the most central key is the entry key. This
32 % key takes two parameters: a time and a value. It specifies that at
33 % the given time the attribute should have the specified value. The
34 % times must be given in ascending order. Between the times given in
35 % this way, the values of the attribute will be interpolated; you can
36 % influence the details of how this interpolation is done using
37 % additional keys.
38 %
39 % The keys in #2 are given in key-value syntax and can be given in any
40 % order, except that the entry keys must be given in order of
41 % ascending times.
42 %
43 % The syntax of the second parameter of the entry key depends on
44 % #1. Currently, these are:
45 %
46 % Attribute Value Type
47 % ---------------------------------------
48 % fill opacity scalar
49 % stroke opacity scalar
50 % opacity scalar
51 % visible boolean
52 % line width dimension
53 % fill color
54 % stroke color
55 % motion motion
56 % translate point
57 % scale scaling
58 % rotate scalar
59 % xskew scalar
60 % yskew scalar
61 % path path
62 % softpath softpath
63 % view viewbox
64 % dash phase dimension
65 % dash pattern dashpattern
66 % none any
67 %
68 % Example:
69 %
70 % \pgfanimateattribute{fill opacity}{entry={0s}{1}, entry={2s}{0}}
71
72 \def\pgfanimateattribute#1#2{%
73 \pgfanimateattributecode{#1}{\pgfkeys{/pgf/animation/.cd,#2}}%
74 }%
75
76
77 % Variant of \pgfanimateattribute
78 %
79 % #1 = attribute
80 % #2 = code
81 %
82 % Description:
83 %
84 % A version of \pgfanimateattribute where instead of keys #2 you
85 % provide a code #2 that calls the animation keys itself.
86
87 \def\pgfanimateattributecode#1#2{%
88 {%
89 \pgfkeys{/pgf/@animation attributes/.cd,#1}%
90 #2%
91 \csname pgf@animation@check@\pgf@animation@attribute\endcsname%
92 \pgfsysanimate{\pgf@animation@attribute}%
93 }%
94 }%
95
96
97
98 % Create a time snapshot
99 %
100 % #1 = a time
101 %
102 % Description:
103 %
104 % This command should be called in a scope prior to all calls of
105 % animation commands in that scope. When called, all animations will
106 % be "intercepted" and, instead of creating the animation code, normal
107 % code will be generated that shows the state of the animation at the
108 % specified "moment" #1. Since no animation code is involved, this
109 % works with all drivers.
110 %
111 % The command \pgfsnapshotafter works the same way as \pgfsnapshot,
112 % only the timing is slightly different: Conceptually, #1 is
113 % interpreted as "#1+epsilon". For instance, if there are two values
114 % specified for the time #1, then \pgfsnapshot will use the first
115 % while \pgfsnapshotafter will use the second. Likewise, when an
116 % animation ends at time #1, \pgfsnapshot will still us the
117 % animation's value, while \pgfsnapshotafter will not.
118 %
119 % Example:
120 %
121 % {
122 % \pgfsnapshot{1.2s}
123 % \pgfanimateattribute{fill opacity}{entry={0s}{1}, entry={2s}{0}}
124 % \fill (0,0) rectangle (1,1);
125 % }
126
127 \def\pgfsnapshot#1{\pgfparsetime{#1}\expandafter\pgfsysanimsnapshot\expandafter{\pgftimeresult}}%
128 \def\pgfsnapshotafter#1{\pgfparsetime{#1}\expandafter\pgfsysanimsnapshotafter\expandafter{\pgftimeresult}}%
129
130
131 % The animation attributes
132
133 \pgfkeys{/pgf/@animation attributes/.cd,
134 visible/.code=\pgf@animate@attr{visibility}{mapped}\def\pgf@anim@map@true{visible}\def\pgf@anim@map@false{hidden},
135 stage/.code=\pgf@animate@attr{visibility}{mapped}\def\pgf@anim@map@true{visible}\def\pgf@anim@map@false{hidden}\pgfsysanimkeybase\pgfsysanimvaltext{hidden},
136 opacity/.code=\pgf@animate@attr{opacity}{scalar},
137 fill opacity/.code=\pgf@animate@attr{fillopacity}{scalar},
138 draw opacity/.code=\pgf@animate@attr{strokeopacity}{scalar},
139 stroke opacity/.style=draw opacity,
140 line width/.code=\pgf@animate@attr{linewidth}{dimension},
141 fill/.code=\pgf@animate@attr{fillcolor}{color},
142 draw/.code=\pgf@animate@attr{strokecolor}{color},
143 color/.code=\pgf@animate@attr{color}{color},
144 stroke/.style=draw,
145 motion/.code=\pgf@animate@attr{motion}{scalar},
146 translate/.code=\pgf@animate@attr{translate}{point},
147 scale/.code=\pgf@animate@attr{scale}{scaling},
148 rotate/.code=\pgf@animate@attr{rotate}{scalar},
149 xskew/.code=\pgf@animate@attr{skewx}{scalar},
150 yskew/.code=\pgf@animate@attr{skewy}{scalar},
151 skew x/.style=xskew,
152 skew y/.style=yskew,
153 path/.code=\pgf@animate@attr{path}{path},
154 softpath/.code=\pgf@animate@attr{path}{softpath},
155 view/.code=\pgf@animate@attr{viewbox}{viewbox},
156 dash/.code=\pgf@animate@attr{dash}{dash},
157 none/.code=\pgf@animate@attr{none}{none},
158 }%
159
160 \def\pgf@animate@attr#1#2{%
161 \def\pgf@animation@attribute{#1}%
162 \expandafter\let\expandafter\pgfanim@type@parser\csname pgfanim@parse@type@#2\endcsname%
163 }%
164
165
166
167 % The time parser
168 %
169 % #1 = a time
170 %
171 % This macro parses the time in #1, but adds some support for times:
172 %
173 % 1) The postfix operator "s" is added, which has no effect.
174 % 2) The postfix operator "ms" is added, which divides a number by
175 % 1000, so "2ms" equals "0.002".
176 % 3) The postfix operator "min" is added, which multiplies a number by
177 % 60.
178 % 4) The postfix operator "h" is added, which multiplies a number by
179 % 3600.
180 % 5) The infix operator ":" is redefined, so that it multiplies its
181 % first argument by 60 and adds the second. This implies that
182 % "1:20" equals "80" and "01:00:00" equals "3600".
183 % 6) The parsing of octal numbers is switched off to allow things like
184 % "01:08" for 68s.
185
186 \def\pgfparsetime#1{%
187 \begingroup%
188 \pgfmathdeclareoperator{s}{@seconds}{1}{postfix}{600}%
189 \pgfmathdeclareoperator{m}{m@encountered}{1}{postfix}{600}%
190 \pgfmathdeclareoperator{i}{i@encountered}{1}{postfix}{600}%
191 \pgfmathdeclareoperator{n}{@minutes}{1}{postfix}{600}%
192 \pgfmathdeclareoperator{h}{@hours}{1}{postfix}{600}%
193 \pgfmathdeclareoperator{:}{time@colon}{2}{infix}{50}%
194 \pgfmath@octalparsingfalse%
195 \pgfmathparse{#1}%
196 \expandafter\endgroup%
197 \expandafter\def\expandafter\pgftimeresult\expandafter{\pgfmathresult}%
198 }%
199
200 \newif\ifpgfanim@m@encountered
201 \newif\ifpgfanim@i@encountered
202 \pgfmathdeclarefunction{@seconds}{1}{%
203 \begingroup%
204 \expandafter\pgfmath@x#1pt\relax%
205 \ifpgfanim@m@encountered%
206 \divide\pgfmath@x by1000\relax%
207 \fi%
208 \global\pgfanim@m@encounteredfalse%
209 \pgfmath@returnone\pgfmath@x%
210 \endgroup%
211 }%
212 \pgfmathdeclarefunction{m@encountered}{1}{%
213 \global\pgfanim@m@encounteredtrue%
214 \begingroup%
215 \expandafter\pgfmath@x#1pt\relax%
216 \pgfmath@returnone\pgfmath@x%
217 \endgroup%
218 }%
219 \pgfmathdeclarefunction{i@encountered}{1}{%
220 \ifpgfanim@m@encountered%
221 \global\pgfanim@m@encounteredfalse%
222 \global\pgfanim@i@encounteredtrue%
223 \else%
224 \pgfmath@error{Unexpected i}{}%
225 \fi%
226 \begingroup%
227 \expandafter\pgfmath@x#1pt\relax%
228 \pgfmath@returnone\pgfmath@x%
229 \endgroup%
230 }%
231 \pgfmathdeclarefunction{@minutes}{1}{%
232 \ifpgfanim@i@encountered%
233 \global\pgfanim@i@encounteredfalse%
234 \else%
235 \pgfmath@error{Unexpected n}{}%
236 \fi%
237 \begingroup%
238 \expandafter\pgfmath@x#1pt\relax%
239 \pgfmath@x60\pgfmath@x\relax%
240 \pgfmath@returnone\pgfmath@x%
241 \endgroup%
242 }%
243 \pgfmathdeclarefunction{@hours}{1}{%
244 \begingroup%
245 \expandafter\pgfmath@x#1pt\relax%
246 \pgfmath@x3600\pgfmath@x\relax%
247 \pgfmath@returnone\pgfmath@x%
248 \endgroup%
249 }%
250 \pgfmathdeclarefunction{time@colon}{2}{%
251 \begingroup%
252 \pgfmath@x=#1pt\relax%
253 \pgfmath@x=60\pgfmath@x\relax%
254 \pgfmath@y=#2pt\relax%
255 \advance\pgfmath@x by\pgfmath@y%
256 \pgfmath@returnone\pgfmath@x%
257 \endgroup%
258 }%
259
260
261
262 % Sets general animation attributes
263 %
264 % #1 = key-value pairs that are executed for the path /pgf/animation/
265
266 \def\pgfanimationset{\pgfqkeys{/pgf/animation}}%
267
268
269 % Sets the target animation scope that should be animated.
270 %
271 % #1 = A name that will be used with an idscope.
272 %
273 % Example:
274 %
275 % \pgfanimateattribute{fill opacity}{whom=some scope, entry={0s}{1}, entry={1s}{0}}
276 % \begin{scope}[name=some scope]
277 % \draw (0,0) -- (1,1);
278 % \draw (1,0) -- (2,1);
279 % \end{scope}
280
281 \pgfanimationset{
282 whom/.code={%
283 \pgf@anim@decomp{#1}%
284 \pgfidrefnextuse\pgf@anim@id\pgf@anim@id@name%
285 \expandafter\expandafter\expandafter\pgfsysanimkeywhom\expandafter\expandafter\expandafter{\expandafter\pgf@anim@id\expandafter}\expandafter{\pgf@anim@type}%
286 \let\pgf@anim@whom@id\pgf@anim@id%
287 \let\pgf@anim@whom@type\pgf@anim@type%
288 }
289 }%
290
291 \def\pgf@anim@decomp#1{%
292 \edef\pgf@temp{#1}%
293 \expandafter\pgfutil@in@\expandafter.\expandafter{\pgf@temp}%
294 \ifpgfutil@in@%
295 \expandafter\pgf@anim@decomp@\pgf@temp\pgf@stop%
296 \else%
297 \expandafter\pgf@anim@decomp@\pgf@temp.\pgf@stop%
298 \fi%
299 }%
300 \def\pgf@anim@decomp@#1.#2\pgf@stop{%
301 \def\pgf@anim@id@name{#1}%
302 \def\pgf@anim@type{#2}%
303 }%
304
305
306 % Assigns a name to this animation so that it can be used as an event
307 % id in another animation
308 %
309 % #1 = A name
310 %
311 % The name "previous" is special and always refers to the most recent
312 % animation before the animation currently being constructed.
313 %
314 % Example:
315 %
316 % \pgfanimateattribute{fill opacity}{name=anim 1, entry={0s}{1}, entry={1s}{0}}
317 % \pgfanimateattribute{fill opacity}{begin on={end,of=anim 1}, entry={0s}{1}, entry={1s}{0}}
318
319 \pgfanimationset{
320 name/.code=\pgfuseid{#1},
321 }%
322
323
324
325
326 % Configures whether an animation can be restarted
327 %
328 % Some animations can restart when certain events take place. This key
329 % configures this. Setting it to
330 %
331 % "true" allows a restart at any time,
332 % "false" does not allow a restart,
333 % "when not active" allows a restart only, when the element is not
334 % active.
335 %
336 % Example:
337 %
338 % \pgfanimateattribute{fill opacity}{entry={0s}{1}, entry={1s}{0}, restart=false}
339
340 \pgfanimationset{
341 restart/.is choice,
342 restart/.default=true,
343 restart/true/.code=\pgfsysanimkeyrestartalways,
344 restart/false/.code=\pgfsysanimkeyrestartnever,
345 restart/never/.code=\pgfsysanimkeyrestartnever,
346 restart/when not active/.code=\pgfsysanimkeyrestartwhennotactive,
347 }%
348
349
350 % Sets the number times an animation should repeat
351 %
352 % #1 = A string of the following form:
353 %
354 % [<empty> | <number> | for <time>] ["accumulating"]
355 %
356 % When empty (the default value) the animation repeats forever.
357 %
358 % When a <number> is provided, the animation will repeat <number>
359 % times, which need not be an integer.
360 %
361 % When a <time> is given, the repeating will stop after this much time.
362 %
363 % When the optional "accumulating" is specified, the repeat
364 % accumulates, otherwise each repeat begins with the original start
365 % value.
366 %
367 % Example:
368 %
369 % \pgfanimateattribute{fill opacity}{repeats, entry={0s}{1}, entry={6s}{0}}
370 % \pgfanimateattribute{fill opacity}{repeats=2, entry={0s}{1}, entry={6s}{0}}
371 % \pgfanimateattribute{fill opacity}{repeats=2 accumulating, entry={0s}{1}, entry={6s}{0}}
372 % \pgfanimateattribute{fill opacity}{repeats=for 15s, entry={0s}{1}, entry={6s}{0}}
373
374 \pgfanimationset{
375 repeats/.code={%
376 \pgfutil@in@{accumulating\pgf@stop}{#1\pgf@stop}%
377 \ifpgfutil@in@%
378 \pgfsysanimkeyaccumulate%
379 \pgfanim@parse@acc#1\pgf@stop%
380 \else%
381 \pgfsysanimkeynoaccumulate%
382 \pgfanim@parse@noacc{#1}%
383 \fi%
384 },
385 repeats/.default=,
386 repeat/.style={repeats={#1}},
387 repeat/.default=,
388 }%
389 \def\pgfanim@parse@acc#1accumulating\pgf@stop{%
390 \pgfanim@parse@noacc{#1}%
391 }%
392 \def\pgfanim@parse@noacc#1{%
393 \pgfutil@in@{\pgf@stop for}{\pgf@stop#1}%
394 \ifpgfutil@in@%
395 \pgfanim@parse@for#1\pgf@stop%
396 \else%
397 \def\pgf@temp{#1}%
398 \ifx\pgf@temp\pgfutil@empty%
399 \pgfsysanimkeyrepeatindefinite%
400 \else%
401 \pgfmathparse{#1}%
402 \expandafter\pgfsysanimkeyrepeat\expandafter{\pgfmathresult}%
403 \fi%
404 \fi%
405 }%
406 \def\pgfanim@parse@for for#1\pgf@stop{\pgfparsetime{#1}\expandafter\pgfsysanimkeyrepeatdur\expandafter{\pgftimeresult}}%
407
408
409
410
411
412 % Specifies that an animation should begin or end at a certain time
413 % (relative to the current context). The "begin..." options may be
414 % used multiple times and their effects accumulate, likewise for the
415 % "end..." options.
416 %
417 % #1 = A time
418 %
419 % Example:
420 %
421 % \pgfanimateattribute{fill opacity}{begin=2s, end=2.5s, entry={0s}{1}, entry={1s}{0}}
422
423 \pgfanimationset{
424 begin/.code=\pgfparsetime{#1}\expandafter\pgfsysanimkeyoffset\expandafter{\pgftimeresult}{begin},
425 end/.code=\pgfparsetime{#1}\expandafter\pgfsysanimkeyoffset\expandafter{\pgftimeresult}{end},
426 }%
427
428
429
430 % Specifies that an animation should begin (or end) when a certain
431 % event takes place.
432 %
433 % #1 = A list of key-value pairs.
434 %
435 % The following keys are allowed:
436 %
437 % event=some event : The begin / end is triggered by that event. The
438 % list of allowed events is defined in the SVG
439 % standard.
440 % of=some name : The event does not refer to the current group,
441 % but to the object named "some name", which must
442 % previously have been named \pgfuseid. If some
443 % name contains a period, the part before the
444 % period must be the name of the id, the part
445 % following it the type of the id.
446 % key=some key : The trigger is some key being pressed
447 % repeat=number : The trigger is that an animation has been
448 % repeated number times.
449 % delay=time : A delay, may be negative.
450 %
451 % These keys are executed with the path prefix /pgf/animation/events.
452 %
453 % Some of them are predefined:
454 %
455 % "click" is a shorthand for "event=click"
456 % "focus in" is a shorthand for "event=focusin"
457 % "focus out" is a shorthand for "event=focusout"
458 % "activate" is a shorthand for "event=activate"
459 % "mouse down" is a shorthand for "event=mousedown"
460 % "mouse up" is a shorthand for "event=mouseup"
461 % "mouse over" is a shorthand for "event=mouseover"
462 % "mouse move" is a shorthand for "event=mousemove"
463 % "mouse out" is a shorthand for "event=mouseout"
464 % "begin" is a shorthand for "event=begin"
465 % "end" is a shorthand for "event=end"
466 %
467 % Example:
468 %
469 % % Begin after 5s or when clicked:
470 % \pgfanimateattribute{fill opacity}{begin=5s, begin on=click, entry={0s}{1}, entry={1s}{0}}
471 %
472 % % Begin, when an object named "button" is clicked
473 % \pgfanimateattribute{fill opacity}{begin on={click, of=button}, entry={0s}{1}, entry={1s}{0}, name=another animation}
474 %
475 % % Begin 1s after some other animation ends
476 % \pgfanimateattribute{fill opacity}{begin on={end, of=another animation, delay=1s}, entry={0s}{1}, entry={1s}{0}}
477
478 \pgfanimationset{
479 begin on/.code={\pgfanim@make@event{#1}{begin}},%
480 end on/.code={\pgfanim@make@event{#1}{end}},
481 }%
482
483 \def\pgfanim@make@event#1#2{%
484 \let\pgfanim@event@event\pgfutil@empty%
485 \let\pgf@anim@id\pgfutil@empty%
486 \let\pgf@anim@type\pgfutil@empty%
487 \let\pgfanim@event@key\pgfutil@empty%
488 \let\pgfanim@event@repeat\pgfutil@empty%
489 \let\pgfanim@event@delay\pgfutil@empty%
490 \pgfkeys{/pgf/animation/events/.cd,#1}%
491 \ifx\pgfanim@event@key\pgfutil@empty%
492 \ifx\pgfanim@event@repeat\pgfutil@empty%
493 \ifx\pgfanim@event@event\pgfutil@empty%
494 \pgferror{No event specified}%
495 \else%
496 \pgfsysanimkeyevent{\pgf@anim@id}{\pgf@anim@type}{\pgfanim@event@event}{\pgfanim@event@delay}{#2}%
497 \fi%
498 \else%
499 \pgfsysanimkeyrepeatevent{\pgf@anim@id}{\pgf@anim@type}{\pgfanim@event@repeat}{\pgfanim@event@delay}{#2}%
500 \fi%
501 \else%
502 \pgfsysanimkeyaccesskey{\pgfanim@event@key}{\pgfanim@event@delay}{#2}%
503 \fi%
504 }%
505
506 \pgfkeys{/pgf/animation/events/.cd,
507 event/.store in=\pgfanim@event@event,
508 of/.code={%
509 \pgf@anim@decomp{#1}%
510 \pgfidrefprevuse\pgf@anim@id\pgf@anim@id@name%
511 \ifx\pgf@anim@id\pgfutil@empty%
512 \pgferror{Unknown object/node name '\pgf@anim@id@name'. Did you
513 mean 'of next=\pgf@anim@id@name'?}%
514 \fi%
515 },
516 of next/.code={%
517 \pgf@anim@decomp{#1}%
518 \pgfidrefnextuse\pgf@anim@id\pgf@anim@id@name%
519 },
520 of id/.code=\def\pgf@anim@id{#1},
521 key/.store in=\pgfanim@event@key,
522 repeat/.code=\pgfmathparse{#1}\let\pgfanim@event@repeat\pgfmathresult,
523 delay/.code=\pgfparsetime{#1}\let\pgfanim@event@delay\pgftimeresult,
524 click/.style={event=click},
525 focus in/.style={event=focusin},
526 focus out/.style={event=focusout},
527 mouse down/.style={event=mousedown},
528 mouse up/.style={event=mouseup},
529 mouse over/.style={event=mouseover},
530 mouse move/.style={event=mousemove},
531 mouse out/.style={event=mouseout},
532 begin/.style={event=begin},
533 end/.style={event=end},
534 }%
535
536
537 % Specifies the timeline start for a snapshot
538 %
539 % #1 = a time
540 %
541 % Description:
542 %
543 % What a snapshot is taken of an animation (using \pgfsnapshot), all
544 % animations normally start at time 0s. When this key is used, the
545 % animation's timeline start is considered to be at moment #1
546 % instead.
547
548 \pgfanimationset{
549 begin snapshot/.code=
550 \pgfparsetime{#1}\expandafter\pgfsysanimkeysnapshotstart\expandafter{\pgftimeresult}
551 }%
552
553
554 % Specifies the origin for transforming animations
555 %
556 % #1 = a pgf point
557 %
558 % Specifies the origin of transformations (for instance, a rotate will
559 % rotate around this point).
560 %
561 % Example:
562 %
563 % \pgfanimateattribute{rotate}{entry={0s}{0}, entry={1s}{90}, origin=\pgfpoint{1cm}{1cm}}
564
565 \pgfanimationset{
566 origin/.code={%
567 \pgf@process{#1}%
568 \edef\pgf@marshal{%
569 \noexpand\pgfsysanimkeycanvastransform%
570 {\noexpand\pgftransformshift{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}{\noexpand\pgflowlevelsynccm}}%
571 {\noexpand\pgftransforminvert\noexpand\pgflowlevelsynccm}%
572 \noexpand\pgf@anim@save@transform{\noexpand\pgftransformshift{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}}%
573 }%
574 \pgf@marshal%
575 },
576 }%
577
578 \pgfsysanimkeycanvastransform{{\pgflowlevelsynccm}}{\pgftransforminvert\pgflowlevelsynccm}%
579
580
581
582 % Specifies the transforming for the animation coordinate system
583 %
584 % #1 = code that changes the pgf coordinate system
585 %
586 % Specifies an additional transformation of the coordinate system for
587 % animations.
588 %
589 % Example:
590 %
591 % \pgfanimateattribute{shift}{entry={0s}{\pgfpointorigin}, entry={1s}{\pgfpoint{1cm}{0cm}}, transform=\pgftransformrotate{30}}
592
593 \pgfanimationset{
594 transform/.code={%
595 \pgfsysanimkeycanvastransform{#1{\pgflowlevelsynccm}}{\pgftransforminvert\pgflowlevelsynccm}%
596 \pgf@anim@save@transform{#1}%
597 },
598 }%
599
600
601
602 % Specifies a motion path.
603 %
604 % #1 = pgf commands for constructing a path
605 %
606 % Use this key to specify a motion path for the motion attribute. The
607 % values of the "entry" key specify fractions along this path.
608 %
609 % Example:
610 %
611 % \pgfanimateattribute{motion}{
612 % entry={0s}{0}, entry={1s}{1},
613 % along=\pgfpathmoveto{\pgfpointorigin} \pgfpathlineto{\pgfpoint{1cm}{1cm}}
614 % }
615
616 \pgfanimationset{
617 along/.code=%
618 {%
619 \pgfsyssoftpath@getcurrentpath\pgfanim@save@path%
620 \pgfsyssoftpath@setcurrentpath\pgfutil@empty%
621 #1%
622 \pgfsyssoftpath@getcurrentpath\pgfanim@the@path%
623 \global\let\pgfanim@the@path\pgfanim@the@path%
624 \pgfsyssoftpath@setcurrentpath\pgfanim@save@path%
625 }%
626 \expandafter\pgf@anim@protocol@path@size\pgfanim@the@path\pgf@stop%
627 \expandafter\pgfsysanimkeymovealong\expandafter{\pgfanim@the@path}%
628 }%
629
630
631 % Specifies a motion soft path.
632 %
633 % #1 = a pgf soft path (result of calling \pgfsyssoftpath@getcurrentpath)
634 %
635 % Use this key to specify a motion path for the motion attribute when
636 % a softpath has already been constructed.
637 %
638 % Example:
639 %
640 % \pgfanimateattribute{motion}{entry={0s}{0}, entry={1s}{1},
641 % along softpath=\pgfsyssoftpath@movetotoken {0pt}{0pt}\pgfsyssoftpath@linetotoken {10pt}{10pt}}
642
643 \pgfanimationset{
644 along softpath/.code=%
645 \pgf@anim@protocol@path@size#1\pgf@stop%
646 \pgfsysanimkeymovealong{#1}%
647 }%
648
649
650 \def\pgf@anim@protocol@path@size{%
651 \pgfutil@ifnextchar\pgf@stop\pgfutil@gobble\pgf@anim@protocol@path@size@%
652 }%
653 \def\pgf@anim@protocol@path@size@#1#2#3{%
654 \pgf@protocolanimsizes@direct{#2}{#3}%
655 \pgf@anim@protocol@path@size%
656 }%
657
658
659 % Configures whether the motion is rotated along the path.
660 %
661 % Example:
662 %
663 % \pgfanimateattribute{motion}{rotate along, entry={0s}{0}, entry={1s}{1},
664 % along=\pgfpathmoveto{\pgfpointorigin} \pgfpathlineto{\pgfpoint{1cm}{1cm}}}
665
666 \pgfanimationset{
667 rotate along/.is choice,
668 rotate along/.default=true,
669 rotate along/true/.code=\pgfsysanimkeyrotatealong,
670 rotate along/false/.code=\pgfsysanimkeynorotatealong,
671 }%
672
673
674
675 % Specifies an entry
676 %
677 % #1 = A time. This time will be parsed using \pgfparsetime
678 % #2 = A value. The format of this value depends on the current type
679 % of the animation attribute. (So for an animation of the "fill
680 % opacity", #1 must be a scalar value, for an animation of the "fill"
681 % color, #1 must be a color, and so on.)
682 % If #2 is the special text "current value", then the current
683 % value will be used. For SVG, this is allowed only when exactly
684 % two entries are specified and this special value is used for
685 % the first one.
686 %
687 % Example:
688 %
689 % \pgfanimateattribute{fill opacity}{entry={0s}{0}, entry={1s}{1}}
690
691 \pgfanimationset{entry/.code 2 args=\pgf@anim@entry{#1}{#2}}%
692 \def\pgf@anim@entry#1#2{%
693 \pgf@anim@entry@giventrue%
694 \pgfparsetime{#1}%
695 \edef\pgf@marshal{\noexpand\pgfsysanimkeytime{\pgftimeresult}\pgf@anim@entry@spline\pgf@anim@exit@spline}%
696 \pgf@marshal%
697 \def\pgf@temp{#2}%
698 \ifx\pgf@temp\pgf@special@current@text%
699 \pgfsysanimvalcurrent%
700 \else%
701 \pgfanim@type@parser{#2}%
702 \fi%
703 }%
704 \def\pgf@special@current@text{current value}%
705 \newif\ifpgf@anim@entry@given
706
707
708 % Specifies a base value
709 %
710 % #1 = A value. The format is as for the entry key.
711 %
712 % Description:
713 %
714 % Will set the "base" value of the animation, which is a value that is
715 % used when the animation is not active.
716 %
717 % Example:
718 %
719 % \pgfanimateattribute{fill opacity}{base = 0.5, entry={0s}{0.5}, entry={1s}{1}}
720
721 \pgfanimationset{base/.code=\pgf@anim@base{#1}}%
722 \def\pgf@anim@base#1{%
723 \pgfsysanimkeybase%
724 \pgfanim@type@parser{#1}%
725 }%
726
727
728 % Specifies that there is an entry "at infinity".
729 %
730 % When an animation ends, its "effect" can either persist or it can be
731 % removed. Setting "freeze at end" to true will cause it to persist,
732 % otherwise it will be removed.
733 %
734 % Example:
735 %
736 % \pgfanimateattribute{fill opacity}{entry={0s}{1}, entry={1s}{0}, freeze at end}
737
738 \pgfanimationset{
739 freeze at end/.is choice,
740 freeze at end/.default=true,
741 freeze at end/true/.code=\pgfsysanimkeyfreezeatend,
742 freeze at end/false/.code=\pgfsysanimkeyremoveatend,
743 }%
744
745
746
747 % Specifies an entry or exit spline control
748 %
749 % #1 = time fraction
750 % #2 = attribute fraction
751 %
752 % Description:
753 %
754 % Suppose that an animation is supposed to interpolate a attribute's
755 % value between the two values "50" and "100" over a time of 10s. The
756 % simplest way of doing so is to do a linear interpolation, where the
757 % value as, say, 1s is 55, at 2s it is 60, and so on.
758 %
759 % Unfortunately, the linear interpolation does not "look" nice in many
760 % cases since the acceleration of a linear interpolation is zero
761 % during the animation, but infinite at the beginning and at the end;
762 % which looks "jerky".
763 %
764 % To avoid this, you can specify that the time--attribute curve should
765 % not be a straight line, but rather a curve. You specify this curve
766 % using a spline.
767 %
768 % The most logical "coordinate rectangle" used for this spline in our
769 % example would be (0s,50) and (10s,100) and we would like to specify
770 % something like "(0s,50) .. controls (5s,50) and (9s,100)
771 % .. (10s,100)". This would result in a time--attribute curve where
772 % the attribute at 50 changes slowly at 0s and also arrives slowly at
773 % 100 at 10s, but speeds up between these values.
774 %
775 % We call the first control point (5s,50) the "exit control" and call
776 % (9s,100) the "entry control": The first control dictates how quickly
777 % or slowly a time point is left, the second dictates how quickly or
778 % slowly we enter the next one.
779 %
780 % The control points are, however, not specified in the coordinate
781 % system indicated above. Rather, the rectangle (0s,50) to (10s, 100),
782 % gets normalized to (0,0) to (1,1). The control point (5s,50) would
783 % thus become (0.5,0) and (9s,100) becomes (0.9,1).
784 %
785 % Example:
786 %
787 % \pgfanimateattribute{rotate}{
788 % exit control={0.5}{0},
789 % entry control={0.9}{1},
790 % entry={0s}{50},
791 % entry={10s}{100}}
792
793 \pgfanimationset{
794 entry control/.code 2 args={%
795 \pgfmathsetmacro\pgf@temp@t{#1}%
796 \pgfmathsetmacro\pgf@temp@a{#2}%
797 \edef\pgf@anim@entry@spline{{\pgf@temp@t}{\pgf@temp@a}}%
798 },
799 exit control/.code 2 args={%
800 \pgfmathsetmacro\pgf@temp@t{#1}%
801 \pgfmathsetmacro\pgf@temp@a{#2}%
802 \edef\pgf@anim@exit@spline{{\pgf@temp@t}{\pgf@temp@a}}%
803 },
804 stay/.code=\let\pgf@anim@exit@spline\pgfsys@stay@text,%
805 jump/.code=\let\pgf@anim@entry@spline\pgfsys@jump@text,%
806 linear/.style={entry control={1}{1},exit control={0}{0}},
807 }%
808 \def\pgf@anim@entry@spline@base{{1}{1}}%
809 \def\pgf@anim@exit@spline@base{{0}{0}}%
810
811 \def\pgf@anim@reset@linear{\let\pgf@anim@entry@spline\pgf@anim@entry@spline@base\let\pgf@anim@exit@spline\pgf@anim@exit@spline@base}%
812 \pgf@anim@reset@linear
813
814
815
816 % Specifies how much arrow tips should be shortened (as in
817 % \pgfsetshortenstart)
818 %
819 % #1 = an additional shortening distance the path start.
820 %
821 % Description:
822 %
823 % Works like \pgfsetshortenstart, only for animated paths.
824
825 \pgfanimationset{
826 shorten </.code={%
827 \ifpgf@anim@entry@given%
828 \pgferror{You must specify shorten < prior to the path entries}%
829 \else%
830 \pgfmathsetmacro\pgf@anim@marker@extra@shorten@start{#1}%
831 \edef\pgf@anim@marker@extra@shorten@start{\pgf@anim@marker@extra@shorten@start pt}%
832 \fi%
833 },
834 shorten >/.code={%
835 \ifpgf@anim@entry@given%
836 \pgferror{You must specify shorten < prior to the path entries}%
837 \else%
838 \pgfmathsetmacro\pgf@anim@marker@extra@shorten@end{#1}%
839 \edef\pgf@anim@marker@extra@shorten@end{\pgf@anim@marker@extra@shorten@end pt}%
840 \fi%
841 },
842 }%
843 \def\pgf@anim@marker@extra@shorten@start{0pt}%
844 \def\pgf@anim@marker@extra@shorten@end{0pt}%
845 \def\pgf@anim@marker@shorten@start{0pt}%
846 \def\pgf@anim@marker@shorten@end{0pt}%
847
848 % Specifies the arrow tips used for path animations
849 %
850 % #1 = an arrow specification of the form <start>-<end> as for the
851 % command \pgfsetarrows
852 %
853 % Description:
854 %
855 % Specifies arrow tips that are used in a path animation. Note that in
856 % order to set the arrow tips of a path that is animated, you always
857 % have to use this command. In particular, you should *not* set arrow
858 % tips for the to-be-animated path, but use this key and the base key
859 % to install a base path with arrow tips.
860
861 \pgfanimationset{
862 arrows/.code={%
863 \ifpgf@anim@entry@given%
864 \pgferror{You must specify animation arrows prior to the path entries}%
865 \else%
866 \pgf@anim@parser@arrows#1\pgf@stop%
867 \fi%
868 },
869 }%
870
871 \def\pgf@anim@parser@arrows#1-#2\pgf@stop{%
872 \pgf@anim@prepare@arrow@start{#1}%
873 \pgf@anim@prepare@arrow@end{#2}%
874 \expandafter\expandafter\expandafter\pgfsysanimkeytipmarkers\expandafter\expandafter\expandafter{\expandafter\pgf@anim@marker@id@start\expandafter}\expandafter{\pgf@anim@marker@id@end}%
875 }%
876
877 \def\pgf@anim@prepare@arrow@start#1{%
878 \def\pgf@anim@temp{#1}%
879 \ifx\pgf@anim@temp\pgfutil@empty%
880 \let\pgf@anim@marker@id@start\pgfutil@empty%
881 \def\pgf@anim@marker@shorten@start{0pt}%
882 \else%
883 {%
884 \pgfsetarrowsstart{#1}%
885 \pgf@anim@prep@marker@arrow\pgf@start@tip@sequence\pgf@anim@marker@id\pgf@anim@marker@shorten%
886 \global\let\pgf@anim@marker@id@start\pgf@anim@marker@id%
887 \global\let\pgf@anim@temp\pgf@anim@marker@shorten%
888 }%
889 \let\pgf@anim@marker@shorten@start\pgf@anim@temp%
890 \fi%
891 }%
892
893 \def\pgf@anim@prepare@arrow@end#1{%
894 \def\pgf@anim@temp{#1}%
895 \ifx\pgf@anim@temp\pgfutil@empty%
896 \let\pgf@anim@marker@id@end\pgfutil@empty%
897 \def\pgf@anim@marker@shorten@end{0pt}%
898 \else%
899 {%
900 \pgfsetarrowsend{#1}%
901 \pgf@anim@prep@marker@arrow\pgf@end@tip@sequence\pgf@anim@marker@id\pgf@anim@marker@shorten%
902 \global\let\pgf@anim@marker@id@end\pgf@anim@marker@id%
903 }%
904 \let\pgf@anim@marker@shorten@end\pgf@anim@marker@shorten%
905 \fi%
906 }%
907
908
909 % Draw an arrow using markers
910
911 \def\pgf@anim@prep@marker@arrow#1#2#3{%
912 % #1 = tip sequence
913 % #2 = macro for storing marker code
914 % #3 = macro for storing shortening length
915 %
916 % First, compute id's:
917 {%
918 \let\pgf@arrow@handle\pgf@anim@marker@id@test%
919 \let\pgf@arrow@handle@dot\relax%?
920 \global\let\pgf@anim@marker@id@list\pgfutil@empty%
921 #1%
922 }%
923 \expandafter\let\expandafter#2\csname pgfanim@marker@cache@\pgf@anim@marker@id@list\endcsname%
924 \expandafter\let\expandafter#3\csname pgfanim@marker@cachel@\pgf@anim@marker@id@list\endcsname%
925 \ifx#2\relax% ok, have to create it!
926 \pgf@relevantforpicturesizefalse%
927 \pgfinterruptpath%
928 \pgf@arrow@compute@shortening{#1}%
929 \xdef#3{\the\pgf@xa}%
930 {%
931 \let\pgf@arrow@handle\pgf@anim@drawer@marker
932 \let\pgf@arrow@handle@dot\relax%
933 \pgfsys@marker@declare#2{%
934 \pgftransformxshift{-\pgf@xb}%
935 \pgftransformxshift{\pgf@xa}%
936 #1%
937 }%
938 }%
939 \endpgfinterruptpath%
940 \expandafter\global\expandafter\let\csname pgfanim@marker@cache@\pgf@anim@marker@id@list\endcsname#2%
941 \expandafter\global\expandafter\let\csname pgfanim@marker@cachel@\pgf@anim@marker@id@list\endcsname#3%
942 \fi%
943 }%
944
945 \def\pgf@anim@marker@id@test#1#2{%
946 \pgfarrows@getid{#1}{#2}%
947 \expandafter\expandafter\expandafter\pgf@arrow@drawer@shift\csname pgf@ar@ends@\pgf@arrow@id\endcsname%
948 \xdef\pgf@anim@marker@id@list{\pgf@anim@marker@id@list:\pgf@arrow@id\ifpgfarrowswap s\else n\fi\pgfarrows@slant w\the\pgf@xc}%
949 }%
950
951 \def\pgf@anim@drawer@marker#1#2{%
952 % Prepare:
953 {%
954 \pgfarrows@getid{#1}{#2}%
955 % Do shift:
956 \expandafter\expandafter\expandafter\pgf@arrow@drawer@shift\csname pgf@ar@ends@\pgf@arrow@id\endcsname%
957 % Do slant:
958 \ifdim\pgfarrows@slant pt=0pt%
959 \else%
960 \pgftransformxslant{\pgfarrows@slant}%
961 \fi%
962 % do swap:
963 \ifpgfarrowswap%
964 \pgftransformyscale{-1}%
965 \fi%
966 {%
967 \csname pgf@ar@saves@\pgf@arrow@id\endcsname%
968 \pgfsys@beginscope%
969 \pgf@arrows@color@setup%
970 \pgflowlevelsynccm\csname pgf@ar@cache@\pgf@arrow@id\endcsname%
971 \pgfsys@endscope%
972 }%
973 \expandafter}%
974 % Transform to next tip:
975 \expandafter\pgftransformxshift\expandafter{\the\pgf@xc}%
976 }%
977
978
979
980
981
982
983
984
985
986 % The parsers
987
988 % Parse no value
989 %
990 % #1 is ignored
991 %
992 % Example:
993 %
994 % entry = {0s}{5+6}
995
996 \def\pgfanim@parse@type@none#1{%
997 \pgfsysanimvalnone%
998 }%
999
1000 % Parse a scalar
1001 %
1002 % #1 is a number parsed using \pgfmathparse
1003 %
1004 % Example:
1005 %
1006 % entry = {0s}{5+6}
1007
1008 \def\pgfanim@parse@type@scalar#1{%
1009 \pgfmathparse{#1}%
1010 \expandafter\pgfsysanimvalscalar\expandafter{\pgfmathresult}%
1011 }%
1012
1013
1014 % Parse a dimension
1015 %
1016 % #1 is a number parsed using \pgfmathparse
1017 %
1018 % Example:
1019 %
1020 % entry = {0s}{5cm + 2pt}
1021
1022 \def\pgfanim@parse@type@dimension#1{%
1023 \pgfmathparse{#1}%
1024 \expandafter\pgfsysanimvaldimension\expandafter{\pgfmathresult pt}%
1025 }%
1026
1027
1028
1029 % Parse a mapped text
1030 %
1031 % #1 is a text. It is looked up in \pgf@anim@map@#1 and gets replaced
1032 % by what this macro expands to.
1033 %
1034 % Example:
1035 %
1036 % entry = {0s}{true}
1037
1038 \def\pgfanim@parse@type@mapped#1{%
1039 {%
1040 \expandafter\let\expandafter\pgf@temp\csname pgf@anim@map@#1\endcsname\relax%
1041 \ifx\pgf@temp\relax%
1042 \pgferror{Value '#1' not allowed for an animation for this attribute}%
1043 \let\pgf@temp\pgfutil@empty%
1044 \fi%
1045 \expandafter}%
1046 \expandafter\pgfsysanimvaltext\expandafter{\pgf@temp}%
1047 }%
1048
1049
1050 % Parse a color
1051 %
1052 % #1 is a color
1053 %
1054 % entry = {0s}{blue!20}
1055
1056 \def\pgfanim@parse@type@color#1{%
1057 \pgfsysanimvalcolor{#1}%
1058 }%
1059
1060
1061 % Parse a path
1062 %
1063 % #1 is a sequence of pgf path construction commands
1064 %
1065 % entry = {0s}{\pgfpathmoveto{\pgfpointorigin} \pgfpathlineto{\pgfpoint{1cm}{1cm}}}
1066
1067 \def\pgfanim@parse@type@path#1{%
1068 {%
1069 \pgfsyssoftpath@getcurrentpath\pgfanim@save@path%
1070 \pgfsyssoftpath@setcurrentpath\pgfutil@empty%
1071 #1%
1072 \pgfsyssoftpath@getcurrentpath\pgfanim@the@path%
1073 \pgfprocessround{\pgfanim@the@path}{\pgfanim@the@path}%
1074 \global\let\pgfanim@the@path\pgfanim@the@path%
1075 \pgfsyssoftpath@setcurrentpath\pgfanim@save@path%
1076 }%
1077 \expandafter\pgfanim@parse@type@softpath\expandafter{\pgfanim@the@path}%
1078 }%
1079
1080
1081 % Parse a softpath
1082 %
1083 % #1 is a sequence of pgf softpath token commands
1084 %
1085 % entry = {0s}{\pgfsyssoftpath@movetotoken {0pt}{0pt}\pgfsyssoftpath@linetotoken {10pt}{10pt}}
1086
1087 \def\pgfanim@parse@type@softpath#1{%
1088 {%
1089 \def\pgf@anim@path{#1}%
1090 % Shorten?
1091 \pgf@worryfalse%
1092 \pgf@xb=\pgf@anim@marker@extra@shorten@start%
1093 \advance\pgf@xb by\pgf@anim@marker@shorten@start%
1094 \pgf@xc=\pgf@anim@marker@extra@shorten@end%
1095 \advance\pgf@xc by\pgf@anim@marker@shorten@end%
1096 \ifdim\pgf@xb=0pt\else\pgf@worrytrue\fi%
1097 \ifdim\pgf@xc=0pt\else\pgf@worrytrue\fi%
1098 \ifpgf@worry%
1099 \edef\pgf@path@shortening@distance@end{\the\pgf@xc}%
1100 \edef\pgf@path@shortening@distance@start{\the\pgf@xb}%
1101 % Yes! Need to shorten.
1102 \pgf@anim@shorten@path%
1103 \fi%
1104 \expandafter}%
1105 \expandafter\pgfsysanimvalpath\expandafter{\pgf@anim@path}%
1106 }%
1107
1108
1109 \def\pgf@anim@shorten@path{%
1110 \pgf@precise@shorteningfalse%
1111 \let\pgf@path@shortening@distance\pgf@path@shortening@distance@end%
1112 %
1113 % Step 1: Split
1114 %
1115 \pgfprocesssplitpath{\pgf@anim@path}%
1116 \pgfprocesssplitsubpath{\pgfprocessresultpathsuffix}%
1117 %
1118 % Step 2: extract
1119 %
1120 \expandafter\pgf@parse@end\pgfprocessresultsubpathsuffix\pgf@stop\pgf@stop\pgf@stop%
1121 %
1122 % Step 3: prep end
1123 %
1124 \pgf@prep@end%
1125 %
1126 % Step 4: shorten end
1127 %
1128 \ifdim\pgf@path@shortening@distance=0pt\else\pgf@do@shorten@end\fi%
1129 %
1130 \let\pgf@path@shortening@distance\pgf@path@shortening@distance@start%
1131 %
1132 % Step 5: extract
1133 %
1134 \expandafter\pgf@parse@start\pgfprocessresultpathsuffix\pgf@stop\pgf@stop\pgf@stop%
1135 %
1136 % Step 6: prep start
1137 %
1138 \pgf@prep@start%
1139 %
1140 % Step 7: shorten start
1141 %
1142 \ifdim\pgf@path@shortening@distance=0pt\else\pgf@do@shorten@start\fi%
1143 \expandafter\expandafter\expandafter\def%
1144 \expandafter\expandafter\expandafter\pgf@anim@path%
1145 \expandafter\expandafter\expandafter{\expandafter\pgfprocessresultpathprefix\pgfprocessresultpathsuffix}%
1146 }%
1147
1148
1149
1150 % Parse a point
1151 %
1152 % #1 is a point
1153 %
1154 % entry = {0s}{\pgfpoint{1cm}{2cm}}
1155
1156 \def\pgfanim@parse@type@point#1{%
1157 \pgf@process{#1}%
1158 \pgf@protocolanimsizes\pgf@x\pgf@y%
1159 \expandafter\expandafter\expandafter\pgfsysanimvaltranslate\expandafter\expandafter\expandafter{\expandafter\the\expandafter\pgf@x\expandafter}\expandafter{\the\pgf@y}%
1160 }%
1161
1162
1163 % Parse a scaling
1164 %
1165 % #1 = if #1 contains a comma, the two parts are passed to
1166 % pgfmathparse, otherwise the whole thing is passed to pgfmathparse.
1167 %
1168 % entry = {0s}{2}
1169 % entry = {0s}{2,1}
1170
1171 \def\pgfanim@parse@type@scaling#1{%
1172 \pgfutil@in@{,}{#1}%
1173 \ifpgfutil@in@%
1174 \pgfanim@unpack@comma#1\pgf@stop%
1175 \else%
1176 \pgfmathparse{#1}%
1177 \expandafter\pgfsysanimvalscale\expandafter{\pgfmathresult}{\pgfmathresult}%
1178 \fi%
1179 }%
1180 \def\pgfanim@unpack@comma#1,#2\pgf@stop{%
1181 \pgfmathsetmacro{\pgf@anim@temp@x}{#1}%
1182 \pgfmathsetmacro{\pgf@anim@temp@y}{#2}%
1183 \expandafter\expandafter\expandafter\pgfsysanimvalscale\expandafter\expandafter\expandafter{\expandafter\pgf@anim@temp@x\expandafter}\expandafter{\pgf@anim@temp@y}%
1184 }%
1185
1186
1187
1188 % Parse a viewbox
1189 %
1190 % #1 consists of two points, each in parentheses
1191 %
1192 % entry = {0s}{{\pgfpoint{1cm}{2cm}}{\pgfpoint{3cm}{4cm}}}
1193
1194 \def\pgfanim@parse@type@viewbox#1{%
1195 {%
1196 \pgfanim@unpack@viewbox#1%
1197 \xdef\pgf@anim@caller{\noexpand\pgfsysanimvalviewbox{\the\pgf@x}{\the\pgf@y}{\the\pgf@xa}{\the\pgf@ya}}%
1198 }%
1199 \pgf@anim@caller%
1200 }%
1201 \def\pgfanim@unpack@viewbox#1#2{%
1202 \pgfpointtransformed{#2}%
1203 \pgf@xa\pgf@x%
1204 \pgf@ya\pgf@y%
1205 \pgfpointtransformed{#1}%
1206 \ifdim\pgf@xa<\pgf@x% swap needed
1207 \pgf@xb=\pgf@x%
1208 \pgf@x=\pgf@xa%
1209 \pgf@xa=\pgf@xb%
1210 \fi%
1211 \ifdim\pgf@ya<\pgf@y% swap needed
1212 \pgf@yb=\pgf@y%
1213 \pgf@y=\pgf@ya%
1214 \pgf@ya=\pgf@yb%
1215 \fi%
1216 }%
1217
1218
1219
1220
1221 % Parse a dash pattern
1222 %
1223 % #1,#2 is a dash pattern as in \pgfsetdash
1224 %
1225 % entry = {0s}{{{1pt}{2pt}{3pt}{1pt}}{1pt}}
1226
1227 \def\pgfanim@parse@type@dash#1{\pgfanim@parse@type@dash@#1}%
1228 \def\pgfanim@parse@type@dash@#1#2{%
1229 \def\pgf@temp{}%
1230 \def\pgf@next{\pgf@strip}%
1231 \pgf@strip#1{pgf@stop}%
1232 \expandafter\pgfsysanimvaldash\expandafter{\pgf@temp}{#2}%
1233 }%
1234
1235
1236
1237
1238
1239 %
1240 %
1241 % Bounding box adjustments in animations.
1242 %
1243 %
1244
1245 \def\pgf@protocolanimsizes#1#2{%
1246 \edef\pgf@temp{\noexpand\pgf@anim@handle@point{\the#1}{\the#2}}%
1247 \expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter\pgf@protocolanim@list\expandafter\expandafter\expandafter{\expandafter\pgf@protocolanim@list\pgf@temp}%
1248 }%
1249 \def\pgf@protocolanimsizes@direct#1#2{%
1250 \expandafter\def\expandafter\pgf@protocolanim@list\expandafter{\pgf@protocolanim@list\pgf@anim@handle@point{#1}{#2}}%
1251 }%
1252 \let\pgf@protocolanim@list\pgfutil@empty
1253
1254 \def\pgf@animation@check@translate{%
1255 \ifx\pgf@protocolanim@list\pgfutil@empty%
1256 \else%
1257 \expandafter\expandafter\expandafter\pgf@animation@check@translate@\expandafter\expandafter\expandafter{\expandafter\pgf@protocolanim@list\expandafter}\expandafter{\pgf@anim@saved@transform}%
1258 \fi%
1259 }%
1260 \let\pgf@animation@check@motion\pgf@animation@check@translate
1261
1262 \def\pgf@animation@check@translate@#1#2{%
1263 \pgfsys@attach@to@id\pgf@anim@whom@id\pgf@anim@whom@type{%
1264 \pgf@size@hookedtrue%
1265 {%
1266 % Compute bounding box in local coordinate system
1267 #2%
1268 \pgf@pt@x0pt%
1269 \pgf@pt@y0pt%
1270 \pgf@picmaxx=-16000pt\relax%
1271 \pgf@picminx=16000pt\relax%
1272 \pgf@picmaxy=-16000pt\relax%
1273 \pgf@picminy=16000pt\relax%
1274 #1%
1275 \edef\pgf@temp{{\the\pgf@picminx}{\the\pgf@picminy}{\the\pgf@picmaxx}{\the\pgf@picmaxy}}%
1276 \expandafter%
1277 }\expandafter%
1278 \def\expandafter\pgf@temp\expandafter{\pgf@temp}%
1279 \expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter\pgf@path@size@hook\expandafter\expandafter\expandafter{%
1280 \expandafter\pgf@path@size@hook\expandafter\pgf@anim@bb\pgf@temp}%
1281 }{}%
1282 }%
1283 \def\pgf@anim@handle@point#1#2{%
1284 \pgf@x#1\pgf@y#2%
1285 \pgf@pos@transform\pgf@x\pgf@y%
1286 \ifdim\pgf@x<\pgf@picminx\pgf@picminx\pgf@x\fi%
1287 \ifdim\pgf@x>\pgf@picmaxx\pgf@picmaxx\pgf@x\fi%
1288 \ifdim\pgf@y<\pgf@picminy\pgf@picminy\pgf@y\fi%
1289 \ifdim\pgf@y>\pgf@picmaxy\pgf@picmaxy\pgf@y\fi%
1290 }%
1291
1292 \newdimen\pgf@anim@dim
1293
1294 \def\pgf@anim@bb#1#2#3#4{% (#1,#2) lower left, (#3, #4) upper right
1295 \pgf@anim@dim\pgf@size@hook@x%
1296 \advance\pgf@anim@dim by#1\relax%
1297 \ifdim\pgf@anim@dim<\pgf@picminx\global\pgf@picminx\pgf@anim@dim\fi%
1298 \pgf@anim@dim\pgf@size@hook@x%
1299 \advance\pgf@anim@dim by#3\relax%
1300 \ifdim\pgf@anim@dim>\pgf@picmaxx\global\pgf@picmaxx\pgf@anim@dim\fi%
1301 \pgf@anim@dim\pgf@size@hook@y%
1302 \advance\pgf@anim@dim by#2\relax%
1303 \ifdim\pgf@anim@dim<\pgf@picminy\global\pgf@picminy\pgf@anim@dim\fi%
1304 \pgf@anim@dim\pgf@size@hook@y%
1305 \advance\pgf@anim@dim by#4\relax%
1306 \ifdim\pgf@anim@dim>\pgf@picmaxy\global\pgf@picmaxy\pgf@anim@dim\fi%
1307 }%
1308
1309 \def\pgf@anim@save@transform#1{%
1310 \def\pgf@anim@saved@transform{#1}%
1311 }%
1312 \let\pgf@anim@saved@transform\pgfutil@empty%
1313
1314 \endinput