texlive[61736] Master/texmf-dist: animate (25jan22)

commits+karl at tug.org commits+karl at tug.org
Tue Jan 25 22:21:24 CET 2022


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

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/animate/ChangeLog
    trunk/Master/texmf-dist/doc/latex/animate/animate.pdf
    trunk/Master/texmf-dist/source/latex/animate/files/exp.mp
    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-25 17:29:20 UTC (rev 61735)
+++ trunk/Master/texmf-dist/doc/latex/animate/ChangeLog	2022-01-25 21:21:23 UTC (rev 61736)
@@ -1,3 +1,6 @@
+2022-01-25
+	* improvement: svg clipping optimized for smaller output size
+
 2022-01-21
 	* fix: clipping for dvisvgm
 

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

Modified: trunk/Master/texmf-dist/source/latex/animate/files/exp.mp
===================================================================
--- trunk/Master/texmf-dist/source/latex/animate/files/exp.mp	2022-01-25 17:29:20 UTC (rev 61735)
+++ trunk/Master/texmf-dist/source/latex/animate/files/exp.mp	2022-01-25 21:21:23 UTC (rev 61736)
@@ -1,5 +1,5 @@
 % Jan Holecek, Alexander Grahn
-% 2021/04/08
+% 2022/01/25
 
 prologues:=3;
 outputtemplate := "%j_%c.mps";
@@ -103,7 +103,6 @@
   axis;
   bounds:=bbox currentpicture;
   setbounds currentpicture to bounds;
-  clip currentpicture to bounds;
 endfig;
 
 for i:=1 upto N:
@@ -112,7 +111,6 @@
     draw ptaylor[i] withcolor blue;
     label.lrt ( nlabel[i], npnt);
     setbounds currentpicture to bounds;
-    clip currentpicture to bounds;
   endfig;
 endfor;
 

Modified: trunk/Master/texmf-dist/tex/latex/animate/animate.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/animate/animate.sty	2022-01-25 17:29:20 UTC (rev 61735)
+++ trunk/Master/texmf-dist/tex/latex/animate/animate.sty	2022-01-25 21:21:23 UTC (rev 61736)
@@ -13,7 +13,7 @@
 
 \NeedsTeXFormat{LaTeX2e}[2020-10-01]
 
-\def\@anim at version{2022/01/21}
+\def\@anim at version{2022/01/25}
 \ProvidesPackage{animate}
 [\@anim at version\space PDF & SVG animations from files and inline graphics]
 
@@ -312,15 +312,15 @@
 
 %helper macro that typesets graphics file into savebox
 \if at anim@dvips
-  \def\@anim at filebox#1#2{% dvips: no multi-page support
-    \edef\@anim at curfile{[\@anim at gropts]{#1}}%
+  \def\@anim at filebox#1#2#3{% dvips: no multi-page support
+    \edef\@anim at curfile{[#3]{#1}}%
     \global\setbox\@anim at box=\hbox{%
       \expandafter\includegraphics\@anim at curfile}%
   }
 \else
   %pdfTeX, LuaTeX, dvipdfmx, xetex, dvisvgm
-  \def\@anim at filebox#1#2{%
-    \edef\@anim at curfile{[\@anim at gropts,page=#2]{#1}}%
+  \def\@anim at filebox#1#2#3{%
+    \edef\@anim at curfile{[#3,page=#2]{#1}}%
     \global\setbox\@anim at box=\hbox{%
       \expandafter\includegraphics\@anim at curfile}%
   }
@@ -346,37 +346,18 @@
 }
 
 %create Form XObject from graphics file
-\def\@anim at ximage#1#2#3#4{%#1:@anim at num, #2:@anim at curframe@zb, #3:filename,
-  %                                      #4: page number of multipage file
-  \if at anim@dvisvgm%
-    % with dvisvgm, final animation dims must be passed to includegraphics;
-    % otherwise, final bbox of the document may be wrong, in particular in the
-    % case of standalone animations with downscaled graphics
-    \ifnum#2=\z@\relax%
-      \@anim at filebox{#3}{#4}% store file in a box
-      \@anim at scale\@anim at box% get final dimensions of animation widget
-      %prevent later re-scaling
-      \gdef\@anim at widtharg{\width}%
-      \gdef\@anim at heightarg{\height}%
-      \gdef\@anim at totheightarg{\totalheight}%
-      \gdef\@anim at boxscale{\@ne}%
-      %append final dims to inclusion opts, also used for the remaining files
-      %of the current animation
-      \xdef\@anim at gropts{\@anim at gropts%
-        \ifx\@anim at gropts\@empty\else,\fi width=\@anim at animwidth%
-        ,height=\@anim at animheight,totalheight=\@anim at animtotalheight}%
-    \fi%
-  \fi%
+\def\@anim at ximage#1#2#3#4#5{%#1:@anim at num, #2:@anim at curframe@zb, #3:filename,
+  %         #4: page number of multipage file, #5 graphicx inclusion options
   % fingerprint "<file chksum>.<page>.<graphicx opts>.<current document page>"
   % of external graphics to prevent re-embedding
   \edef\@anim at fingerprint{%
-    \@anim at pdfmdfivesum{#3}.#4.\@anim at gropts%
+    \@anim at pdfmdfivesum{#3}.#4.#5%
     \if at anim@dvisvgm.\@anim at abspage\fi%
   }%
   \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}% store file in a box
+    \@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}%
     }%
@@ -408,6 +389,9 @@
       \vrule width \z@ height \ht#3 depth \dp#3\hss}%
     %determine final dims of animation widget
     \@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}%
   \fi%
   %test if natural dimensions of the current frame differ from
   %final widget size
@@ -476,32 +460,11 @@
 \def\@anim at makeframe#1#2{%
   %container box
   \edef\@anim at tmpvar{\@anim at getkeyval{frmcontent@#2},}%
-  \if at anim@dvisvgm%
-    \global\setbox\@anim at box=\hbox to \@anim at animwidth{%
-      \raise\@anim at animheight\hbox{%
-        \special{dvisvgm:raw
-          <g transform="translate({?x},{?y})"><svg overflow="hidden"
-            width="\strip at pt\dimexpr0.996264\dimexpr\@anim at animwidth"
-            height="\strip at pt\dimexpr0.996264\dimexpr\@anim at animtotalheight"
-            viewBox="%
-              {?x}
-              {?(y-\strip at pt\dimexpr0.996264\dimexpr\@anim at animheight)}
-              {?(\strip at pt\dimexpr0.996264\dimexpr\@anim at animwidth)}
-              {?(\strip at pt\dimexpr0.996264\dimexpr\@anim at animtotalheight)}%
-            ">%
-        }%
-        \vrule width \z@ height \@anim at animheight depth \@anim at animdepth%
-        \expandafter\@anim at insertfrmcontent\@anim at tmpvar\@nil%
-        \special{dvisvgm:raw </svg></g>}%
-      }\hss%
-    }%
-  \else%
-    \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%
-    }%
-  \fi%
+  \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%
@@ -1487,6 +1450,11 @@
       \@anim at getpagecount{\filename at area\filename at base}{\filename at ext}{%
         \@anim at lastpage%
       }%
+      \ifdefined\@anim at lastpage\else% double check multipage support
+        \setboolean{@anim at multipage}{false}%
+      \fi%
+    \fi%
+    \if at anim@multipage%
       %we need it zero-based
       \edef\@anim at lastpage{\the\numexpr\@anim at lastpage-\@ne\relax}%
       \ifx\@anim at first\@empty%
@@ -1644,11 +1612,11 @@
   \if at anim@draft%
     \if at anim@multipage%
       %store file in a box
-      \@anim at filebox{\@anim at pathtofile}{\@anim at first}%
+      \@anim at filebox{\@anim at pathtofile}{\@anim at first}{\@anim at gropts}%
     \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 filebox{\@anim at pathtofile}{1}{\@anim at gropts}%
     \fi%
     \@anim at scale{\@anim at box}%
     %draw draftbox according to dimensions of the first frame
@@ -1666,7 +1634,12 @@
     \if at anim@export\if at anim@timeline%
       \anim at export%
     \fi\fi%
-    %read all frames of the sequence
+    %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%
     \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%
@@ -1674,7 +1647,7 @@
       \if at anim@multipage%
         %embed graphics
         \@anim at ximage{\the\@anim at num}{\the\@anim at curframe@zb}{%
-          \@anim at pathtofile}{\the\@anim at curframe}%
+          \@anim at pathtofile}{\the\@anim at curframe}{\@anim at gropts}%
       \else%
         %get path to current file end its extension
         \@anim at getpath{%
@@ -1682,7 +1655,7 @@
         }{\@anim at ftype}%
         %embed graphics
         \@anim at ximage{\the\@anim at num}{\the\@anim at curframe@zb}{%
-          \@anim at pathtofile}{1}%
+          \@anim at pathtofile}{1}{\@anim at gropts}%
       \fi%
       \if at anim@export\if at anim@timeline\else%
         \endanim at export%
@@ -1690,12 +1663,25 @@
       \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\@anim at buildtmln{\the\@anim at num}\fi%
+    \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%
+      \@anim at buildtmln{\the\@anim at num}%
+      \if at anim@dvisvgm\ifcsname a\the\@anim at num.htbp\endcsname%
+        \@anim at endsvgclip%
+      \fi\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}%
@@ -2139,11 +2125,21 @@
   \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
@@ -2151,7 +2147,15 @@
     \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\@anim at buildtmln{\the\@anim at num}\fi%
+    \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%
+      \@anim at buildtmln{\the\@anim at num}%
+      \if at anim@dvisvgm\ifcsname a\the\@anim at num.htbp\endcsname%
+        \@anim at endsvgclip%
+      \fi\fi%
+    \fi%
     %insert animation widget & controls
     \if at anim@export\else%
       % insert <script> part
@@ -2176,6 +2180,22 @@
 \let\@anim at animateinline\animateinline
 \def\animateinline{\@anim at sanitizeColon\@anim at animateinline}
 
+% clip animation to final dimensions (dvisvgm)
+\def\@anim at beginsvgclip#1{%
+  \special{dvisvgm:raw
+    <g transform="translate({?x},{?(y-\@anim at getkeyval{a#1.htbp})})">%
+      <svg overflow="hidden"
+        width="\@anim at getkeyval{a#1.wdbp}" height="\@anim at getkeyval{a#1.thtbp}"
+        viewBox="%
+          {?x} {?(y-\@anim at getkeyval{a#1.htbp})}
+          \@anim at getkeyval{a#1.wdbp} \@anim at getkeyval{a#1.thtbp}%
+        ">%
+  }%
+}%
+\def\@anim at endsvgclip{%
+  \special{dvisvgm:raw </svg></g>}%
+}
+
 %usercommand for use within `animateinline' environment;
 %terminates the current frame and starts a new one
 \def\@anim@@newframe{% aliased to \newframe inside `animateinline'



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