diff options
author | Karl Berry <karl@freefriends.org> | 2014-02-07 23:23:32 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2014-02-07 23:23:32 +0000 |
commit | e768bd4467a0c031caef65ceb6ca960a4ee11208 (patch) | |
tree | 76e382ccbfa040dd12cba3f8143ab79853a63729 /Master/texmf-dist/tex | |
parent | 187f01497820820a6075023f1825aacdac0e86cc (diff) |
animate (7feb14)
git-svn-id: svn://tug.org/texlive/trunk@32909 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r-- | Master/texmf-dist/tex/latex/animate/animate.sty | 797 |
1 files changed, 371 insertions, 426 deletions
diff --git a/Master/texmf-dist/tex/latex/animate/animate.sty b/Master/texmf-dist/tex/latex/animate/animate.sty index d493f0fa054..96771b6038b 100644 --- a/Master/texmf-dist/tex/latex/animate/animate.sty +++ b/Master/texmf-dist/tex/latex/animate/animate.sty @@ -12,7 +12,7 @@ \NeedsTeXFormat{LaTeX2e} -\def\@anim@version{2013/09/24} +\def\@anim@version{2014/02/06} \ProvidesPackage{animate} [\@anim@version\space PDF animations from files and inline graphics] @@ -91,35 +91,8 @@ be embedded using pdfTeX% } }} - %macro for adding AcroForm entry to PDF Catalog - \def\@anim@acroform{% - \ifdefined\Acro@Form@added\else% - \pdfcatalog{/AcroForm<</Fields []/NeedAppearances true>>}% - \gdef\Acro@Form@added{}% - \fi% - } \else - \if@anim@@dvipdfmx - %macro for adding AcroForm entry to PDF Catalog - \def\@anim@acroform{% - \ifdefined\Acro@Form@added\else% - \special{pdf:put @catalog <<% - /AcroForm<</Fields []/NeedAppearances true>>>>}% - \gdef\Acro@Form@added{}% - \fi% - } - \else % dvips - %macro for adding AcroForm entry to PDF Catalog - \def\@anim@acroform{% - \ifdefined\Acro@Form@added\else% - \special{ps: - mark {Catalog} <<% - /AcroForm <</Fields []/NeedAppearances true>>% - >> /PUT pdfmark - }% - \gdef\Acro@Form@added{}% - \fi% - } + \if@anim@@dvipdfmx\else % dvips %if geometry package is loaded, execute `\geometry{dvips}' right before % `\begin{document}' \let\@anim@document\document @@ -240,12 +213,13 @@ \newboolean{@anim@useocg} % true if any of `autoplay' or `autoresume' options is set \newboolean{@anim@autoplayorresume} -% true if any of `controls' or `palindrome' options is set -\newboolean{@anim@ctrlorplndrm} +% true if any of `controls' or `palindrome' or `label' options is set +\newboolean{@anim@morejs} \newboolean{@anim@timeline} %true if `timeline' option is set \newboolean{@anim@multipage} % multipage document? -%add OCProperties entries to Catalog +%add AcroForm and OCProperties entries to Catalog +\ifdefined\@anim@fields\else\def\@anim@fields{}\fi %takes Field object refs \ifpdf \newcount\@anim@@ocgs \pdfobj reserveobjnum @@ -261,6 +235,23 @@ >> >> } + %macro for adding AcroForm entry to PDF Catalog + \def\@anim@acroform{% + \ifdefined\Acro@Form@added\else% + \newcount\@anim@@fields% + \pdfobj reserveobjnum% + \global\@anim@@fields=\pdflastobj% + \pdfcatalog{% + /AcroForm <</Fields \the\@anim@@fields\space 0 R /NeedAppearances true>>% + }% + \AtEndDocument{% + \immediate\pdfobj useobjnum \@anim@@fields {% + [\@anim@fields]% + }% + }% + \gdef\Acro@Form@added{}% + \fi% + } \def\@anim@ocgs{} \def\@anim@offocgs{} \AtEndDocument{% @@ -285,6 +276,19 @@ /D <</BaseState/ON /OFF @anim@offocgs>> >> >>} + %macro for adding AcroForm entry to PDF Catalog + \def\@anim@acroform{% + \ifdefined\Acro@Form@added\else% + %array which takes refs to all widget annotations + \special{pdf:obj @anim@fields [ ]}% + \special{pdf:put @catalog <<% + /AcroForm <</Fields @anim@fields /NeedAppearances true>>>>}% + \AtEndDocument{% + \special{pdf:put @anim@fields \@anim@fields}% + }% + \gdef\Acro@Form@added{}% + \fi% + } \else \special{ps: mark /_objdef {@anim@ocgs} /type/array /OBJ pdfmark @@ -294,7 +298,22 @@ /OCGs {@anim@ocgs} /D <</BaseState/ON /OFF {@anim@offocgs}>> >> - >> /PUT pdfmark + >> /PUT pdfmark% + } + %macro for adding AcroForm entry to PDF Catalog + \def\@anim@acroform{% + \ifdefined\Acro@Form@added\else% + \special{ps: + mark /_objdef {@anim@fields} /type/array /OBJ pdfmark + mark {Catalog} <<% + /AcroForm <</Fields {@anim@fields} /NeedAppearances true>> + >> /PUT pdfmark% + }% + \AtEndDocument{% + \special{ps: mark {@anim@fields} 0 [\@anim@fields] /PUTINTERVAL pdfmark}% + }% + \gdef\Acro@Form@added{}% + \fi% } \fi \fi @@ -535,12 +554,12 @@ }{% flip around horizontal axis in portrait mode [1 0 0 -1 0 frame@lly frame@ury add] concat% }ifelse - }?pdfmark + }?pdfmark% }% \begin{picture}(0,0)\put(0,0){\box#3}\end{picture}% \special{ps: mark /EP pdfmark - grestore + grestore% }% \xdef\@anim@lastxform{@anim@frm@#1@#2}% \@anim@newkey{img@#2}{{@anim@frm@#1@#2}}% @@ -579,7 +598,7 @@ \special{ps: mark /_objdef {@anim@ocg@#1@#2} /type/dict /OBJ pdfmark mark {@anim@ocg@#1@#2} <</Type/OCG /Name (#1.#2)>> /PUT pdfmark - mark {@anim@ocgs} {@anim@ocg@#1@#2} /APPEND pdfmark + mark {@anim@ocgs} {@anim@ocg@#1@#2} /APPEND pdfmark% }% } \fi @@ -646,9 +665,10 @@ \fi% /FT/Btn/Ff 65537% non-interactive push button /BS <</W 0>>% - /AP <</N \the\pdflastxform\space 0 R>>% + /MK <</TP 1/I \the\pdflastxform\space 0 R/IF<</S/A/FB true>>>>% /T (#1.#2)% }% + \xdef\@anim@fields{\@anim@fields\the\pdflastannot\space 0 R\space}% } \else \if@anim@@dvipdfmx @@ -706,10 +726,11 @@ \if@anim@useocg/OC @anim@ocg@#1@#2\fi% /FT/Btn/Ff 65537% /BS <</W 0>>% - /AP <</N @anim@anmfrm@#1@#2>>% + /MK <</TP 1/I @anim@anmfrm@#1@#2/IF<</S/A/FB true>>>>% /T (#1.#2)% >>% }% + \xdef\@anim@fields{\@anim@fields @annot@\the\@anim@fieldnum\space}% \global\advance\@anim@fieldnum by \@ne% } \else @@ -723,7 +744,7 @@ /Type/XObject/Subtype/Form/FormType 1 /BBox [frame@llx frame@lly frame@urx frame@ury] /Resources <</XObject <<\@anim@getkeyval{frmxobject@#2}>>>> - >> /PUT pdfmark + >> /PUT pdfmark% }% \if@anim@useocg% \@anim@newocg{#1}{#2}% @@ -783,10 +804,11 @@ \if@anim@useocg/OC {@anim@ocg@#1@#2}\fi% /FT/Btn/Ff 65537 /BS <</W 0>>% - /AP <</N {@anim@anmfrm@#1@#2}>>% + /MK <</TP 1/I {@anim@anmfrm@#1@#2}/IF<</S/A/FB true>>>>% /T (#1.#2)% - /ANN pdfmark + /ANN pdfmark% }% + \xdef\@anim@fields{\@anim@fields{annot@\the\@anim@fieldnum}\space}% \global\advance\@anim@fieldnum by \@ne% } \fi @@ -859,7 +881,7 @@ /Properties <</oc0 {#1.Play#2} /oc1 {#1.Pause#2}>>% /XObject <</im0 {btnPlay#2:#3} /im1 {btnPause#2:#3}>>% >>% - >> /PUT pdfmark + >> /PUT pdfmark% }% } \fi @@ -1043,7 +1065,7 @@ }if #2 }?pdfmark mark /EP pdfmark - grestore + grestore% }% } \else @@ -1527,8 +1549,11 @@ \setboolean{@anim@autoplayorresume}{true}% }{}% \ifthenelse{\boolean{@anim@controls}\OR\boolean{@anim@palindrome}}{% - \setboolean{@anim@ctrlorplndrm}{true}% + \setboolean{@anim@morejs}{true}% }{}% + \ifx\empty\@anim@label\empty\else% + \setboolean{@anim@morejs}{true}% + \fi% \ifthenelse{\NOT\boolean{@anim@controls}\AND\boolean{@anim@step}}{% \setboolean{@anim@loop}{true}% }{}% @@ -1588,8 +1613,14 @@ \@anim@getkeyval{btncol:\@anim@bgcolour:\@anim@fgcolour}}% \fi% \fi% - \xdef\@anim@fps{#2}% current frame rate - \xdef\@anim@nfps{#2}% + \xdef\@anim@nfps{#2\space}% current frame rate + \xdef\@anim@nfps{\expandafter\zap@space\@anim@nfps\@empty}% + \ifdim\@anim@nfps\p@<\z@% + \PackageError{animate}{% + Negative frame rate `\@anim@nfps' is not allowed% + }{}% + \fi% + \xdef\@anim@fps{\@anim@nfps}% % %read all frames of the sequence \loop\ifnum\@anim@curframe\@anim@relop\@anim@last\else% @@ -1623,6 +1654,7 @@ \fi% \endgroup% \global\advance\@anim@num by \@ne% + \@anim@acroform% }% %adjust catcodes of several characters within \animategraphics \let\@anim@animategraphics\animategraphics @@ -1768,7 +1800,7 @@ \@anim@otherjscriptkey% >>% }% - \@anim@acroform% + \xdef\@anim@fields{\@anim@fields\the\pdflastannot\space 0 R\space}% \hbox to \@anim@animwidth\p@ {% \vrule width 0pt height \@anim@animheight\p@ depth \@anim@animdepth\p@% \hss% @@ -1796,7 +1828,7 @@ >> >>% }% - \@anim@acroform% + \xdef\@anim@fields{\@anim@fields @annot@\the\@anim@fieldnum\space}% \global\advance\@anim@fieldnum by \@ne% \hbox to \@anim@animwidth\p@ {% \vrule width 0pt height \@anim@animheight\p@ depth \@anim@animdepth\p@% @@ -1839,9 +1871,9 @@ >>% \@anim@otherjscriptkey% >>% - /ANN pdfmark + /ANN pdfmark% }% - \@anim@acroform% + \xdef\@anim@fields{\@anim@fields{annot@\the\@anim@fieldnum}\space}% \global\advance\@anim@fieldnum by \@ne% \hbox to \@anim@animwidth\p@ {% \vrule width 0pt height \@anim@animheight\p@ depth \@anim@animdepth\p@% @@ -1866,11 +1898,12 @@ /FT/Btn/Ff 65536% push button /BS <</W 0>>% /H/I% - /AP <</N \@anim@getkeyval{btn#3}>>% + /MK <</TP 1/I \@anim@getkeyval{btn#3}/IF<</S/A/FB true>>>>% /T (#1.#2)% \@anim@tooltip% /A <</S/JavaScript/JS (\@anim@upjscriptstring)>>% }% + \xdef\@anim@fields{\@anim@fields\the\pdflastannot\space 0 R\space}% \vrule width 0pt height \@anim@tmpdima depth 0pt% \hss% }% @@ -1888,12 +1921,13 @@ /FT/Btn/Ff 65536% /BS <</W 0>>% /H/I% - /AP <</N @btn#3>>% + /MK <</TP 1/I @btn#3/IF<</S/A/FB true>>>>% /T (#1.#2)% \@anim@tooltip% /A <</S/JavaScript/JS (\@anim@upjscriptstring)>>% >>% }% + \xdef\@anim@fields{\@anim@fields @annot@\the\@anim@fieldnum\space}% \global\advance\@anim@fieldnum by \@ne% \vrule width 0pt height \@anim@tmpdima depth 0pt% \hss% @@ -1926,12 +1960,13 @@ /FT/Btn/Ff 65536 /BS <</W 0>> /H/I - /AP <</N {btn#3}>>% + /MK <</TP 1/I {btn#3}/IF<</S/A/FB true>>>>% /T (#1.#2)% \@anim@tooltip% /A <</S/JavaScript/JS (\@anim@upjscriptstring)>>% - /ANN pdfmark + /ANN pdfmark% }% + \xdef\@anim@fields{\@anim@fields{annot@\the\@anim@fieldnum}\space}% \global\advance\@anim@fieldnum by \@ne% \hbox to \the\@anim@tmpdima {% \vrule width 0pt height \the\@anim@tmpdima\space depth 0pt% @@ -1968,11 +2003,16 @@ \setboolean{@anim@autoplayorresume}{true}% }{}% \ifthenelse{\boolean{@anim@controls}\OR\boolean{@anim@palindrome}}{% - \setboolean{@anim@ctrlorplndrm}{true}% + \setboolean{@anim@morejs}{true}% }{}% + \ifx\empty\@anim@label\empty\else% + \setboolean{@anim@morejs}{true}% + \fi% \ifthenelse{\NOT\boolean{@anim@controls}\AND\boolean{@anim@step}}{% \setboolean{@anim@loop}{true}% }{}% + \global\@anim@curframe@zb=\z@% + \global\@anim@skipfram=\z@% \if@anim@draft\else% %create button faces if necessary \if@anim@controls% @@ -1988,11 +2028,11 @@ \@anim@getkeyval{btncol:\@anim@bgcolour:\@anim@fgcolour}}% \fi% \fi% - \xdef\@anim@fps{#2}% - \xdef\@anim@nfps{#2}% current frame rate (for use in \newframe) + \if@anim@step\else% + \xdef\@anim@nfps{-1}% + \@anim@processfpsarg{#2}% + \fi% \fi% - \global\@anim@curframe@zb=\z@% - \global\@anim@skipfram=\z@% \@anim@beginframe% \ignorespaces% }{% @@ -2015,6 +2055,7 @@ \endgroup% \global\advance\@anim@num by \@ne% \setboolean{@anim@inside}{false}% + \@anim@acroform% } \let\@anim@animateinline\animateinline \def\animateinline{\@anim@sanitize\@anim@animateinline} @@ -2032,37 +2073,42 @@ \@anim@endframe{\the\@anim@num}{\the\@anim@curframe@zb}% \@ifstar\@anim@newframestar\@anim@newframe% } +\def\@anim@processfpsarg#1{% + %process frame rate argument + \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}% + \fi% + \ifnum\@anim@curframe@zb=\z@% + \xdef\@anim@fps{\@anim@nfps}% default fps + \xdef\@anim@nfpsat{\@anim@nfps}% + \else% + \xdef\@anim@nfpsat{\@anim@nfpsat,\@anim@nfps}% + \fi% + \ifdim\@anim@nfps\p@=\@anim@pfps\p@\else% + \ifnum\@anim@curframe@zb=\z@\else% + \setboolean{@anim@chfps}{true}% change fps + \fi% + \fi% + \ifdim\@anim@nfps\p@<\z@% + \PackageError{animate}{% + Negative frame rate `\@anim@nfps' is not allowed% + }{}% + \fi% +}% \newcommand{\@anim@newframe}[1][]{% #1: new frame rate \ifnum\@anim@skipfram=\z@% + \global\advance\@anim@curframe@zb by \@ne% \if@anim@draft\else% \if@anim@step\else% \if@anim@timeline\else% - \edef\@anim@pfps{\@anim@nfps}% - \edef\@anim@nfps{#1}% - \ifx\@anim@nfps\@empty% - \edef\@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% + %process frame rate argument + \@anim@processfpsarg{#1}% \fi% \fi% \fi% - \global\advance\@anim@curframe@zb by \@ne% \fi% \@anim@beginframe% \ignorespaces% @@ -2078,32 +2124,18 @@ a\the\@anim@num.pauseAt[\the\@anim@curframe@zb]=1;% }% \setboolean{@anim@pauseframes}{true}% - \xdef\@anim@pfps{\@anim@nfps}% - \xdef\@anim@nfps{#1}% - \ifx\@anim@nfps\@empty% - \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% \fi% \fi% \global\advance\@anim@curframe@zb by \@ne% + \if@anim@draft\else% + \if@anim@step\else% + \if@anim@timeline\else% + %process frame rate argument + \@anim@processfpsarg{#1}% + \fi% + \fi% + \fi% \fi% \@anim@beginframe% \ignorespaces% @@ -2522,28 +2554,7 @@ \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% + \@anim@processfpsarg{#1}% \fi% \global\advance\@anim@curfield by \@ne% \@anim@parseline#2\@nil% @@ -2713,6 +2724,22 @@ } %command options +\define@key{anim@user}{label}{% + \gdef\@anim@label{#1}% + \ifcsname @anim@#1\endcsname% + \PackageWarning{animate}{Label #1 multiply defined} + \ifdefined\@anim@multlabel\else + \gdef\@anim@multlabel{}% + \AtEndDocument{% + \PackageWarningNoLine{animate}{% + @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\MessageBreak + @@ There were multiply-defined labels! @@\MessageBreak + @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@}% + }% + \fi% + \fi% + \expandafter\gdef\csname @anim@#1\endcsname{}% +} %setting the widget size \define@key{anim@user}{width}{% \gdef\@anim@widtharg{#1}% @@ -2909,6 +2936,10 @@ \if@anim@grxloaded\g@addto@macro\@anim@gropts{, trim=#1}% \else\@anim@missing{graphicx}\fi% } +\define@key{anim@user}{angle}{% + \if@anim@grxloaded\g@addto@macro\@anim@gropts{, angle=#1}% + \else\@anim@missing{graphicx}\fi% +} \newboolean{@anim@meas} \define@key{anim@user}{measure}[true]{% \setboolean{@anim@meas}{#1}% @@ -2928,6 +2959,7 @@ %macro to reset macros and booleans \def\@anim@reset{% + \gdef\@anim@label{}% \gdef\@anim@boxscale{1.0}% \global\@anim@resize\z@% \gdef\@anim@widtharg{\width}% @@ -2969,7 +3001,7 @@ \setboolean{@anim@multipage}{false}% \setboolean{@anim@meas}{false}% \setboolean{@anim@autoplayorresume}{false}% - \setboolean{@anim@ctrlorplndrm}{false}% + \setboolean{@anim@morejs}{false}% } %package options @@ -3161,7 +3193,7 @@ \def\@anim@pojscript#1{% \special{ps: mark /_objdef {a#1@pojscript} /type/stream /OBJ pdfmark - mark {a#1@pojscript} (\@anim@@pojscript{#1}) /PUT pdfmark + mark {a#1@pojscript} (\@anim@@pojscript{#1}) /PUT pdfmark% }% } \fi @@ -3174,14 +3206,13 @@ var a#1_intd;% \fi var a#1,a#1_int;% - if(typeof(a#1)=='undefined'){% initialize animation - a#1=new Object();% + if(typeof(a#1)==='undefined'){% initialize animation + a#1=new Object();% animation object %takes references to frame ocgs/Field objects belonging to the current %animation a#1.fr=new Array();% \if@anim@controls a#1.btn=new Array();%takes references to control button face ocgs - a#1.sm=1;% speed multiplier \fi% %initialize fr & btn properties \if@anim@useocg @@ -3224,18 +3255,14 @@ \fi% \ifx\@anim@poster\@anim@posterlast % set default frame %holds index of the frame to be displayed - a#1.idx=\@anim@maxframe;% + a#1.on=a#1.idx=\@anim@maxframe;% \else % first & none - a#1.idx=0;% + a#1.on=a#1.idx=0;% \fi% %playing state and direction - \if@anim@step% - \if@anim@palindrome - a#1.playsRight=true;% - \fi% - \else - a#1.isPlaying=false;% - a#1.playsRight=true;% + \if@anim@morejs a#1.playsRight=true;\fi% + \if@anim@step\else + a#1.playing=false;% a#1.isPaused=false;% \if@anim@pauseframes %this array takes the frame numbers at which to pause playback @@ -3244,13 +3271,19 @@ \fi% \if@anim@chfps %arrays that take frame numbers (array index) and fps values - a#1.nFpsAt=new Array();% - \@anim@nfpsat% - a#1.pFpsAt=new Array();% - \@anim@pfpsat% - a#1.fps=Math.abs(\@anim@fps);% + a#1.nFpsAt=new Array(\@anim@nfpsat);% \fi - a#1.dt=1000/(1e-6+Math.abs(\@anim@fps));% + a#1.fps=\@anim@fps;a#1.sm=1;% + a#1.setFps=function(f){% + a#1.fps=f;% + if(a#1.playing){% + \if@anim@morejs + if(a#1.playsRight){a#1.playRight();}else{a#1.playLeft();}% + \else + a#1.playRight();% + \fi% + }% + };% \fi% \if@anim@usrjs %array to take frame numbers (array index) and user provided JavaScript @@ -3258,189 +3291,125 @@ \@anim@usrjsat% \fi% %actions - a#1.actnEndLeft=function(){% - \if@anim@step\else - a#1.actnPause();% - a#1.isPaused=false;% because it has been explicitly stopped + a#1.seekFrame=function(f){% + if(f>\@anim@maxframe||f<0){return(-1);}% + var old=a#1.idx;a#1.idx=f;% + \if@anim@usrjs + if(a#1.usrJSat[f]){% + var ret=app.setTimeOut('try{a#1.usrJSat[a#1.idx]();}catch(e){% + console.show();console.println(e);}',1);% + }% \fi% \if@anim@useocg - a#1.fr[a#1.idx].state=false;% - a#1.idx=0;% - a#1.fr[0].state=true;% + a#1.fr[a#1.on].state=false;% \else - a#1.fr[a#1.idx].display=display.hidden;% - a#1.idx=0;% - a#1.fr[0].display=display.visible;% - curdoc.dirty=false;% - \fi% - \if@anim@chfps - a#1.fps=Math.abs(\@anim@fps);% - a#1.dt=1000/(1e-6+a#1.fps);% - \fi% - };% - a#1.actnEndRight=function(){% - \if@anim@step\else - a#1.actnPause();% - a#1.isPaused=false;% + a#1.fr[a#1.on].display=display.hidden;% \fi% \if@anim@useocg - a#1.fr[a#1.idx].state=false;% - a#1.idx=\@anim@maxframe;% - a#1.fr[a#1.idx].state=true;% + a#1.fr[f].state=true;% \else - a#1.fr[a#1.idx].display=display.hidden;% - a#1.idx=\@anim@maxframe;% - a#1.fr[a#1.idx].display=display.visible;% + a#1.fr[f].display=display.visible;% curdoc.dirty=false;% + \fi + a#1.on=f;% + \if@anim@step\else% + \if@anim@chfps + if(a#1.nFpsAt[f]!=a#1.fps){% + a#1.setFps(a#1.nFpsAt[f]);% + }% + \fi% \fi% - \if@anim@chfps %frame rate from the last fps change (\@anim@nfps) - a#1.fps=Math.abs(\@anim@nfps);% - a#1.dt=1000/(1e-6+a#1.fps);% - \fi% + \if@anim@step\else\if@anim@meas a#1.frcnt++;\fi\fi + return(old);% };% - a#1.actnNext=function(){% - \if@anim@useocg - a#1.fr[a#1.idx].state=false;% - \else - a#1.fr[a#1.idx].display=display.hidden;% + a#1.stopFirst=function(){% + \if@anim@step\else + a#1.pause();% + a#1.isPaused=false;% because it has been explicitly stopped \fi - try{% - \if@anim@useocg - a#1.fr[++a#1.idx].state=true;% - \else - 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;% + a#1.seekFrame(0);% + };% + a#1.stopLast=function(){% + \if@anim@step\else + a#1.pause();% + a#1.isPaused=false;% + \fi + a#1.seekFrame(\@anim@maxframe);% + };% + a#1.gotoNext=function(){% + if(a#1.seekFrame(a#1.idx+1)<0){% \if@anim@palindrome% \if@anim@step - a#1.actnEndRight();% + a#1.stopLast();% a#1.playsRight=false;% - \else% - if(a#1.isPlaying){--a#1.idx;}% - \if@anim@useocg - a#1.fr[a#1.idx].state=true;% - \else - a#1.fr[a#1.idx].display=display.visible;% - curdoc.dirty=false;% - \fi% - \if@anim@meas if(a#1.isPlaying){a#1.stopMeas();}\fi - if(a#1.isPlaying){a#1.isPaused=true;a#1.actnPlayLeft();}% + \else + if(a#1.playing){% + \if@anim@meas a#1.stopMeas();\fi + a#1.seekFrame(a#1.idx-1);% + a#1.playLeft();% + }% \fi% \else% \if@anim@step - a#1.actnEndRight();% + a#1.stopLast();% \else% \if@anim@loop - if(a#1.isPlaying){% - \if@anim@chfps - 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();}% + if(a#1.playing){% + a#1.seekFrame(0);% + a#1.setFps(\@anim@fps);% + }else{a#1.stopLast();}% \else - a#1.actnEndRight();% + a#1.stopLast();% \fi% \fi% - \fi% + \fi }% \if@anim@step\else% - \if@anim@chfps - if(% - a#1.nFpsAt[a#1.idx]>=0&&% - a#1.nFpsAt[a#1.idx]!=a#1.fps% - ){% - a#1.fps=a#1.nFpsAt[a#1.idx];% - a#1.dt=1000/(1e-6+a#1.fps);% - if(a#1.isPlaying){a#1.isPaused=true;a#1.actnPlayRight();}% - }% - \fi% \if@anim@pauseframes - if(a#1.isPlaying&&a#1.pauseAt[a#1.idx]){a#1.actnPause();}% + if(a#1.playing&&a#1.pauseAt[a#1.idx]){a#1.pause();}% \fi% \fi% };% - \if@anim@ctrlorplndrm - a#1.actnPrev=function(){% - \if@anim@useocg - a#1.fr[a#1.idx].state=false;% - \else - a#1.fr[a#1.idx].display=display.hidden;% - \fi - try{% - \if@anim@useocg - a#1.fr[--a#1.idx].state=true;% - \else - a#1.fr[--a#1.idx].display=display.visible;% - 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@morejs + a#1.gotoPrev=function(){% + if(a#1.seekFrame(a#1.idx-1)<0){% \if@anim@palindrome% \if@anim@step - a#1.actnEndLeft();% + a#1.stopFirst();% a#1.playsRight=true;% - \else% - if(a#1.isPlaying){++a#1.idx;}% - \if@anim@useocg - a#1.fr[a#1.idx].state=true;% - \else - a#1.fr[a#1.idx].display=display.visible;% - curdoc.dirty=false;% - \fi% - \if@anim@meas if(a#1.isPlaying){a#1.stopMeas();}\fi - if(a#1.isPlaying){a#1.isPaused=true;a#1.actnPlayRight();}% + \else + if(a#1.playing){% + \if@anim@meas a#1.stopMeas();\fi + a#1.seekFrame(a#1.idx+1);% + a#1.playRight();% + }% \fi% \else% \if@anim@step - a#1.actnEndLeft();% + a#1.stopFirst();% \else% \if@anim@loop - if(a#1.isPlaying){% - \if@anim@chfps - 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();}% + if(a#1.playing){% + a#1.seekFrame(\@anim@maxframe);% + }else{a#1.stopFirst();}% \else - a#1.actnEndLeft();% + a#1.stopFirst();% \fi% \fi% \fi% }% \if@anim@step\else% - \if@anim@chfps - if(% - a#1.pFpsAt[a#1.idx]>=0&&% - a#1.pFpsAt[a#1.idx]!=a#1.fps% - ){% - a#1.fps=a#1.pFpsAt[a#1.idx];% - a#1.dt=1000/(1e-6+a#1.fps);% - if(a#1.isPlaying){a#1.isPaused=true;a#1.actnPlayLeft();}% - }% - \fi% \if@anim@pauseframes - if(a#1.isPlaying&&a#1.pauseAt[a#1.idx]){a#1.actnPause();}% + if(a#1.playing&&a#1.pauseAt[a#1.idx]){a#1.pause();}% \fi% \fi% };% \fi% \if@anim@step\else - a#1.actnPause=function(){% - \if@anim@meas if(a#1.isPlaying){a#1.stopMeas();}\fi + a#1.pause=function(){% + \if@anim@meas if(a#1.playing){a#1.stopMeas();}\fi try{app.clearInterval(a#1_int);}catch(e){}% - a#1.isPlaying=false;% + a#1.playing=false;% a#1.isPaused=true;% \if@anim@controls a#1.btn['PauseLeft'].state=false;% @@ -3449,10 +3418,10 @@ a#1.btn['PlayRight'].state=true;% \fi% };% - a#1.actnPlayRight=function(){% + a#1.playRight=function(){% try{app.clearInterval(a#1_int);}catch(e){}% - a#1.playsRight=true;% - a#1.isPlaying=true;% + \if@anim@morejs a#1.playsRight=true;\fi + a#1.playing=true;% a#1.isPaused=false;% \if@anim@controls a#1.btn['PauseLeft'].state=true;% @@ -3461,15 +3430,14 @@ a#1.btn['PlayRight'].state=false;% \fi% \if@anim@meas a#1.startMeas();\fi - a#1_int=app.setInterval(% - 'a#1.actnNext()',a#1.dt\if@anim@controls/a#1.sm\fi% - );% + a#1_int=app.setInterval('a#1.gotoNext()',% + 1000/(1e-6+a#1.fps)/a#1.sm);% };% - \if@anim@ctrlorplndrm - a#1.actnPlayLeft=function(){% + \if@anim@morejs + a#1.playLeft=function(){% try{app.clearInterval(a#1_int);}catch(e){}% a#1.playsRight=false;% - a#1.isPlaying=true;% + a#1.playing=true;% a#1.isPaused=false;% \if@anim@controls a#1.btn['PauseLeft'].state=true;% @@ -3478,48 +3446,24 @@ a#1.btn['PlayRight'].state=false;% \fi% \if@anim@meas a#1.startMeas();\fi - a#1_int=app.setInterval(% - 'a#1.actnPrev()',a#1.dt\if@anim@controls/a#1.sm\fi% - );% + a#1_int=app.setInterval('a#1.gotoPrev()',% + 1000/(1e-6+a#1.fps)/a#1.sm);% };% \fi% \if@anim@controls - a#1.actnIncr=function(){% speed up animation - try{app.clearInterval(a#1_int);}catch(e){}% - a#1.sm*=1.2;% - if(a#1.isPlaying){% - if(a#1.playsRight){% - a#1_int=app.setInterval('a#1.actnNext()',a#1.dt/a#1.sm);% - }else{% - a#1_int=app.setInterval('a#1.actnPrev()',a#1.dt/a#1.sm);% - }% - }% + a#1.fpsIncr=function(){% speed up animation + a#1.sm*=1.1;% + a#1.setFps(a#1.fps);% };% - a#1.actnDecr=function(){% slow down animation - try{app.clearInterval(a#1_int);}catch(e){}% - a#1.sm/=1.2;% - if(a#1.isPlaying){% - if(a#1.playsRight){% - a#1_int=app.setInterval('a#1.actnNext()',a#1.dt/a#1.sm);% - }else{% - a#1_int=app.setInterval('a#1.actnPrev()',a#1.dt/a#1.sm);% - }% - }% + a#1.fpsDecr=function(){% slow down animation + a#1.sm/=1.1;% + a#1.setFps(a#1.fps);% };% - a#1.actnReset=function(){% reset to default speed + a#1.fpsReset=function(){% reset to default speed a#1.sm=1;% - try{app.clearInterval(a#1_int);}catch(e){}% - if(a#1.isPlaying){% - if(a#1.playsRight){% - a#1_int=app.setInterval('a#1.actnNext()',a#1.dt/a#1.sm);% - }else{% - a#1_int=app.setInterval('a#1.actnPrev()',a#1.dt/a#1.sm);% - }% - }% + a#1.setFps(a#1.fps);% };% \fi% - \fi% - \if@anim@step\else% \if@anim@meas var spc=String.fromCharCode(32);% a#1.frcnt=0;% frame counter for speed measurements @@ -3531,58 +3475,87 @@ };% a#1.stopMeas=function(){% a#1.msEnd=(new Date()).getTime();% - app.alert({% - cMsg:'av.'+spc+'frame'+spc+'rate:'+spc+% - 1e3*a#1.frcnt/(a#1.msEnd-a#1.msStart)+spc+'fps',% - nIcon:3% - }); + console.show();console.println(% + 'av.'+spc+'frame'+spc+'rate:'+spc+% + 1e3*a#1.frcnt/(a#1.msEnd-a#1.msStart)+spc+'fps'% + );% };% \fi% \fi% - }% - \if@anim@step\else% - \if@anim@autoplay% - \if@anim@useocg% - \if@anim@ctrlorplndrm - if(a#1.playsRight){a#1.actnPlayRight();}else{a#1.actnPlayLeft();}% - \else% - a#1.actnPlayRight();% - \fi% + \if@anim@morejs% + \if@anim@step + a#1.stepBwd=function(){a#1.seekFrame(a#1.idx-1);};% + a#1.stepFwd=function(){a#1.seekFrame(a#1.idx+1);};% \else - \if@anim@ctrlorplndrm - if(a#1.playsRight){% - a#1_intd=app.setTimeOut('a#1.actnPlayRight()',1);% - }else{% - a#1_intd=app.setTimeOut('a#1.actnPlayLeft()',1);% - }% - \else% - a#1_intd=app.setTimeOut('a#1.actnPlayRight()',1);% - \fi% + a#1.stepBwd=function(){if(!a#1.playing){a#1.seekFrame(a#1.idx-1);}};% + a#1.stepFwd=function(){if(!a#1.playing){a#1.seekFrame(a#1.idx+1);}};% + a#1.playBwd=function(){% + if(a#1.idx==0){a#1.stopLast();}% + a#1.playLeft();% + };% + a#1.playFwd=function(){% + if(a#1.idx==\@anim@maxframe){a#1.stopFirst();}% + a#1.playRight();% + };% \fi% - \if@anim@usrjs try{a#1.usrJSat[a#1.idx]();}catch(e){}\fi% \fi% - \if@anim@autoresume - if(a#1.isPaused){% - \if@anim@useocg% - \if@anim@ctrlorplndrm - if(a#1.playsRight){a#1.actnPlayRight();}else{a#1.actnPlayLeft();}% - \else - a#1.actnPlayRight();% - \fi% - \else% - \if@anim@ctrlorplndrm - if(a#1.playsRight){% - a#1_intd=app.setTimeOut('a#1.actnPlayRight()',1);% - }else{% - a#1_intd=app.setTimeOut('a#1.actnPlayLeft()',1);% + \ifx\empty\@anim@label\empty\else + if(typeof(anim)==='undefined'){anim=new Array();}% + if(typeof(anim['\@anim@label'])==='undefined'){% + anim['\@anim@label']={% + \if@anim@step\else + playBwd: a#1.playBwd,% + playFwd: a#1.playFwd,% + pause: a#1.pause,% + get isPlaying(){return(a#1.playing);},% + get fps(){return(a#1.fps);},% + set fps(f){% + if(f>=0){a#1.setFps(f);}else{% + console.show();console.println('Error:fpsNotAllowed');% + }% + },% + get dt(){return(1000/(1e-6+a#1.fps)/a#1.sm);},% + \fi + get playsFwd(){return(a#1.playsRight);},% + get numFrames(){return(\@anim@frames);},% + get frameNum(){return(a#1.idx);},% + set frameNum(f){% + f=Math.floor(f);% + if(f<0||f>\@anim@maxframe||isNaN(f)){% + console.show();console.println('Error:frameNumNotInRange');% + return;% }% - \else - a#1_intd=app.setTimeOut('a#1.actnPlayRight()',1);% - \fi% - \fi% - \if@anim@usrjs try{a#1.usrJSat[a#1.idx]();}catch(e){}\fi% + \if@anim@step + a#1.seekFrame(f);% + \else + if(a#1.playing){% + a#1.pause();a#1.seekFrame(f);% + if(a#1.playsRight){a#1.playRight();}else{a#1.playLeft();}% + }else{a#1.seekFrame(f);}% + \fi% + },% + stopFirst: a#1.stopFirst,% + stopLast: a#1.stopLast% + };% }% \fi% + a#1.seekFrame(a#1.on);% + }% + curdoc.dirty=false;% + \if@anim@step\else% + \if@anim@autoplayorresume% + \if@anim@autoresume + if(a#1.isPaused){% + \fi% + \if@anim@morejs + if(a#1.playsRight){a#1.playRight();}else{a#1.playLeft();}% + \else + a#1.playRight();% + \fi% + \if@anim@autoresume% + }% + \fi% + \fi% \fi% } @@ -3593,10 +3566,10 @@ \if@anim@step\else if(% \if@anim@autopause - a#1.isPlaying||% + a#1.playing||% \fi a#1.isPaused% - ){a#1.actnPause();}% + ){a#1.pause();}% else{% \if@anim@controls a#1.playsRight=true;% @@ -3606,18 +3579,10 @@ \fi% \fi% \fi% - \ifx\@anim@poster\@anim@posterlast% - \if@anim@useocg - a#1.actnEndRight();% - \else - a#1_intd=app.setTimeOut('a#1.actnEndRight()',1);% - \fi% - \else% - \if@anim@useocg - a#1.actnEndLeft();% - \else - a#1_intd=app.setTimeOut('a#1.actnEndLeft()',1);% - \fi% + \ifx\@anim@poster\@anim@posterlast + a#1.stopLast();% + \else + a#1.stopFirst();% \fi% \if@anim@step\else% }% @@ -3627,7 +3592,7 @@ /D <</S/JavaScript/JS (% pause on MouseDown %disable focus rectangle app.focusRect=false;% - try{if(a#1.isPlaying){a#1.actnPause();}}catch(e){}% + try{if(a#1.playing){a#1.pause();}}catch(e){}% )>>% \fi% /U <</S/JavaScript/JS (% play/resume on MouseUp @@ -3636,39 +3601,37 @@ \if@anim@palindrome if(a#1.idx==\@anim@maxframe){% a#1.playsRight=false;% - a#1.actnPrev();% + a#1.gotoPrev();% }else if(a#1.idx==0){% a#1.playsRight=true;% - a#1.actnNext();% + a#1.gotoNext();% }else if(a#1.playsRight){% - a#1.actnNext();% + a#1.gotoNext();% }else{% - a#1.actnPrev();% + a#1.gotoPrev();% }% \else if(a#1.idx==\@anim@maxframe){% - a#1.actnEndLeft();% - \if@anim@usrjs try{a#1.usrJSat[a#1.idx]();}catch(e){}\fi% + a#1.stopFirst();% }else{% - a#1.actnNext();% + a#1.gotoNext();% }% \fi% \else% - \if@anim@palindrome% + \if@anim@palindrome if(a#1.idx==\@anim@maxframe){% - a#1.actnPlayLeft();% + a#1.playLeft();% }else if(a#1.idx==0){% - a#1.actnPlayRight();% + a#1.playRight();% }else if(a#1.playsRight){% - a#1.actnPlayRight();% + a#1.playRight();% }else{% - a#1.actnPlayLeft();% + a#1.playLeft();% }% \else - if(a#1.idx==\@anim@maxframe){a#1.actnEndLeft();}% - a#1.actnPlayRight();% + if(a#1.idx==\@anim@maxframe){a#1.stopFirst();}% + a#1.playRight();% \fi% - \if@anim@usrjs try{a#1.usrJSat[a#1.idx]();}catch(e){}\fi% \fi% }catch(e){}% )>>% @@ -3689,49 +3652,31 @@ \xdef\@anim@upjscriptstring{% app.focusRect=false;% \ifx\@anim@action\@anim@EndLeft - a#1.actnEndLeft();% + a#1.stopFirst();% \else% - \ifx\@anim@action\@anim@StepLeft% - \if@anim@step - if(a#1.idx!=0){a#1.actnPrev();}% - \else - if(!a#1.isPlaying&&a#1.idx!=0){a#1.isPaused=true;a#1.actnPrev();}% - \fi% + \ifx\@anim@action\@anim@StepLeft + a#1.stepBwd();% \else% \ifx\@anim@action\@anim@PlayPauseLeft - 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% - }% + if(a#1.playing){a#1.pause();}else{a#1.playBwd();}% \else% \ifx\@anim@action\@anim@PlayPauseRight - 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% - }% + if(a#1.playing){a#1.pause();}else{a#1.playFwd();}% \else% - \ifx\@anim@action\@anim@StepRight% - \if@anim@step - if(a#1.idx!=\@anim@maxframe){a#1.actnNext();}% - \else - if(!a#1.isPlaying&&a#1.idx!=\@anim@maxframe){% - a#1.isPaused=true;a#1.actnNext();% - }% - \fi% + \ifx\@anim@action\@anim@StepRight + a#1.stepFwd();% \else% \ifx\@anim@action\@anim@EndRight - a#1.actnEndRight();% + a#1.stopLast();% \else% \ifx\@anim@action\@anim@Minus - a#1.actnDecr();% + a#1.fpsDecr();% \else% \ifx\@anim@action\@anim@Reset - a#1.actnReset();% + a#1.fpsReset();% \else% \ifx\@anim@action\@anim@Plus - a#1.actnIncr();% + a#1.fpsIncr();% \fi\fi\fi\fi\fi\fi\fi\fi\fi% }% } |