texlive[61821] Master/texmf-dist: animate (31jan22)

commits+karl at tug.org commits+karl at tug.org
Mon Jan 31 22:13:21 CET 2022


Revision: 61821
          http://tug.org/svn/texlive?view=revision&revision=61821
Author:   karl
Date:     2022-01-31 22:13:21 +0100 (Mon, 31 Jan 2022)
Log Message:
-----------
animate (31jan22)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/animate/ChangeLog
    trunk/Master/texmf-dist/doc/latex/animate/animate.pdf
    trunk/Master/texmf-dist/tex/latex/animate/animate.sty

Modified: trunk/Master/texmf-dist/doc/latex/animate/ChangeLog
===================================================================
--- trunk/Master/texmf-dist/doc/latex/animate/ChangeLog	2022-01-31 21:13:01 UTC (rev 61820)
+++ trunk/Master/texmf-dist/doc/latex/animate/ChangeLog	2022-01-31 21:13:21 UTC (rev 61821)
@@ -1,3 +1,6 @@
+2022-01-31
+	* improvement: optimizing XObject nesting for smaller output files
+
 2022-01-25
 	* improvement: svg clipping optimized for smaller output size
 

Modified: trunk/Master/texmf-dist/doc/latex/animate/animate.pdf
===================================================================
(Binary files differ)

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



More information about the tex-live-commits mailing list.