Debian Codegraph @

texmf-dist/source/latex/animate/animate.tex

raw
1 \listfiles
2 %
3 % Copyright 2007--\today Alexander Grahn
4 %
5 % This material is subject to the LaTeX Project Public License. See
6 % http://mirrors.ctan.org/macros/latex/base/lppl.txt
7 % for the details of that license.
8 %
9 %%% force dvi %%%
10 \ifdefined\outputmode\outputmode=0\fi
11 \ifdefined\pdfoutput\pdfoutput=0\fi
12 %%%%%%% pdfmanagement-testphase %%%%%%
13 \DocumentMetadata % activates the PDF management interface
14 {
15 %testphase=new-or-1
16 %uncompress,
17 }
18 %%%%%% /pdfmanagement-testphase %%%%%%
19 \documentclass[a4paper]{article}
20 \frenchspacing
21 \usepackage[buttonbg=0.9]{animate}
22 \usepackage[UKenglish]{babel}
23 \usepackage{pst-3dplot}
24 \usepackage{pst-node,pst-plot,pst-tools,pst-text,pst-ode}
25 \usepackage{media9}
26 \usepackage{intcalc}
27 \usepackage{graphicx}
28 \graphicspath{{files/}}
29 \addmediapath{files}
30 \usepackage{textcomp}
31 \usepackage{mflogo}
32 \usepackage[T1]{fontenc}
33 \usepackage[utf8]{inputenc}
34 %\usepackage{lmodern}
35 \usepackage[tt=false]{libertine} %override beramono (doesn't look like tt font)
36 \usepackage{libertinust1math}
37 \usepackage[protrusion]{microtype}
38 \usepackage{parskip}
39 \usepackage{tabls}
40 \usepackage{multirow}
41 \usepackage{hyperref}
42 \usepackage[ocgcolorlinks]{ocgx2}
43 \usepackage{amsmath}
44 \usepackage{fancyvrb}
45 \usepackage{tabularx}
46 \usepackage[all]{hypcap}
47 \usepackage{listings}
48 \lstset{basicstyle=\ttfamily,columns=fullflexible,language={[LaTeX]TeX},commentstyle=\color{gray}}
49
50 \clubpenalty=10000
51 \widowpenalty=10000
52 \displaywidowpenalty=10000
53 \renewcommand{\textfraction}{0.0}
54 \renewcommand{\topfraction}{1.0}
55 \renewcommand{\bottomfraction}{1.0}
56
57 \makeatletter
58 \renewcommand{\fnum@figure}[1]{\figurename~\thefigure}
59 \newcommand\myparagraph{\@startsection{paragraph}{3}{\z@}%
60 {\parskip}%
61 {0.001\parskip}%
62 {\itshape\normalsize}}
63 \makeatother
64
65 \def\keywords{include portable PDF animation SVG animation animated PDF animated SVG dvisvgm html TeX4ht Web animating embed animated graphics LaTeX pdfLaTeX LuaLaTeX PSTricks pgf TikZ LaTeX-picture MetaPost inline graphics vector graphics animated GIF LaTeX dvips ps2pdf dvipdfmx XeLaTeX JavaScript Acrobat Reader KDE Okular PDF-XChange Foxit Reader PDF.js Firefox Chrome Chromium}
66 \hypersetup{
67 pdftitle={The animate Package},
68 pdfsubject={Documentation},
69 pdfauthor={Alexander Grahn},
70 pdfkeywords={\keywords},
71 allcolors=blue,
72 bookmarksnumbered,linktocpage
73 }
74
75 \def\XeLaTeX{X\kern-.1667em\lower.5ex\hbox{\reflectbox{E}}\kern-.125em\LaTeX}
76 \def\XeTeX{X\kern-.1667em\lower.5ex\hbox{\reflectbox{E}}\kern-.125em\TeX}
77 \def\pXepLaTeX{(X\kern-.1667em\lower.5ex\hbox{\reflectbox{E}})\kern-.125em\LaTeX}
78
79 \def\parsedate#1/#2/#3\relax{
80 \def\year{#1}
81 \def\month{#2}
82 \def\day{#3}
83 }
84
85 \hyphenation{Ja-va-Script pro-vid-ed}
86 \makeatletter
87 \let\animVersion\@anim@version
88 \makeatother
89
90 \begin{document}
91 \title{The {\sffamily animate} Package}
92 \begingroup
93 \makeatletter
94 \def\@anim@sanitizeColon{}\def\@anim@sanitizeJS{}\def\@anim@endsanitize{}
95 \expandafter\parsedate\animVersion\relax %set current date to package date
96 \makeatother
97 \author{Alexander Grahn \animategraphics[autoplay,loop,height=1.8ex,nomouse]{8}{bye_}{0}{3}\protect\footnote{Animated GIF taken from \href{http://www.phpBB.com}{phpBB} forum software and burst into a set of EPS files using \href{http://www.imagemagick.org}{ImageMagick} before embedding.}% \protect\footnote{Animation examples in this document have all been built with the `\texttt{method=widget}' option to make them work in PDF.js, Mozilla's PDF viewer built into the Firefox Web browser.}%
98 %\space\protect\footnote{Animations may run slowly if viewed in the Acrobat Reader browser plugin.}%
99 \\[1ex]\url{https://gitlab.com/agrahn/animate}}
100 \maketitle
101 \endgroup
102 \begin{abstract}
103 \raggedright
104
105 \noindent A LaTeX package for creating portable, JavaScript driven PDF and SVG animations from sets of vector graphics or raster image files or from inline graphics.
106 \vskip 0.2\baselineskip
107
108 \emph{Keywords}: \keywords
109 \end{abstract}
110 %\vspace{1.5cm}
111 \tableofcontents
112
113 %\newpage
114 \section{Introduction}\label{sect:intro}
115 This package provides an interface for creating PDF and SVG files with animated content from sets of graphics or image files, from inline graphics, such as \LaTeX-picture, PSTricks or pgf/TikZ generated pictures, or just from typeset text. Unlike standard movie/video formats, package `animate' allows for animating vector graphics. The result is roughly similar to the SWF (Flash) format, although not as space-efficient.
116
117 Package `animate' supports the usual workflows for making PDF, i.\,e. pdf\LaTeX{}, Lua\-\LaTeX{}, \LaTeX{} $\rightarrow$ \verb+dvips+ $\rightarrow$ \verb+ps2pdf+/Distiller and \pXepLaTeX{} $\rightarrow$ \verb+(x)dvipdfmx+. For animated SVG, it supports the \verb+dvisvgm+ driver. The DVI/XDV used as input for \verb+dvisvgm+ can be generated with \LaTeX{}, Lua\LaTeX{} (in DVI mode with command `\verb+dvilualatex+') and \XeLaTeX{} (with option `\verb+--no-pdf+').
118
119 PDF files with animations can be viewed in Acrobat Reader (except on mobile devices), KDE Okular, PDF-XChange, Foxit Reader, PDF.js (Firefox' built-in PDF viewer and extension for Chromium-based Web browsers). To view a local PDF file in the Web browser, open it by right-click in a file explorer or by starting the Web browser on the command-line, passing the PDF file name as its argument. The full-screen mode, also known as Presentation Mode in PDF.js, can be reached via the \raisebox{0.5\depth}{{\fboxsep=3pt\colorbox{lightgray}{\texttt{\large>>}}}} button at the right end of the toolbar. The PDF.js extension for Chromium/Chrome/Edge can be installed from
120
121 \makebox[\linewidth][l]{\href{https://chromewebstore.google.com/detail/pdf-viewer/oemmndcbldboiebfnladdacbdfmadadm}{\nolinkurl{https://chromewebstore.google.com/detail/pdf-viewer/}}}\\
122 \makebox[\linewidth][r]{\href{https://chromewebstore.google.com/detail/pdf-viewer/oemmndcbldboiebfnladdacbdfmadadm}{\nolinkurl{oemmndcbldboiebfnladdacbdfmadadm}}}
123
124 For animations to play in the Chromium extension, JavaScript needs to be enabled in the settings:
125
126 \makebox[\linewidth][l]{\url{chrome://extensions/?id=oemmndcbldboiebfnladdacbdfmadadm} $\rightarrow$}\\
127 \makebox[\linewidth][r]{Extension options $\rightarrow$ Enable active content (JavaScript) in PDFs}
128
129 Viewing of local files also needs to be enabled in Chromium-based browsers:
130
131 \makebox[\linewidth][l]{\url{chrome://extensions/?id=oemmndcbldboiebfnladdacbdfmadadm} $\rightarrow$}\\
132 \makebox[\linewidth][r]{Allow access to file URLs}
133
134 %Note that option `\texttt{method=widget}' must be set to produce animations that are compatible with PDF.js.
135 %PDF files with animations can be viewed in Acrobat Reader (except on mobile devices), KDE Okular, PDF-XChange, Foxit Reader, PDF.js (as Firefox built-in PDF viewer, or in other Web browsers via URL). The most recent release of PDF.js can be accessed online in a Web browser (Firefox, Chromium, Chrome, Edge, ...) via the following URL:
136 %
137 %\url{https://mozilla.github.io/pdf.js/web/viewer.html?file=}
138 %
139 %Then, to open a local PDF file in PDF.js, click \raisebox{0.5\depth}{{\fboxsep=3pt\colorbox{lightgray}{\texttt{\large>>}}}} at the right end of its tool bar. In the `Tools' menu, click on `Open'. Note that option `\texttt{method=widget}' must be set to produce animations that are compatible with PDF.js.
140
141 Animated SVG produced by means of \LaTeX{} and \verb+dvisvgm+ are self-sufficient files that can be embedded into HTML using the \verb+<object>+ tag or opened directly in a Web browser, such as Chromium or Firefox. Also, presentations, such as `beamer'-class documents, with embedded animations can be exported to SVG instead of PDF and viewed in a Web browser. SVG-capable Web browsers are standard on many platforms and operating systems and thus make SVG a very portable file format. A \LaTeX{} package for embedding video and audio into SVG is also available\cite{media4svg}.
142
143 The user interacts with the animation through optional animation controls or using the mouse like so: pressing the mouse button over the animation widget immediately pauses a playing animation and releasing it resumes playback. Pressing the shift-key at the same time reverses the playback direction. Keeping the mouse button pressed while moving the mouse pointer off the animation widget permanently pauses playback. On mobile devices, tapping on the animation toggles between play and pause.
144
145 %On mobile devices, interaction with an animated SVG is similar to that on desktop devices, just using finger touches instead of mouse button press/release. To permanently pause an animation without the pause button, touch the animation with a second finger, then lift both fingers off.
146
147
148 \section{Requirements}
149 \begin{trivlist}
150 %\item $\varepsilon$-\TeX
151 \item pdf\TeX{}, version $\ge1.40$, or Lua\TeX{}, version $\ge0.95$, for direct PDF output
152 \item Ghostscript, version $\ge9.15$, or Adobe Distiller for PS to PDF conversion
153 \item \verb+dvipdfmx+ for DVI to PDF conversion
154 \item \verb+dvisvgm+ for DVI to SVG conversion (also requires Ghostscript and MuPDF)
155 \item PDF: Acrobat Reader, KDE Okular, PDF-XChange, Foxit Reader, Firefox, version $\ge130$, PDF.js, version $\ge4.4.168$
156 \item SVG: Chromium-based browsers for best performance
157 \end{trivlist}
158
159 \section{Installation}
160 Unzip the file \href{http://mirrors.ctan.org/install/macros/latex/contrib/animate.tds.zip}{`animate.tds.zip'} into the local TDS root directory which can be found by running `\verb+kpsewhich -var-value TEXMFLOCAL+' on the command line.
161
162 After installation, update the file name database by running `\verb+texhash+' on the command line.
163
164 \TeX-Live and MiK\TeX{} users should run the package manager of their system for installation.
165
166 \section{Using the package}
167 First of all, read Section~\ref{sect:bugs} on problems related to this package. Then, invoke the package by putting the line
168 \begin{verbatim}
169 \usepackage[<package options>]{animate}
170 \end{verbatim}
171 to the preamble of the document source, i.\,e. somewhere between \verb+\documentclass+ and \verb+\begin{document}+.
172
173 `animate' honours the package options:
174 \begin{verbatim}
175 dvipdfmx
176 xetex
177 dvisvgm
178 export
179 autoplay
180 autopause
181 autoresume
182 loop
183 palindrome
184 draft
185 final
186 controls[=(all|true|on) |
187 (none|false|off) | {[play][,step][,stop][,speed]}]
188 controlsaligned=left[+<indent>] | center | right[+<indent>]
189 width=<h-size>
190 height=<v-size> | totalheight=<v-size>
191 keepaspectratio
192 scale=<factor>
193 bb=<llx> <lly> <urx> <ury>
194 viewport=<llx> <lly> <urx> <ury>
195 trim=<left> <bottom> <right> <top>
196 hiresbb
197 interpolate
198 pagebox=...
199 buttonsize=<size>
200 buttonbg=<colour>
201 buttonfg=<colour>
202 buttonalpha=<opacity>
203 step
204 nomouse
205 type=<file ext>
206 method=icon | widget | ocg
207 poster[=first | <num> | last | none]
208 alttext=none | {<alternative description>}
209 \end{verbatim}
210 Except for `\verb+dvipdfmx+', `\verb+xetex+', `\verb+dvisvgm+' and `\verb+export+', the listed package options are also available (among others) as command options and will be explained shortly. However, if used as package options they have global scope, taking effect on all animations in the document. In turn, command options locally override global settings. Options without an argument are boolean options and can be negated, with the exception of package-only options `\verb+dvipdfmx+', `\verb+xetex+', `\verb+dvisvgm+ and `\verb+export+', by appending `\verb+=false+'.
211
212 \begin{animateinline}[autoplay,loop,nomouse]{1}\strut\emph{Important:}\newframe[3]\end{animateinline} Option `\verb+-Ppdf+' should \emph{not} be used with \verb+dvips+ when converting DVI to PostScript. If you cannot do without, put `\verb+-D 1200+' \emph{after} `\verb+-Ppdf+' on the command line. Users of \LaTeX-aware text editors with menu-driven toolchain invocation, such as \TeX{}nicCenter, should check the configuration of the \verb+dvips+ call.
213
214 All workflows require the `graphicx' package to be loaded explicitly.
215
216 Options `\verb+dvipdfmx+' or `\verb+dvisvgm+' must be set for the document class, as in
217 %\verb+\documentclass[dvipdfmx,...]{...}+,
218 \begin{verbatim}
219 \documentclass[dvipdfmx,...]{...}
220 \end{verbatim}
221 or
222 \begin{verbatim}
223 \documentclass[dvisvgm,...]{...}
224 \end{verbatim}
225 because these drivers cannot be auto-detected by `animate', `graphicx' and other packages.
226
227 Usually, a second \LaTeX{} run is necessary to resolve internally created object references. A warning message will be issued if appropriate.
228
229 With option `\verb+export+', animation frames are output as individual pages of a multipage document that can be converted to other file formats, such as animated GIF. The `standalone' document class must be used together with `\verb+export+':
230 \begin{verbatim}
231 \documentclass{standalone}
232 \usepackage[export]{animate}
233 \end{verbatim}
234 or
235 \begin{verbatim}
236 \documentclass[export]{standalone}
237 \usepackage{animate}
238 \end{verbatim}
239
240 %\clearpage
241 \section{The user interface}
242 Package `animate' provides the command
243 \begin{verbatim}
244 \animategraphics[<options>]{<frame rate>}{<file basename>}{<first>}{<last>}
245 \end{verbatim}
246 and the environment
247 \begin{verbatim}
248 \begin{animateinline}[<options>]{<frame rate>}
249 ... typeset material ...
250 \newframe[<frame rate>]
251 ... typeset material ...
252 \newframe*[<frame rate>]
253 ... typeset material ...
254 \newframe
255 \multiframe{<number of frames>}{[<variables>]}{
256 ... repeated (parameterized) material ...
257 \multiframebreak % optional!
258 }
259 \newframe*[...] % some \newframe variant required
260 \multiframe{...}{...}{ % between two \multiframes
261 ...
262 }
263 \end{animateinline}
264 \end{verbatim}
265
266 While \verb+\animategraphics+ can be used to assemble animations from sets of existing graphics files or from multipage PDF, the environment `\verb+animateinline+' is meant to create the animation from the typeset material it encloses. This material can be pictures drawn within the \LaTeX{} `\verb+picture+' environment or using the advanced capabilities of PSTricks or pgf/TikZ. Even ordinary textual material may be animated in this way. The parameter \verb+<frame rate>+ specifies the number of frames per second of the animation.
267
268 The \verb+\newframe+ command terminates a frame and starts the next one. It can be used only inside the `\verb+animateinline+' environment. There is a starred variant, \verb+\newframe*+. If placed after a particular frame, it causes the animation to pause at that frame. The animation continues as normal after clicking it again. Both \verb+\newframe+ variants take an optional argument that allows the frame rate to be changed in the middle of an animation.
269
270 The \verb+\multiframe+ command allows the construction of loops around pictures. The first argument \verb+<number of frames>+ does what one would expect it to do, the second argument \verb+<variables>+ is a comma-separated list of variable declarations. The list may be of arbitrary, even zero, length. Variables may be used to parameterize pictures which are defined in the loop body (third argument of \verb+\multiframe+). A single variable declaration has the form
271 \begin{verbatim}
272 <variable name>=<initial value>+<increment>
273 \end{verbatim}
274 \verb+<variable name>+ is a sequence of one or more letters \emph{without} a leading backslash\footnote{This is different from {\tt\string\multido} (package `multido') where variable names have a leading `{\tt\textbackslash}' in the declaration.}. The first (and possibly only) letter of the variable name determines the type of the variable. There are three different types: integers (`\verb+i+', `\verb+I+'), reals (`\verb+n+', `\verb+N+', `\verb+r+', `\verb+R+') and dimensions or \LaTeX{} lengths (`\verb+d+', `\verb+D+'). Upon first execution of the loop body, the variable takes the value \verb+<initial value>+. Each further iteration increments the variable by \verb+<increment>+. Negative increments must be preceded by `\verb+-+'. Here are some examples: `\verb:i=1+2:', `\verb:Rx=10.0+-2.25:', `\verb:dim=20pt+1ex:'. Within the loop body, variables are expanded to their current value by prepending a backslash to the variable name, that is \verb+\i+, \verb+\Rx+ and \verb+\dim+ according to the previous examples. \verb+\multiframe+ must be surrounded by \verb+\begin{animateinline}+ and \verb+\end{animateinline}+ or by any of the \verb+\newframe+ variants. Two consecutive \verb+\multiframe+ commands must be separated by one of the \verb+\newframe+ variants.
275
276 \verb+\multiframebreak+ can be called to terminate a \verb+\multiframe+ loop prematurely, usually as part of a conditional statement. This command should preferably be placed near the end of the loop body in order not to produce an empty animation frame.
277
278 By default, the animation is built frame by frame in the order of inclusion of the embedded material. However, extended control of the order of appearance, superposition and repetition of the material is available through the `\verb+timeline+' option (see Section~\ref{sect:timeline}).
279
280 \myparagraph*{Sets of graphics files}
281 All files of the sequence should exist and be consecutively numbered. (Exception to this rule is allowed in connection with the `\verb+every+' option, see below.) {\tt <file base\-name>} is the leftmost part of the file name that is common to all members of the sequence. \verb+<first>+ is the number of the first and \verb+<last>+ the number of the last file in the set. If \verb+<first>+ is greater than \verb+<last>+, files are embedded in reverse order. File names may be simply numbered, such as $0\dots99$. If there are leading zeros, make sure that all file numbers have the same number of digits, such as $0000\dots0099$, and that the \verb+<first>+ and \verb+<last>+ arguments are filled in accordingly.
282
283 For example, given the sequence `frame\_5.png' through `frame\_50.png' from a possibly larger set that shall be used to build an animation running at 12 frames per second, the correct inclusion command would read
284 \begin{verbatim}
285 \animategraphics{12}{frame_}{5}{50}
286 \end{verbatim}
287
288 The possible file formats depend on the output driver being used. In the case of \LaTeX{} + \verb+dvips+, files with the `eps' extension are at first searched for, followed by `mps' (\MP-generated PostScript) and `ps'. With pdf\LaTeX{} and Lua\LaTeX{} the searching order is: (1)~`pdf', (2)~`mps', (3)~`png', (4)~`jpg', (5)~`jpeg', (6)~`jp2'\footnotemark[1], (7)~`j2k'\footnotemark[1], (10)~`jpx'\footnotemark[1]\footnotetext[1]{Only Lua\LaTeX{} currently supports JPEG2000.}, with \XeLaTeX{} or \LaTeX{}+\verb+dvipdfmx+: (1)~`pdf', (2)~`mps', (3)~`eps', (4)~`ps', (5)~`png', (6)~`jpg', (7)~`jpeg', (8)~`bmp', and with \LaTeX{}+\verb+dvisvgm+: (1)~`pdf', (2)~`eps', (3)~`ps', (4)~`mps', (5)~`svg', (6)~`png', (7)~`jpg', (8)~`jpeg'. That is, files capable of storing vector graphics are found first. Make sure that all file names have \emph{lower case} extensions.
289
290 This searching procedure can be skipped thanks to the package and command option `\verb+type=<file ext>+'. It enforces the embedding of files with the given file name extension \verb+<file ext>+.
291
292 Command \verb+\graphicspath{}+ from the `graphicx' package can be used to specify directories to be browsed for graphics files.
293
294 \myparagraph*{Multipage PDF inclusion} %{\rm(pdf\LaTeX, \XeLaTeX, \texttt{dvipdfmx})} and JBIG2 {\rm(pdf\LaTeX)} inclusion}
295 Lua\LaTeX{}, pdf\LaTeX{}, \XeLaTeX{} and the \verb+dvipdfmx+ and \verb+dvisvgm+ backends are able to embed animation frames from multipage PDF. If the file `\verb+<file basename>+.pdf' exists, it is taken as a multipage document where each page represents one frame of the animation. In this case, the last two arguments, \verb+<first>+ \& \verb+<last>+, are interpreted differently from above; they specify a zero-based range of pages to be included in the animation. Either or both of them may be omitted, `\verb+{}+', in which case they default to $0$ and $n-1$, where $n$ is the total number of available pages. Arguments that fall outside this range are automatically corrected to the actual limits. If \verb+<first>+ is greater than \verb+<last>+, pages are embedded in reverse order. Again, option `\verb+type=<file ext>+' can be used to enforce a particular file extension.
296
297 For example, the line
298 \begin{verbatim}
299 \animategraphics{12}{frames}{}{}
300 \end{verbatim}
301 would create an animation from all pages of the file `frames.pdf', running at 12 fps.
302
303 %\clearpage
304 \section{Command options}
305 The following options to \verb+\animategraphics+ and `\verb+animateinline+' have been provided.
306 \subsection{Basic options}
307 \begin{verbatim}
308 label=<label text>
309 \end{verbatim}
310 The animation is given a label, \verb+<label text>+, which must be unique. Labelling an animation enables its JavaScript programming interface by defining \verb+anim['<label+ \verb+text>']+, which is a JavaScript reference to the animation object. The animation object provides a number of properties and methods that can be used for controlling the animation playback from within user defined JavaScript. For details, see Section~\ref{sect:api}.
311 \begin{verbatim}
312 type=[<file ext>]
313 \end{verbatim}
314 Overrides the searching procedure for graphics files explained in the previous section and forces files with extension \verb+<file ext>+ to be used. Given with an empty argument as in `\verb+type=+', this option locally reinstates the default searching procedure if it was globally disabled through the package option.
315 \begin{verbatim}
316 poster[=first | <num> | last | none]
317 \end{verbatim}
318 Specifies which frame to display and print if the animation is not activated. The first frame is shown by default. Thus, `\verb+poster+' or `\verb+poster=first+' need not be explicitly set. A frame number \verb+<num>+ may as well be given; \verb+<num>+ is zero-based, that is, the first frame has number `0'.
319 \begin{verbatim}
320 every=<num>
321 \end{verbatim}
322 Build animation from every \verb+<num>+\emph{th} frame only. Skipped frames are discarded and not embedded into the document. In the case of \verb+\animategraphics+, skipped input files may be missing.
323 \begin{verbatim}
324 autopause
325 \end{verbatim}
326 Pause animation when the page is closed, instead of stopping and rewinding it to the default frame.
327 \begin{verbatim}
328 autoplay
329 \end{verbatim}
330 Start animation after the page has opened. Also resumes playback of a previously paused animation.
331 \begin{verbatim}
332 autoresume
333 \end{verbatim}
334 Resume previously paused animation when the page is opened again.
335 \begin{verbatim}
336 loop
337 \end{verbatim}
338 The animation restarts immediately after reaching the end.
339 \begin{verbatim}
340 palindrome
341 \end{verbatim}
342 The animation continuously plays forwards and backwards.
343 \begin{verbatim}
344 step
345 \end{verbatim}
346 Step through the animation one frame at a time per mouse-click. The \verb+<frame rate>+ argument will be ignored.
347 \begin{verbatim}
348 width=<h-size>
349 height=<v-size> | totalheight=<v-size>
350 keepaspectratio
351 \end{verbatim}
352 Resize the animation widget. If only one of `\verb+width+' or `\verb+[total]height+' is given, the other dimension of the animation widget is scaled to maintain the aspect ratio of the first frame's content. If both `\verb+width+' and `\verb+[total]height+' are given together with `\verb+keepaspectratio+', the first frame's content is resized to fit within \verb+<h-size>+ and \verb+<v-size>+ while maintaining its original aspect ratio. Any valid \TeX{} dimension is accepted as a parameter. In addition, the length commands \verb+\width+, \verb+\height+, \verb+\depth+ and \verb+\totalheight+ can be used to refer to the original dimensions of the first frame of the animated sequence.
353 \begin{verbatim}
354 scale=<factor>
355 \end{verbatim}
356 Scales the animation widget by \verb+<factor>+.
357 \begin{verbatim}
358 bb=<llx> <lly> <urx> <ury>
359 \end{verbatim}
360 (\verb+\animategraphics+ only.) The four, space separated arguments set the bounding box of the graphics files. Units can be omitted, in which case `bp' (PostScript points) is assumed.
361 \begin{verbatim}
362 viewport=<llx> <lly> <urx> <ury>
363 \end{verbatim}
364 (\verb+\animategraphics+ only.) This option takes four arguments, just like `\verb+bb+'. However, in this case the values are taken relative to the origin specified by the bounding box in the graphics files.
365 \begin{verbatim}
366 trim=<left> <bottom> <right> <top>
367 \end{verbatim}
368 (\verb+\animategraphics+ only.) Crops graphic at the edges. The four lengths specify the amount to be removed from or, if negative values have been provided, to be added to each side of the graphic.
369 %\begin{verbatim}
370 %clip
371 %\end{verbatim}
372 %(\verb+\animategraphics+ only.) Clips the graphic to the (possibly modified) bounding box.
373 \begin{verbatim}
374 pagebox=...
375 hiresbb
376 interpolate
377 \end{verbatim}
378 (\verb+\animategraphics+ only.) Options from the `graphics' bundle. Refer to the `graphics' package manual for their meaning.
379 \begin{verbatim}
380 controls[=all | true | on]
381 controls=(none | false | off) | {[play][,step][,stop][,speed]}
382 \end{verbatim}
383 Inserts control buttons below the animation widget. Visibility of buttons can be fine-tuned through optional keys. By default, if setting `\verb+controls+' alone, all available buttons are shown, while any of `\verb+none+', `\verb+false+' or `\verb+off+' suppresses them altogether. A comma-separated selection from `\verb+play+', `\verb+step+', `\verb+stop+' and `\verb+speed+' enables corresponding pairs or groups of buttons. Such a comma list must be enclosed in braces, i.\,e. \verb+controls={play, stop}+. If all buttons are shown, their meaning is as follows, from left to right: stop \& first frame, step backwards, play backwards, play forwards, step forwards, stop \& last frame, decrease speed, default speed, increase speed. Both `play' buttons are replaced by a large `pause' button while the animation is playing.
384 \begin{verbatim}
385 controlsaligned=left[+<indent>] | center | right[+<indent>]
386 \end{verbatim}
387 Animation controls are centred below the animation widget by default. With this option one can choose between centred, flush-left or flush-right alignment. The optional \verb+<indent>+ inserts additional horizontal space that pushes the control buttons away from the left or right edge of the animation widget towards the opposite side. \verb+<indent>+ must be a valid \TeX{} dimension. Negative values may be used, as in
388 \begin{verbatim}
389 controlsaligned=right+-4em,
390 \end{verbatim}
391 in which case control buttons protrude beyond the animation's right vertical edge by \verb+4em+.
392 \begin{verbatim}
393 buttonsize=<size>
394 \end{verbatim}
395 Changes the control button height to \verb+<size>+, which must be a valid \TeX{} dimension. The default button height is \verb+1.44em+ and thus scales with the current font size.
396 \begin{verbatim}
397 buttonbg=<colour>
398 buttonfg=<colour>
399 buttonalpha=<opacity>
400 \end{verbatim}
401 By default, control button widgets are drawn with black strokes on empty, fully transparent background. The background can be filled with colour using the first option, while the second option specifies the stroke colour. Option \verb+buttonalpha+ adds transparency to the background colour. The parameter \verb+<colour>+ is an array of colon-(\verb+:+)-separated numbers in the range from 0.0 to 1.0. The number of array elements determines the colour model in which the colour is defined: (1) gray value, (3) RGB, (4) CMYK. For example, `\verb+1+', `\verb+1:0.5:0.2+' and `\verb+0.5:0.3:0.7:0.1+' are valid colour specifications. The parameter \verb+<opacity>+ is a number between 0.0 and 1.0, where 0.0 produces fully transparent and 1.0 fully opaque buttons.
402 \begin{verbatim}
403 draft
404 final
405 \end{verbatim}
406 With `\verb+draft+' the animation is not embedded. Instead, a box with the exact dimensions of the animation is inserted. Option `\verb+final+' does the opposite as it forces the animation to be built and embedded. Both options can be used to reduce compilation time during authoring of a document. To get the most out of them it is recommended to set `\verb+draft+' globally as a package or class option and to set `\verb+final+' locally as a command option of the animation that is currently being worked on. After the document has been finished, the global `\verb+draft+' option can be removed to embed all animations.
407 \begin{verbatim}
408 nomouse
409 \end{verbatim}
410 Animation widget will not respond to mouse clicks. Unless the JavaScript interface, Section~\ref{sect:api}, p.~\pageref{sect:api}, is used to control the animation, it is recommended to also set at least one of the `\verb+autoplay+' or `\verb+controls+' options.
411 \begin{verbatim}
412 method=icon | widget | ocg
413 \end{verbatim}\hypertarget{method}{}%
414 The package implements three different animation methods. The `\verb+icon+' method usually gives the best performance in terms of animation frame rate in Acrobat Reader. However, the `\verb+widget+' method is now set by default because it extends the range of supporting viewers. Beginning with version 130, Firefox renders functional animations too. The PDF viewer bundled with Firefox, PDF.js, is also available as an extension for Chrome and releated browsers, see Section~\ref{sect:intro}. In rare cases, such as standalone animations without animation controls, the alternative `\verb+ocg+' method may lead to a better animation performance than the other two. Also, `\verb+ocg+' allows an animation to be overlaid with other typeset material, that is, it can play in the page background. However, support is limited to Acrobat Reader and Okular.
415 \begin{verbatim}
416 measure
417 \end{verbatim}
418 Measures the frame rate during one cycle of the animation and prints the value to the JavaScript console of the Reader. (For testing purposes.)
419 \begin{verbatim}
420 alttext=none | {<alternative description>}
421 \end{verbatim}\hypertarget{beginend}{}%
422 Changes or suppresses alternative description text. The default is `{\ttfamily animation by animate\verb+[+\animVersion\verb+]+}'. This text is shown by some PDF viewers that are not capable of rendering JavaScript animations or used for accessibility purposes.
423 \begin{verbatim}
424 begin={<begin text>}
425 end={<end text>}
426 \end{verbatim}\hypertarget{beginend}{}%
427 (`\verb+animateinline+' only.) \verb+<begin text>+ and \verb+<end text>+ are inserted into the code at start and end of each frame. Mainly used for setting up some drawing environment, such as
428 \begin{verbatim}
429 begin={\begin{pspicture}(... , ...)(... , ...)},
430 end={\end{pspicture}}
431 \end{verbatim}
432 A short note on the `\verb+tikzpicture+' environment: Unlike `\verb+pspicture+', the `{\tt tikz\-pic\-ture}' environment is able to determine its size from the graphical objects it encloses. However, this may result in differently sized frames of a sequence, depending on the size and position of the graphical objects. Thus, in order to ensure that all frames of the sequence be displayed at the same scale in the animation widget, a common bounding box should be shared by the frames. A bounding box can be provided by means of an invisible `\verb+rectangle+' object:
433 \begin{verbatim}
434 begin={
435 \begin{tikzpicture}
436 \useasboundingbox (... , ...) rectangle (... , ...);
437 },
438 end={\end{tikzpicture}}
439 \end{verbatim}
440
441 %\clearpage
442 \subsection{The `{\tt timeline}' option}\label{sect:timeline}
443 \begin{verbatim}
444 timeline=<timeline file>
445 \end{verbatim}
446 \verb+<timeline file>+ is a plain text file whose contents determines the order of appearance of the embedded material during the animation. It allows the user to freely rearrange, repeat and overlay the material at any point of the animation. This may greatly reduce the file size of the resulting PDF, as objects that do not change between several or all frames, such as coordinate axes or labels, can be embedded once and re-used in other frames of the animation. (Technically, this is done by the XObject referencing mechanism of PDF.)
447
448 If a timeline is associated with the animation, the graphics files or inline graphics embedded by \verb+\animategraphics+ and `\verb+animateinline+' no longer represent the actual frames of the animation. Rather, they are a collection of \emph{transparencies} that can be played with at will. However, it is now up to the author's responsibility to construct a timeline that makes use of \emph{each} of those transparencies and to put them into a sensible order. In order to identify the transparencies within the timeline file, they are numbered in the order of their inclusion, starting at zero.
449
450 A timeline-based animation can be thought of as a \emph{living stack} of translucent transparencies. Each animation frame is a snapshot of the stack viewed \emph{from above}. Transparencies are usually put on top of that stack and stay there for a given number of frames before expiring (becoming invisible). The lifetime of each transparency within the stack can be set individually. Once expired, a transparency can be put on the stack again, if desired. The stack may also be divided into an arbitrary number of \emph{sub-stacks} to facilitate the creation of layers, such as background, foreground and intermediate layers. Sub-stacks allow the insertion of transparencies at depth positions of the global stack other than just the top. It is important to keep the stack-like nature of animations in mind because graphical objects on transparencies at higher stack positions overlay the content of transparencies at lower stack positions.
451
452 \myparagraph*{General structure of the timeline file}
453 Each line of the timeline file that is not blank and which does not begin with a comment (`\verb+%+') corresponds to \emph{one} frame of the animation. There may be more transparencies than animation frames and vice-versa. A frame specification consists of three or four colon-(\verb+:+)-separated fields:
454 \begin{verbatim}
455 [*]:[<frame rate>]:[<transparencies>][:<JavaScript>]
456 \end{verbatim}
457 While any field may be left blank, the first two colons are mandatory. The fourth field, \verb+<JavaScript>+, is explained on p.~\pageref{sect:jsfield}.
458
459 An asterisk (`\verb+*+') in the leftmost field causes the animation to pause at that frame, very much as a \verb+\newframe*+ would do; a number in the second field changes the frame rate of the animation section that follows. In connection with the `\verb+timeline+' option, the asterisk extension and the optional \verb+<frame rate>+ argument of \verb+\newframe+ cease to make sense and will be tacitly ignored if present.
460
461 The third field \verb+<transparencies>+ is a comma-separated \emph{list} of \emph{transparency specifications} that determines the transparencies to be put on the stack. Semicolons (\verb+;+) are used to separate sub-stacks (= layers) from each other. A \emph{single} transparency specification obeys the syntax
462 \begin{verbatim}
463 <transparency ID>[x<number of frames>]
464 \end{verbatim}
465 where \verb+<transparency ID>+ is an integer number that identifies the transparency to be drawn into the current animation frame. As pointed out above, the transparencies are consecutively numbered in the order of their inclusion, starting at zero. The optional postfix `\verb+x<number of frames>+' specifies the number of consecutive frames within which the transparency is to appear. If omitted, a postfix of `\verb+x1+' is assumed, which causes the transparency to be shown in the current frame only. Obviously, \verb+<number of frames>+ must be a non-negative integer number. The meaning of postfix `\verb+x0+' is special; it causes the transparency to be shown in all frames, starting with the current one, until the end of the animation or until the animation sub-stack to which it belongs is explicitly cleared.
466
467 The letter `\verb+c+', if put into \verb+<transparencies>+, clears an animation sub-stack, that is, it causes all transparencies added so far to be removed from the sub-stack, overriding any \verb+<number of frames>+ value. The effect of `\verb+c+' is restricted to the sub-stack in which it appears. Thus, a `\verb+c+' must be applied to every sub-stack if the complete animation stack is to be cleared. Moreover, if applied, `\verb+c+' should go into the first position of the transparency list of a sub-stack because \emph{everything} in the sub-stack up to `\verb+c+' will be cleared.
468
469 %If a frame is composed of more than one transparency, transparency specifications on the left of the input line are closer to the background and will be overprinted by those on the right of the input line or which appear on subsequent lines of the timeline file. That is, the depth \emph{de}creases from left to right within \verb+<transparencies>+ as well as in top-down direction within the timeline file.
470 %Also, if there are transparency specifications which span several frames (using postfix `\verb+x<number of frames>+'), they will be overprinted by transparency specifications that appear on subsequent lines in the timeline file. That is, the depth decreases in top-down direction within the timeline file.
471
472 \myparagraph*{Timeline example with a single animation stack}
473 Table~\ref{tab:single} is an example of a single-stack animation. It lists the contents of a timeline file together with the resulting stack of transparencies. Note how the stack is strictly built from the bottom up as transparency specifications are read from left to right and line by line from the timeline file. In frame No. 4, the stack is first cleared before new transparencies are deposited on it. Also note that the stack is viewed from above and transparencies in higher stack position overprint the lower ones.
474
475 \begin{table}[h]\centering
476 \caption{Timeline example of a single-stack animation}\label{tab:single}
477 \begin{tabular}[t]{c|l|c}\hline
478 frame No. & timeline file & transparency stack\\\hline\hline
479 \multirow{2}{*}{0} & \multirow{2}{*}{\tt::0x0,1x2} & ---------1---------\\&&---------0---------\\\cline{1-1}\cline{3-3}
480 \multirow{3}{*}{1} & \multirow{3}{*}{\tt::2} & ---------2---------\\&&---------1---------\\&&---------0---------\\\cline{1-1}\cline{3-3}
481 \multirow{2}{*}{2} & \multirow{2}{*}{\tt::3} & ---------3---------\\&&---------0---------\\\cline{1-1}\cline{3-3}
482 \multirow{2}{*}{3} & \multirow{2}{*}{\tt::4} & ---------4---------\\&&---------0---------\\\cline{1-1}\cline{3-3}
483 \multirow{2}{*}{4} & \multirow{2}{*}{\tt::c,5x0,6} & ---------6---------\\&&---------5---------\\\cline{1-1}\cline{3-3}
484 \multirow{2}{*}{5} & \multirow{2}{*}{\tt::7} & ---------7---------\\&&---------5---------\\\cline{1-1}\cline{3-3}
485 \multirow{2}{*}{6} & \multirow{2}{*}{\tt::8} & ---------8---------\\&&---------5---------\\\cline{1-1}\cline{3-3}
486 \multirow{2}{*}{7} & \multirow{2}{*}{\tt::9} & ---------9---------\\&&---------5---------\\\hline
487 \end{tabular}
488 \end{table}
489
490 Figures~\ref{fig:taylor} and \ref{fig:lorenz} in Section~\ref{sect:examples} are animation examples with a single transparency stack.
491
492 \myparagraph*{Grouping objects into layers (= sub-stacks) using `{\tt;}'}
493 Due to the stack-like nature of the animation, the position of a transparency specification in the timeline file determines its \emph{depth} level in relation to other transparencies. The timeline file is processed line by line and from left to right. In a single-stack animation, the stack is strictly built from the bottom up, such that earlier transparencies are overprinted by more recent ones. This may turn out to be inconvenient in certain situations. For example, it might be desirable to change the background image in the middle of an animation without affecting objects that are located in the foreground. For this purpose, transparency specifications can be grouped into layers (sub-stacks) using the semicolon (\verb+;+) as a separator. New transparencies can now be put on top of the individual sub-stacks. After a line of the timeline file has been processed, the global stack is built by placing the sub-stacks on top of the other. Again, the left-to-right rule applies when determining the height of the sub-stacks in relation to each other within the global stack.
494
495 The layer concept is best illustrated by an example. In the timeline of Table~\ref{tab:multi}, transparencies are grouped into two sub-stacks only. One is reserved for the background images, transparencies No. 0 \& 1, to be exchanged in frame No. 3, as well as for two other transparencies, No. 7 \& 8, to be interspersed in frame No. 1. A second sub-stack takes the foreground objects that are successively added to the scene. The dotted lines in the third column of the table just mark the border between the two sub-stacks. In frame No. 3, `\verb+c+' first clears the bottom sub-stack before the new background image is inserted. (Instead, `\verb+x3+' could have been used with transparency No. 0 in frame No. 0.) As can be seen in the specifications of frames No. 2 \& 4, sub-stacks need not be explicitly populated; the leading semicolons just ensure the proper assignment of transparencies to animation sub-stacks.
496
497 \begin{table}[t]\centering
498 \caption{Timeline example with two sub-stacks}\label{tab:multi}
499 \begin{tabular}[t]{c|l|c}\hline
500 frame No. & timeline file & transparency stack\\\hline\hline
501 \multirow{3}{*}{0} & \multirow{3}{*}{\tt::\ \ 0x0 ; 2x0} & ---------2---------\\&&{\tiny\dotfill}\\&&---------0---------\\\cline{1-1}\cline{3-3}
502 \multirow{6}{*}{1} & \multirow{6}{*}{\tt::7,8x2 ; 3x0} & ---------3---------\\&&---------2---------\\&&\tiny\dotfill\\&&---------8---------\\&&---------7---------\\&&---------0---------\\\cline{1-1}\cline{3-3}
503 \multirow{6}{*}{2} & \multirow{6}{*}{\tt::\ \ \ \ \ \ ; 4x0} & ---------4---------\\&&---------3---------\\&&---------2---------\\&&\tiny\dotfill\\&&---------8---------\\&&---------0---------\\\cline{1-1}\cline{3-3}
504 \multirow{6}{*}{3} & \multirow{6}{*}{\tt::c,1x0 ; 5x0} & ---------5---------\\&&---------4---------\\&&---------3---------\\&&---------2---------\\&&\tiny\dotfill\\&&---------1---------\\\cline{1-1}\cline{3-3}
505 \multirow{7}{*}{4} & \multirow{7}{*}{\tt::\ \ \ \ \ \ ; 6x0} & ---------6---------\\&&---------5---------\\&&---------4---------\\&&---------3---------\\&&---------2---------\\&&\tiny\dotfill\\&&---------1---------\\\hline
506 \end{tabular}
507 \end{table}
508
509 %\small
510 %\begin{verbatim}
511 % % <--layer 1--> <--layer 2-->
512 % %
513 % :: 0x49 ; 2x0,3x0 % transparency `0' used as background
514 % :: ; 4x0,5x0 % image during the first 49 frames
515 % :: ; 6x0,7x0
516 % etc...
517 % :: ; 98x0,99x0
518 % :: 1x0 ; 100x0,101x0 % transparency `1' used as new background
519 % :: ; 102x0,103x0 % image until end of animation
520 % :: ; 104x0,105x0
521 % etc...
522 %\end{verbatim}
523 %\normalsize
524 %
525 %Note that \emph{without} setting up two layers, that is, by replacing the semicolons with commas, the foreground objects (transparencies 2 through 99) which have been added during the first 49 frames would be overprinted by the new background image, transparency 1, from frame 50 onward.
526
527 See the second animation, Fig.~\ref{fig:scarab}, in Section~\ref{sect:examples} for a working example that makes use of the timeline and the layer concept.
528
529 \myparagraph*{Associate JavaScript actions with animation frames}\label{sect:jsfield}
530 The optional fourth field \verb+<JavaScript>+ in a frame specification takes JavaScript code to be executed upon display of that frame. This could be used, for instance, to play a sound that was embedded using the `media9' \LaTeX{} package \cite{media9} or to execute JavaScript methods of the animation object. A non-trivial example is looping over a sub-range of frames which can be programmed by setting the `\verb+frameNum+' property of the animation object. See Section~\ref{sect:api} for details of the animation programming interface.
531
532 The backslash `\verb+\+' and percent `\verb+%+' characters retain their special meaning from \LaTeX{} and must be escaped by a backslash `\verb+\+' in the JavaScript code. The same applies to unbalanced braces `\verb+{+' and `\verb+}+'. Thus, a code line such as
533 \begin{verbatim}
534 console.println('{}%}{\n');
535 \end{verbatim}
536 would have to look like
537 \begin{verbatim}
538 console.println('{}\%\}\{\\n');
539 \end{verbatim}
540 in the timeline file. The first pair of braces are balancing themselves and do not need to be escaped.
541
542 Note that JavaScript is executed at the start of displaying the frame. If something is to be executed at the end of a particular frame, the \verb+<JavaScript>+ field should be added to the next frame in the timeline file. However, this is not possible for the last frame in a timeline file. Here, the `\verb+setTimeOut+' method can be used to delay the execution of commands:
543 \begin{verbatim}
544 app.setTimeOut('anim.myanim.frameNum=5;', 0.5*anim.myanim.dt)
545 \end{verbatim}
546 In this example, the 6th frame will be displayed after half of the current frame's lifetime has elapsed.
547
548 \myparagraph*{Other things to note}
549 When designing the timeline, care should be taken not to include a transparency more than once into the \emph{same} animation frame. Besides the useless redundancy, this may slow down the animation speed in the Reader because the graphical objects of a multiply included transparency have to be rendered unnecessarily often at the same time. `animate' is smart enough to detect multiple inclusion and issues a warning message along with the transparency ID and the frame number if it occurs. Here is an example of a poorly designed timeline:
550 %\small
551 \begin{lstlisting}
552 ::0
553 ::1x0
554 ::2
555 ::3
556 ::4,2
557 ::5,1 % bad: transparency `1' included twice
558 ::6
559 \end{lstlisting}
560 \normalsize
561 Also, `animate' finds and warns about transparencies that have never been used in an animation timeline. This may help to avoid dead code in the final PDF.
562
563 %\clearpage
564 \section{Programming interface}\label{sect:api}
565 The package provides a simple JavaScript programming interface which gives access to the animation objects in a PDF file. A particular animation property or method can be accessed by
566 \begin{verbatim}
567 anim['<anim label>'].<property or method>
568 \end{verbatim}
569 or
570 \begin{verbatim}
571 anim.<anim label>.<property or method>
572 \end{verbatim}
573 `\verb+anim+' is an array of animation object references. Animations must be labelled using the `\verb+label=...+' command option in order to be present in the `\verb+anim+' array. As usual, properties and methods are accessed via the dot notation. Properties and methods of the animation object are summarized in Tables \ref{tab:props} and \ref{tab:methods}.
574
575 \begin{table}[hbp]%[p]%[hbp]
576 \centering
577 \caption{Animation object properties}\label{tab:props}
578 \begin{tabularx}{\linewidth}[t]{lllX}\hline
579 name & type & access & description\\\hline\hline
580 {\tt numFrames} & Integer & read-only & Holds the total number of animation frames.\\
581 {\tt frameNum} & Integer & read+write & Gets or sets the current frame being/to\,be displayed. Note that frame numbers are zero-based. Assigning a value less than zero or greater than {\tt numFrames-1} results in an error.\\
582 {\tt fps} & Number & read+write & Gets or temporarily sets the animation frame rate (frames per second). Reset after reaching the end of a sequence, or if the frame rate is set in a timeline or by {\tt\string\newframe[<frame rate>]}. For scaling overall animation speed, consider using the \Verb+speed+ property. Assigning a value less than zero results in an error.\\
583 {\tt speed} & Number & read+write & Globally scales animation speed. The value must be greater than zero. A value of {\tt 1} means `normal speed' as specified by the frame rate in the document source. Larger values mean `faster', values between zero and one mean `slower'.\\
584 {\tt dt} & Number & read-only & Holds the time span (milliseconds) for display of the current frame.\\
585 {\tt isPlaying} & Boolean & read-only & Holds the value {\tt true} if the animation is currently playing, {\tt false} otherwise.\\
586 {\tt playsFwd} & Boolean & read-only & Holds the value {\tt true} if the animation is played forward, independently of whether the animation is currently paused or not.\\
587 \hline
588 \end{tabularx}
589 \end{table}
590
591 \begin{table}[htp]%[p]%[htbp]
592 \centering
593 \caption{Animation object methods}\label{tab:methods}
594 \begin{tabularx}{\linewidth}[t]{lX}\hline
595 name & description\\\hline\hline
596 {\tt playFwd()} & Starts playing the animation in the forward direction, setting the properties {\tt isPlaying} and {\tt playsFwd} to {\tt true}.\\
597 {\tt playBwd()} & Starts playing the animation in the backward direction, setting {\tt isPlaying} to {\tt true} and {\tt playsFwd} to {\tt false}.\\
598 {\tt pause()} & Pauses animation, setting {\tt isPlaying} to {\tt false}.\\
599 {\tt stopFirst()} & Stops animation and rewinds to the first frame. {\tt isPlaying} is set to false.\\
600 {\tt stopLast()} & Stops animation and goes to the last frame. {\tt isPlaying} is set to false.\\
601 \hline
602 \end{tabularx}
603 \end{table}
604
605 One potential use of the JavaScript interface could be within a timeline file associated with an animation. For example, loops over a sub-range of frames can be programmed by setting the `\verb+frameNum+' property. See Section~\ref{sect:timeline}, p.~\pageref{sect:jsfield} for details.
606
607 Also, the programming interface can be used to create custom buttons for playback control. The command \verb+\mediabutton+ from the `media9' package provides a convenient way for achieving this:
608 \begin{lstlisting}
609 \usepackage{media9}
610 \usepackage{animate}
611 ...
612
613 \animategraphics[label=my_anim]{12}{...}{...}{...}
614
615 \mediabutton[
616 jsaction={anim['my_anim'].playFwd();}
617 ]{\fbox{Play}}
618 \mediabutton[
619 jsaction={anim['my_anim'].frameNum=5;}
620 ]{\fbox{Goto 6th frame}}
621 \end{lstlisting}
622
623 %\clearpage
624 \section{Examples}
625 \subsection{Animations from sets of files, using {\tt\textbackslash animategraphics}}\label{sect:examples}
626 Animations in this section are made from graphics files that were prepared with \MP. Run `\verb+mpost --tex=latex+' on the files ending in `.mp' in the `files' directory to generate the graphics files. Both examples make use of the `\verb+timeline+' option to reduce the resulting PDF file size.
627
628 The first example, Fig.~\ref{fig:taylor}, originally written by Jan Holeček~\cite{hol}, shows the exponential function $y=e^x$ and its approximation by Taylor polynomials of different degree. Below the animation, a custom button was inserted using the JavaScript programming interface and the \verb+\mediabutton+ command from the `media9' package.
629
630 %\small
631 \begin{lstlisting}
632 \documentclass{article}
633 \usepackage{animate}
634 \usepackage{media9}
635 \usepackage{graphicx}
636
637 \begin{filecontents}{timeline.txt}
638 ::0x0 % coordinate system & y=e^x, repeated until last frame
639 ::1 % one blue curve per frame
640 ::2
641 ::3
642 ::4
643 ::5
644 ::6
645 ::7
646 ::8
647 \end{filecontents}
648
649 \begin{document}
650
651 \begin{center}
652 \animategraphics[
653 label=taylor,
654 controls, loop,
655 timeline=timeline.txt
656 ]{4}{exp_}{0}{8}
657
658 \mediabutton[
659 jsaction={
660 if(anim['taylor'].isPlaying)
661 anim['taylor'].pause();
662 else
663 anim['taylor'].playFwd();
664 }
665 ]{\fbox{Play/Pause}}
666 \end{center}
667
668 \end{document}
669 \end{lstlisting}
670 %\normalsize
671 \begin{figure}\capstart
672 \centering
673 \begin{VerbatimOut}{timeline.txt}
674 ::0x0 % coordinate system & y=e^x, repeated until last frame
675 ::1 % one blue curve per frame
676 ::2
677 ::3
678 ::4
679 ::5
680 ::6
681 ::7
682 ::8
683 \end{VerbatimOut}
684 \animategraphics[
685 label=taylor,
686 controls, loop,
687 timeline=timeline.txt
688 ]{4}{exp_}{0}{8}
689
690 \mediabutton[
691 jsaction={
692 if(anim['taylor'].isPlaying)
693 anim['taylor'].pause();
694 else
695 anim['taylor'].playFwd();
696 }
697 ]{\fbox{Play/Pause}}
698 \caption{}\label{fig:taylor}
699 \end{figure}
700
701 The second, somewhat more complex example, Fig.~\ref{fig:scarab}, animates the geometric construction of a scarabaeus. In addition to the use of a timeline, it introduces the layer concept. This example is adapted from Maxime Chupin's original \MP{} source file \cite{chupin}. The present version separates stationary from moving parts of the drawing and saves them into different files. A total of 254 files, scarab\_0.mps through scarab\_253.mps, is written out by running `\verb+mpost --tex=latex+' on the source file `scarab.mp'. Files 0 through 100 contain the red line segments that make up the growing scarabaeus. Files 101 through 201 contain the moving construction lines and files 202 through 252 contain the gray lines which represent intermediate stages of the construction. The last file, No. 253, contains the coordinate axes, two stationary construction lines and the labels which do not move. A timeline file `scarab.tln' is written out on-the-fly during the \LaTeX{} run. It arranges the animation into three layers, forcing the gray lines into the background, the coordinate axes into the intermediate layer and the scarabaeus along with the moving construction lines into the foreground. The final animation consists of 101 individual frames.
702 \begin{figure}[t]
703 \centering
704 \newcounter{scarab}
705 \setcounter{scarab}{0}
706 \newcounter{blueline}
707 \setcounter{blueline}{101}
708 \newcounter{grayline}
709 \setcounter{grayline}{202}
710 %
711 \newwrite\TimeLineFile
712 \immediate\openout\TimeLineFile=scarab.tln
713 \whiledo{\thescarab<101}{
714 \ifthenelse{\intcalcMod{\thescarab}{2}=0}{
715 \immediate\write\TimeLineFile{::\thegrayline x0;253;\thescarab x0,\theblueline}
716 \stepcounter{grayline}
717 }{
718 \immediate\write\TimeLineFile{::;253;\thescarab x0,\theblueline}
719 }
720 \stepcounter{scarab}
721 \stepcounter{blueline}
722 }
723 \immediate\closeout\TimeLineFile
724 %
725 \animategraphics[
726 type=mps,
727 width=0.8\linewidth,
728 controls,
729 loop,
730 timeline=scarab.tln
731 ]{12}{scarab_}{0}{253}
732 %
733 \caption{}\label{fig:scarab}
734 \end{figure}
735
736 %\small
737 \begin{lstlisting}
738 \documentclass{article}
739 \usepackage{intcalc} %defines \intcalcMod for Modulo computation
740 \usepackage{animate}
741 \usepackage{graphicx}
742
743 \newcounter{scarab}
744 \setcounter{scarab}{0}
745 \newcounter{blueline}
746 \setcounter{blueline}{101}
747 \newcounter{grayline}
748 \setcounter{grayline}{202}
749
750 %write timeline file
751 \newwrite\TimeLineFile
752 \immediate\openout\TimeLineFile=scarab.tln
753 \whiledo{\thescarab<101}{
754 \ifthenelse{\intcalcMod{\thescarab}{2}=0}{
755 %a gray line is added to every 2nd frame
756 \immediate\write\TimeLineFile{%
757 ::\thegrayline x0;253;\thescarab x0,\theblueline}
758 \stepcounter{grayline}
759 }{
760 \immediate\write\TimeLineFile{%
761 ::;253;\thescarab x0,\theblueline}
762 }
763 \stepcounter{scarab}
764 \stepcounter{blueline}
765 }
766 \immediate\closeout\TimeLineFile
767
768 \begin{document}
769
770 \begin{center}
771 \animategraphics[
772 width=0.8\linewidth,
773 controls, loop,
774 timeline=scarab.tln
775 ]{12}{scarab_}{0}{253}
776 \end{center}
777
778 \end{document}
779 \end{lstlisting}
780 %\normalsize
781 \subsection{Animating PSTricks graphics, using `{\tt animateinline}' environment}
782 Fig.~\ref{fig:torus} is an inline graphics example adapted from \cite{gilg05}.
783 %\small
784 \begin{lstlisting}
785 \documentclass{article}
786 \usepackage{pst-3dplot}
787 \usepackage{animate}
788
789 %draws a torus sector
790 \newcommand{\torus}[2]{% #1: angle of the torus sector,
791 % #2: linewidth of leading circle
792 \psset{Beta=20,Alpha=50,linewidth=0.1pt,origin={0,0,0},unit=0.35}%
793 \begin{pspicture}(-12.3,-6.3)(12.3,7)%
794 \parametricplotThreeD[xPlotpoints=100](80,#1)(0,360){%
795 t cos 2 mul 4 u sin 2 mul add mul
796 t sin 2 mul 4 u sin 2 mul add mul
797 u cos 4 mul
798 }%
799 \parametricplotThreeD[yPlotpoints=75](0,360)(80,#1){%
800 u cos 2 mul 4 t sin 2 mul add mul
801 u sin 2 mul 4 t sin 2 mul add mul
802 t cos 4 mul
803 }%
804 \parametricplotThreeD[yPlotpoints=1,linewidth=#2](0,360)(#1,#1){%
805 u cos 2 mul 4 t sin 2 mul add mul
806 u sin 2 mul 4 t sin 2 mul add mul
807 t cos 4 mul
808 }%
809 \end{pspicture}%
810 }
811
812 \begin{document}
813
814 \begin{center}
815 \begin{animateinline}[poster=last, controls, palindrome]{12}%
816 \multiframe{29}{iAngle=80+10, dLineWidth=2.9pt+-0.1pt}{%
817 %iAngle = 80, 90, ..., 360 degrees
818 %dLineWidth = 2.9pt, 2.8pt, ..., 0.1pt
819 \torus{\iAngle}{\dLineWidth}%
820 }%
821 \end{animateinline}%
822 \end{center}
823
824 \end{document}
825 \end{lstlisting}
826 %\normalsize
827
828 \begin{figure}
829 \centering
830 \newcommand{\torus}[2]{%
831 \psset{Beta=20,Alpha=50,linewidth=0.1pt,origin={0,0,0},unit=0.35}%
832 \begin{pspicture}(-12.3,-6.3)(12.3,7)%
833 \parametricplotThreeD[xPlotpoints=100](80,#1)(0,360){%
834 t cos 2 mul 4 u sin 2 mul add mul
835 t sin 2 mul 4 u sin 2 mul add mul
836 u cos 4 mul
837 }%
838 \parametricplotThreeD[yPlotpoints=75](0,360)(80,#1){%
839 u cos 2 mul 4 t sin 2 mul add mul
840 u sin 2 mul 4 t sin 2 mul add mul
841 t cos 4 mul
842 }%
843 \parametricplotThreeD[yPlotpoints=1,linewidth=#2](0,360)(#1,#1){%
844 u cos 2 mul 4 t sin 2 mul add mul
845 u sin 2 mul 4 t sin 2 mul add mul
846 t cos 4 mul
847 }%
848 \end{pspicture}%
849 }
850
851 \begin{animateinline}[poster=last,controls,palindrome]{12}%
852 \multiframe{29}{iAngle=80+10, dLineWidth=2.9pt+-0.1pt}{%
853 \torus{\iAngle}{\dLineWidth}%
854 }%
855 \end{animateinline}%
856 \caption{}\label{fig:torus}
857 \end{figure}
858
859 Another inline example, Fig.~\ref{fig:lorenz}, is an animation of the Lorenz Attractor. The Lorenz Attractor is a three-dimensional parametric curve whose coordinates are obtained by integrating the set of three ordinary differential equations
860 \begin{align*}
861 \frac{\mathrm{d}x}{\mathrm{d}t}& = \alpha (y-x)\\
862 \frac{\mathrm{d}y}{\mathrm{d}t}& = x(\beta-z)-y\\
863 \frac{\mathrm{d}z}{\mathrm{d}t}& = x y - \gamma z
864 \end{align*}
865 with respect to the independent parameter $t$. The shape of the attractor strongly depends on the values chosen for the coefficients $\alpha$, $\beta$ and $\gamma$ as well as on the initial conditions, that is, the coordinates $x_0$, $y_0$ and $z_0$ of the starting point of the curve. Here we use the values $\alpha=10$, $\beta=28$, $\gamma=8/3$ and the starting point $\mathbf{x}_0=(10,10,30)$.
866
867 The right hand sides of the equations above are defined in the macro \verb+\lorenz+ as algebraic expressions. The initial value problem is solved by the macro \verb+\pstODEsolve+ from the PSTricks package `pst-ode' and plotted by the macro \verb+\parametricplotThreeD+ from the PSTricks package `pst-3dplot'.
868
869 A timeline file, written on-the-fly, is used to assemble the curve segments frame by frame to the growing attractor which, in turn, is put on top of the $x$-$y$-$z$ coordinate system. After the attractor has been completed, the transparency stack is cleared. Then, transparencies containing the complete curve and the coordinate system seen from different viewpoints are put in a row to produce the animated fly-around.
870
871 \begin{figure}[t]
872 \centering
873 %
874 %Lorenz' set of differential equations
875 \def\lorenz{%
876 10*(x[1]-x[0]) | %dx/dt
877 x[0]*(28-x[2]) - x[1] | %dy/dt
878 x[0]*x[1] - 8/3*x[2] %dz/dt
879 }%
880 %
881 %write timeline file
882 \newwrite\OutFile%
883 \immediate\openout\OutFile=lorenz.tln%
884 \multido{\iLorenz=0+1}{101}{%
885 \immediate\write\OutFile{::\iLorenz x0}%
886 }%
887 \immediate\write\OutFile{::c,101}%
888 \multido{\iLorenz=102+1}{89}{%
889 \immediate\write\OutFile{::\iLorenz}%
890 }%
891 \immediate\closeout\OutFile%
892 %
893 \psset{unit=0.155,linewidth=0.5pt}%
894 \noindent\begin{animateinline}[
895 timeline=lorenz.tln,
896 controls,poster=last,
897 begin={\begin{pspicture}(-39,-13)(39,60)},
898 end={\end{pspicture}}
899 ]{10}
900 %coordinate axes
901 \psset{Alpha=120,Beta=20}%
902 \pstThreeDCoor[xMax=33,yMax=33,zMax=55,linecolor=black]%
903 \newframe
904 %attractor segments
905 \gdef\initCond{10 10 30}% initial condition
906 \pstVerb{/lorenzXYZall {} def} %takes the whole attractor
907 \multiframe{100}{rtZero=0+0.25,rtOne=0.25+0.25}{%
908 %compute current attractor segment, store it in `lorenzXYZseg'
909 \pstODEsolve[algebraic]{%
910 lorenzXYZseg}{0 1 2}{\rtZero}{\rtOne}{26}{\initCond}{\lorenz}%
911 %empty initial condition --> next \pstODEsolve continues
912 \gdef\initCond{}% from last state vector
913 %append segment to the whole attractor stored in `lorenzXYZall'
914 \pstVerb{%
915 /lorenzXYZall [lorenzXYZall lorenzXYZseg] aload astore cvx def}
916 %plot the current segment
917 \listplotThreeD[plotstyle=line]{lorenzXYZseg}%
918 }%
919 \newframe% required between two \multiframe
920 %fly-around (whole attractor)
921 \multiframe{90}{rAlpha=116+-4}{%
922 \psset{Alpha=\rAlpha,Beta=20}%
923 \pstThreeDCoor[xMax=33,yMax=33,zMax=55,linecolor=black]%
924 \listplotThreeD[plotstyle=line]{lorenzXYZall}%
925 }%
926 \end{animateinline}
927 \caption{}\label{fig:lorenz}
928 \end{figure}
929
930 %\small
931 \begin{lstlisting}
932 \documentclass{article}
933 \usepackage{multido}
934 \usepackage{pst-3dplot}
935 \usepackage{pst-ode}
936 \usepackage{animate}
937
938 \begin{document}
939
940 %Lorenz' set of differential equations
941 \def\lorenz{%
942 10*(x[1]-x[0]) | %dx/dt
943 x[0]*(28-x[2]) - x[1] | %dy/dt
944 x[0]*x[1] - 8/3*x[2] %dz/dt
945 }%
946 %
947 %write timeline file
948 \newwrite\OutFile%
949 \immediate\openout\OutFile=lorenz.tln%
950 \multido{\iLorenz=0+1}{101}{%
951 \immediate\write\OutFile{::\iLorenz x0}%
952 }%
953 \immediate\write\OutFile{::c,101}%
954 \multido{\iLorenz=102+1}{89}{%
955 \immediate\write\OutFile{::\iLorenz}%
956 }%
957 \immediate\closeout\OutFile%
958 %
959 \psset{unit=0.155,linewidth=0.5pt}%
960 \noindent\begin{animateinline}[
961 timeline=lorenz.tln,
962 controls,poster=last,
963 begin={\begin{pspicture}(-36,-13)(36,55)},
964 end={\end{pspicture}}
965 ]{10}
966 %coordinate axes
967 \psset{Alpha=120,Beta=20}%
968 \pstThreeDCoor[xMax=33,yMax=33,zMax=55,linecolor=black]%
969 \newframe
970 %attractor segments
971 \gdef\initCond{10 10 30}% initial condition
972 \pstVerb{/lorenzXYZall {} def} %takes the whole attractor
973 \multiframe{100}{rtZero=0+0.25,rtOne=0.25+0.25}{%
974 %compute current attractor segment, store it in `lorenzXYZseg'
975 \pstODEsolve[algebraic]{%
976 lorenzXYZseg}{0 1 2}{\rtZero}{\rtOne}{26}{\initCond}{\lorenz}%
977 %empty initial condition --> next \pstODEsolve continues
978 \gdef\initCond{}% from last state vector
979 %append segment to the whole attractor stored in `lorenzXYZall'
980 \pstVerb{%
981 /lorenzXYZall [lorenzXYZall lorenzXYZseg] aload astore cvx def}%
982 %plot the current segment
983 \listplotThreeD[plotstyle=line]{lorenzXYZseg}%
984 }%
985 \newframe% required between two \multiframe
986 %fly-around (whole attractor)
987 \multiframe{90}{rAlpha=116+-4}{%
988 \psset{Alpha=\rAlpha,Beta=20}%
989 \pstThreeDCoor[xMax=33,yMax=33,zMax=55,linecolor=black]%
990 \listplotThreeD[plotstyle=line]{lorenzXYZall}%
991 }%
992 \end{animateinline}
993
994 \end{document}
995 \end{lstlisting}
996 \normalsize
997
998 The last inline example in Fig.~\ref{fig:metronome} is a ticking metronome written by Manuel Luque~\cite{luque12}. The short clicking sound was embedded by means of the `media9' package. Whenever the pendulum reaches one of its reversal points, playback of the sound file is started using JavaScript. The JavaScript code was inserted at the corresponding frame specifications in a timeline file. Since the PSTricks macros for drawing the metronome body and the pendulum are quite long they have been moved into an external file, \verb+files/pstmetronome.tex+. Note that the sound can be heard only on Win and Mac platforms. Even then, mileage may vary. A dual core CPU may be necessary for fluent playback.
999 \begin{figure}[hb]
1000 \centering
1001 \begin{VerbatimOut}{files/pstmetronome.tex}
1002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1003 % animated metronome
1004 % this code is based to 99.9 percent on the work by Manuel Luque
1005 % (pstricks.blogspot.com)
1006 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1007 \makeatletter
1008 \pst@addfams{pst-metronome}
1009 \define@key[psset]{pst-metronome}{theta0}{\def\psk@oscmetronomethetai{#1 }}
1010 \psset[pst-metronome]{theta0=45} % position initiale du metronome
1011 \define@key[psset]{pst-metronome}{M}{\def\psk@oscmetronometM{#1 }}
1012 \psset[pst-metronome]{M=25} % masse du disque en g
1013 \define@key[psset]{pst-metronome}{m}{\def\psk@oscmetronometm{#1 }}
1014 \psset[pst-metronome]{m=6} % masse du curseur en g
1015 \define@key[psset]{pst-metronome}{r}{\def\psk@oscmetronomer{#1 }}
1016 \psset[pst-metronome]{r=1} % rayon du disque en cm
1017 \define@key[psset]{pst-metronome}{x}{\def\psk@oscmetronomex{#1 }}
1018 \psset[pst-metronome]{x=8.4} % position du curseur en cm par rapport à l'axe
1019 \define@key[psset]{pst-metronome}{d}{\def\psk@oscmetronomed{#1 }}
1020 \psset[pst-metronome]{d=3.2} % distance de l'axe au centre du disque en cm
1021 \define@key[psset]{pst-metronome}{dt}{\def\psk@oscmetronomedt{#1 }}
1022 \psset[pst-metronome]{dt=0.01} % pas pour RK4
1023 \define@key[psset]{pst-metronome}{nT}{\def\psk@oscmetronomenT{#1 }}
1024 \psset[pst-metronome]{nT=1} % nombre de périodes représentées
1025 %---- calculer theta(t) et thetapoint(t) --------
1026 \def\psmetronome{\pst@object{psmetronome}}
1027 \def\psmetronome@i{%
1028 \begingroup%
1029 \use@par%
1030 \begin@SpecialObj%
1031 \pstVerb{%
1032 /deg2rad {180 div 3.14159 mul} def
1033 /rad2deg {180 mul 3.14159 div} def
1034 /gp 9.8 def % pesanteur
1035 /radius \psk@oscmetronomer 1e-2 mul def % en m
1036 /OA \psk@oscmetronomed 1e-2 mul def % distance de l'axe au centre du disque en m
1037 /xC \psk@oscmetronomex 1e-2 mul def % position du curseur en m par rapport à l'axe
1038 /theta0 \psk@oscmetronomethetai def % en degrés
1039 /theta0rad theta0 deg2rad def % en radians
1040 /Md \psk@oscmetronometM 1e-3 mul def % en kg
1041 /mc \psk@oscmetronometm 1e-3 mul def % en kg
1042 /dt \psk@oscmetronomedt def
1043 /nT \psk@oscmetronomenT def
1044 % moment d'inertie du métronome
1045 % J=1/2M*R^2+M*a^2+m*x^2
1046 /Ji {0.5 Md mul radius dup mul mul Md OA dup mul mul add mc xC dup mul mul add} def
1047 /AT {4
1048 Ji
1049 gp Md OA mul mc xC mul sub mul
1050 div
1051 sqrt
1052 mul} def
1053 % Pour le calcul de la période
1054 % coefficients de l'approximation polynômiale du calcul
1055 % de l'intégrale elliptique
1056 % coefficient pour le calcul de l'intégrale elliptique
1057 /m0 theta0 2 div sin def
1058 /m1 {1 m0 dup mul sub} def
1059 /m2 {m1 dup mul} def
1060 /m3 {m2 m1 mul} def
1061 /m4 {m2 dup mul} def
1062 /m_1 {1 m1 div} def
1063 /EllipticK {
1064 0.5
1065 0.12498593597 m1 mul add
1066 0.06880248576 m2 mul add
1067 0.03328355376 m3 mul add
1068 0.00441787012 m4 mul add
1069 m_1 ln mul
1070 1.38629436112 add
1071 0.09666344259 m1 mul add
1072 0.03590092383 m2 mul add
1073 0.03742563713 m3 mul add
1074 0.01451196212 m4 mul add
1075 } def
1076 /Tm {AT EllipticK mul} def
1077 % tableau des valeurs de theta(t)
1078 /W 0 def % vitesse angulaire
1079 /theta theta0 def
1080 /oscillateur {sin gp Md OA mul mc xC mul sub mul neg mul Ji div} def
1081 /j1 {W dt mul} def
1082 /k1 {theta oscillateur dt mul} def
1083 /j2 {W k1 2 div add dt mul} def
1084 /k2 {theta j1 2 div rad2deg add oscillateur dt mul} def
1085 /j3 {W k2 2 div add dt mul} def
1086 /k3 {theta j2 2 div rad2deg add oscillateur dt mul} def
1087 /j4 {W k3 add dt mul} def
1088 /k4 {theta j3 rad2deg add oscillateur dt mul} def
1089 /theta2 {theta j1 rad2deg 2 j2 rad2deg j3 rad2deg add mul add j4 rad2deg add 6 div add} def
1090 /tabTheta [ % pour l'animation
1091 0 theta0 % date angle
1092 dt dt Tm nT mul{ %
1093 theta2 %
1094 /W2 W k1 2 k2 k3 add mul add k4 add 6 div add def
1095 /theta theta2 def
1096 /W W2 def
1097 } for
1098 ] def
1099 /Nvaleurs tabTheta length 2 div cvi def
1100 /W 0 def % vitesse angulaire
1101 /theta theta0 def
1102 /tabThetaGraph [ % pour le graphique theta(t)
1103 0 theta0 % date angle
1104 0 dt Tm nT mul { % pop
1105 theta2 % 180 div 3.14159 mul
1106 /W2 W k1 2 k2 k3 add mul add k4 add 6 div add def
1107 /theta theta2 def
1108 /W W2 def
1109 } for
1110 ] def
1111 /W 0 def % vitesse angulaire
1112 /theta theta0 def
1113 /tabThetaPoint [ % pour le graphique thetapoint(t)
1114 0 0 % date angle
1115 dt dt Tm nT mul { % pop
1116 % theta2 % 180 div 3.14159 mul
1117 /W2 W k1 2 k2 k3 add mul add k4 add 6 div add def
1118 W2
1119 /theta theta2 def
1120 /W W2 def
1121 } for
1122 ] def
1123 /tabXOSC [ % oscillations par min en fonction de x
1124 0.5 0.1 12 {/xc exch def
1125 /xC xc 1e-2 mul def
1126 xc 60 Tm div % cvi
1127 } for
1128 ] def
1129 /tabXbattements [ % battements par min en fonction de x
1130 3 0.1 12 {/xc exch def
1131 /xC xc 1e-2 mul def
1132 xc 60 Tm div 2 mul % cvi
1133 } for
1134 ] def
1135 % graduation T --> x
1136 /tabXT [ % [T,x]
1137 40 1 220 {/batt exch def % battements
1138 /Tmetronome2 120 batt div dup mul def
1139 /A1 16 mc mul EllipticK dup mul mul def
1140 /B1 gp Tmetronome2 mul mc mul def
1141 /C1 gp Md mul OA mul Tmetronome2 mul neg
1142 8 Md mul radius dup mul mul 16 Md mul OA dup mul mul add EllipticK dup mul mul add def
1143 /Delta B1 dup mul 4 A1 mul C1 mul sub sqrt def
1144 /xC1 B1 neg Delta sub 2 div A1 div def
1145 /xC2 B1 neg Delta add 2 div A1 div def
1146 xC2 0 ge {/posC xC2 def}{/posC xC1 def} ifelse
1147 batt posC 1e2 mul
1148 } for
1149 ] def
1150 /xT { % pour une valeur particulière battement -> position du curseur
1151 /batt exch def
1152 /Tmetronome2 120 batt div dup mul def
1153 /A1 16 mc mul EllipticK dup mul mul def
1154 /B1 gp Tmetronome2 mul mc mul def
1155 /C1 gp Md mul OA mul Tmetronome2 mul neg
1156 8 Md mul radius dup mul mul 16 Md mul OA dup mul mul add EllipticK dup mul mul add def
1157 /Delta B1 dup mul 4 A1 mul C1 mul sub sqrt def
1158 /xC1 B1 neg Delta sub 2 div A1 div def
1159 /xC2 B1 neg Delta add 2 div A1 div def
1160 xC2 0 ge {/posC xC2 def}{/posC xC1 def} ifelse
1161 posC 1e2 mul
1162 } def
1163 /xC \psk@oscmetronomex 1e-2 mul def % position du curseur en m par rapport à l'axe
1164 /Tm {AT EllipticK mul} def
1165 }%
1166 \end@SpecialObj%
1167 \endgroup}
1168 %
1169 \def\psmetronomeA{\pst@object{psmetronomeA}}
1170 \def\psmetronomeA@i{%
1171 \begingroup%
1172 \use@par%
1173 \begin@SpecialObj%
1174 \pstVerb{%
1175 /radius \psk@oscmetronomer 1e-2 mul def % en m
1176 /OA \psk@oscmetronomed 1e-2 mul def % distance de l'axe au centre du disque en m
1177 /xC \psk@oscmetronomex 1e-2 mul def % position du curseur en m par rapport à l'axe
1178 }%
1179 \psframe[fillstyle=solid](! -0.075 \psk@oscmetronomed neg)(0.075,13)
1180 \pscircle[fillstyle=solid,fillcolor={[rgb]{0.75 0.75 0.75}}](! 0 \psk@oscmetronomed neg){!radius 1e2 mul}
1181 \pscircle[fillstyle=solid,linewidth=0.05](0,0){0.15}
1182 \pscircle*[linecolor=red](0,0){0.05}
1183 % curseur
1184 \pspolygon[fillstyle=solid](! -0.25 \psk@oscmetronomex 0.5 sub)(! -0.5 \psk@oscmetronomex 0.5 add)(!-0.075 \psk@oscmetronomex 0.5 add)(!-0.075 \psk@oscmetronomex 0.5 sub)
1185 \pspolygon[fillstyle=solid](! 0.25 \psk@oscmetronomex 0.5 sub)(! 0.5 \psk@oscmetronomex 0.5 add)(!0.075 \psk@oscmetronomex 0.5 add)(!0.075 \psk@oscmetronomex 0.5 sub)
1186 \pspolygon[fillstyle=solid,fillcolor=gray](! -0.25 \psk@oscmetronomex 0.5 sub)(! -0.3 \psk@oscmetronomex 0.3 sub)(! -0.075 \psk@oscmetronomex 0.3 sub)(!-0.075 \psk@oscmetronomex 0.3 add)(!0.075 \psk@oscmetronomex 0.3 add)(!0.075 \psk@oscmetronomex 0.3 sub)(!0.3 \psk@oscmetronomex 0.3 sub)(!0.25 \psk@oscmetronomex 0.5 sub)
1187 \pscircle[fillstyle=solid](!-0.125 \psk@oscmetronomex 0.4 sub){0.08}
1188 \pscircle[fillstyle=solid](!0.125 \psk@oscmetronomex 0.4 sub){0.08}
1189 % fin curseur
1190 {\psset{linecolor=red}
1191 \psline(!-.1 \psk@oscmetronomex)(!0.1 \psk@oscmetronomex)\psline(!0 \psk@oscmetronomex 0.1 sub)(!0 \psk@oscmetronomex 0.1 add)
1192 \psline(! -.1 \psk@oscmetronomed neg)(!0.1 \psk@oscmetronomed neg)\psline(! 0 \psk@oscmetronomed neg 0.1 sub)(!0 \psk@oscmetronomed neg 0.1 add)}
1193 \pnode(!0 \psk@oscmetronomex){C}% curseur
1194 \pnode(! 0 \psk@oscmetronomed neg){D}% disque
1195 %\pstextpath[c](0,-2ex){\psarcn[linestyle=none](D){1}{180}{0}}{\small\textsf{\textbf{m e t r o n o m e}}}
1196 %\pstextpath[c](0,1ex){\psarc[linestyle=none](D){1}{180}{0}}{\small\textsf{\textbf{P S t r i c k s}}}
1197 \end@SpecialObj%
1198 \endgroup}
1199 \psmetronome%
1200 \pstVerb{/tabTempos [40 42 44 46 48 50 52 54 46 58 60 63 66 69 72 76 80 84 88 92 96 100 104 108 112 116 120 126 132 138 144 152 160 168 176 184 192 200 208] def}%
1201
1202 \def\metronomebody{%
1203 \pspolygon[fillstyle=solid,linewidth=2\pslinewidth,linearc=0.5,fillcolor=yellow!30](-5,-4.5)(5,-4.5)(1,14)(-1,14)
1204 \psline(1.2,4.5)(1.2,12.5)
1205 \psline(-1.2,4.5)(-1.2,12.5)
1206 \multido{\i=0+2}{20}{%
1207 \pstVerb{/BATT tabTempos \i\space get def}
1208 \psline[linecolor=red](!1.2 BATT xT)(!0.7 BATT xT)
1209 \uput[r](!0.7 BATT xT){\psPrintValue[PSfont=Helvetica,fontscale=6]{BATT}}
1210 }%
1211 \multido{\i=1+2}{19}{%
1212 \pstVerb{/BATT tabTempos \i\space get def}
1213 \psline[linecolor=red](!-1.2 BATT xT)(!-0.7 BATT xT)
1214 \uput[r](!-1.3 BATT xT){\psPrintValue[PSfont=Helvetica,fontscale=6]{BATT}}}%
1215 \rput(!0 40 xT){\textsf{\tiny GRAVE}}%
1216 \rput(!0 46 xT){\textsf{\tiny LARGO}}%
1217 \rput(!0 52 xT){\textsf{\tiny LENTO}}%
1218 \rput(!0 58 xT){\textsf{\tiny ADAGIO}}%
1219 \rput(!0 60 xT){\textsf{\tiny LARGETTO}}%
1220 \rput(!0 66 xT){\textsf{\tiny ANDANTE}}%
1221 \rput(!0 76 xT){\textsf{\tiny ANDANTINO}}%
1222 \rput(!0 84 xT){\textsf{\tiny MODERATO}}%
1223 \rput(!0 108 xT){\textsf{\tiny ALLEGRETTO}}%
1224 \rput(!0 132 xT){\textsf{\tiny ALLEGRO}}%
1225 \rput(!0 160 xT){\textsf{\tiny VIVACE}}%
1226 \rput(!0 184 xT){\textsf{\tiny PRESTO}}%
1227 \rput(!0 200 xT){\textsf{\tiny PRESTISSIMO}}%
1228 }
1229
1230 \def\pendulum#1{%
1231 \pstVerb{/iA #1\space def /date tabTheta iA get def /Theta tabTheta iA 1 add get def}%
1232 \rput{!Theta}{\psmetronomeA}%
1233 }
1234 \makeatother
1235 \end{VerbatimOut}
1236 \begin{VerbatimOut}{metro.txt}
1237 ::0x0,1 : annotRM['click'].callAS('play');
1238 ::2
1239 ::3
1240 ::4
1241 ::5
1242 ::6
1243 ::7
1244 ::8
1245 ::9
1246 ::10
1247 ::11
1248 ::12
1249 ::13
1250 ::14
1251 ::15
1252 ::16
1253 ::17
1254 ::18
1255 ::19
1256 ::20
1257 ::21
1258 ::22
1259 ::23
1260 ::24
1261 ::25
1262 ::26 : annotRM['click'].callAS('play');
1263 \end{VerbatimOut}
1264 %loading metronome macros from external file
1265 \input{files/pstmetronome}
1266 %sound inclusion: click.mp3
1267 \makebox[0pt][r]{\includemedia[
1268 width=1ex,height=1ex,
1269 label=click,
1270 addresource=click.mp3,
1271 activate=pageopen,transparent,noplaybutton,
1272 flashvars={source=click.mp3&hideBar=true}
1273 ]{}{APlayer.swf}}%
1274 %animated metronome
1275 \begin{animateinline}[
1276 controls,
1277 width=0.7\linewidth,
1278 palindrome,
1279 begin={\begin{pspicture}(-9.5,-5)(9.5,15)},
1280 end={\end{pspicture}},
1281 timeline=metro.txt
1282 ]{25}
1283 %metronome without pendulum
1284 \metronomebody
1285 \newframe
1286 %half period of pendulum swing (26 frames)
1287 \multiframe{26}{i=0+4}{
1288 \pendulum{\i}
1289 }
1290 \end{animateinline}
1291 \caption{}\label{fig:metronome}
1292 \end{figure}
1293 %\small
1294 \begin{lstlisting}
1295 \documentclass[12pt]{article}
1296 \usepackage{pstricks,pst-node,pst-plot,pst-tools,pst-text}
1297 \usepackage{animate}
1298 \usepackage{media9}
1299
1300 %writing timeline to external file
1301 \begin{filecontents}{metro.txt}
1302 ::0x0,1 : annotRM['click'].callAS('play');
1303 ::2
1304 ::3
1305 ::4
1306 ::5
1307 ::6
1308 ::7
1309 ::8
1310 ::9
1311 ::10
1312 ::11
1313 ::12
1314 ::13
1315 ::14
1316 ::15
1317 ::16
1318 ::17
1319 ::18
1320 ::19
1321 ::20
1322 ::21
1323 ::22
1324 ::23
1325 ::24
1326 ::25
1327 ::26 : annotRM['click'].callAS('play');
1328 \end{filecontents}
1329
1330 \begin{document}
1331
1332 \begin{center}
1333 %loading metronome macros from external file
1334 \input{files/pstmetronome}
1335 %
1336 %sound inclusion: click.mp3
1337 \makebox[0pt][r]{\includemedia[
1338 width=1ex,height=1ex,
1339 label=click,
1340 addresource=click.mp3,
1341 activate=pageopen,transparent,noplaybutton,
1342 flashvars={source=click.mp3&hideBar=true}
1343 ]{}{APlayer.swf}}%
1344 %
1345 %animated metronome
1346 \begin{animateinline}[
1347 controls,
1348 width=0.7\linewidth,
1349 palindrome,
1350 begin={\begin{pspicture}(-9.5,-5)(9.5,15)},
1351 end={\end{pspicture}},
1352 timeline=metro.txt
1353 ]{25}
1354 %metronome without pendulum
1355 \metronomebody
1356 \newframe
1357 %half period of pendulum swing (26 frames)
1358 \multiframe{26}{i=0+4}{
1359 \pendulum{\i}
1360 }
1361 \end{animateinline}
1362 \end{center}
1363
1364 \end{document}
1365 \end{lstlisting}
1366
1367 \section{Animated SVG}
1368 Thanks to Martin Gieseking's \verb+dvisvgm+ utility~\cite{dvisvgm} that ships with all major \TeX{} distributions, package `animate' can produce self-contained animated SVG, with all the bits and pieces already included that are necessary to run in modern Web browsers as standalone files or as embedded objects within a Web page made of HTML. Animations have the same look and usability, including optional control buttons, as if they were embedded in a PDF document. Animated SVG even work on mobile devices.
1369
1370 As \verb+dvisvgm+ is linked against the Ghostscript library, it can parse and convert embedded PostScript to inline SVG code. It is therefore compatible with the popular TikZ and PSTricks \LaTeX{} packages.
1371
1372 SVG is a single-page graphics format. Therefore, it is recommended to produce documents with a single animation per file or page. Thereafter, \verb+dvisvgm+ converts every page of the DVI input to a standalone animated SVG file. You may want to use the `standalone' document class for creating standalone SVG animations. Pass `\verb+dvisvgm+' as a global document class option. In this way, it gets conveyed to `animate' and other packages to be loaded, such as `graphicx' or TikZ.
1373
1374 The following code may serve as a template for generating standalone animated SVG:
1375 \begin{lstlisting}
1376 \documentclass[dvisvgm]{standalone}
1377
1378 %\usepackage{xcolor}
1379 %\pagecolor{white} % opaque background with solid colour
1380
1381 %\usepackage{pstricks} % enable as needed
1382 %\usepackage{tikz}
1383
1384 \usepackage{animate}
1385 \usepackage{graphicx}
1386
1387 \begin{document}
1388 %
1389 % \animategraphics{..}{...}{...}{...}
1390 %
1391 % or
1392 %
1393 % \begin{animateinline}{..} ... \end{animateinline}
1394 %
1395 \end{document}
1396 \end{lstlisting}
1397 Note that when animating external graphics with \verb+\animategraphics+, only PDF and PostScript (EPS, PS, MPS) files are converted to inline SVG code; files in other formats (SVG, PNG, JPEG) remain external and must be bundled with the final SVG output. Thus, for obtaining self-contained SVG, it is recommended to convert PNG, JPEG and SVG files to PostScript or PDF first. Also note that PostScript files must have all required fonts embedded. This is not always the case for \MP-generated PostScript. Here, embedding of fonts is ensured by putting `\verb+prologues := 3;+' into the header of the \MP{} input. If PDF is chosen as file format for input graphics, the conversion utility `\verb+mutool+' must be present on the system. It is installed as part of the MuPDF (\url{https://mupdf.com}) package.
1398
1399 Use one of
1400 \begin{verbatim}
1401 latex
1402 platex
1403 dvilualatex
1404 xelatex -no-pdf
1405 \end{verbatim}
1406 to produce DVI or XDV output from the \LaTeX{} source. After this, SVG is obtained by running
1407 \begin{verbatim}
1408 dvisvgm --font-format=woff --exact --zoom=-1 --page=1,- --optimize ...
1409 \end{verbatim}
1410 %\begin{verbatim}
1411 %dvisvgm --font-format=woff --exact --zoom=-1 --page=1,- ...
1412 %\end{verbatim}
1413 on the intermediate DVI or XDV file.
1414
1415 Option `\verb+--font-format=woff+' (or `\verb+--font-format=woff2+') prompts \verb+dvisvgm+ to embed document fonts in a format that is understood by Web browsers. It ensures that typeset text looks as in normal PDF output.
1416
1417 Option `\verb+--exact+' tells \verb+dvisvgm+ to calculate exact bounding boxes around font glyphs. This avoids clipping of glyphs in the SVG output, as glyphs usually tend to be slightly bigger than their boxes defined in the font files.
1418
1419 The purpose of `\verb+--zoom=-1+' is to produce responsive SVG. If embedded in a Web page, this kind of SVG will automatically scale to fill up the available space of its surrounding container, usually an \verb+<object>+ tag (see below). If viewed standalone in a Web browser, a responsive SVG fills up the complete browser tab.
1420
1421 By default, \verb+dvisvgm+ processes only the very first page of the input file. To convert multipage DVI/XDV with several animations, add option `\verb+--page=1,-+'.
1422
1423 With option `\verb+--optimize+', \verb+dvisvgm+ applies several optimizations to reduce the output file size.
1424
1425 As SVG derives from XML it is not known to be particularly economical in terms of file size. Compressed SVG, with file extension `\verb+svgz+', shortens download times and is supported by most Web browsers. It can be generated by adding option `\verb+-z+'. Also, option `\verb+--precision=1+' may be used to reduce the SVG file size. It limits the precision of floating point numbers, such as coordinates, to one decimal figure. Sometimes, animations may behave stangely after applying this option. Then, of course, it should be omitted.
1426
1427 The recommended way to include animated SVG into HTML is to use the \verb+<object>+ tag. The \verb+<img>+ tag does not work here, as it ignores the embedded JavaScript. However, it may still be used as fallback. Also, it allows for search engine indexing, if desired:
1428 \begin{lstlisting}
1429 <object type="image/svg+xml" data="animatedImage.svg">
1430 <!-- optional (increases loading time):
1431 fallback & search engine indexing -->
1432 <img src="animatedImage.svg" />
1433 </object>
1434 \end{lstlisting}
1435
1436 In \TeX4ht documents, the whole \verb+<object>...</object>+ tag can be inserted by wrapping it in a \verb+\HCode{...}+ command.
1437
1438 \section{Bugs}\label{sect:bugs}
1439 \begin{itemize}
1440 \item The maximum frame rate that can actually be achieved largely depends on the complexity of the graphics and on the available hardware. In Acrobat Reader, you might want to experiment with the 2D graphical hardware acceleration feature. Go to menu `Edit' $\rightarrow$ `Preferences' $\rightarrow$ `Page Display' $\rightarrow$ `Rendering' to see whether hardware acceleration is available. A 2D GPU acceleration check box will be visible if a supported video card has been detected. Also, enabling or disabling the page cache (`Edit' $\rightarrow$ `Preferences' $\rightarrow$ `Page Display' $\rightarrow$ `Rendering' $\rightarrow$ `Use page cache') may affect the rendering performance.
1441
1442 \item Animated SVG is best viewed in Web browsers that are based on the Blink rendering engine. The most prominent representatives are Chrome, its open-source base Chromium and Opera. Unfortunately, in Firefox some animations run slowly, especially if the graphics make use of clipping operations.
1443
1444 \item The \verb+dvips+ option `\verb+-Ppdf+' should be avoided entirely or followed by something like `\verb+-D 1200+' on the command line in order to set a sensible DVI resolution. This does \emph{not} degrade the output quality! The configuration file `config.pdf' loaded by option `\verb+-Ppdf+' specifies an excessively high DVI resolution that will be passed on to the final PDF. Eventually, Acrobat Reader gets confused and will not display the frames within the animation widget.
1445
1446 \item Animations do not work if the PDF was produced with Ghostscript versions older than 9.15.
1447
1448 \item If the `\verb+animateinline+' environment is used in a right-to-left typesetting context (RTL) and using the (pdf)\LaTeX{} and \XeLaTeX{} engines, every frame's content should be enclosed in a pair of \verb+\beginR+ and \verb+\endR+ commands in order to correctly typeset RTL text contained therein. This can be conveniently done by means of the `\verb+begin+' and `\verb+end+' \hyperlink{beginend}{options} of the `\verb+animateinline+' environment.
1449
1450 % \item If the \LaTeX{} $\rightarrow$ \verb+dvips+ $\rightarrow$ \verb+ps2pdf+/Distiller route is being taken, make sure that the original graphics size (i.\,e. not scaled by any of the `{\tt scale}', `{\tt width}', `{\tt height}' or `{\tt totalheight}' options) does not exceed the page size of the final document. During PS to PDF conversion every graphic of the animation is temporarily moved to the upper left page corner. Those parts of the graphics that do not fit onto the document page will be clipped in the resulting PDF. Fortunately, graphics files for building animations may be resized easily to fit into a given bounding box by means of the `{\tt epsffit}' command line tool:
1451 %
1452 %\quad{\tt epsffit -c <llx> <lly> <urx> <ury> infile.eps outfile.eps}
1453 %
1454 %{\tt <llx> <lly> <urx> <ury>} are the bounding box coordinates of the target document. They can be determined using Ghostscript. For a document named `document.ps' the command line is
1455 %
1456 %\quad{\tt gs -dNOPAUSE -q -dBATCH -sDEVICE=bbox document.ps}
1457 %
1458 %Note that the name of the Ghostscript executable may vary between operating systems (e.\,g. `{\tt gswin32c.exe}' on Win/DOS).
1459
1460 \item\hypertarget{dest:mem}{} Animations with complex graphics and/or many frames may cause \LaTeX{} to fail with a `\verb+TeX capacity exceeded+' error. The following steps should fix most of the memory related problems.
1461
1462 MiK\TeX:
1463 \begin{enumerate}
1464 \item Open a DOS command prompt window (execute `cmd.exe' via `Start' $\rightarrow$ `Run').
1465 \item\label{item:firststep} At the DOS prompt, enter\\
1466 {\tt initexmf -{}-edit-config-file=latex}
1467 \item Type\\
1468 {\tt main\_memory=12000000}\\
1469 into the editor window that opens, save the file and quit the editor.
1470 \item\label{item:laststep} To rebuild the format, enter\\
1471 {\tt initexmf -{}-dump=latex}
1472 \item Repeat steps \ref{item:firststep}--\ref{item:laststep} with config files {\tt pdflatex} and {\tt xelatex}
1473 \end{enumerate}
1474
1475 \TeX\ Live:
1476 \begin{enumerate}
1477 \item Find the configuration file `texmf.cnf' by means of\\
1478 {\tt kpsewhich texmf.cnf}\\
1479 at the shell prompt in a terminal.
1480 \item As Root, open the file in your favourite text editor, scroll to the\\`{\tt main\_memory}' entry and change it to the value given above; save and quit.
1481 \item Rebuild the formats by\\
1482 {\tt fmtutil-sys -{}-byfmt latex}\\
1483 {\tt fmtutil-sys -{}-byfmt pdflatex}\\
1484 {\tt fmtutil-sys -{}-byfmt xelatex}
1485 \end{enumerate}
1486
1487 % \item If a PDF containing animations is post-processed using tools like PDFtk to split the document into separate files, then animations in the output documents may not work.
1488
1489 \item PDFs with animations cannot be embedded (via {\tt\string\includegraphics},\\ {\tt\string\includepdf}) into other documents as the animation capability gets lost.
1490
1491 \item Animations should not be placed on \emph{multilayered} slides, also known as overlays, created with presentation making classes such as Beamer or Powerdot. Those document classes turn overlays into separate PDF pages and re-insert the animation on every page thus produced. The animations are independent from each other and do not share the current playing state, such as frame number, playing speed and direction. Therefore, put animations on flat slides only; slides without animations may still have overlays, of course. On \href{https://tex.stackexchange.com/a/385209}{\TeX.SE}~\cite{texsx}, a method is suggested for placing an animation on a slide with overlays. It makes use of the programming interface introduced in Section~\ref{sect:api}, p.~\pageref{sect:api}.
1492 \end{itemize}
1493
1494 \section{Acknowledgements}
1495 I would like to thank François Lafont who discovered quite a few bugs and made many suggestions that helped to improve the functionality of the package. Many thanks to Jin-Hwan Cho, the developer of \verb+dvipdfmx+, for contributing the \verb+dvipdfmx+ specific code, and to Walter Scott for proof-reading the documentation.
1496
1497 %\enlargethispage{4ex}
1498 \begin{thebibliography}{8}
1499 \bibitem{chupin} Chupin, M.: \emph{Syracuse MetaPost/Animations.} URL: \href{http://melusine.eu.org/syracuse/metapost/animations/chupin/?idsec=scara}{\nolinkurl{http://melusine.eu.org/}} \href{http://melusine.eu.org/syracuse/metapost/animations/chupin/?idsec=scara}{\nolinkurl{syracuse/metapost/animations/chupin/?idsec=scara}}
1500 \bibitem{dvisvgm} \emph{dvisvgm: A fast DVI to SVG converter} URL: \url{http://dvisvgm.de}
1501 \bibitem{gilg05} Gilg, J.: PDF-Animationen. In: \emph{Die \TeX nische Kom\"odie}, Issue 4, 2005, pp.~30--37
1502 \bibitem{hol} Holeček, J.; Sojka, P.: Animations in pdf\TeX-generated PDF. In: \emph{\TeX, XML, and Digital Typography}, Springer, 2004, pp.~179--191. doi:10.1007/978-3-540-27773-6\textunderscore14
1503 \bibitem{luque12} Luque, M.: \emph{PSTricks : applications.} URL: \url{http://pstricks.blogspot.com}
1504 \bibitem{media4svg} \emph{The media4svg Package}. URL: \url{http://www.ctan.org/pkg/media4svg}
1505 \bibitem{media9} \emph{The media9 Package}. URL: \url{http://www.ctan.org/pkg/media9}
1506 \bibitem{texsx} \emph{Beamer: animate package and overlay}. URL: \href{https://tex.stackexchange.com/a/385209}{\nolinkurl{https://tex.stackexchange.com}}\\ \href{https://tex.stackexchange.com/a/385209}{\nolinkurl{/a/385209}}
1507 \end{thebibliography}
1508
1509 \end{document}