summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2012-05-14 23:51:56 +0000
committerKarl Berry <karl@freefriends.org>2012-05-14 23:51:56 +0000
commit08a89f62a5bda383c4c15dfc0fc006d190573213 (patch)
tree7cd88eb57973c4a3a39edb3a734e56200dff7142 /Master/texmf-dist/tex
parent0c3f9432e0660b6ef2af2ea0c692a0ac33cb66be (diff)
animate (14may12)
git-svn-id: svn://tug.org/texlive/trunk@26382 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r--Master/texmf-dist/tex/latex/animate/animate.sty282
1 files changed, 197 insertions, 85 deletions
diff --git a/Master/texmf-dist/tex/latex/animate/animate.sty b/Master/texmf-dist/tex/latex/animate/animate.sty
index 38f8b10e404..831f472149e 100644
--- a/Master/texmf-dist/tex/latex/animate/animate.sty
+++ b/Master/texmf-dist/tex/latex/animate/animate.sty
@@ -1,4 +1,4 @@
-% Copyright 2007--2011 Alexander Grahn
+% Copyright 2007--today Alexander Grahn
% This material is subject to the LaTeX Project Public License. See
% http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html
@@ -12,7 +12,7 @@
\NeedsTeXFormat{LaTeX2e}
-\def\@anim@version{2011/12/20}
+\def\@anim@version{2012/05/11}
\ProvidesPackage{animate}
[\@anim@version\space PDF animations from files and inline graphics]
@@ -1609,24 +1609,16 @@
\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%
+ \@anim@sanitize\@anim@buildtmln{\the\@anim@num}\@anim@endsanitize%
+ \fi%
%insert animation widget & controls
\@anim@insertwidgets{\the\@anim@num}{%
\@anim@getkeyval{btncol:\@anim@bgcolour:\@anim@fgcolour}}%
\fi%
\endgroup%
\global\advance\@anim@num by \@ne%
- \catcode`\:=\@anim@colon\catcode`\;=\@anim@semicolon%
- \catcode`\*=\@anim@star\catcode`\,=\@anim@comma%
}%
-%adjust catcodes of several characters within \animategraphics
-\let\@anim@animategraphics\animategraphics
-\def\animategraphics{%
- \edef\@anim@colon{\the\catcode`\:}\edef\@anim@semicolon{\the\catcode`\;}%
- \edef\@anim@star{\the\catcode`\*}\edef\@anim@comma{\the\catcode`\,}%
- \catcode`\:=12\catcode`\;=12\catcode`\*=12\catcode`\,=12%
- \@anim@animategraphics%
-}
%inserts animation and control button widgets
\def\@anim@insertwidgets#1#2{%#1:@anim@num, #2 existing btn colour combination
@@ -1968,6 +1960,7 @@
\newboolean{@anim@pauseframes} % true if \newframe* is being used
\newboolean{@anim@chfps} % true if \newframe or \newframe* is being used
% with optional `new frame rate' argument
+\newboolean{@anim@usrjs} % true if user JavaScript provided by user
\newcount\@anim@skipfram % counter for skipped frames
@@ -2013,14 +2006,11 @@
\fi%
\global\@anim@curframe@zb=\z@%
\global\@anim@skipfram=\z@%
- \catcode`\:=\@anim@colon\catcode`\;=\@anim@semicolon%
- \catcode`\*=\@anim@star\catcode`\,=\@anim@comma%
\@anim@beginframe%
\ignorespaces%
}{%
\unskip%
\@anim@endframe{\the\@anim@num}{\the\@anim@curframe@zb}%
- \catcode`\:=12\catcode`\;=12\catcode`\*=12\catcode`\,=12%
\global\advance\@anim@curframe@zb by \@ne%
\if@anim@draft\else%
\xdef\@anim@frames{\the\@anim@curframe@zb}% total number
@@ -2028,24 +2018,17 @@
\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%
+ \@anim@sanitize\@anim@buildtmln{\the\@anim@num}\@anim@endsanitize%
+ \fi%
%insert animation widget & controls
\@anim@insertwidgets{\the\@anim@num}{%
\@anim@getkeyval{btncol:\@anim@bgcolour:\@anim@fgcolour}}%
\fi%
\endgroup%
\global\advance\@anim@num by \@ne%
- \catcode`\:=\@anim@colon\catcode`\;=\@anim@semicolon%
- \catcode`\*=\@anim@star\catcode`\,=\@anim@comma%
\setboolean{@anim@inside}{false}%
}
-\let\@anim@animateinline\animateinline
-\def\animateinline{%
- \edef\@anim@colon{\the\catcode`\:}\edef\@anim@semicolon{\the\catcode`\;}%
- \edef\@anim@star{\the\catcode`\*}\edef\@anim@comma{\the\catcode`\,}%
- \catcode`\:=12\catcode`\;=12\catcode`\*=12\catcode`\,=12%
- \@anim@animateinline%
-}
%usercommand for use within `animateinline' environment;
%terminates the current frame and starts a new one
@@ -2349,6 +2332,52 @@
\endgroup
\catcode`\_=\@anim@catcode
+%macros for sanitizing characters read from timeline file
+\ifpdf
+ \begingroup
+ \catcode`\$=0 $catcode`$\=12
+ $gdef$@anim@bksl{\}
+ $endgroup
+\else
+ \begingroup
+ \catcode`\$=0 $catcode`$\=12
+ $gdef$@anim@bksl{\\}
+ $endgroup
+\fi
+\begingroup
+\catcode`\<=1 \catcode`\>=2
+\catcode`\{=12 \catcode`\}=12
+\catcode`\%=12
+\gdef\@anim@lbr<{> \gdef\@anim@rbr<}>
+\gdef\@anim@per<%>
+\endgroup
+
+\def\@anim@@sanitize#1#2\@nil{%
+ \expandafter\edef\csname @anim@\number`#1\endcsname{\the\catcode`#1}%
+ \catcode`#1=12%
+ \ifx\@empty#2\@empty%
+ \else%
+ \@anim@@sanitize#2\@nil%
+ \fi%
+ \catcode`\#=12%
+ \let\@anim@newline=\\\let\\=\@anim@bksl%
+ \let\@anim@leftbrace=\{\let\{=\@anim@lbr%
+ \let\@anim@rightbrace=\}\let\}=\@anim@rbr%
+ \let\@anim@percent=\%\let\%=\@anim@per%
+}
+\def\@anim@@endsanitize#1#2\@nil{%
+ \let\%=\@anim@percent%
+ \let\}=\@anim@rightbrace%
+ \let\{=\@anim@leftbrace%
+ \let\\=\@anim@newline%
+ \catcode`\#=6%
+ \catcode`#1=\csname @anim@\number`#1\endcsname%
+}
+\def\@anim@sanitize{%
+ \@anim@@sanitize.:;?!/"'*+,->=<$&@][)(^_`|~\@nil}%
+\def\@anim@endsanitize{%
+ \@anim@@endsanitize.:;?!/"'*+,->=<$&@][)(^_`|~\@nil}%
+
%building timeline from timeline file
\newread\@anim@@tmlnfile
\newboolean{@anim@eof}
@@ -2356,6 +2385,7 @@
\newcounter{@anim@ltxcnt} %scratch LaTeX counter for different uses
\newcount\@anim@curlayer %takes the number of the current layer being processed
\newcount\@anim@lineno %current input line No.
+\newcount\@anim@curfield %current field of input line processed
\def\@anim@buildtmln#1{% #1:@anim@num
\endlinechar=-1% suppress trailing space at input line end
@@ -2394,16 +2424,18 @@
\openin\@anim@@tmlnfile=\@anim@tmlnfile%
\global\@anim@lineno=\z@%
\read\@anim@@tmlnfile to \@anim@inputline%
- \edef\@anim@inputline{\@anim@inputline\space}%
- \edef\@anim@inputline{\expandafter\zap@space\@anim@inputline\@empty}%
+ \edef\@anim@inputlinenospc{\@anim@inputline\space}%
+ \edef\@anim@inputlinenospc{%
+ \expandafter\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%
- \ifthenelse{\equal{\@anim@inputline}{}}{}{%
+ \ifthenelse{\equal{\@anim@inputlinenospc}{}}{}{%
%process input line
- \expandafter\@anim@parseline\@anim@inputline\@nil%
+ \global\@anim@curfield=\z@%
+ \expandafter\@anim@parseline\@anim@inputline:\@nil%
%combine the layers of the current frame
\global\@anim@curlayer=\z@%
\loop\ifnum\@anim@curlayer>\@anim@maxlayer\else%
@@ -2445,8 +2477,9 @@
\global\advance\@anim@curframe@zb by \@ne%
}%
\read\@anim@@tmlnfile to \@anim@inputline%
- \edef\@anim@inputline{\@anim@inputline\space}%
- \edef\@anim@inputline{\expandafter\zap@space\@anim@inputline\@empty}%
+ \edef\@anim@inputlinenospc{\@anim@inputline\space}%
+ \edef\@anim@inputlinenospc{%
+ \expandafter\zap@space\@anim@inputlinenospc\@empty}%
\ifeof\@anim@@tmlnfile\setboolean{@anim@eof}{true}\else%
\setboolean{@anim@eof}{false}\fi%
}%
@@ -2477,41 +2510,61 @@
}
%reads one line of timeline file and splits into its colon separated parts
-\def\@anim@parseline#1:#2:#3\@nil{%
- \if@anim@step\else%
- \ifthenelse{\equal{#1}{*}}{%first field is a star (pause frame)
- \xdef\@anim@pauseat{%
- \@anim@pauseat%
- a\the\@anim@num.pauseAt[\the\@anim@curframe@zb]=1;%
- }%
- \setboolean{@anim@pauseframes}{true}%
- }{}%
- \xdef\@anim@pfps{\@anim@nfps}%
- \xdef\@anim@nfps{#2}%
- %treat the second field (new frame rate)
- \ifx\@anim@nfps\@empty% no change of frame rate
- \xdef\@anim@nfps{\@anim@pfps}%
- \else%
- \ifdim\@anim@nfps\p@=\@anim@pfps\p@\else%
- \ifnum\@anim@curframe@zb=\z@%
- \xdef\@anim@fps{#2}%
- \fi%
- %build JavaScript commands to fill the `nFpsAt' & `pFpsAt' arrays
- \xdef\@anim@nfpsat{%
- \@anim@nfpsat%
- a\the\@anim@num.nFpsAt[\the\@anim@curframe@zb]=Math.abs(#2);%
- }%
- \xdef\@anim@pfpsat{%
- \@anim@pfpsat%
- a\the\@anim@num.pFpsAt[\the\@anim@curframe@zb]=Math.abs(\@anim@pfps);%
+\def\@anim@parseline#1:#2\@nil{%
+ \ifcase\@anim@curfield\relax%
+ %first field: a star (pause frame)
+ \if@anim@step\else%
+ \edef\@anim@tmp{#1\space}%
+ \edef\@anim@tmp{\expandafter\zap@space\@anim@tmp\@empty}%
+ \ifthenelse{\equal{\@anim@tmp}{*}}{%
+ \xdef\@anim@pauseat{%
+ \@anim@pauseat%
+ a\the\@anim@num.pauseAt[\the\@anim@curframe@zb]=1;%
}%
- \setboolean{@anim@chfps}{true}% change fps
+ \setboolean{@anim@pauseframes}{true}%
+ }{}%
+ \fi%
+ \global\advance\@anim@curfield by \@ne%
+ \@anim@parseline#2\@nil%
+ \or%
+ \if@anim@step\else%
+ %second field: new frame rate
+ \xdef\@anim@pfps{\@anim@nfps}%
+ \xdef\@anim@nfps{#1\space}%
+ \xdef\@anim@nfps{\expandafter\zap@space\@anim@nfps\@empty}%
+ \ifx\@anim@nfps\@empty% no change of frame rate
+ \xdef\@anim@nfps{\@anim@pfps}%
+ \else%
+ \ifdim\@anim@nfps\p@=\@anim@pfps\p@\else%
+ \ifnum\@anim@curframe@zb=\z@%
+ \xdef\@anim@fps{#1}%
+ \fi%
+ %build JavaScript commands to fill the `nFpsAt' & `pFpsAt' arrays
+ \xdef\@anim@nfpsat{%
+ \@anim@nfpsat%
+ a\the\@anim@num.nFpsAt[\the\@anim@curframe@zb]=Math.abs(#1);%
+ }%
+ \xdef\@anim@pfpsat{%
+ \@anim@pfpsat%
+ a\the\@anim@num.pFpsAt[\the\@anim@curframe@zb]=Math.abs(\@anim@pfps);%
+ }%
+ \setboolean{@anim@chfps}{true}% change fps
+ \fi%
\fi%
\fi%
+ \global\advance\@anim@curfield by \@ne%
+ \@anim@parseline#2\@nil%
+ \or%
+ %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}%
+ \expandafter\@anim@parsethird\@anim@tmp;\@nil%
+ \edef\@anim@tmp{#2\space}%
+ \edef\@anim@tmp{\expandafter\zap@space\@anim@tmp\@empty}%
+ %fourth field: JavaScript provided by the user
+ \ifx\@anim@tmp\empty\else\@anim@parseforth#2\@nil\fi%
\fi%
- %parse the third field (list of layer specifications)
- \global\@anim@curlayer=\z@%
- \@anim@parsethird#3;\@nil%
}
%parses frame contents specification (semicolon separated list of layer
@@ -2527,6 +2580,19 @@
}%
}
+%parses JavaScript field
+\def\@anim@parseforth#1:\@nil{%
+ \edef\@anim@tmp{#1\space}%
+ \edef\@anim@tmp{\expandafter\zap@space\@anim@tmp\@empty}%
+ \ifx\@anim@tmp\@empty\else%
+ \xdef\@anim@usrjsat{%
+ \@anim@usrjsat%
+ a\the\@anim@num.usrJSat[\the\@anim@curframe@zb]=function(){#1};%
+ }%
+ \setboolean{@anim@usrjs}{true}%
+ \fi%
+}
+
%parses contents of one layer specification (comma separated list of transp.
%specs)
\def\@anim@parselayer#1,#2\@nil{%
@@ -2858,6 +2924,15 @@
\define@key{anim@user}{useocg}[true]{%
\setboolean{@anim@useocg}{#1}%
}
+\define@key{anim@user}{firstframejs}{%
+ \@anim@firstjs{#1}%
+}
+\define@key{anim@user}{lastframejs}{%
+ \@anim@lastjs{#1}%
+}
+\define@key{anim@user}{otherframejs}{%
+ \@anim@otherjs{#1}%
+}
%macro to reset macros and booleans
\def\@anim@reset{%
@@ -2887,8 +2962,13 @@
\setboolean{@anim@pauseframes}{false}%
\gdef\@anim@pauseat{}%
\setboolean{@anim@chfps}{false}%
+ \setboolean{@anim@usrjs}{false}%
\gdef\@anim@nfpsat{}%
\gdef\@anim@pfpsat{}%
+ \gdef\@anim@usrjsat{}%
+ \gdef\@anim@firstjs{}%
+ \gdef\@anim@lastjs{}%
+ \gdef\@anim@otherjs{}%
\gdef\@anim@tmlnfile{}%
\setboolean{@anim@timeline}{false}%
\global\@anim@begin={}%
@@ -3181,6 +3261,11 @@
\fi
a#1.dt=1000/(1e-6+Math.abs(\@anim@fps));%
\fi%
+ \if@anim@usrjs
+ %array to take frame numbers (array index) and user provided JavaScript
+ a#1.usrJSat=new Array();%
+ \@anim@usrjsat%
+ \fi%
%actions
a#1.actnEndLeft=function(){%
\if@anim@step\else
@@ -3235,6 +3320,7 @@
a#1.fr[++a#1.idx].display=display.visible;%
curdoc.dirty=false;%
\fi%
+ \if@anim@usrjs try{a#1.usrJSat[a#1.idx]();}catch(e){}\fi%
\if@anim@step\else\if@anim@meas a#1.frcnt++;\fi\fi%
}catch(e){%
--a#1.idx;%
@@ -3243,6 +3329,7 @@
a#1.actnEndRight();%
a#1.playsRight=false;%
\else%
+ if(a#1.isPlaying){--a#1.idx;}%
\if@anim@useocg
a#1.fr[a#1.idx].state=true;%
\else
@@ -3262,6 +3349,8 @@
a#1.fps=Math.abs(\@anim@fps);%
a#1.dt=1000/(1e-6+a#1.fps);%
\fi
+ a#1.actnEndLeft();%
+ \if@anim@usrjs try{a#1.usrJSat[a#1.idx]();}catch(e){}\fi%
a#1.actnPlayRight();%
}else{a#1.actnEndRight();}%
\else
@@ -3301,6 +3390,7 @@
curdoc.dirty=false;%
\fi%
\if@anim@step\else\if@anim@meas a#1.frcnt++;\fi\fi%
+ \if@anim@usrjs try{a#1.usrJSat[a#1.idx]();}catch(e){}\fi%
}catch(e){%
++a#1.idx;%
\if@anim@palindrome%
@@ -3308,6 +3398,7 @@
a#1.actnEndLeft();%
a#1.playsRight=true;%
\else%
+ if(a#1.isPlaying){++a#1.idx;}%
\if@anim@useocg
a#1.fr[a#1.idx].state=true;%
\else
@@ -3327,6 +3418,8 @@
a#1.fps=Math.abs(\@anim@nfps);%
a#1.dt=1000/(1e-6+a#1.fps);%
\fi
+ a#1.actnEndRight();%
+ \if@anim@usrjs try{a#1.usrJSat[a#1.idx]();}catch(e){}\fi%
a#1.actnPlayLeft();%
}else{a#1.actnEndLeft();}%
\else
@@ -3367,7 +3460,6 @@
};%
a#1.actnPlayRight=function(){%
try{app.clearInterval(a#1_int);}catch(e){}%
- if(!a#1.isPaused){a#1.actnEndLeft();}%
a#1.playsRight=true;%
a#1.isPlaying=true;%
a#1.isPaused=false;%
@@ -3385,7 +3477,6 @@
\if@anim@ctrlorplndrm
a#1.actnPlayLeft=function(){%
try{app.clearInterval(a#1_int);}catch(e){}%
- if(!a#1.isPaused){a#1.actnEndRight();}%
a#1.playsRight=false;%
a#1.isPlaying=true;%
a#1.isPaused=false;%
@@ -3477,6 +3568,7 @@
a#1_intd=app.setTimeOut('a#1.actnPlayRight()',1);%
\fi%
\fi%
+ \if@anim@usrjs try{a#1.usrJSat[a#1.idx]();}catch(e){}\fi%
\fi%
\if@anim@autoresume
if(a#1.isPaused){%
@@ -3497,6 +3589,7 @@
a#1_intd=app.setTimeOut('a#1.actnPlayRight()',1);%
\fi%
\fi%
+ \if@anim@usrjs try{a#1.usrJSat[a#1.idx]();}catch(e){}\fi%
}%
\fi%
\fi%
@@ -3550,32 +3643,41 @@
try{%
\if@anim@step%
\if@anim@palindrome
- if(a#1.playsRight){%
+ if(a#1.idx==\@anim@maxframe){%
+ a#1.playsRight=false;%
+ a#1.actnPrev();%
+ }else if(a#1.idx==0){%
+ a#1.playsRight=true;%
+ a#1.actnNext();%
+ }else if(a#1.playsRight){%
a#1.actnNext();%
}else{%
a#1.actnPrev();%
}%
- \else%
- \if@anim@loop
- if(a#1.idx==\@anim@maxframe){%
- a#1.actnEndLeft();%
- }else{%
- \fi
- a#1.actnNext();%
- \if@anim@loop%
- }%
- \fi%
+ \else
+ if(a#1.idx==\@anim@maxframe){%
+ a#1.actnEndLeft();%
+ \if@anim@usrjs try{a#1.usrJSat[a#1.idx]();}catch(e){}\fi%
+ }else{%
+ a#1.actnNext();%
+ }%
\fi%
\else%
- \if@anim@ctrlorplndrm
- if(a#1.playsRight){%
+ \if@anim@palindrome%
+ if(a#1.idx==\@anim@maxframe){%
+ a#1.actnPlayLeft();%
+ }else if(a#1.idx==0){%
+ a#1.actnPlayRight();%
+ }else if(a#1.playsRight){%
a#1.actnPlayRight();%
}else{%
a#1.actnPlayLeft();%
}%
- \else%
+ \else
+ if(a#1.idx==\@anim@maxframe){a#1.actnEndLeft();}%
a#1.actnPlayRight();%
\fi%
+ \if@anim@usrjs try{a#1.usrJSat[a#1.idx]();}catch(e){}\fi
\fi%
}catch(e){}%
)>>%
@@ -3600,22 +3702,32 @@
\else%
\ifx\@anim@action\@anim@StepLeft%
\if@anim@step
- a#1.actnPrev();%
+ if(a#1.idx!=0){a#1.actnPrev();}%
\else
- if(!a#1.isPlaying){a#1.isPaused=true;a#1.actnPrev();}%
+ if(!a#1.isPlaying&&a#1.idx!=0){a#1.isPaused=true;a#1.actnPrev();}%
\fi%
\else%
\ifx\@anim@action\@anim@PlayPauseLeft
- if(a#1.isPlaying){a#1.actnPause();}else{a#1.actnPlayLeft();}%
+ if(a#1.isPlaying){a#1.actnPause();}else{%
+ if(a#1.idx==0){a#1.actnEndRight();}%
+ a#1.actnPlayLeft();%
+ \if@anim@usrjs try{a#1.usrJSat[a#1.idx]();}catch(e){}\fi
+ }%
\else%
\ifx\@anim@action\@anim@PlayPauseRight
- if(a#1.isPlaying){a#1.actnPause();}else{a#1.actnPlayRight();}%
+ if(a#1.isPlaying){a#1.actnPause();}else{%
+ if(a#1.idx==\@anim@maxframe){a#1.actnEndLeft();}%
+ a#1.actnPlayRight();%
+ \if@anim@usrjs try{a#1.usrJSat[a#1.idx]();}catch(e){}\fi
+ }%
\else%
\ifx\@anim@action\@anim@StepRight%
\if@anim@step
- a#1.actnNext();%
+ if(a#1.idx!=\@anim@maxframe){a#1.actnNext();}%
\else
- if(!a#1.isPlaying){a#1.isPaused=true;a#1.actnNext();}%
+ if(!a#1.isPlaying&&a#1.idx!=\@anim@maxframe){%
+ a#1.isPaused=true;a#1.actnNext();%
+ }%
\fi%
\else%
\ifx\@anim@action\@anim@EndRight