diff options
author | Karl Berry <karl@freefriends.org> | 2022-01-31 21:13:21 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2022-01-31 21:13:21 +0000 |
commit | 5cc8fec8e88d40cff4f5e3e0dc83c0232833feff (patch) | |
tree | 4c1de6a5f57f761525810e6cf11d564de5da88ff /Master/texmf-dist/tex/latex | |
parent | 44368f1f8ccb875b96a8d4c0ee2018a2eec315b3 (diff) |
animate (31jan22)
git-svn-id: svn://tug.org/texlive/trunk@61821 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r-- | Master/texmf-dist/tex/latex/animate/animate.sty | 433 |
1 files changed, 219 insertions, 214 deletions
diff --git a/Master/texmf-dist/tex/latex/animate/animate.sty b/Master/texmf-dist/tex/latex/animate/animate.sty index fe5636586d5..9a4fed23749 100644 --- a/Master/texmf-dist/tex/latex/animate/animate.sty +++ b/Master/texmf-dist/tex/latex/animate/animate.sty @@ -13,7 +13,7 @@ \NeedsTeXFormat{LaTeX2e}[2020-10-01] -\def\@anim@version{2022/01/25} +\def\@anim@version{2022/01/31} \ProvidesPackage{animate} [\@anim@version\space PDF & SVG animations from files and inline graphics] @@ -312,16 +312,16 @@ %helper macro that typesets graphics file into savebox \if@anim@dvips - \def\@anim@filebox#1#2#3{% dvips: no multi-page support + \def\@anim@filebox#1#2#3#4{% dvips: no multi-page support \edef\@anim@curfile{[#3]{#1}}% - \global\setbox\@anim@box=\hbox{% + \setbox#4=\hbox{% \expandafter\includegraphics\@anim@curfile}% } \else %pdfTeX, LuaTeX, dvipdfmx, xetex, dvisvgm - \def\@anim@filebox#1#2#3{% + \def\@anim@filebox#1#2#3#4{% \edef\@anim@curfile{[#3,page=#2]{#1}}% - \global\setbox\@anim@box=\hbox{% + \setbox#4=\hbox{% \expandafter\includegraphics\@anim@curfile}% } \fi @@ -357,14 +357,16 @@ \edef\@anim@curxform{\@anim@getkeyval{xform:\@anim@fingerprint}}% \ifthenelse{\equal{\@anim@curxform}{}}{% % new "<file chksum>.<page>.<graphicx opts>" - \@anim@filebox{#3}{#4}{#5}% store file in a box - \@anim@newkey{natdims:\@anim@fingerprint}{% - {\the\wd\@anim@box}{\the\ht\@anim@box}{\the\dp\@anim@box}% + \@anim@filebox{#3}{#4}{#5}{\@anim@box}% store file in a box + \edef\@anim@natdims{{\the\wd\@anim@box}{\the\ht\@anim@box}{\the\dp\@anim@box}}% + \@anim@xinline{#1}{#2}{\@anim@box}{newfile}% Form XObject creation + \@anim@newkey{natdims:\@anim@lastxform}{\@anim@natdims}% + \@anim@newkey{scaleddims:\@anim@lastxform}{% scaled dimensions + {\@anim@animwidth}{\@anim@animheight}{\@anim@animdepth}% }% - \@anim@xinline{#1}{#2}{\@anim@box}{newfile}% delegate Form XObject creation - \@anim@newkey{xform:\@anim@fingerprint}{\@anim@@lastxform}% - }{% file known, re-using existing form xobject - \edef\@anim@curndims{\@anim@getkeyval{natdims:\@anim@fingerprint}}% + \@anim@newkey{xform:\@anim@fingerprint}{\@anim@lastxform}% + }{% file known, re-using existing xform + \edef\@anim@curndims{\@anim@getkeyval{scaleddims:\@anim@curxform}}% \setbox\@anim@box=\hbox to \@anim@xformnatwd{\@anim@curndims}{% \vrule width \z@ height \@anim@xformnatht{\@anim@curndims} @@ -372,76 +374,67 @@ \@anim@refxform{\@anim@curxform}% \hss% }% - \global\let\@anim@@lastxform\@anim@curxform% - \@anim@xinline{#1}{#2}{\@anim@box}{knownfile}% + \@anim@xinline{#1}{#2}{\@anim@box}{\@anim@curxform}% }% } %creates Form XObject from box contents -\def\@anim@xinline#1#2#3#4{% - \def\@anim@status{#4}% "newfile", "knownfile" or "inline" (inline graphics) - \edef\@anim@curwd{\the\wd#3}% +\def\@anim@xinline#1#2#3#4{% #1 anim num, #2 frame num, #3 box num, #4 status ( + \edef\@anim@curwd{\the\wd#3}% `newfile', xform ref of known file or `inline') \edef\@anim@curht{\the\ht#3}% \edef\@anim@curdp{\the\dp#3}% + % measure 0th frame, to determine final animation widget dims \ifnum#2=\z@\relax% - %measure 0th frame - \setbox\@anim@measbox=\hbox to \wd#3{% - \vrule width \z@ height \ht#3 depth \dp#3\hss}% - %determine final dims of animation widget + \ifthenelse{\equal{#4}{newfile}\OR\equal{#4}{inline}}{% + \setbox\@anim@measbox=\hbox to \wd#3{% + \vrule width \z@ height \ht#3 depth \dp#3\hss}% + }{% known file + \edef\@anim@curndims{\@anim@getkeyval{natdims:#4}}% + \setbox\@anim@measbox=\hbox to \@anim@xformnatwd{\@anim@curndims}{% + \vrule width \z@ + height \@anim@xformnatht{\@anim@curndims} + depth \@anim@xformnatdp{\@anim@curndims}% + \hss% + }% + }% \@anim@scale{\@anim@measbox}% - \@anim@keytoaux{a#1.wdbp}{\strip@pt\dimexpr0.996264\dimexpr\@anim@animwidth}% - \@anim@keytoaux{a#1.htbp}{\strip@pt\dimexpr0.996264\dimexpr\@anim@animheight}% - \@anim@keytoaux{a#1.thtbp}{\strip@pt\dimexpr0.996264\dimexpr\@anim@animtotalheight}% + \if@anim@dvisvgm% for clipping purposes + \@anim@keytoaux{a#1.wdbp}{\strip@pt\dimexpr0.996264\dimexpr\@anim@animwidth}% + \@anim@keytoaux{a#1.htbp}{\strip@pt\dimexpr0.996264\dimexpr\@anim@animheight}% + \@anim@keytoaux{a#1.thtbp}{\strip@pt\dimexpr0.996264\dimexpr\@anim@animtotalheight}% + \fi% \fi% - %test if natural dimensions of the current frame differ from - %final widget size \def\@anim@needresize{0}% + % test if content dimensions differ from those of the final widget \ifdim\@anim@curwd=\@anim@animwidth\else\def\@anim@needresize{1}\fi% \ifdim\@anim@curht=\@anim@animheight\else\def\@anim@needresize{1}\fi% \ifdim\@anim@curdp=\@anim@animdepth\else\def\@anim@needresize{1}\fi% - %if it's a new file, make xobject from it at its natural size - \ifthenelse{\equal{\@anim@status}{newfile}}{% - \@anim@xform{1}{0}{}{}{#3}% `{1}'-->with additional resources (opacity etc.) - \global\let\@anim@@lastxform\@anim@lastxform% - \def\@anim@status{knownfile}% - \ifnum\@anim@needresize>\z@\relax% - \global\setbox#3=\hbox to \@anim@curwd{% - \vrule width \z@ height \@anim@curht depth \@anim@curdp% - \@anim@refxform{\@anim@lastxform}% - \hss% - }% - \fi% - }{% - \ifthenelse{\equal{\@anim@status}{knownfile}}{% - \global\let\@anim@lastxform\@anim@@lastxform% - }{}% - }% - %adjust size of current frame to final animation dims, if necessary + % resize content to final dimensions, if necessary \ifnum\@anim@needresize>\z@\relax% - \global\setbox#3=\hbox{% + \setbox#3=\hbox{% \raisebox{-\@anim@animdepth}{% \resizebox*{\@anim@animwidth}{% \@anim@animtotalheight}{\raisebox{\depth}{\box#3}}% }% }% - \ifthenelse{\equal{\@anim@status}{knownfile}}{% - \@anim@xform{0}{0}{}{}{#3}% without additional Resources - }{}% - \fi% - %distill box with inline graphics to xobject - \ifthenelse{\equal{\@anim@status}{inline}}{% - \@anim@xform{1}{0}{}{}{#3}% with additional Resources - }{}% - %keep a record of XObject number - \@anim@newkey{img@#2}{\@anim@lastxform}% - \if@anim@timeline\else% - \@anim@newkey{frmcontent@#2}{\@anim@getkeyval{img@#2},}% - \@anim@makeframe{#1}{#2}% \fi% + \ifthenelse{\equal{#4}{newfile}\OR\equal{#4}{inline}}{% + \@anim@xform{1}{1}{}{}{#3}% + %keep a record of XObject number, needed when timeline is built + \@anim@newkey{img@#2}{\@anim@lastxform}% + }{% + %known file + \ifnum\@anim@needresize>\z@% + \@anim@xform{0}{1}{}{}{#3}% + \@anim@newkey{img@#2}{\@anim@lastxform}% + \else% + \@anim@newkey{img@#2}{#4}% + \fi% + }% \message{<a#1,fr#2>}% } -\def\@anim@insertfrmcontent#1,#2\@nil{% +\def\@anim@refxformlist#1,#2\@nil{% \ifthenelse{\equal{#1}{}}{}{% \if@anim@dvips% \@anim@refxform{{#1}}% @@ -449,38 +442,79 @@ \@anim@refxform{#1}% \fi% }% - \ifthenelse{\equal{#2}{}}{}{\@anim@insertfrmcontent#2\@nil}% + \ifthenelse{\equal{#2}{}}{}{\@anim@refxformlist#2\@nil}% } -%inserts one animation frame into the output acc. to -% \ifcase\@anim@method as -% 0 & 1: non-interactive Widget annotation -% 2: Form XObject referenced in the page content, tagged as OC -% or dvisvgm -\def\@anim@makeframe#1#2{% - %container box - \edef\@anim@tmpvar{\@anim@getkeyval{frmcontent@#2},}% - \global\setbox\@anim@box=\hbox to \@anim@animwidth{% - \vrule width \z@ height \@anim@animheight depth \@anim@animdepth% - \expandafter\@anim@insertfrmcontent\@anim@tmpvar\@nil% - \hss% - }% - %inside a `landscape' environment together with the icon and widget methods, - %the frame content needs to be rotated counter-clockwise by 90 deg - \ifnum\@anim@method>\@ne\else% - \ifx\@anim@lscape\@anim@@lscape% - \global\setbox\@anim@box=\hbox{\rotatebox{90}{\box\@anim@box}}% +% this counts the length of a clist <item a>,<item b>,<item b>,..., (note the +% trailing comma) +\def\@anim@countxformlist#1{% + \expandafter\@anim@@countxformlist\expandafter0\expandafter:#1,\@nil% +} +\def\@anim@@countxformlist#1:#2,#3\@nil{% + \ifx\relax#2\relax% + \the\numexpr#1% + \else% + \ifx\relax#3\relax% + \the\numexpr#1% + \else% + \expandafter\@anim@@countxformlist\the\numexpr #1+1:#3\@nil% + \fi% + \fi% +} + +\def\@anim@zaptrailingcommafromxref#1,\@nil{\if@anim@dvips{#1}\else#1\fi}% + +% inserts one animation frame into the output acc. to \ifcase\@anim@method +% as a non-interactive Widget annotation (0 or 1) or an an xform (2) that is +% referenced in the page content (and tagged as OCG or for multipage PDF export) +% args: #1 animation num, #2 frame number, #3 comma-separated list of xform +% refs (transparencies) +\def\@anim@makeframe#1#2#3{% + \edef\@anim@arg{#3}% + \setboolean{@anim@singleref}{false}\def\@anim@framexform{}% + % count number of xforms in the frame content; a single xform can be referenced + % at once, while a transparency list (multiple, overlayed xforms) must be boxed + % and nested in an additional xform + \ifnum\@anim@countxformlist{\@anim@arg}=\@ne% + \setboolean{@anim@singleref}{true}% + \edef\@anim@framexform{\expandafter\@anim@zaptrailingcommafromxref\@anim@arg\@nil}% + \fi% + % however, this isn't possible on landscape pages with \@anim@method==0|1 + % because frame content needs to be rotated by 90 deg counterclockwise + \ifnum\@anim@method>\@ne\else\ifx\@anim@lscape\@anim@@lscape% + \setboolean{@anim@singleref}{false}\def\@anim@framexform{}% + \fi\fi% + % ... nor if the animation is to be exported to multipage PDF + \if@anim@export% + \setboolean{@anim@singleref}{false}\def\@anim@framexform{}% + \fi% + \if@anim@singleref\else% + % put frame content in a box if necessary + \setbox\@anim@box=\hbox to \@anim@animwidth{% + \vrule width \z@ height \@anim@animheight depth \@anim@animdepth% + \expandafter\@anim@refxformlist\@anim@arg,\@nil% + \hss% + }% + % rotate content on lscape pages + \ifnum\@anim@method>\@ne\else% + \ifx\@anim@lscape\@anim@@lscape% + \setbox\@anim@box=\hbox{\rotatebox{90}{\box\@anim@box}}% + \fi% + \fi% + % convert it to an xform + \if@anim@export\else% + \@anim@xform{0}{1}{}{}{\@anim@box}% + \let\@anim@framexform\@anim@lastxform% \fi% \fi% \ifcase\@anim@method% icon based - \@anim@xform{0}{1}{}{}{\@anim@box}% %initial visibility \ifnum\@anim@poster>\@anim@mtwo\relax% insert poster frame \ifnum#2=\@anim@poster\relax% - \let\@anim@posterap\@anim@lastxform% + \let\@anim@posterap\@anim@framexform% \else% \ifnum\@anim@poster=\@anim@mone\relax% use last frame as poster - \let\@anim@posterap\@anim@lastxform% + \let\@anim@posterap\@anim@framexform% \fi% \fi% \fi% @@ -490,8 +524,9 @@ /F 2% /FT/Btn/Ff 65537% /BS <</W 0>>% - /AP <</N \@anim@lastxform>>% - /MK <</TP 1/I \@anim@lastxform/IF<</S/A/FB true>>>>% + /AP <</N \@anim@framexform>>% + /MK <</TP 1/I \@anim@framexform% + /IF<</S/A/FB true>>>>% /T (#1.#2)% }% \or% widget based @@ -512,20 +547,22 @@ \fi% \fi% %frame insertion - \@anim@xform{0}{1}{}{}{\@anim@box}% \@anim@widget{\@anim@animwidth}{\@anim@animheight}{\@anim@animdepth}{% /Subtype/Widget% \@anim@annotflag% /FT/Btn/Ff 65537% /BS <</W 0>>% - /AP <</N \@anim@lastxform>>% - /MK <</TP 1/I \@anim@lastxform/IF<</S/A/FB true>>>>% + /AP <</N \@anim@framexform>>% + /MK <</TP 1/I \@anim@framexform% + /IF<</S/A/FB true>>>>% /T (#1.#2)% }% - \or% ocg based (abused for dvisvgm backend as well as for + \or% ocg-based (abused for dvisvgm backend as well as for % multipage PDF export) \if@anim@export% + \if@anim@insideexport\else\anim@export\fi% \box\@anim@box% + \endanim@export% \else% \@anim@newocg{#1}{#2}% %initial visibility @@ -542,25 +579,13 @@ \fi% \fi% %frame insertion - \if@anim@dvisvgm% - % `marked content' method for dvisvgm - \@anim@xform{0}{0}{}{}{\@anim@box}% - \ocgbase@oc@bdc{\@anim@curocg}% - \@anim@refxform{\@anim@lastxform}% - \ocgbase@oc@emc% - \else% - % /OC method for PDF output - \@anim@xform{0}{0}{}{/OC \@anim@curocg}{\@anim@box}% - \@anim@refxform{\@anim@lastxform}% - %% `marked content' method (slower, perhaps) - %\@anim@xform{0}{0}{}{}{\@anim@box}% - %\ocgbase@oc@bdc{\@anim@curocg}% - %\@anim@refxform{\@anim@lastxform}% - %\ocgbase@oc@emc% - \fi% + \ocgbase@oc@bdc{\@anim@curocg}% + \@anim@refxform{\@anim@framexform}% + \ocgbase@oc@emc% \fi% \fi% } +\newboolean{@anim@singleref} %create XObjects of all button faces \ifnum\if@anim@dvips 1\else\if@anim@dvisvgm 1\else0\fi\fi=1 @@ -843,7 +868,7 @@ \@anim@xbutton{ResetFG}{\@anim@btnreset}{#2}% \endgroup% \ifx\empty\@anim@bg\empty\else% - \global\setbox\@anim@box=\hbox to \@anim@btnsize {% + \setbox\@anim@box=\hbox to \@anim@btnsize {% \vbox to \@anim@btnsize {\vss% \@anim@refxform{\@anim@getkeyval{btnResetBG:#2}}% \@anim@refxform{\@anim@lastxform}% @@ -878,7 +903,7 @@ \def\@anim@xbutton#1#2#3{% #1: name; #2: stroking commands, % only create if button face doesn't exist yet \ifcsname btn#1:#3\endcsname\else% #3: current colour+alpha+ ... combination - \global\setbox\@anim@box=\hbox to 15bp {\vbox to 15bp {\vss% + \setbox\@anim@box=\hbox to 15bp {\vbox to 15bp {\vss% \@anim@literal{}{% save \ifx\empty\@anim@alpha\empty% @@ -909,7 +934,7 @@ }% }\hss}% \if@anim@dvisvgm% - \global\setbox\@anim@box=\hbox{% + \setbox\@anim@box=\hbox{% \resizebox*{!}{\@anim@btnsize}{\box\@anim@box}}% \fi% %distill box into XObject @@ -1607,23 +1632,22 @@ \fi% \if@anim@dvisvgm% \def\@anim@method{\tw@}% using ocg-like method for dvisvgm - \setboolean{@anim@doscaling}{false}% \fi% \if@anim@draft% \if@anim@multipage% %store file in a box - \@anim@filebox{\@anim@pathtofile}{\@anim@first}{\@anim@gropts}% + \@anim@filebox{\@anim@pathtofile}{\@anim@first}{\@anim@gropts}{\@anim@box}% \else% %get file name extension \@anim@getpath{\@anim@base\@anim@first}{\@anim@ftype}% - \@anim@filebox{\@anim@pathtofile}{1}{\@anim@gropts}% + \@anim@filebox{\@anim@pathtofile}{1}{\@anim@gropts}{\@anim@box}% \fi% \@anim@scale{\@anim@box}% %draw draftbox according to dimensions of the first frame \@anim@draftbox% \else% \xdef\@anim@nfps{#2\space}% current frame rate - \xdef\@anim@nfps{\expandafter\zap@space\@anim@nfps\@empty}% + \xdef\@anim@nfps{\expandafter\@anim@zap@space\@anim@nfps\@empty}% \ifdim\@anim@nfps pt<\z@% \PackageError{animate}{% Negative frame rate `\@anim@nfps' is not allowed% @@ -1631,19 +1655,11 @@ \fi% \global\let\@anim@fps\@anim@nfps% % - \if@anim@export\if@anim@timeline% + \if@anim@export% \anim@export% - \fi\fi% - %make all frames of the sequence - \if@anim@dvisvgm\if@anim@timeline\else% - \ifcsname a\the\@anim@num.htbp\endcsname% - \@anim@beginsvgclip{\the\@anim@num}% - \fi% - \fi\fi% + \fi% + %embed content (graphics sequence) \loop\ifnum\@anim@curframe\@anim@relop\@anim@last\relax\else% - \if@anim@export\if@anim@timeline\else% - \anim@export% - \fi\fi% \if@anim@multipage% %embed graphics \@anim@ximage{\the\@anim@num}{\the\@anim@curframe@zb}{% @@ -1657,31 +1673,31 @@ \@anim@ximage{\the\@anim@num}{\the\@anim@curframe@zb}{% \@anim@pathtofile}{1}{\@anim@gropts}% \fi% - \if@anim@export\if@anim@timeline\else% - \endanim@export% - \fi\fi% \global\advance\@anim@curframe by \@anim@every% \global\advance\@anim@curframe@zb by \@ne% \repeat% - \if@anim@dvisvgm\if@anim@timeline\else% - \ifcsname a\the\@anim@num.htbp\endcsname% - \@anim@endsvgclip% - \fi% - \fi\fi% \xdef\@anim@frames{\the\@anim@curframe@zb}% total number \global\@anim@tmpcnt=\@anim@frames% \global\advance\@anim@tmpcnt by -\@ne% \xdef\@anim@maxframe{\the\@anim@tmpcnt}% highest frame index - %build timeline from optional timeline file - \if@anim@timeline% - \if@anim@dvisvgm\ifcsname a\the\@anim@num.htbp\endcsname% - \@anim@beginsvgclip{\the\@anim@num}% - \fi\fi% + %make animation frames from embedded content ... + \if@anim@dvisvgm\ifcsname a\the\@anim@num.htbp\endcsname% + \@anim@beginsvgclip{\the\@anim@num}% + \fi\fi% + \if@anim@timeline% ... by building timeline (optional timeline file) \@anim@buildtmln{\the\@anim@num}% - \if@anim@dvisvgm\ifcsname a\the\@anim@num.htbp\endcsname% - \@anim@endsvgclip% - \fi\fi% + \else% ... or by direct insertion + \global\@anim@curframe@zb=\z@% + \whiledo{\@anim@curframe@zb<\@anim@frames}{% + \@anim@makeframe{\the\@anim@num}{\the\@anim@curframe@zb}{% + \@anim@getkeyval{img@\the\@anim@curframe@zb},% + }% + \global\advance\@anim@curframe@zb by \@ne% + }% \fi% + \if@anim@dvisvgm\ifcsname a\the\@anim@num.htbp\endcsname% + \@anim@endsvgclip% + \fi\fi% % if last frame used as poster, write frame num to aux file \ifnum\@anim@poster=\@anim@mone\relax% \@anim@keytoaux{a\the\@anim@num.poster}{\@anim@maxframe}% @@ -1776,9 +1792,6 @@ \newcount\@anim@resizeflags% resizing flags according to options given. -%post-scaling, not possible for embedded files with dvisvgm -\newboolean{@anim@doscaling} - %set animation widget dimensions \def\@anim@scale#1{% #1: box number \begingroup% @@ -1796,11 +1809,11 @@ %now resize \ifcase\@anim@resizeflags% bit 2^2=width, 2^1=height, 2^0=totalhight given \or% 1 - \global\setbox#1=\hbox{\resizebox*{!}{\@anim@animtotalheight}{\box#1}}% + \setbox#1=\hbox{\resizebox*{!}{\@anim@animtotalheight}{\box#1}}% \or% 2 - \global\setbox#1=\hbox{\resizebox{!}{\@anim@animheight}{\box#1}}% + \setbox#1=\hbox{\resizebox{!}{\@anim@animheight}{\box#1}}% \or\or% 4 - \global\setbox#1=\hbox{\resizebox{\@anim@animwidth}{!}{\box#1}}% + \setbox#1=\hbox{\resizebox{\@anim@animwidth}{!}{\box#1}}% \or% 5 \if@anim@iso% \setlength{\@anim@tmpdima}{% @@ -1809,13 +1822,13 @@ \setlength{\@anim@tmpdimb}{\@anim@animtotalheight}% \ifdim\@anim@tmpdimb<\z@\@anim@tmpdimb=-\@anim@tmpdimb\fi% \ifdim\@anim@tmpdima<\@anim@tmpdimb% - \global\setbox#1=\hbox{\resizebox*{\@anim@animwidth}{!}{\box#1}}% + \setbox#1=\hbox{\resizebox*{\@anim@animwidth}{!}{\box#1}}% \else% - \global\setbox#1=\hbox{% + \setbox#1=\hbox{% \resizebox*{!}{\@anim@animtotalheight}{\box#1}}% \fi% \else% - \global\setbox#1=\hbox{% + \setbox#1=\hbox{% \resizebox*{\@anim@animwidth}{\@anim@totheightarg}{\box#1}}% \fi% \or% 6 @@ -1825,18 +1838,18 @@ \setlength{\@anim@tmpdimb}{\@anim@animheight}% \ifdim\@anim@tmpdimb<\z@\@anim@tmpdimb=-\@anim@tmpdimb\fi% \ifdim\@anim@tmpdima<\@anim@tmpdimb% - \global\setbox#1=\hbox{\resizebox{\@anim@animwidth}{!}{\box#1}}% + \setbox#1=\hbox{\resizebox{\@anim@animwidth}{!}{\box#1}}% \else% - \global\setbox#1=\hbox{\resizebox{!}{\@anim@animheight}{\box#1}}% + \setbox#1=\hbox{\resizebox{!}{\@anim@animheight}{\box#1}}% \fi% \else% - \global\setbox#1=\hbox{% + \setbox#1=\hbox{% \resizebox{\@anim@animwidth}{\@anim@animheight}{\box#1}}% \fi% \fi% %apply scale \ifdim\@anim@boxscale pt=\p@\else% - \global\setbox#1=\hbox{\scalebox{\@anim@boxscale}{\box#1}}% + \setbox#1=\hbox{\scalebox{\@anim@boxscale}{\box#1}}% \fi% %dimensions after resizing \xdef\@anim@animwidth{\the\wd#1}% @@ -1886,7 +1899,7 @@ \ifnum\@anim@poster=\@anim@mtwo\relax% \ifdefined\@anim@apdummy\else% empty appearance widget \setbox\@anim@box=\hbox{\phantom{x}}% - \@anim@xform{0}{0}{}{}{\@anim@box}% + \@anim@xform{0}{1}{}{}{\@anim@box}% \global\let\@anim@apdummy\@anim@lastxform% \@anim@widget{1ex}{1ex}{\z@}{% /Subtype/Widget% @@ -1905,7 +1918,7 @@ \else% \ifdefined\@anim@apdummy\else% empty appearance dummy \setbox\@anim@box=\hbox{\phantom{x}}% - \@anim@xform{0}{0}{}{}{\@anim@box}% + \@anim@xform{0}{1}{}{}{\@anim@box}% \global\let\@anim@apdummy\@anim@lastxform% \fi% \def\@anim@apmk{\@anim@apdummy}% @@ -2015,7 +2028,7 @@ \if@anim@mk\else% \ifdefined\@anim@apdummy\else% empty appearance dummy \setbox\@anim@box=\hbox{\phantom{x}}% - \@anim@xform{0}{0}{}{}{\@anim@box}% + \@anim@xform{0}{1}{}{}{\@anim@box}% \global\let\@anim@apdummy\@anim@lastxform% \fi% \fi% @@ -2119,43 +2132,41 @@ \xdef\@anim@nfps{-1}% \@anim@processfpsarg{#2}% \fi% - \if@anim@export\if@anim@timeline% + \if@anim@export% \anim@export% - \fi\fi% + \fi% \fi% \let\newframe\@anim@@newframe% \let\multiframe\@anim@multiframe% - \if@anim@dvisvgm\if@anim@timeline\else\if@anim@draft\else% - \ifcsname a\the\@anim@num.htbp\endcsname% - \@anim@beginsvgclip{\the\@anim@num}% - \fi% - \fi\fi\fi% \@anim@beginframe% \ignorespaces% }{% \unskip% \@anim@endframe{\the\@anim@num}{\the\@anim@curframe@zb}% - \if@anim@dvisvgm\if@anim@timeline\else\if@anim@draft\else% - \ifcsname a\the\@anim@num.htbp\endcsname% - \@anim@endsvgclip% - \fi% - \fi\fi\fi% \global\advance\@anim@curframe@zb by \@ne% \if@anim@draft\else% \xdef\@anim@frames{\the\@anim@curframe@zb}% total number \global\@anim@tmpcnt=\@anim@frames% \global\advance\@anim@tmpcnt by -\@ne% \xdef\@anim@maxframe{\the\@anim@tmpcnt}% highest frame index - %build timeline from optional timeline file - \if@anim@timeline% - \if@anim@dvisvgm\ifcsname a\the\@anim@num.htbp\endcsname% - \@anim@beginsvgclip{\the\@anim@num}% - \fi\fi% + %make animation frames from embedded content ... + \if@anim@dvisvgm\ifcsname a\the\@anim@num.htbp\endcsname% + \@anim@beginsvgclip{\the\@anim@num}% + \fi\fi% + \if@anim@timeline% ... by building timeline (optional timeline file) \@anim@buildtmln{\the\@anim@num}% - \if@anim@dvisvgm\ifcsname a\the\@anim@num.htbp\endcsname% - \@anim@endsvgclip% - \fi\fi% + \else% ... or by direct insertion + \global\@anim@curframe@zb=\z@% + \whiledo{\@anim@curframe@zb<\@anim@frames}{% + \@anim@makeframe{\the\@anim@num}{\the\@anim@curframe@zb}{% + \@anim@getkeyval{img@\the\@anim@curframe@zb},% + }% + \global\advance\@anim@curframe@zb by \@ne% + }% \fi% + \if@anim@dvisvgm\ifcsname a\the\@anim@num.htbp\endcsname% + \@anim@endsvgclip% + \fi\fi% %insert animation widget & controls \if@anim@export\else% % insert <script> part @@ -2207,7 +2218,7 @@ %process frame rate argument \global\let\@anim@pfps\@anim@nfps% \xdef\@anim@nfps{#1\space}% - \xdef\@anim@nfps{\expandafter\zap@space\@anim@nfps\@empty}% + \xdef\@anim@nfps{\expandafter\@anim@zap@space\@anim@nfps\@empty}% \ifx\@anim@nfps\@empty% no change of frame rate \global\let\@anim@nfps\@anim@pfps% \fi% @@ -2273,9 +2284,6 @@ %starts new frame \def\@anim@beginframe{% - \if@anim@export\if@anim@timeline\else\ifnum\@anim@skipfram=\z@\relax% - \anim@export% - \fi\fi\fi% \begingroup% \lrbox{\@anim@box}% store graphics in a box \ifdefined\@anim@curTxtDir\textdir\@anim@curTxtDir\fi% @@ -2291,7 +2299,7 @@ \ifnum#2=\z@\relax% \ifdim\wd\@anim@box=\z@% \PackageError{animate}{% - Contents of first frame must not have zero width% + Content of first frame must not have zero width% }{% Possible reason: \protect\begin{animateinline}{...} immediately followed by \protect\newframe% @@ -2299,7 +2307,7 @@ \fi% \ifdim\ht\@anim@box=\z@\ifdim\dp\@anim@box=\z@% \PackageError{animate}{% - Contents of first frame must not have zero height% + Content of first frame must not have zero height% }{}% \fi\fi% %draw draftbox according to dimensions of the first frame @@ -2309,18 +2317,15 @@ \fi% \else% remaining frames %deal with zero width or totalheight boxes - \ifdim\wd\@anim@box=\z@\global\setbox\@anim@box=\hbox{\phantom{X}}\fi% + \ifdim\wd\@anim@box=\z@\setbox\@anim@box=\hbox{\phantom{X}}\fi% \ifdim\ht\@anim@box=\z@\ifdim\dp\@anim@box=\z@% - \global\setbox\@anim@box=\hbox{\phantom{X}}% + \setbox\@anim@box=\hbox{\phantom{X}}% \fi\fi% \fi% %now create Form XObject of box contents \if@anim@draft\else% \@anim@xinline{#1}{#2}{\@anim@box}{inline}% \fi% - \if@anim@export\if@anim@timeline\else% - \endanim@export% - \fi\fi% \fi% \global\advance\@anim@skipfram by \@ne% \ifnum\@anim@skipfram=\@anim@every\relax% @@ -2347,7 +2352,7 @@ \global\@anim@mulframecnt=\z@% %remove spaces from variable declaration list (2nd arg) \xdef\@anim@vardecls{#2\space}% - \xdef\@anim@vardecls{\expandafter\zap@space\@anim@vardecls\@empty}% + \xdef\@anim@vardecls{\expandafter\@anim@zap@space\@anim@vardecls\@empty}% \ifnum#1<\z@\relax% \PackageError{animate}{% \protect\multiframe: first argument must be greater than zero% @@ -2386,7 +2391,7 @@ \edef\@anim@vartype{\@anim@getvartype#1\@nil}% \ifthenelse{\equal{\@anim@vartype}{d}\OR\equal{\@anim@vartype}{D}}{% % dimensions, prefix d, D - %initialize variable + %initialise variable \setlength{\@anim@tmpdima}{#2}% \expandafter\edef\csname#1\endcsname{\number\@anim@tmpdima sp}% %global copy that saves current variable value between loops @@ -2408,7 +2413,7 @@ \equal{\@anim@vartype}{n}\OR\equal{\@anim@vartype}{N}% \OR\equal{\@anim@vartype}{r}\OR\equal{\@anim@vartype}{R}% }{% real numbers, prefix n, N, r, R - %initialize variable + %initialise variable \expandafter\edef\csname#1\endcsname{\@anim@fpeval{#2}}% %global copy that saves current variable value between loops \expandafter\xdef\csname#1@old\endcsname{\@anim@fpeval{#2}}% @@ -2424,7 +2429,7 @@ }{% \ifthenelse{\equal{\@anim@vartype}{i}\OR\equal{\@anim@vartype}{I}}{% % integers, prefix i, I - %initialize variable + %initialise variable \setcounter{@anim@ltxcnt}{#2}% \expandafter\edef\csname#1\endcsname{\the@anim@ltxcnt}% %global copy that saves current variable value between loops @@ -2530,14 +2535,11 @@ \@anim@endsanitize% \edef\@anim@inputline{\@anim@inputline\space}% %remove all spaces from input line - \edef\@anim@inputline{\expandafter\zap@space\@anim@inputline\@empty}% + \edef\@anim@inputline{\expandafter\@anim@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 & transparency lists for each frame - \@anim@newkey{trlst@\the\@anim@curframe@zb}{}% - \@anim@newkey{frmcontent@\the\@anim@curframe@zb}{}% \global\advance\@anim@curframe@zb by \@ne% }% \@anim@sanitizeJS% @@ -2545,7 +2547,7 @@ \global\read\@anim@@tmlnfile to \@anim@inputline% \@anim@endsanitize% \edef\@anim@inputline{\@anim@inputline\space}% - \edef\@anim@inputline{\expandafter\zap@space\@anim@inputline\@empty}% + \edef\@anim@inputline{\expandafter\@anim@zap@space\@anim@inputline\@empty}% \ifeof\@anim@@tmlnfile\setboolean{@anim@eof}{true}\else% \setboolean{@anim@eof}{false}\fi% }% @@ -2566,12 +2568,15 @@ \@anim@endsanitize% \edef\@anim@inputlinenospc{\@anim@inputline\space}% \edef\@anim@inputlinenospc{% - \expandafter\zap@space\@anim@inputlinenospc\@empty}% + \expandafter\@anim@zap@space\@anim@inputlinenospc\@empty}% \ifeof\@anim@@tmlnfile\setboolean{@anim@eof}{true}\else% \setboolean{@anim@eof}{false}\fi% \message{<building timeline a#1 from file `\@anim@tmlnfile':}% \whiledo{\NOT\boolean{@anim@eof}}{% \global\advance\@anim@lineno by \@ne% + %initialise content and transparency lists for current frame + \def\@anim@frmcontent{}% + \def\@anim@trlst{}% \ifthenelse{\equal{\@anim@inputlinenospc}{}}{}{% %process input line \global\@anim@curfield=\z@% @@ -2579,13 +2584,13 @@ %combine the layers of the current frame \global\@anim@curlayer=\z@% \loop\ifnum\@anim@curlayer>\@anim@maxlayer\relax\else% - \@anim@newkey{frmcontent@\the\@anim@curframe@zb}{% - \@anim@getkeyval{frmcontent@\the\@anim@curframe@zb}% + \edef\@anim@frmcontent{% + \@anim@frmcontent% \@anim@getkeyval{% layercontent@\the\@anim@curframe@zb.\the\@anim@curlayer}% }% - \@anim@newkey{trlst@\the\@anim@curframe@zb}{% - \@anim@getkeyval{trlst@\the\@anim@curframe@zb}% + \edef\@anim@trlst{% + \@anim@trlst% \@anim@getkeyval{% layertrlst@\the\@anim@curframe@zb.\the\@anim@curlayer}% }% @@ -2596,17 +2601,12 @@ \global\advance\@anim@curlayer by \@ne% \repeat% %detect multiple inclusion of the same transp. in the current frame - \xdef\@anim@trlst{% - \the\@anim@curframe@zb.\@anim@getkeyval{trlst@\the\@anim@curframe@zb}}% - \expandafter\@anim@findmult\@anim@trlst,\@nil% - \if@anim@export\if@anim@insideexport\else\anim@export\fi\fi% + \xdef\@anim@@trlst{\the\@anim@curframe@zb.\@anim@trlst}% + \expandafter\@anim@findmult\@anim@@trlst,\@nil% %insert frame Widget - \@anim@makeframe{#1}{\the\@anim@curframe@zb}% - \if@anim@export\endanim@export\fi% + \@anim@makeframe{#1}{\the\@anim@curframe@zb}{\@anim@frmcontent}% %clean-up - \expandafter\@anim@resetmult\@anim@trlst,\@nil% - \@anim@newkey{trlst@\the\@anim@curframe@zb}{}% - \@anim@newkey{frmcontent@\the\@anim@curframe@zb}{}% + \expandafter\@anim@resetmult\@anim@@trlst,\@nil% \message{.}% \global\advance\@anim@curframe@zb by \@ne% }% @@ -2616,7 +2616,7 @@ \@anim@endsanitize% \edef\@anim@inputlinenospc{\@anim@inputline\space}% \edef\@anim@inputlinenospc{% - \expandafter\zap@space\@anim@inputlinenospc\@empty}% + \expandafter\@anim@zap@space\@anim@inputlinenospc\@empty}% \ifeof\@anim@@tmlnfile\setboolean{@anim@eof}{true}\else% \setboolean{@anim@eof}{false}% \fi% @@ -2653,7 +2653,7 @@ %first field: a star (pause frame) \if@anim@step\else% \edef\@anim@tmp{#1\space}% - \edef\@anim@tmp{\expandafter\zap@space\@anim@tmp\@empty}% + \edef\@anim@tmp{\expandafter\@anim@zap@space\@anim@tmp\@empty}% \ifthenelse{\equal{\@anim@tmp}{*}}{% \xdef\@anim@pauseat{% \@anim@pauseat% @@ -2675,10 +2675,10 @@ %parse the third field (list of layer specifications) \global\@anim@curlayer=\z@% \edef\@anim@tmp{#1\space}% - \edef\@anim@tmp{\expandafter\zap@space\@anim@tmp\@empty}% + \edef\@anim@tmp{\expandafter\@anim@zap@space\@anim@tmp\@empty}% \expandafter\@anim@parsethird\@anim@tmp;\@nil% \edef\@anim@tmp{#2\space}% - \edef\@anim@tmp{\expandafter\zap@space\@anim@tmp\@empty}% + \edef\@anim@tmp{\expandafter\@anim@zap@space\@anim@tmp\@empty}% %fourth field: JavaScript provided by the user \ifx\@anim@tmp\empty\else\@anim@parseforth#2\@nil\fi% \fi% @@ -2700,7 +2700,7 @@ %process JavaScript field \def\@anim@parseforth#1:\@nil{% \edef\@anim@tmp{#1\space}% - \edef\@anim@tmp{\expandafter\zap@space\@anim@tmp\@empty}% + \edef\@anim@tmp{\expandafter\@anim@zap@space\@anim@tmp\@empty}% \ifx\@anim@tmp\@empty\else% \xdef\@anim@usrjsat{% \@anim@usrjsat% @@ -2826,6 +2826,12 @@ }% } +\def\@anim@zap@space#1 #2{% + #1% + \ifx#2\@empty\else\expandafter\@anim@zap@space\fi + #2% +} + %command options \define@key{anim@user}{label}{% \gdef\@anim@label{#1}% @@ -3189,7 +3195,6 @@ %macro to reset macros and booleans \def\@anim@reset{% \gdef\@anim@label{}% - \setboolean{@anim@doscaling}{true}% \global\let\@anim@boxscale\@anim@@boxscale% \global\let\if@anim@iso=\if@anim@@iso% \global\let\@anim@bb\@anim@@bb% @@ -3436,7 +3441,7 @@ \define@key{anim@pkg}{buttonsize}{% \gdef\@anim@@btnsize{#1}% } -\edef\@anim@@alttext{/Contents(animation by animate[\@anim@version])} +\edef\@anim@@alttext{/Contents (animation by animate, v. \@anim@version)} \define@key{anim@pkg}{alttext}{% \ifthenelse{\equal{#1}{none}}{% \gdef\@anim@@alttext{}% |