summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/animate/animate.sty
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2018-12-20 23:33:07 +0000
committerKarl Berry <karl@freefriends.org>2018-12-20 23:33:07 +0000
commitabaa7495cdb0085d22d3b04bb5a1f19bdd132fd9 (patch)
tree94cf40068d2323860d94679df98f395a14af2557 /Master/texmf-dist/tex/latex/animate/animate.sty
parentc1c2f89e5ac31208bb51e9e29ebbd21084474d96 (diff)
animate (20dec18)
git-svn-id: svn://tug.org/texlive/trunk@49461 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/animate/animate.sty')
-rw-r--r--Master/texmf-dist/tex/latex/animate/animate.sty249
1 files changed, 148 insertions, 101 deletions
diff --git a/Master/texmf-dist/tex/latex/animate/animate.sty b/Master/texmf-dist/tex/latex/animate/animate.sty
index 87ce38afa0c..e72ae9635cd 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}
-\def\@anim@version{2018/11/30}
+\def\@anim@version{2018/12/19}
\ProvidesPackage{animate}
[\@anim@version\space PDF & SVG animations from files and inline graphics]
@@ -86,6 +86,7 @@
%(remaining package options will be processed near end of this file)
\RequirePackage{graphics}%\scalebox, \resizebox, \rotatebox
+\RequirePackage{zref-abspage}
\if@anim@dvisvgm
\setboolean{@anim@export}{false}
@@ -437,9 +438,12 @@
,height=\@anim@animheight,totalheight=\@anim@animtotalheight}%
\fi%
\fi%
- % fingerprint "<file chksum>.<page>.<graphicx opts>" for external graphics
- % for preventing re-embedding
- \edef\@anim@fingerprint{\@anim@pdfmdfivesum{#3}.#4.\@anim@gropts}%
+ % fingerprint "<file chksum>.<page>.<graphicx opts>.<current document page>"
+ % of external graphics to prevent re-embedding
+ \edef\@anim@fingerprint{%
+ \@anim@pdfmdfivesum{#3}.#4.\@anim@gropts%
+ \if@anim@dvisvgm.\@anim@abspage\fi%
+ }%
\edef\@anim@curxform{\@anim@getkeyval{xform:\@anim@fingerprint}}%
\ifthenelse{\equal{\@anim@curxform}{}}{%
% new "<file chksum>.<page>.<graphicx opts>"
@@ -455,8 +459,8 @@
\vrule width \z@
height \@anim@xformnatht{\@anim@curndims}
depth \@anim@xformnatdp{\@anim@curndims}%
- \@anim@refxform{\@anim@curxform}%
- \hss%
+ \@anim@refxform{\@anim@curxform}%
+ \hss%
}%
\global\let\@anim@@lastxform\@anim@curxform%
\@anim@xinline{#1}{#2}{\@anim@box}{knownfile}%
@@ -465,7 +469,7 @@
%creates Form XObject from box contents
\def\@anim@xinline#1#2#3#4{%
- \edef\@anim@status{#4}% "newfile", "knownfile" or "inline" (inline graphics)
+ \def\@anim@status{#4}% "newfile", "knownfile" or "inline" (inline graphics)
\edef\@anim@curwd{\the\wd#3}%
\edef\@anim@curht{\the\ht#3}%
\edef\@anim@curdp{\the\dp#3}%
@@ -487,12 +491,18 @@
\@anim@xform{1}{0}{}{}{#3}% `{1}'-->with additional resources (opacity etc.)
\global\let\@anim@@lastxform\@anim@lastxform%
\def\@anim@status{knownfile}%
- \global\setbox#3=\hbox to \@anim@curwd{%
- \vrule width \z@ height \@anim@curht depth \@anim@curdp%
- \@anim@refxform{\@anim@lastxform}%
- \hss%
- }%
- }{}%
+ \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
\ifnum\@anim@needresize>\z@\relax%
\global\setbox#3=\hbox{%
@@ -503,16 +513,14 @@
}%
\ifthenelse{\equal{\@anim@status}{knownfile}}{%
\@anim@xform{0}{0}{}{}{#3}% without additional Resources
- \global\let\@anim@@lastxform\@anim@lastxform%
}{}%
\fi%
%distill box with inline graphics to xobject
\ifthenelse{\equal{\@anim@status}{inline}}{%
\@anim@xform{1}{0}{}{}{#3}% with additional Resources
- \global\let\@anim@@lastxform\@anim@lastxform%
}{}%
%keep a record of XObject number
- \@anim@newkey{img@#2}{\@anim@@lastxform}%
+ \@anim@newkey{img@#2}{\@anim@lastxform}%
\if@anim@timeline\else%
\@anim@newkey{frmcontent@#2}{\@anim@getkeyval{img@#2},}%
\@anim@makeframe{#1}{#2}%
@@ -840,7 +848,7 @@
11.5 7.5 lineto
stroke
}
- \def\@anim@makebutton#1#2{% #1: name ; #2: current colour combination
+ \def\@anim@makebutton#1#2{% #1: name ; #2:current colour, alpha, ...
\edef\@anim@arg{#1}%
\ifx\@anim@EndLeft\@anim@arg%
\@anim@xbutton{EndLeft}{%
@@ -900,8 +908,8 @@
\@anim@btnstep}{#2}%
\fi%
}
- \def\@anim@xbutton#1#2#3{% #1: name; #2: stroking commands, #3 current colour
- \ifcsname btn#1:#3\endcsname\else% % combination
+ \def\@anim@xbutton#1#2#3{% #1: name; #2: stroking commands,
+ \ifcsname btn#1:#3\endcsname\else% #3: current colour+alpha+ ... combination
% only create if button face doesn't exist yet
\global\setbox\@anim@box=\hbox to 15bp {\vbox to 15bp {\vss%
\@anim@literal{}{#2}%
@@ -1123,7 +1131,7 @@
115 75 l
S
}
- \def\@anim@makebutton#1#2{% #1: name ; #2: current colour combination
+ \def\@anim@makebutton#1#2{% #1: name ; #2: current colour, alpha, ...
\edef\@anim@arg{#1}%
\ifx\@anim@EndLeft\@anim@arg%
\@anim@xbutton{EndLeft}{%
@@ -1592,7 +1600,18 @@
\fi%
\fi%
\@anim@reset% to default settings
+ \if@anim@dvisvgm%
+ \special{dvisvgm:raw{?nl}%
+ <!-- animation by LaTeX-package `animate',
+ https://ctan.org/tex-archive/macros/latex/contrib/animate,
+ v. \@anim@version\space-->%
+ }%
+ \fi%
\begingroup%
+ %store current abs. page num in macro \@anim@abspage
+ \zref@labelbyprops{anim@abspage\the\@anim@num}{abspage}%
+ \zref@def@extractdefault{\@anim@abspage}{%
+ anim@abspage\the\@anim@num}{abspage}{-1}%
\@anim@beginLTR%
\ifcsname Ginput@path\endcsname% make use of graphic[xs] search path
\let\input@path\Ginput@path%
@@ -1717,8 +1736,11 @@
\if@anim@export\else%
% insert <script> part
\if@anim@dvisvgm\@anim@script{\the\@anim@num}\fi%
- \@anim@insertwidgets{\the\@anim@num}{\@anim@bgcolour:\@anim@fgcolour:%
- \@anim@alpha\if@anim@dvisvgm:\@anim@btnsize\fi\@anim@lscape}%
+ \@anim@insertwidgets{\the\@anim@num}{%
+ \@anim@bgcolour:\@anim@fgcolour:\@anim@alpha%
+ \if@anim@dvisvgm:\@anim@btnsize:\@anim@abspage\fi%
+ \@anim@lscape%
+ }%
\fi%
\fi%
\@anim@endLTR%
@@ -1731,7 +1753,7 @@
%inserts animation and control button widgets
\newboolean{@anim@controls@firstgrp}
-\def\@anim@insertwidgets#1#2{%#1:@anim@num, #2 btn colour combination
+\def\@anim@insertwidgets#1#2{%#1:@anim@num, #2 btn colour, alpha, ...
\vtop{%
\offinterlineskip%
\hbox{\@anim@animwidget{#1}}%
@@ -2019,7 +2041,7 @@
}
\else
\def\@anim@buttonwidget#1#2#3{%#1:@anim@num, #2:action,
- %#3:button face and colour combination
+ %#3:button face and colour+alpha+... combination
\edef\@anim@arg{#2}\@anim@jstrue\@anim@mktrue%
\def\@anim@annotflag{/F 0}% visible, but don't print
\ifx\@anim@PlayLeft\@anim@arg\@anim@jsfalse\fi% %hidden, don't print |
@@ -2078,7 +2100,18 @@
\@anim@endsanitize%
\if@anim@export\else\leavevmode\fi%
\@anim@reset% to default settings
+ \if@anim@dvisvgm%
+ \special{dvisvgm:raw{?nl}%
+ <!-- animation by LaTeX-package `animate',
+ https://ctan.org/tex-archive/macros/latex/contrib/animate,
+ v. \@anim@version\space-->%
+ }%
+ \fi%
\begingroup%
+ %store current abs. page num in macro \@anim@abspage
+ \zref@labelbyprops{anim@abspage\the\@anim@num}{abspage}%
+ \zref@def@extractdefault{\@anim@abspage}{%
+ anim@abspage\the\@anim@num}{abspage}{-1}%
\@anim@beginLTR%
\ifdefined\NoHyper\NoHyper\fi% silently suppress any hyperref specials
\ifcsname Ginput@path\endcsname% make use of graphic[xs] search path
@@ -2145,8 +2178,11 @@
\if@anim@export\else%
% insert <script> part
\if@anim@dvisvgm\@anim@script{\the\@anim@num}\fi%
- \@anim@insertwidgets{\the\@anim@num}{\@anim@bgcolour:\@anim@fgcolour:%
- \@anim@alpha\if@anim@dvisvgm:\@anim@btnsize\fi\@anim@lscape}%
+ \@anim@insertwidgets{\the\@anim@num}{%
+ \@anim@bgcolour:\@anim@fgcolour:\@anim@alpha%
+ \if@anim@dvisvgm:\@anim@btnsize:\@anim@abspage\fi%
+ \@anim@lscape%
+ }%
\fi%
% if last frame used as poster, write frame num to aux file
\ifnum\@anim@poster=\@anim@mone\relax%
@@ -3532,9 +3568,6 @@
\fi
var a#1_fps,a#1_spd;$% frames per second (FPS), speed scaling factor
var a#1_setFps;$% function pointer for setting FPS
- \if@anim@controls@speed
- var a#1_spdIncr,a#1_spdDecr,a#1_spdReset;$% function pointers
- \fi%
\if@anim@meas % speed measurement
var spc=String.fromCharCode(32);$%
var a#1_frcnt,% frame counter
@@ -3547,8 +3580,17 @@
% array of function pointers to timeline JS actions, indexed by frame number
var a#1_usrJS,a#1_curjs;$%
\fi
- var a#1_seekFrame,a#1_stopFirst,a#1_stopLast,a#1_gotoNext,a#1_gotoPrev,%
- a#1_stepBwd,a#1_stepFwd;$%
+ var a#1_seekFrame,a#1_gotoNext,a#1_gotoPrev;$%
+ var a#1_stopFirst,a#1_stopLast;$%
+ \if@anim@controls@play
+ var a#1_playPauseBwd,a#1_playPauseFwd;$%
+ \fi%
+ \if@anim@controls@step
+ var a#1_stepBwd,a#1_stepFwd;$%
+ \fi%
+ \if@anim@controls@speed
+ var a#1_spdIncr,a#1_spdDecr,a#1_spdReset;$%
+ \fi%
\ifx\empty\@anim@label\empty\else
var anim;$%
\fi%
@@ -3870,6 +3912,14 @@
\fi%
\fi%
};$%
+ \if@anim@controls@play
+ a#1_playPauseBwd=function(){%
+ if(a#1_playing){a#1_pause();}else{a#1_playBwd();}%
+ };$%
+ a#1_playPauseFwd=function(){%
+ if(a#1_playing){a#1_pause();}else{a#1_playFwd();}%
+ };$%
+ \fi%
\if@anim@controls@speed
a#1_spdIncr=function(){% speed up animation
a#1_spd*=1.1;%
@@ -4009,6 +4059,7 @@
\@anim@streamobj{}{%
% \@anim@consoleshow%
% console.clear();%
+ app.focusRect=false;%
\@anim@@jsvardecls{#1}%
\@anim@@jsinit{#1}%
\@anim@@pojscript{#1}%
@@ -4051,9 +4102,6 @@
%other trigger events in the anim widget's AA dictionary
\gdef\@anim@wdgtDownJS#1{%
- \if@anim@dvisvgm\else
- app.focusRect=false;$% disable focus rectangle
- \fi%
\if@anim@step\else % pause on MouseDown
try{if(a#1_playing){a#1_pause();}}catch(e){}$%
\fi%
@@ -4124,9 +4172,6 @@
%actions for control buttons
\gdef\@anim@btnJS#1#2{%
- \if@anim@dvisvgm\else
- app.focusRect=false;%
- \fi%
\ifx#2\@anim@EndLeft
a#1_stopFirst();%
\else%
@@ -4134,10 +4179,10 @@
a#1_stepBwd();%
\else%
\ifx#2\@anim@PlayPauseLeft
- if(a#1_playing){a#1_pause();}else{a#1_playBwd();}%
+ a#1_playPauseBwd();%
\else%
\ifx#2\@anim@PlayPauseRight
- if(a#1_playing){a#1_pause();}else{a#1_playFwd();}%
+ a#1_playPauseFwd();%
\else%
\ifx#2\@anim@StepRight
a#1_stepFwd();%
@@ -4162,73 +4207,75 @@
$<defs>$%
<script type="text/javascript">$%
<![CDATA[$%
- \@anim@@jsvardecls{#1}%
- function onload(){$%
- \@anim@@jsinit{#1}%
- \if@anim@nomouse\else
- document.getElementById('anm#1').addEventListener('mouseup',%
- onMouseUpWdgt);$%
- document.getElementById('anm#1').addEventListener('mousedown',%
- onMouseDownWdgt);$%
- document.getElementById('anm#1').addEventListener('touchend',%
- onTouchEndWdgt);$%
- document.getElementById('anm#1').addEventListener('touchstart',%
- onTouchStartWdgt);$%
- document.getElementById('anm#1').addEventListener('touchmove',%
- onTouchMove);$%
- \fi%
- onvisible();$% in case of `autoplay' option
- }$%
- function onvisible(){$%
- \@anim@@pojscript{#1}%
- }$%
- function onhidden(){$%
- \@anim@@pcjscript{#1}%
- }$%
- function onVisibilityChange(){$%
- if(document.hidden){%
- try{onhidden();}catch(e){}%
- }else{%
- try{onvisible();}catch(e){}%
+ \@anim@@jsvardecls{#1}% variables that are supposed to be global
+ (function(){$% IIFE (self-executing anon. function) to limit scope
+ function onload(){$%
+ \@anim@@jsinit{#1}%
+ \if@anim@nomouse\else
+ document.getElementById('anm#1').addEventListener('mouseup',%
+ onMouseUpWdgt);$%
+ document.getElementById('anm#1').addEventListener('mousedown',%
+ onMouseDownWdgt);$%
+ document.getElementById('anm#1').addEventListener('touchend',%
+ onTouchEndWdgt);$%
+ document.getElementById('anm#1').addEventListener('touchstart',%
+ onTouchStartWdgt);$%
+ document.getElementById('anm#1').addEventListener('touchmove',%
+ onTouchMove);$%
+ \fi%
+ onvisible();$% in case of `autoplay' option
}$%
- }$%
- document.addEventListener('visibilitychange',onVisibilityChange);$%
- window.addEventListener('load',onload);$%
- \if@anim@nomouse\else
- var permPause#1=false;
- function onWidgetUpAction(event){$%
- \@anim@wdgtUpJS{#1}%
+ function onvisible(){$%
+ \@anim@@pojscript{#1}%
}$%
- function onTouchStartWdgt(event){$%
- event.preventDefault();$%
- event.stopPropagation();$%
- permPause#1=false;
- \@anim@wdgtDownJS{#1}%
+ function onhidden(){$%
+ \@anim@@pcjscript{#1}%
}$%
- function onTouchEndWdgt(event){$%
- event.preventDefault();$%
- event.stopPropagation();$%
- if(event.targetTouches.length>0){permPause#1=true;}$%
- else{$%
- if(permPause#1){permPause#1=false;}$%
- else{onWidgetUpAction(event);}$%
+ function onVisibilityChange(){$%
+ if(document.hidden){%
+ try{onhidden();}catch(e){}%
+ }else{%
+ try{onvisible();}catch(e){}%
}$%
}$%
- function onTouchMove(event){$%
- event.preventDefault();$%
- event.stopPropagation();$%
- }$%
- function onMouseDownWdgt(event){$%
- event.preventDefault();$%
- event.stopPropagation();$%
- \@anim@wdgtDownJS{#1}%
- }$%
- function onMouseUpWdgt(event){$%
- event.preventDefault();$%
- event.stopPropagation();$%
- onWidgetUpAction(event);$%
- }$%
- \fi%
+ document.addEventListener('visibilitychange',onVisibilityChange);$%
+ window.addEventListener('load',onload);$%
+ \if@anim@nomouse\else
+ var permPause#1=false;
+ function onWidgetUpAction(event){$%
+ \@anim@wdgtUpJS{#1}%
+ }$%
+ function onTouchStartWdgt(event){$%
+ event.preventDefault();$%
+ event.stopPropagation();$%
+ permPause#1=false;
+ \@anim@wdgtDownJS{#1}%
+ }$%
+ function onTouchEndWdgt(event){$%
+ event.preventDefault();$%
+ event.stopPropagation();$%
+ if(event.targetTouches.length>0){permPause#1=true;}$%
+ else{$%
+ if(permPause#1){permPause#1=false;}$%
+ else{onWidgetUpAction(event);}$%
+ }$%
+ }$%
+ function onTouchMove(event){$%
+ event.preventDefault();$%
+ event.stopPropagation();$%
+ }$%
+ function onMouseDownWdgt(event){$%
+ event.preventDefault();$%
+ event.stopPropagation();$%
+ \@anim@wdgtDownJS{#1}%
+ }$%
+ function onMouseUpWdgt(event){$%
+ event.preventDefault();$%
+ event.stopPropagation();$%
+ onWidgetUpAction(event);$%
+ }$%
+ \fi%
+ })();$% end of IIFE
]]>$%
</script>$%
</defs>%