From 1c6f91e2f1461fb51774bb5f93fde101f9cf376b Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Tue, 25 Jan 2022 21:21:23 +0000 Subject: animate (25jan22) git-svn-id: svn://tug.org/texlive/trunk@61736 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/animate/ChangeLog | 3 + Master/texmf-dist/doc/latex/animate/animate.pdf | Bin 3871621 -> 3865127 bytes .../texmf-dist/source/latex/animate/files/exp.mp | 4 +- Master/texmf-dist/tex/latex/animate/animate.sty | 142 ++++++++++++--------- 4 files changed, 85 insertions(+), 64 deletions(-) diff --git a/Master/texmf-dist/doc/latex/animate/ChangeLog b/Master/texmf-dist/doc/latex/animate/ChangeLog index 1c2cbfcd747..0d6aa65da50 100644 --- a/Master/texmf-dist/doc/latex/animate/ChangeLog +++ b/Master/texmf-dist/doc/latex/animate/ChangeLog @@ -1,3 +1,6 @@ +2022-01-25 + * improvement: svg clipping optimized for smaller output size + 2022-01-21 * fix: clipping for dvisvgm diff --git a/Master/texmf-dist/doc/latex/animate/animate.pdf b/Master/texmf-dist/doc/latex/animate/animate.pdf index 5c84024b339..eb1b44c371c 100644 Binary files a/Master/texmf-dist/doc/latex/animate/animate.pdf and b/Master/texmf-dist/doc/latex/animate/animate.pdf differ diff --git a/Master/texmf-dist/source/latex/animate/files/exp.mp b/Master/texmf-dist/source/latex/animate/files/exp.mp index 3bd6a031484..45ca8b634a3 100644 --- a/Master/texmf-dist/source/latex/animate/files/exp.mp +++ b/Master/texmf-dist/source/latex/animate/files/exp.mp @@ -1,5 +1,5 @@ % Jan Holecek, Alexander Grahn -% 2021/04/08 +% 2022/01/25 prologues:=3; outputtemplate := "%j_%c.mps"; @@ -103,7 +103,6 @@ beginfig(0); axis; bounds:=bbox currentpicture; setbounds currentpicture to bounds; - clip currentpicture to bounds; endfig; for i:=1 upto N: @@ -112,7 +111,6 @@ for i:=1 upto N: draw ptaylor[i] withcolor blue; label.lrt ( nlabel[i], npnt); setbounds currentpicture to bounds; - clip currentpicture to bounds; endfig; endfor; diff --git a/Master/texmf-dist/tex/latex/animate/animate.sty b/Master/texmf-dist/tex/latex/animate/animate.sty index ff05e49d9c1..fe5636586d5 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/21} +\def\@anim@version{2022/01/25} \ProvidesPackage{animate} [\@anim@version\space PDF & SVG animations from files and inline graphics] @@ -312,15 +312,15 @@ %helper macro that typesets graphics file into savebox \if@anim@dvips - \def\@anim@filebox#1#2{% dvips: no multi-page support - \edef\@anim@curfile{[\@anim@gropts]{#1}}% + \def\@anim@filebox#1#2#3{% dvips: no multi-page support + \edef\@anim@curfile{[#3]{#1}}% \global\setbox\@anim@box=\hbox{% \expandafter\includegraphics\@anim@curfile}% } \else %pdfTeX, LuaTeX, dvipdfmx, xetex, dvisvgm - \def\@anim@filebox#1#2{% - \edef\@anim@curfile{[\@anim@gropts,page=#2]{#1}}% + \def\@anim@filebox#1#2#3{% + \edef\@anim@curfile{[#3,page=#2]{#1}}% \global\setbox\@anim@box=\hbox{% \expandafter\includegraphics\@anim@curfile}% } @@ -346,37 +346,18 @@ } %create Form XObject from graphics file -\def\@anim@ximage#1#2#3#4{%#1:@anim@num, #2:@anim@curframe@zb, #3:filename, - % #4: page number of multipage file - \if@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@filebox{#3}{#4}% store file in a box - \@anim@scale\@anim@box% get final dimensions of animation widget - %prevent later re-scaling - \gdef\@anim@widtharg{\width}% - \gdef\@anim@heightarg{\height}% - \gdef\@anim@totheightarg{\totalheight}% - \gdef\@anim@boxscale{\@ne}% - %append final dims to inclusion opts, also used for the remaining files - %of the current animation - \xdef\@anim@gropts{\@anim@gropts% - \ifx\@anim@gropts\@empty\else,\fi width=\@anim@animwidth% - ,height=\@anim@animheight,totalheight=\@anim@animtotalheight}% - \fi% - \fi% +\def\@anim@ximage#1#2#3#4#5{%#1:@anim@num, #2:@anim@curframe@zb, #3:filename, + % #4: page number of multipage file, #5 graphicx inclusion options % fingerprint "..." % of external graphics to prevent re-embedding \edef\@anim@fingerprint{% - \@anim@pdfmdfivesum{#3}.#4.\@anim@gropts% + \@anim@pdfmdfivesum{#3}.#4.#5% \if@anim@dvisvgm.\@anim@abspage\fi% }% \edef\@anim@curxform{\@anim@getkeyval{xform:\@anim@fingerprint}}% \ifthenelse{\equal{\@anim@curxform}{}}{% % new ".." - \@anim@filebox{#3}{#4}% store file in a box + \@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}% }% @@ -408,6 +389,9 @@ \vrule width \z@ height \ht#3 depth \dp#3\hss}% %determine final dims of animation widget \@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}% \fi% %test if natural dimensions of the current frame differ from %final widget size @@ -476,32 +460,11 @@ \def\@anim@makeframe#1#2{% %container box \edef\@anim@tmpvar{\@anim@getkeyval{frmcontent@#2},}% - \if@anim@dvisvgm% - \global\setbox\@anim@box=\hbox to \@anim@animwidth{% - \raise\@anim@animheight\hbox{% - \special{dvisvgm:raw - % - }% - \vrule width \z@ height \@anim@animheight depth \@anim@animdepth% - \expandafter\@anim@insertfrmcontent\@anim@tmpvar\@nil% - \special{dvisvgm:raw }% - }\hss% - }% - \else% - \global\setbox\@anim@box=\hbox to \@anim@animwidth{% - \vrule width \z@ height \@anim@animheight depth \@anim@animdepth% - \expandafter\@anim@insertfrmcontent\@anim@tmpvar\@nil% - \hss% - }% - \fi% + \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% @@ -1487,6 +1450,11 @@ \@anim@getpagecount{\filename@area\filename@base}{\filename@ext}{% \@anim@lastpage% }% + \ifdefined\@anim@lastpage\else% double check multipage support + \setboolean{@anim@multipage}{false}% + \fi% + \fi% + \if@anim@multipage% %we need it zero-based \edef\@anim@lastpage{\the\numexpr\@anim@lastpage-\@ne\relax}% \ifx\@anim@first\@empty% @@ -1644,11 +1612,11 @@ \if@anim@draft% \if@anim@multipage% %store file in a box - \@anim@filebox{\@anim@pathtofile}{\@anim@first}% + \@anim@filebox{\@anim@pathtofile}{\@anim@first}{\@anim@gropts}% \else% %get file name extension \@anim@getpath{\@anim@base\@anim@first}{\@anim@ftype}% - \@anim@filebox{\@anim@pathtofile}{1}% + \@anim@filebox{\@anim@pathtofile}{1}{\@anim@gropts}% \fi% \@anim@scale{\@anim@box}% %draw draftbox according to dimensions of the first frame @@ -1666,7 +1634,12 @@ \if@anim@export\if@anim@timeline% \anim@export% \fi\fi% - %read all frames of the sequence + %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% \loop\ifnum\@anim@curframe\@anim@relop\@anim@last\relax\else% \if@anim@export\if@anim@timeline\else% \anim@export% @@ -1674,7 +1647,7 @@ \if@anim@multipage% %embed graphics \@anim@ximage{\the\@anim@num}{\the\@anim@curframe@zb}{% - \@anim@pathtofile}{\the\@anim@curframe}% + \@anim@pathtofile}{\the\@anim@curframe}{\@anim@gropts}% \else% %get path to current file end its extension \@anim@getpath{% @@ -1682,7 +1655,7 @@ }{\@anim@ftype}% %embed graphics \@anim@ximage{\the\@anim@num}{\the\@anim@curframe@zb}{% - \@anim@pathtofile}{1}% + \@anim@pathtofile}{1}{\@anim@gropts}% \fi% \if@anim@export\if@anim@timeline\else% \endanim@export% @@ -1690,12 +1663,25 @@ \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\@anim@buildtmln{\the\@anim@num}\fi% + \if@anim@timeline% + \if@anim@dvisvgm\ifcsname a\the\@anim@num.htbp\endcsname% + \@anim@beginsvgclip{\the\@anim@num}% + \fi\fi% + \@anim@buildtmln{\the\@anim@num}% + \if@anim@dvisvgm\ifcsname a\the\@anim@num.htbp\endcsname% + \@anim@endsvgclip% + \fi\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}% @@ -2139,11 +2125,21 @@ \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 @@ -2151,7 +2147,15 @@ \global\advance\@anim@tmpcnt by -\@ne% \xdef\@anim@maxframe{\the\@anim@tmpcnt}% highest frame index %build timeline from optional timeline file - \if@anim@timeline\@anim@buildtmln{\the\@anim@num}\fi% + \if@anim@timeline% + \if@anim@dvisvgm\ifcsname a\the\@anim@num.htbp\endcsname% + \@anim@beginsvgclip{\the\@anim@num}% + \fi\fi% + \@anim@buildtmln{\the\@anim@num}% + \if@anim@dvisvgm\ifcsname a\the\@anim@num.htbp\endcsname% + \@anim@endsvgclip% + \fi\fi% + \fi% %insert animation widget & controls \if@anim@export\else% % insert