summaryrefslogtreecommitdiff
path: root/Master/texmf-dist
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2007-07-16 16:32:07 +0000
committerKarl Berry <karl@freefriends.org>2007-07-16 16:32:07 +0000
commit1b0d01e91a7b4080895db481fb57b9b8ed53d887 (patch)
tree4356d1b4f531c143ba71f2ff91a4b910b99e3fc0 /Master/texmf-dist
parent7a69017ffdc2b91356c7e2f3ae8160cbc7f09564 (diff)
animate update (4jul07)
git-svn-id: svn://tug.org/texlive/trunk@4619 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r--Master/texmf-dist/doc/latex/animate/README186
-rw-r--r--Master/texmf-dist/doc/latex/animate/doc/animate.pdfbin964597 -> 964629 bytes
-rw-r--r--Master/texmf-dist/doc/latex/animate/doc/animate.tex82
-rw-r--r--Master/texmf-dist/doc/latex/animate/doc/files/timeline.txt9
-rw-r--r--Master/texmf-dist/tex/latex/animate/animate.sty574
5 files changed, 551 insertions, 300 deletions
diff --git a/Master/texmf-dist/doc/latex/animate/README b/Master/texmf-dist/doc/latex/animate/README
index fb0e666a0f2..d3b570d2956 100644
--- a/Master/texmf-dist/doc/latex/animate/README
+++ b/Master/texmf-dist/doc/latex/animate/README
@@ -1,92 +1,94 @@
- =====================
- The animate Package
- =====================
-
-Author:
-
- Alexander Grahn
-
-
-Description:
-
- This package provides an interface to create portable, JavaScript driven PDF
- animations from sets of (vector) graphics files or from inline (vector)
- graphics, such as LaTeX-picture, PSTricks or pgf/TikZ generated pictures,
- or just from typeset text.
-
- It supports the usual PDF making workflows, i. e. pdfLaTeX and LaTeX ->
- dvips -> ps2pdf (Ghostscript).
-
- The resulting PDF can be viewed in current Adobe Readers on all supported
- platforms.
-
- The first release of `animate' was based on the work by Jan Holecek and Petr
- Sojka:
-
- http://www.fi.muni.cz/~xholecek/tex/pdfanim.xhtml
-
- Meanwhile, the package was rewritten to use Optional Content Groups (OCG),
- aka PDF-Layers. OCG-based animations are fully supported by Adobe Reader 8,
- but have some performance issues. Playback is usually slower in Reader 8
- than in previous versions, which is probably a bug.
-
- The old, non-OCG approach is still available if the package file
- `animate-noocg.sty' is used instead of `animate.sty'. However, options
- `autoplay', `autopause' and `autoresume' are not functional in Reader 8.
- Moreover, the animation position and the play/pause buttons are not properly
- reset on page change. This is due to usage restrictions that Adobe imposed
- on some important JavaScript methods in Reader 8.
-
- Note, this file only gives a summary of usage and available package and
- command options. Please refer to the documentation `animate.pdf' in the
- `doc/' directory for details and examples.
-
- Keywords: include, portable, PDF, animation, animating, embed, animated,
- graphics, LaTeX, pdfLaTeX, PSTricks, pgf, TikZ, LaTeX-picture,
- inline graphics, vector graphics, dvips, ps2pdf, JavaScript,
- Adobe Reader
-
-
-Usage:
-
- \usepackage[<package options>]{animate}
-
- -- Package options: autopause, autoplay, autoresume, controls,
- buttonsize=<size>, screenbg=<colour>, buttonbg=<colour>,
- loop, palindrome, step, poster=[first | none | last]
-
-
- \animategraphics[<options>]{<frame rate>}{<file basename>}{<first>}{<last>}
-
- \begin{animateinline}[<options>]{<frame rate>}
- ... typeset material ...
- \newframe[<frame rate>]
- ... typeset material ...
- \newframe*[<frame rate>]
- ... typeset material ...
- \end{animateinline}
-
- -- Command options: width=<width>, height=<height>, depth=<depth>,
- scale=<factor>, autopause, autoplay, autoresume, controls,
- buttonsize=<size>, screenbg=<colour>, buttonbg=<colour>,
- loop, palindrome, step, poster=[first | none | last]
-
-
-Requirements:
-
- pdfeTeX, version >= 1.20
- Adobe Reader, version >= 6
-
-
-Installation:
-
- Put the file animate.sty to a place where TeX can find it.
-
-
-License:
-
- This material is subject to the LaTeX Project Public License. See
-
- http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html
-
- for the details of that license.
+ =====================
+ The animate Package
+ =====================
+
+Author:
+
+ Alexander Grahn
+
+
+Description:
+
+ This package provides an interface to create portable, JavaScript driven PDF
+ animations from sets of (vector) graphics files or from inline (vector)
+ graphics, such as LaTeX-picture, PSTricks or pgf/TikZ generated pictures,
+ or just from typeset text.
+
+ It supports the usual PDF making workflows, i. e. pdfLaTeX and LaTeX ->
+ dvips -> ps2pdf (Ghostscript).
+
+ The resulting PDF can be viewed in current Adobe Readers on all supported
+ platforms.
+
+ The first release of `animate' was based on the work by Jan Holecek and Petr
+ Sojka:
+
+ http://www.fi.muni.cz/~xholecek/tex/pdfanim.xhtml
+
+ Meanwhile, the package was rewritten to use Optional Content Groups (OCG),
+ aka PDF-Layers. OCG-based animations are fully supported by Adobe Reader 8,
+ but have some performance issues. Playback is usually slower in Reader 8
+ than in previous versions, which is probably a bug.
+
+ The old, non-OCG approach is still available if the package file
+ `animate-noocg.sty' is used instead of `animate.sty'. However, options
+ `autoplay', `autopause' and `autoresume' are not functional in Reader 8.
+ Moreover, the animation position and the play/pause buttons are not properly
+ reset on page change. This is due to usage restrictions that Adobe imposed
+ on some important JavaScript methods in Reader 8.
+
+ Note, this file only gives a summary of usage and available package and
+ command options. Please refer to the documentation `animate.pdf' in the
+ `doc/' directory for details and examples.
+
+ Keywords: include, portable, PDF, animation, animating, embed, animated,
+ graphics, LaTeX, pdfLaTeX, PSTricks, pgf, TikZ, MetaPost,
+ LaTeX-picture, inline graphics, vector graphics, dvips, ps2pdf,
+ JavaScript, Adobe Reader
+
+
+Usage:
+
+ \usepackage[<package options>]{animate}
+
+ * Package options: autopause, autoplay, autoresume, controls,
+ buttonsize=<size>, screenbg=<colour>, buttonbg=<colour>,
+ loop, palindrome, step, poster=[first | none | last]
+
+
+ \animategraphics[<options>]{<frame rate>}{<file basename>}{<first>}{<last>}
+
+ \begin{animateinline}[<options>]{<frame rate>}
+ ... typeset material ...
+ \newframe[<frame rate>]
+ ... typeset material ...
+ \newframe*[<frame rate>]
+ ... typeset material ...
+ \end{animateinline}
+
+ * Command options: width=<width>, height=<height>, depth=<depth>,
+ scale=<factor>, autopause, autoplay, autoresume, controls,
+ buttonsize=<size>, screenbg=<colour>, buttonbg=<colour>,
+ loop, palindrome, step, poster=[first | none | last],
+ begin={<begin text>}, end={<end text>},
+ timeline=<timeline file>
+
+
+Requirements:
+
+ pdfeTeX, version >= 1.20
+ Adobe Reader, version >= 6
+
+
+Installation:
+
+ Put the file animate.sty to a place where TeX can find it.
+
+
+License:
+
+ This material is subject to the LaTeX Project Public License. See
+
+ http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html
+
+ for the details of that license.
diff --git a/Master/texmf-dist/doc/latex/animate/doc/animate.pdf b/Master/texmf-dist/doc/latex/animate/doc/animate.pdf
index 1d89bfa140e..4f6af7af3ac 100644
--- a/Master/texmf-dist/doc/latex/animate/doc/animate.pdf
+++ b/Master/texmf-dist/doc/latex/animate/doc/animate.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/animate/doc/animate.tex b/Master/texmf-dist/doc/latex/animate/doc/animate.tex
index 6090d6b0021..7e9cc0dc8d1 100644
--- a/Master/texmf-dist/doc/latex/animate/doc/animate.tex
+++ b/Master/texmf-dist/doc/latex/animate/doc/animate.tex
@@ -28,7 +28,7 @@
\parindent0pt
\parskip1.2ex
-\def\keywords{include, portable, PDF, animation, animating, embed, animated, graphics, LaTeX, pdfLaTeX, PSTricks, pgf, TikZ, LaTeX-picture, inline graphics, vector graphics, dvips, ps2pdf, JavaScript, Adobe Reader}
+\def\keywords{include, portable, PDF, animation, animating, embed, animated, graphics, LaTeX, pdfLaTeX, PSTricks, pgf, TikZ, LaTeX-picture, MetaPost, inline graphics, vector graphics, dvips, ps2pdf, JavaScript, Adobe Reader}
\hypersetup{
bookmarksnumbered,linktocpage,breaklinks,
pdftitle={The animate Package},
@@ -119,9 +119,11 @@ and the environment
While \verb+\animategraphics+ can be used to assemble animations from sets of existing graphics files, the environment `\verb+animateinline+' is intended 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.
-The command \verb+\newframe+ terminates a frame and starts the next one. It can be used inside the `\verb+animateinline+' environment only. There is a starred version, \verb+\newframe*+. If placed after a particular frame it causes the animation to pause at that frame. The animation continues normally after clicking it again. Both \verb+\newframe+ variants take an optional argument that allows to change the frame rate in the middle of an animation.
+By default, the animation is build 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 below).
-All files of the sequence must be consecutively numbered. {\tt <file base\-name>} is the leftmost part of the file name that all members of the sequence have in common. \verb+<first>+ is the number of the first and \verb+<last>+ the number of the last file in the set. 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 $0001\dots0100$.
+The command \verb+\newframe+ terminates a frame and starts the next one. It can be used inside the `\verb+animateinline+' environment only. 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 normally after clicking it again. Both \verb+\newframe+ variants take an optional argument that allows to change the frame rate in the middle of an animation.
+
+All files of the sequence must be consecutively numbered. {\tt <file base\-name>} is the leftmost part of the file name that all members of the sequence have in common. \verb+<first>+ is the number of the first and \verb+<last>+ the number of the last file in the set. 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$.
There is no file name extension to be specified as parameter. The possible file formats depend on whether \LaTeX{} or pdf\LaTeX{} is used. In the case of \LaTeX{}, files with the extension `\verb+eps+' are searched for at first, followed by `\verb+mps+' (\MP-generated Postscript) and `\verb+ps+'. With pdf\LaTeX{} the searching order is: (1)~`\verb+pdf+', (2)~`\verb+mps+', (3)~`\verb+png+', (4)~`\verb+jpg+', (5)~`\verb+jpeg+', (6)~`\verb+jbig2+' and (7)~`\verb+jb2+'. That is, files capable to store vector graphics are found first. Make sure that all file names have \emph{lower case} extensions.
@@ -141,6 +143,11 @@ autoresume
\end{verbatim}
Resume previously paused animation when the page is opened again.
\begin{verbatim}
+begin={<begin text>}
+end={<end text>}
+\end{verbatim}
+(`\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\\ \verb+begin={\begin{pspicture}(...)(...)},+ \verb+end={\end{pspicture}}+.
+\begin{verbatim}
loop
\end{verbatim}
The animation restarts immediately after reaching the end.
@@ -172,16 +179,54 @@ buttonbg=<colour>
\end{verbatim}
The background of the animation and control button widgets is transparent by default. It can be turned into a solid colour by the parameter \verb+<colour>+, which is an array of space-separated numbers (\emph{without} surrounding brackets) 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.
\begin{verbatim}
+poster=[first | none | last]
+\end{verbatim}
+Specifies which frame (first, last or none) to display and print if the animation is not activated. Option `poster=first' need not be explicitly set because it is the default.
+\begin{verbatim}
step
\end{verbatim}
Step through the animation by one frame per mouse-click.
\begin{verbatim}
-poster=[first | none | last]
+timeline=<timeline file>
\end{verbatim}
-Specifies which frame (first, last or none) to display and print if the animation is not activated. Option `poster=first' need not be explicitly set because it is the default.
+\verb+<timeline file>+ is a plain text file whose contents determines the order of appearance of the embedded material during the animation. In addition, it allows to freely reorder, 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 reused in other frames of the animation.
+
+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. In order to identify the transparencies within the timeline file, they are numbered in the order of their inclusion, starting at zero.
+
+Each line of the timeline file that is not blank and which does not begin with a comment (`\verb+%+') specifies \emph{one} frame of the animation. There may be more transparencies than animation frames and vice-versa. A frame specification consists of three, colon (`\verb+:+') separated fields:
+\begin{verbatim}
+ [*]:[<frame rate>]:[<frame content>]
+\end{verbatim}
+While any field may be left blank, the colons are mandatory.
+
+An asterisk (`\verb+*+') in the leftmost field causes the animation to pause at that frame, very much like a \verb+\newframe*+ would do; a number in the second field changes the frame rate of the animation section that follows. (In connexion 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.) The third field \verb+<frame content>+ is a comma separated list of \emph{transparency specifications} that determines the content of the frame. A single transparency specification obeys the syntax
+\begin{verbatim}
+ <transparency ID>[x<number of frames>]
+\end{verbatim}
+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 the transparency is to appear within. 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.
+
+Note, that the order in which transparency specifications appear in the timeline file determines their depth level. The animation can be visualised as a pile of transparencies. Transparencies are always put on top of that pile, possibly overdrawing objects that are on previously deposited transparencies. Once on the pile, each transparency remains at its place for the specified number of frames and is removed afterwards. That is, for a transparency to appear always on top it must be put to the rightmost end of each line in the timeline file.
+
+Consider the two timelines
+\begin{verbatim}
+ ::1,0 % zero'th transparency always on top
+ ::2,0
+ ::3,0
+ ::4,0
+ ...
+\end{verbatim}
+and
+\begin{verbatim}
+ ::0x0,1 % zero'th transparency in the lowest level
+ ::2
+ ::3
+ ::4
+ ...
+\end{verbatim}
+In the first example, transparency no. `0' appears in the uppermost depth level throughout the animation; it will never be obscured by other transparencies' content. In the second example it is put on the lowest level (because it is the first transparency specification in the file) and stays there for the rest of the animation.
\section{Examples}
-\subsection[Animation from a set of files, using `animategraphics' command]{Animation from a set of files, using `{\tt animategraphics}' command}
+\subsection[Animation from a set of files, using `animategraphics' command]{Animation from a set of files, using `{\tt animategraphics}' command together with `{\tt timeline'} option}
\small
\begin{verbatim}
\documentclass{article}
@@ -191,15 +236,32 @@ Specifies which frame (first, last or none) to display and print if the animatio
\begin{document}
\begin{center}
- \animategraphics[controls,loop]{4}{frame_}{0}{8}
+ \animategraphics[
+ controls, loop,
+ timeline=timeline.txt
+ ]{4}{frame_}{0}{8}
\end{center}
\end{document}
\end{verbatim}
-
\normalsize
+Contents of file `\verb+timeline.txt+':
+\small
+\begin{verbatim}
+::0x0 % coordinate system & y=e^x, repeated until last frame
+::1 % one blue curve per frame
+::2
+::3
+::4
+::5
+::6
+::7
+::8
+\end{verbatim}
+\normalsize
+
\begin{center}
- \animategraphics[controls,loop]{4}{frame_}{0}{8}
+ \animategraphics[controls,loop,timeline=timeline.txt]{4}{frame_}{0}{8}
\end{center}
\subsection[Animating PSTricks graphics, using `animateinline' environment]{Animating PSTricks graphics, using `{\tt animateinline}' environment}
@@ -329,7 +391,7 @@ Specifies which frame (first, last or none) to display and print if the animatio
\item Currently, animations should not be placed on \emph{multilayered} slides created with the Beamer class. Although possible, the result might be disappointing. Put animations on flat slides only. (Of course, slides without animations may still have overlays.)
- \item The \verb+dvips+ option `\verb+-Ppdf+' should be avoided entirely or followed by `\verb+-X 2400+ \verb+-Y 2400+' on the command line in order to set a sensible DVI resolution. In times of Type-1 fonts, this does \emph{not} degrade the output quality! The configuration file `\verb+config.pdf+' loaded by option `\verb+-Ppdf+' specifies an excessively high DVI resolution that will be passed on to the final PDF. Eventually, Adobe Reader gets confused and will not display the frames within the animation widget.
+ \item The \verb+dvips+ option `\verb+-Ppdf+' should be avoided entirely or followed by something like `\verb+-X 2400+ \verb+-Y 2400+' on the command line in order to set a sensible DVI resolution. In times of Type-1 fonts, this does \emph{not} degrade the output quality! The configuration file `\verb+config.pdf+' loaded by option `\verb+-Ppdf+' specifies an excessively high DVI resolution that will be passed on to the final PDF. Eventually, Adobe Reader gets confused and will not display the frames within the animation widget.
\item Animations with complex graphics and/or many frames may cause \LaTeX{} to fail with a `\verb+TeX capacity exceeded+' error. Enlarge \TeX{}'s memory with command line option `\verb+--mem-max=...+'.
diff --git a/Master/texmf-dist/doc/latex/animate/doc/files/timeline.txt b/Master/texmf-dist/doc/latex/animate/doc/files/timeline.txt
new file mode 100644
index 00000000000..c0945a66a6b
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/animate/doc/files/timeline.txt
@@ -0,0 +1,9 @@
+::0x0 % coordinate system & y=e^x, repeated until last frame
+::1 % one blue curve per frame
+::2
+::3
+::4
+::5
+::6
+::7
+::8
diff --git a/Master/texmf-dist/tex/latex/animate/animate.sty b/Master/texmf-dist/tex/latex/animate/animate.sty
index 6067ebadf1b..6001e2f51aa 100644
--- a/Master/texmf-dist/tex/latex/animate/animate.sty
+++ b/Master/texmf-dist/tex/latex/animate/animate.sty
@@ -13,7 +13,7 @@
% Supports LaTeX->dvips->ps2pdf or pdfLaTeX workflows.
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{animate}[2007/05/24]
+\ProvidesPackage{animate}[2007/07/04]
\RequirePackage{keyval}
\RequirePackage{ifthen}
\RequirePackage{ifpdf}
@@ -89,7 +89,8 @@
\pdfcatalog{
/OCProperties <<
/OCGs \the\@anim@@ocgs\space 0 R
- /D <</BaseState/OFF /ON \the\@anim@@posterocgs\space 0 R>>
+ /D <</BaseState/OFF /ON \the\@anim@@posterocgs\space 0 R
+ /Order \the\@anim@@ocgs\space 0 R>>
>>
}
\def\@anim@ocgs{}
@@ -111,17 +112,13 @@
mark {Catalog} <<
/OCProperties <<
/OCGs {@anim@ocgs}
- /D <</BaseState/OFF /ON {@anim@posterocgs}>>
+ /D <</BaseState/OFF /ON {@anim@posterocgs} /Order {@anim@ocgs}>>
>>
>> /PUT pdfmark
}
- \newcount\@anim@occnt % counter for optional content groups
- \global\@anim@occnt=0
- \newcount\@anim@resnum % counter for content resources
- \global\@anim@resnum=0
\fi
-\newbox\@anim@@box %stores single frame
+\newbox\@anim@box %stores animation frames
\newdimen\@anim@tmpdima %length register for occasional use
%creates Form XObject from graphics file
@@ -134,13 +131,13 @@
%store file in a box
\def\@anim@mps{.mps}%
\ifx\@anim@ext\@anim@mps%
- \global\setbox\@anim@@box=\hbox{\convertMPtoPDF{#3}{1}{1}}%
+ \global\setbox\@anim@box=\hbox{\convertMPtoPDF{#3}{1}{1}}%
\else%
\immediate\pdfximage{#3}%
- \global\setbox\@anim@@box=\hbox{\pdfrefximage\pdflastximage}%
+ \global\setbox\@anim@box=\hbox{\pdfrefximage\pdflastximage}%
\fi
%delegate Form XObject creation
- \@anim@xinline{#1}{#2}{\@anim@@box}%
+ \@anim@xinline{#1}{#2}{\@anim@box}%
}
\else
\def\@anim@ximage#1#2#3{%
@@ -149,80 +146,42 @@
}%
%store file in a box
\edef\@anim@curfile{{#3}}%
- \global\setbox\@anim@@box=\hbox{\expandafter\includegraphics\@anim@curfile}%
+ \global\setbox\@anim@box=\hbox{\expandafter\includegraphics\@anim@curfile}%
%delegate Form XObject creation
- \@anim@xinline{#1}{#2}{\@anim@@box}%
+ \@anim@xinline{#1}{#2}{\@anim@box}%
}
\fi
-%creates Form XObject from box contents and associates it with a newly created
-%OCG
+\newboolean{@anim@timeline} %true if `timeline' option was set
+
+%creates Form XObject from box contents and associates it with a newly
+%created OCG
\ifpdf
- \newbox\@anim@box %stores all graphics of a sequence
\def\@anim@xinline#1#2#3{%#1:@anim@num, #2:@anim@curframe@zb, #3:box number
- %new ocg
- \immediate\pdfobj{<</Type/OCG /Name (#1.#2)>>}%
- \xdef\@anim@curocg{\the\pdflastobj\space 0 R}%
- %append to ocg array
- \xdef\@anim@ocgs{\@anim@ocgs\space\@anim@curocg}%
- %store ref to ocg if it's a poster
- \ifnum#2=0%
- \def\@anim@posterframe{first}%
- \else%
- \def\@anim@posterframe{last}%
- \fi%
- \ifx\@anim@poster\@anim@posterframe%
- \xdef\@anim@posterocg{\@anim@curocg}%
- \fi%
- %new XObject
- \immediate\pdfxform attr {%
- /OC <</Type/OCMD /OCGs \@anim@curocg>>%
- }#3%
- \ifnum#2=0%
- \global\setbox\@anim@box=\hbox{\pdfrefxform\pdflastxform}%
- % size (measuring the first frame only)
- \xdef\@anim@animwidth{\strip@pt\wd\@anim@box}%
- \xdef\@anim@animheight{\strip@pt\ht\@anim@box}%
- \xdef\@anim@animdepth{\strip@pt\dp\@anim@box}%
- \setlength{\@anim@tmpdima}{\ht\@anim@box}%
- \addtolength{\@anim@tmpdima}{\dp\@anim@box}%
+ \ifnum#2=0% measuring the size of the box (first frame only)
+ \xdef\@anim@animwidth{\strip@pt\wd#3}%
+ \xdef\@anim@animheight{\strip@pt\ht#3}%
+ \xdef\@anim@animdepth{\strip@pt\dp#3}%
+ \setlength{\@anim@tmpdima}{\ht#3}%
+ \addtolength{\@anim@tmpdima}{\dp#3}%
\xdef\@anim@animtotalheight{\strip@pt\@anim@tmpdima}%
- \else% overlay current XObject over previous content
- \def\@anim@oldunitlength{\the\unitlength}% make backup
- \setlength{\unitlength}{1pt}%
- \global\setbox\@anim@box=\hbox{%
- \begin{picture}(%
- \@anim@animwidth,\@anim@animtotalheight%
- )(%
- 0,-\@anim@animdepth%
- )%
- \put(0,0){\box\@anim@box}%
- \put(0,0){\pdfrefxform\pdflastxform}%
- \end{picture}%
+ \fi%
+ %put graphics into XObject
+ \immediate\pdfxform #3%
+ %XObject resource entry of container XObject
+ \xdef\@anim@xobject{%
+ \@anim@xobject\space/im#2\space\the\pdflastxform\space 0 R%
+ }%
+ \if@anim@timeline\else%
+ \@anim@newocg{#1}{#2}%new ocg
+ %compose content stream of container XObject
+ \xdef\@anim@content{%
+ \@anim@content\space /OC/oc#2\space BDC q /im#2\space Do Q EMC%
}%
- \setlength{\unitlength}{\@anim@oldunitlength}% restore previous unitlen
\fi%
- }
+ }
\else
\def\@anim@xinline#1#2#3{%
- \special{ps:
- %new ocg
- mark /_objdef {@anim@ocg@\the\@anim@occnt} /type/dict /OBJ pdfmark
- mark {@anim@ocg@\the\@anim@occnt} <<
- /Type/OCG /Name (#1.#2)
- >> /PUT pdfmark
- %append to ocg array
- mark {@anim@ocgs} {@anim@ocg@\the\@anim@occnt} /APPEND pdfmark
- }%
- %store ref to ocg if it is a poster
- \ifnum#2=0%
- \def\@anim@posterframe{first}%
- \else%
- \def\@anim@posterframe{last}%
- \fi%
- \ifx\@anim@poster\@anim@posterframe%
- \xdef\@anim@posterocg{@anim@ocg@\the\@anim@occnt}%
- \fi%
\ifnum#2=0%
\xdef\@anim@animwidth{\strip@pt\wd#3}%
\xdef\@anim@animheight{\strip@pt\ht#3}%
@@ -230,11 +189,8 @@
\setlength{\@anim@tmpdima}{\ht#3}%
\addtolength{\@anim@tmpdima}{\dp#3}%
\xdef\@anim@animtotalheight{\strip@pt\@anim@tmpdima}%
- \gdef\@anim@properties{}%
- \gdef\@anim@xobject{}%
- \gdef\@anim@content{}%
\fi%
- \def\@anim@oldunitlength{\the\unitlength}% make backup
+ \edef\@anim@oldunitlength{\the\unitlength}% make backup
\setlength{\unitlength}{1pt}%
%mark BBox of the graphics
\begin{picture}(0,0)%
@@ -254,7 +210,7 @@
\special{ps:
gsave
mark
- /_objdef {@anim@frm@\the\@anim@occnt}
+ /_objdef {@anim@frm@#1@#2}
/BBox [frame@llx frame@lly frame@urx frame@ury]
/BP pdfmark
%flip around horizontal axis
@@ -267,30 +223,88 @@
mark /EP pdfmark
grestore
}%
- %compose resources for use in container XObject
+ %XObject resource entry of container XObject
+ \xdef\@anim@xobject{%
+ \@anim@xobject\space/im#2\space
+ {@anim@frm@#1@#2}%
+ }%
+ \if@anim@timeline\else%
+ \@anim@newocg{#1}{#2}% new ocg
+ %compose content stream of container XObject
+ \xdef\@anim@content{%
+ \@anim@content\space /OC/oc#2\space BDC q /im#2\space Do Q EMC%
+ }%
+ \fi%
+ }
+\fi
+
+%creates OCG and builds Properties entry for use in container XObject
+\ifpdf
+ \def\@anim@newocg#1#2{%#1:@anim@num, #2:@anim@curframe@zb
+ \immediate\pdfobj{<</Type/OCG /Name (#1.#2)>>}% new ocg
+ \xdef\@anim@curocg{\the\pdflastobj\space 0 R}%
+ %append to ocg array
+ \xdef\@anim@ocgs{\@anim@ocgs\space\@anim@curocg}%
+ %store ref to ocg if it's a poster
+ \ifnum#2=0%
+ \def\@anim@posterframe{first}%
+ \else%
+ \def\@anim@posterframe{last}%
+ \fi%
+ \ifx\@anim@poster\@anim@posterframe%
+ \xdef\@anim@posterocg{\@anim@curocg}%
+ \fi%
+ %compose Properties entry for use in container XObject
\xdef\@anim@properties{%
- \@anim@properties\space/oc\the\@anim@resnum\space
- {@anim@ocg@\the\@anim@occnt}%
+ \@anim@properties\space/oc#2\space\@anim@curocg%
}%
- \xdef\@anim@xobject{%
- \@anim@xobject\space/im\the\@anim@resnum\space
- {@anim@frm@\the\@anim@occnt}%
+ }
+\else
+ \def\@anim@newocg#1#2{%#1:@anim@num, #2:@anim@curframe@zb
+ \special{ps:
+ mark /_objdef {@anim@ocg@#1@#2} /type/dict /OBJ pdfmark %new ocg
+ mark {@anim@ocg@#1@#2} <<
+ /Type/OCG /Name (#1.#2)
+ >> /PUT pdfmark
+ %append to ocg array
+ mark {@anim@ocgs} {@anim@ocg@#1@#2} /APPEND pdfmark
}%
- %compose content stream of container XObject
- \xdef\@anim@content{%
- \@anim@content\space
- /OC/oc\the\@anim@resnum\space
- BDC q /im\the\@anim@resnum\space Do Q EMC%
+ %store ref to ocg if it is a poster
+ \ifnum#2=0%
+ \def\@anim@posterframe{first}%
+ \else%
+ \def\@anim@posterframe{last}%
+ \fi%
+ \ifx\@anim@poster\@anim@posterframe%
+ \xdef\@anim@posterocg{@anim@ocg@#1@#2}%
+ \fi%
+ %compose Properties entry for use in container XObject
+ \xdef\@anim@properties{%
+ \@anim@properties\space/oc#2\space {@anim@ocg@#1@#2}%
}%
- \global\advance\@anim@occnt by 1% increment ocg counter
- \global\advance\@anim@resnum by 1% increment resource number
}
\fi
%create XObject which contains all frames of the sequence
\ifpdf
- \def\@anim@makecontainer#1{%
- \immediate\pdfxform\@anim@box% make it from box
+ \def\@anim@makecontainer#1{% #1:@anim@num
+ \edef\@anim@oldunitlength{\the\unitlength}% make backup
+ \setlength{\unitlength}{1pt}%
+ \global\setbox\@anim@box=\hbox{%
+ \pdfliteral{q}%
+ \begin{picture}(%
+ \@anim@animwidth,\@anim@animtotalheight%
+ )(%
+ 0,-\@anim@animdepth%
+ )%
+ \end{picture}%
+ \pdfliteral{Q\@anim@content}%
+ }%
+ \setlength{\unitlength}{\@anim@oldunitlength}% restore previous unitlen
+ \immediate\pdfxform resources {%
+ /Properties <<\@anim@properties>>
+ /XObject <<\@anim@xobject>>
+ }\@anim@box%
\xdef\@anim@container{\the\pdflastxform\space 0 R}%
}
\else
@@ -307,7 +321,6 @@
>>
>> /PUT pdfmark
}%
- \global\@anim@resnum=0% reset resource number
}
\fi
@@ -803,8 +816,8 @@
% #1: options
% #2: frame rate (fps)
% #3: basename of graphics file sequence (without frame number and extension)
-% #4: first frame (zero padded integer of same width as #5)
-% #5: last frame (zero padded integer of same width as #4)
+% #4: first frame (integer)
+% #5: last frame (integer)
\newcommand{\animategraphics}[5][]{%
\leavevmode%
\ifpdf\else%
@@ -822,12 +835,14 @@
\@anim@makebuttons%
\setboolean{@anim@buttonsmade}{true}%
\fi%
- %combine Pause & Play button faces into one XObject
- \@anim@makeppcontainer{\the\@anim@num}{Right}%
- \@anim@makeppcontainer{\the\@anim@num}{Left}%
+ \if@anim@step\else%
+ %combine Pause & Play button faces into one XObject
+ \@anim@makeppcontainer{\the\@anim@num}{Right}%
+ \@anim@makeppcontainer{\the\@anim@num}{Left}%
+ \fi%
\fi%
\xdef\@anim@fps{#2}% current frame rate
- \xdef\@anim@nfps{#2}% not used, actually, with `animategraphics'
+ \xdef\@anim@nfps{#2}%
\xdef\@anim@pauseat{}%
\xdef\@anim@nfpsat{}%
\xdef\@anim@pfpsat{}%
@@ -846,43 +861,48 @@
}%
\advance\@anim@curframe by 1%
\advance\@anim@curframe@zb by 1%
- \xdef\@anim@frames{\the\@anim@curframe@zb}% total number
\repeat%
+ \xdef\@anim@frames{\the\@anim@curframe@zb}% total number
+ %build timeline from optional timeline file
+ \if@anim@timeline\@anim@buildtmln{\the\@anim@num}\fi%
\@anim@makecontainer{\the\@anim@num}% create container XObject
%insert animation widget & controls
+ \@anim@insertwidgets{\the\@anim@num}%
+ \global\advance\@anim@num by 1%
+}%
+
+%insert the animation and control button widgets
+\def\@anim@insertwidgets#1{%#1:@anim@num
\vtop{%
\offinterlineskip%
- \hbox{\@anim@animwidget{\the\@anim@num}}%
+ \hbox{\@anim@animwidget{#1}}%
\if@anim@controls%
\setlength{\@anim@tmpdima}{\@anim@btnsize}%
\setlength{\@anim@tmpdima}{0.1\@anim@tmpdima}%
\vskip \@anim@tmpdima%
\hbox to \@anim@animwidth\@anim@pt {%
\hss%
- \@anim@buttonwidget{\the\@anim@num}{EndLeft}{EndLeft}%
- \@anim@buttonwidget{\the\@anim@num}{StepLeft}{StepLeft}%
+ \@anim@buttonwidget{#1}{EndLeft}{EndLeft}%
+ \@anim@buttonwidget{#1}{StepLeft}{StepLeft}%
\if@anim@step\else%
- \@anim@buttonwidget{\the\@anim@num}{PlayPauseLeft}{%
- \the\@anim@num.PlayPauseLeft}%
- \@anim@buttonwidget{\the\@anim@num}{PlayPauseRight}{%
- \the\@anim@num.PlayPauseRight}%
+ \@anim@buttonwidget{#1}{PlayPauseLeft}{#1.PlayPauseLeft}%
+ \@anim@buttonwidget{#1}{PlayPauseRight}{#1.PlayPauseRight}%
\fi%
- \@anim@buttonwidget{\the\@anim@num}{StepRight}{StepRight}%
- \@anim@buttonwidget{\the\@anim@num}{EndRight}{EndRight}%
+ \@anim@buttonwidget{#1}{StepRight}{StepRight}%
+ \@anim@buttonwidget{#1}{EndRight}{EndRight}%
\if@anim@step\else%
\setlength{\@anim@tmpdima}{\@anim@btnsize}%
\setlength{\@anim@tmpdima}{0.3\@anim@tmpdima}%
\hskip \@anim@tmpdima%
- \@anim@buttonwidget{\the\@anim@num}{Minus}{Minus}%
- \@anim@buttonwidget{\the\@anim@num}{Reset}{Reset}%
- \@anim@buttonwidget{\the\@anim@num}{Plus}{Plus}%
+ \@anim@buttonwidget{#1}{Minus}{Minus}%
+ \@anim@buttonwidget{#1}{Reset}{Reset}%
+ \@anim@buttonwidget{#1}{Plus}{Plus}%
\fi%
\hss%
}%
\fi%
}%
- \global\advance\@anim@num by 1%
-}%
+}
%calculates widget dimensions from natural ones, taking resizing options
%into account
@@ -956,7 +976,7 @@
\def\@anim@posterframe{none}%
\ifx\@anim@poster\@anim@posterframe\else%
\xdef\@anim@posterocgs{\@anim@posterocgs\space\@anim@posterocg}%
- \fi
+ \fi%
\pdfannot
width \@anim@animwidth\@anim@pt
height \@anim@animheight\@anim@pt
@@ -988,7 +1008,7 @@
\else
\def\@anim@animwidget#1{%
\@anim@rescale%
- \def\@anim@oldunitlength{\the\unitlength}%
+ \edef\@anim@oldunitlength{\the\unitlength}%
\setlength{\unitlength}{1pt}%
%mark annotation rectangle
\begin{picture}(0,0)%
@@ -1074,7 +1094,7 @@
\def\@anim@buttonwidget#1#2#3{%
\@anim@upjscript{#1}{#2}%
\setlength{\@anim@tmpdima}{\@anim@btnsize}%
- \def\@anim@oldunitlength{\the\unitlength}%
+ \edef\@anim@oldunitlength{\the\unitlength}%
\setlength{\unitlength}{1pt}%
\begin{picture}(0,0)%
\put(0,0){%
@@ -1133,9 +1153,11 @@
\@anim@makebuttons%
\setboolean{@anim@buttonsmade}{true}%
\fi%
- %combine Pause & Play button faces into one XObject
- \@anim@makeppcontainer{\the\@anim@num}{Right}%
- \@anim@makeppcontainer{\the\@anim@num}{Left}%
+ \if@anim@step\else%
+ %combine Pause & Play button faces into one XObject
+ \@anim@makeppcontainer{\the\@anim@num}{Right}%
+ \@anim@makeppcontainer{\the\@anim@num}{Left}%
+ \fi%
\fi%
\xdef\@anim@fps{#2}%
\xdef\@anim@nfps{#2}% current frame rate (for use in \newframe)
@@ -1147,39 +1169,11 @@
\@anim@endframe{\the\@anim@num}{\the\@anim@curframe@zb}%
\global\advance\@anim@curframe@zb by 1%
\xdef\@anim@frames{\the\@anim@curframe@zb}% total number
+ %build timeline from optional timeline file
+ \if@anim@timeline\@anim@buildtmln{\the\@anim@num}\fi%
\@anim@makecontainer{\the\@anim@num}% create container XObject
%insert animation widget & controls
- \vtop{%
- \offinterlineskip%
- \hbox{\@anim@animwidget{\the\@anim@num}}%
- \if@anim@controls%
- \setlength{\@anim@tmpdima}{\@anim@btnsize}%
- \setlength{\@anim@tmpdima}{0.1\@anim@tmpdima}%
- \vskip \@anim@tmpdima%
- \hbox to \@anim@animwidth\@anim@pt {%
- \hss%
- \@anim@buttonwidget{\the\@anim@num}{EndLeft}{EndLeft}%
- \@anim@buttonwidget{\the\@anim@num}{StepLeft}{StepLeft}%
- \if@anim@step\else%
- \@anim@buttonwidget{\the\@anim@num}{PlayPauseLeft}{%
- \the\@anim@num.PlayPauseLeft}%
- \@anim@buttonwidget{\the\@anim@num}{PlayPauseRight}{%
- \the\@anim@num.PlayPauseRight}%
- \fi%
- \@anim@buttonwidget{\the\@anim@num}{StepRight}{StepRight}%
- \@anim@buttonwidget{\the\@anim@num}{EndRight}{EndRight}%
- \if@anim@step\else%
- \setlength{\@anim@tmpdima}{\@anim@btnsize}%
- \setlength{\@anim@tmpdima}{0.3\@anim@tmpdima}%
- \hskip \@anim@tmpdima%
- \@anim@buttonwidget{\the\@anim@num}{Minus}{Minus}%
- \@anim@buttonwidget{\the\@anim@num}{Reset}{Reset}%
- \@anim@buttonwidget{\the\@anim@num}{Plus}{Plus}%
- \fi%
- \hss%
- }%
- \fi%
- }%
+ \@anim@insertwidgets{\the\@anim@num}%
\global\advance\@anim@num by 1%
\setboolean{@anim@inside}{false}%
}
@@ -1199,27 +1193,32 @@
}
\newcommand{\@anim@newframestar}[1][]{% starred variant to pause animation
\if@anim@step\else% % #1: new frame rate
- %build JavaScript commands to fill the `pauseAt' array
- \xdef\@anim@pauseat{%
- \@anim@pauseat%
- a\the\@anim@num.pauseAt[\the\@anim@curframe@zb]=1;%
- }%
- \setboolean{@anim@pauseframes}{true}%
- \xdef\@anim@pfps{\@anim@nfps}%
- \xdef\@anim@nfps{#1}%
- \ifx\@anim@nfps\@empty%
- \xdef\@anim@nfps{\@anim@pfps}%
- \else%
- %build JavaScript commands to fill the `nFpsAt' & `pFpsAt' arrays
- \xdef\@anim@nfpsat{%
- \@anim@nfpsat%
- a\the\@anim@num.nFpsAt[\the\@anim@curframe@zb]=Math.abs(#1);%
- }%
- \xdef\@anim@pfpsat{%
- \@anim@pfpsat%
- a\the\@anim@num.pFpsAt[\the\@anim@curframe@zb]=Math.abs(\@anim@pfps);%
+ \if@anim@timeline\else%
+ %build JavaScript commands to fill the `pauseAt' array
+ \xdef\@anim@pauseat{%
+ \@anim@pauseat%
+ a\the\@anim@num.pauseAt[\the\@anim@curframe@zb]=1;%
}%
- \setboolean{@anim@chfps}{true}% change fps
+ \setboolean{@anim@pauseframes}{true}%
+ \xdef\@anim@pfps{\@anim@nfps}%
+ \xdef\@anim@nfps{#1}%
+ \ifx\@anim@nfps\@empty%
+ \xdef\@anim@nfps{\@anim@pfps}%
+ \else%
+ \ifnum\@anim@curframe@zb=0%
+ \xdef\@anim@fps{#1}%
+ \fi%
+ %build JavaScript commands to fill the `nFpsAt' & `pFpsAt' arrays
+ \xdef\@anim@nfpsat{%
+ \@anim@nfpsat%
+ a\the\@anim@num.nFpsAt[\the\@anim@curframe@zb]=Math.abs(#1);%
+ }%
+ \xdef\@anim@pfpsat{%
+ \@anim@pfpsat%
+ a\the\@anim@num.pFpsAt[\the\@anim@curframe@zb]=Math.abs(\@anim@pfps);%
+ }%
+ \setboolean{@anim@chfps}{true}% change fps
+ \fi%
\fi%
\fi%
\global\advance\@anim@curframe@zb by 1%
@@ -1228,21 +1227,26 @@
}
\newcommand{\@anim@newframe}[1][]{% #1: new frame rate
\if@anim@step\else%
- \edef\@anim@pfps{\@anim@nfps}%
- \edef\@anim@nfps{#1}%
- \ifx\@anim@nfps\@empty%
- \edef\@anim@nfps{\@anim@pfps}%
- \else%
- %build JavaScript commands to fill the `nFpsAt' & `pFpsAt' arrays
- \xdef\@anim@nfpsat{%
- \@anim@nfpsat%
- a\the\@anim@num.nFpsAt[\the\@anim@curframe@zb]=Math.abs(#1);%
- }%
- \xdef\@anim@pfpsat{%
- \@anim@pfpsat%
- a\the\@anim@num.pFpsAt[\the\@anim@curframe@zb]=Math.abs(\@anim@pfps);%
- }%
- \setboolean{@anim@chfps}{true}% change fps
+ \if@anim@timeline\else%
+ \edef\@anim@pfps{\@anim@nfps}%
+ \edef\@anim@nfps{#1}%
+ \ifx\@anim@nfps\@empty%
+ \edef\@anim@nfps{\@anim@pfps}%
+ \else%
+ \ifnum\@anim@curframe@zb=0%
+ \xdef\@anim@fps{#1}%
+ \fi%
+ %build JavaScript commands to fill the `nFpsAt' & `pFpsAt' arrays
+ \xdef\@anim@nfpsat{%
+ \@anim@nfpsat%
+ a\the\@anim@num.nFpsAt[\the\@anim@curframe@zb]=Math.abs(#1);%
+ }%
+ \xdef\@anim@pfpsat{%
+ \@anim@pfpsat%
+ a\the\@anim@num.pFpsAt[\the\@anim@curframe@zb]=Math.abs(\@anim@pfps);%
+ }%
+ \setboolean{@anim@chfps}{true}% change fps
+ \fi%
\fi%
\fi%
\global\advance\@anim@curframe@zb by 1%
@@ -1252,17 +1256,19 @@
%starts a new frame
\def\@anim@beginframe{%
- \begin{lrbox}{\@anim@@box}% store the graphics in a box
+ \begin{lrbox}{\@anim@box}% store the graphics in a box
+ \the\@anim@begin%
}
%terminates current frame
\def\@anim@endframe#1#2{%
+ \the\@anim@end%
\end{lrbox}%
\message{< a#1, fr#2}%
%determine size of graphics
\ifnum #2=0%
- \xdef\@anim@animwidth{\strip@pt\wd\@anim@@box}%
- \ifdim\wd\@anim@@box=0pt%
+ \xdef\@anim@animwidth{\strip@pt\wd\@anim@box}%
+ \ifdim\wd\@anim@box=0pt%
\PackageError{animate}{%
Contents of first frame must not have zero width%
}{%
@@ -1270,10 +1276,10 @@
immediately followed by \protect\newframe%
}%
\fi%
- \xdef\@anim@animheight{\strip@pt\ht\@anim@@box}%
- \xdef\@anim@animdepth{\strip@pt\dp\@anim@@box}%
- \ifdim\ht\@anim@@box=0pt%
- \ifdim\dp\@anim@@box=0pt%
+ \xdef\@anim@animheight{\strip@pt\ht\@anim@box}%
+ \xdef\@anim@animdepth{\strip@pt\dp\@anim@box}%
+ \ifdim\ht\@anim@box=0pt%
+ \ifdim\dp\@anim@box=0pt%
\PackageError{animate}{%
Contents of first frame must not have zero height%
}{}%
@@ -1281,12 +1287,12 @@
\fi%
\fi%
%now create Form XObject of box contents
- \@anim@xinline{#1}{#2}{\@anim@@box}%
+ \@anim@xinline{#1}{#2}{\@anim@box}%
\message{>}%
}
%prints zero padded integers
-% #1: arbitrary, non-zero integer number as template specifying the
+% #1: arbitrary integer number as template specifying the
% width, e. g. `987654' for a width of 6 digits
% #2: the number to be formatted (zero padded)
\def\@anim@pad#1#2{%
@@ -1312,6 +1318,152 @@
\fi%
}%
+%building timeline from timeline file
+\newread\@anim@@tmlnfile
+\newboolean{@anim@eof}
+\def\@anim@buildtmln#1{% #1:@anim@num
+ \edef\@anim@endlinechar{\the\endlinechar}%
+ \endlinechar=-1% suppress trailing space at input line end
+ \global\@anim@curframe@zb=0%
+ %read timeline file a first time to get number lines (= number of frames)
+ \openin\@anim@@tmlnfile=\@anim@tmlnfile%
+ \read\@anim@@tmlnfile to \@anim@inputline%
+ \edef\@anim@inputline{\@anim@inputline\space}%
+ %remove all spaces from input line
+ \edef\@anim@inputline{\expandafter\zap@space\@anim@inputline\@empty}%
+ \ifeof\@anim@@tmlnfile\setboolean{@anim@eof}{true}\else%
+ \setboolean{@anim@eof}{false}\fi%
+ \whiledo{\NOT\boolean{@anim@eof}}{%
+ \ifthenelse{\equal{\@anim@inputline}{}}{}{%
+ %initialise contents of each frame (to be filled with refs to XObjects
+ \@anim@newkey{@anim@content@\the\@anim@curframe@zb}{}% to be drawn)
+ \global\advance\@anim@curframe@zb by 1%
+ }%
+ \read\@anim@@tmlnfile to \@anim@inputline%
+ \edef\@anim@inputline{\@anim@inputline\space}%
+ \edef\@anim@inputline{\expandafter\zap@space\@anim@inputline\@empty}%
+ \ifeof\@anim@@tmlnfile\setboolean{@anim@eof}{true}\else%
+ \setboolean{@anim@eof}{false}\fi%
+ }%
+ \closein\@anim@@tmlnfile%
+ \xdef\@anim@images{\@anim@frames}% total number of images
+ \xdef\@anim@frames{\the\@anim@curframe@zb}% total number of anim positions
+ \global\@anim@curframe@zb=0%
+ %reopen timeline file and build timeline
+ \openin\@anim@@tmlnfile=\@anim@tmlnfile%
+ \read\@anim@@tmlnfile to \@anim@inputline%
+ \edef\@anim@inputline{\@anim@inputline\space}%
+ \edef\@anim@inputline{\expandafter\zap@space\@anim@inputline\@empty}%
+ \ifeof\@anim@@tmlnfile\setboolean{@anim@eof}{true}\else%
+ \setboolean{@anim@eof}{false}\fi%
+ \whiledo{\NOT\boolean{@anim@eof}}{%
+ \ifthenelse{\equal{\@anim@inputline}{}}{}{%
+ \expandafter\@anim@parseline\@anim@inputline;%
+ %create OCG and compose Properties entry
+ \@anim@newocg{#1}{\the\@anim@curframe@zb}%
+ %compose content stream of container XObject
+ \xdef\@anim@content{%
+ \@anim@content\space%
+ /OC/oc\the\@anim@curframe@zb\space%
+ BDC\@anim@getkeyval{@anim@content@\the\@anim@curframe@zb} EMC%
+ }%
+ \global\advance\@anim@curframe@zb by 1%
+ }%
+ \read\@anim@@tmlnfile to \@anim@inputline%
+ \edef\@anim@inputline{\@anim@inputline\space}%
+ \edef\@anim@inputline{\expandafter\zap@space\@anim@inputline\@empty}%
+ \ifeof\@anim@@tmlnfile\setboolean{@anim@eof}{true}\else%
+ \setboolean{@anim@eof}{false}\fi%
+ }%
+ \closein\@anim@@tmlnfile%
+ \endlinechar=\@anim@endlinechar% reset endlinechar
+}
+
+%reads one line of timeline file and splits into its colon separated parts
+\def\@anim@parseline#1:#2:#3;{%
+ \if@anim@step\else%
+ \ifx #1*% first column is a star (pause frame)
+ \xdef\@anim@pauseat{%
+ \@anim@pauseat%
+ a\the\@anim@num.pauseAt[\the\@anim@curframe@zb]=1;%
+ }%
+ \setboolean{@anim@pauseframes}{true}%
+ \fi%
+ \xdef\@anim@pfps{\@anim@nfps}%
+ \xdef\@anim@nfps{#2}%
+ \ifx\@anim@nfps\@empty% second column contains a number (new frame rate)
+ \xdef\@anim@nfps{\@anim@pfps}%
+ \else%
+ \ifnum\@anim@curframe@zb=0%
+ \xdef\@anim@fps{#2}%
+ \fi%
+ %build JavaScript commands to fill the `nFpsAt' & `pFpsAt' arrays
+ \xdef\@anim@nfpsat{%
+ \@anim@nfpsat%
+ a\the\@anim@num.nFpsAt[\the\@anim@curframe@zb]=Math.abs(#2);%
+ }%
+ \xdef\@anim@pfpsat{%
+ \@anim@pfpsat%
+ a\the\@anim@num.pFpsAt[\the\@anim@curframe@zb]=Math.abs(\@anim@pfps);%
+ }%
+ \setboolean{@anim@chfps}{true}% change fps
+ \fi%
+ \fi%
+ %parse the third column
+ \@anim@parsethird#3,:;%
+}
+
+%parses 3rd column of timeline file (comma separated list of image specs)
+\def\@anim@parsethird#1,#2;{%
+ \def\@anim@firstarg{#1}%
+ \ifx\@anim@firstarg\@empty\else%
+ \@anim@process#1x:;% process one image spec
+ \fi%
+ \ifx #2:\else%
+ \@anim@parsethird#2;%
+ \fi%
+}
+
+\newcount\@anim@tmpcnt %scratch counter for different uses
+%process image spec, such as 123 or 456x78 or 9x0
+\def\@anim@process#1x#2;{%
+ %determine number of repetitions of current image
+ \ifx #2:%
+ \gdef\@anim@repeats{1}%
+ \else%
+ \@anim@processsecond#2;%
+ \fi%
+ \ifnum\@anim@repeats=0% 0= means: repeat until end of timeline
+ \edef\@anim@repeatuntil{\@anim@frames}%
+ \else%
+ \@anim@tmpcnt=\@anim@curframe@zb%
+ \advance\@anim@tmpcnt by \@anim@repeats%
+ \ifnum\@anim@frames<\@anim@tmpcnt%
+ \edef\@anim@repeatuntil{\@anim@frames}%
+ \else%
+ \edef\@anim@repeatuntil{\the\@anim@tmpcnt}%
+ \fi%
+ \fi%
+ %build contents of animation frames according to image specifications
+ \ifnum\@anim@images<#1\else% ignore image specifications which do not exist
+ \ifnum\@anim@images=#1\else%
+ \@anim@tmpcnt=\@anim@curframe@zb%
+ \loop\ifnum\@anim@repeatuntil>\@anim@tmpcnt%
+ \@anim@newkey{@anim@content@\the\@anim@tmpcnt}{%
+ \@anim@getkeyval{@anim@content@\the\@anim@tmpcnt}
+ q /im#1\space Do Q%
+ }%
+ \advance\@anim@tmpcnt by 1%
+ \repeat%
+ \fi%
+ \fi%
+}
+
+%get number of repetitions of frame
+\def\@anim@processsecond#1x:;{%
+ \gdef\@anim@repeats{#1}%
+}
+
%command options
%setting the widget size
\define@key{anim@user}{width}{%
@@ -1349,7 +1501,7 @@
\define@key{anim@user}{loop}[true]{%
\setboolean{@anim@loop}{#1}%
}
-\newboolean{@anim@autoplay} %doen't work anymore in AR8
+\newboolean{@anim@autoplay}
\setboolean{@anim@autoplay}{false}
\define@key{anim@user}{autoplay}[true]{%
\setboolean{@anim@autoplay}{#1}%
@@ -1389,6 +1541,25 @@
\define@key{anim@user}{step}[true]{%
\setboolean{@anim@step}{#1}%
}
+\define@key{anim@user}{timeline}{%
+ \IfFileExists{#1}{%
+ \gdef\@anim@tmlnfile{#1}%
+ \setboolean{@anim@timeline}{true}%
+ }{%
+ \PackageError{animate}{timeline file `#1' cannot be opened for reading%
+ }{%
+ Make sure file `#1' exists and is readable!%
+ }%
+ }%
+}
+\newtoks\@anim@begin
+\define@key{anim@user}{begin}{%
+ \@anim@begin{#1}%
+}
+\newtoks\@anim@end
+\define@key{anim@user}{end}{%
+ \@anim@end{#1}%
+}
%macro to reset macros and booleans
\def\@anim@reset{%
@@ -1408,11 +1579,18 @@
\let\if@anim@palindrome=\if@anim@@palindrome%
\let\if@anim@step=\if@anim@@step%
\gdef\@anim@posterocg{}%
+ \gdef\@anim@properties{}%
+ \gdef\@anim@xobject{}%
+ \gdef\@anim@content{}%
\setboolean{@anim@pauseframes}{false}%
\gdef\@anim@pauseat{}%
\setboolean{@anim@chfps}{false}%
\gdef\@anim@nfpsat{}%
\gdef\@anim@pfpsat{}%
+ \gdef\@anim@tmlnfile{}%
+ \setboolean{@anim@timeline}{false}%
+ \@anim@begin={}%
+ \@anim@end={}%
}
%package options