diff options
author | Karl Berry <karl@freefriends.org> | 2007-07-16 16:32:07 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2007-07-16 16:32:07 +0000 |
commit | 1b0d01e91a7b4080895db481fb57b9b8ed53d887 (patch) | |
tree | 4356d1b4f531c143ba71f2ff91a4b910b99e3fc0 /Master/texmf-dist/tex/latex/animate | |
parent | 7a69017ffdc2b91356c7e2f3ae8160cbc7f09564 (diff) |
animate update (4jul07)
git-svn-id: svn://tug.org/texlive/trunk@4619 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/animate')
-rw-r--r-- | Master/texmf-dist/tex/latex/animate/animate.sty | 574 |
1 files changed, 376 insertions, 198 deletions
diff --git a/Master/texmf-dist/tex/latex/animate/animate.sty b/Master/texmf-dist/tex/latex/animate/animate.sty index 6067ebadf1b..6001e2f51aa 100644 --- a/Master/texmf-dist/tex/latex/animate/animate.sty +++ b/Master/texmf-dist/tex/latex/animate/animate.sty @@ -13,7 +13,7 @@ % Supports LaTeX->dvips->ps2pdf or pdfLaTeX workflows. \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{animate}[2007/05/24] +\ProvidesPackage{animate}[2007/07/04] \RequirePackage{keyval} \RequirePackage{ifthen} \RequirePackage{ifpdf} @@ -89,7 +89,8 @@ \pdfcatalog{ /OCProperties << /OCGs \the\@anim@@ocgs\space 0 R - /D <</BaseState/OFF /ON \the\@anim@@posterocgs\space 0 R>> + /D <</BaseState/OFF /ON \the\@anim@@posterocgs\space 0 R + /Order \the\@anim@@ocgs\space 0 R>> >> } \def\@anim@ocgs{} @@ -111,17 +112,13 @@ mark {Catalog} << /OCProperties << /OCGs {@anim@ocgs} - /D <</BaseState/OFF /ON {@anim@posterocgs}>> + /D <</BaseState/OFF /ON {@anim@posterocgs} /Order {@anim@ocgs}>> >> >> /PUT pdfmark } - \newcount\@anim@occnt % counter for optional content groups - \global\@anim@occnt=0 - \newcount\@anim@resnum % counter for content resources - \global\@anim@resnum=0 \fi -\newbox\@anim@@box %stores single frame +\newbox\@anim@box %stores animation frames \newdimen\@anim@tmpdima %length register for occasional use %creates Form XObject from graphics file @@ -134,13 +131,13 @@ %store file in a box \def\@anim@mps{.mps}% \ifx\@anim@ext\@anim@mps% - \global\setbox\@anim@@box=\hbox{\convertMPtoPDF{#3}{1}{1}}% + \global\setbox\@anim@box=\hbox{\convertMPtoPDF{#3}{1}{1}}% \else% \immediate\pdfximage{#3}% - \global\setbox\@anim@@box=\hbox{\pdfrefximage\pdflastximage}% + \global\setbox\@anim@box=\hbox{\pdfrefximage\pdflastximage}% \fi %delegate Form XObject creation - \@anim@xinline{#1}{#2}{\@anim@@box}% + \@anim@xinline{#1}{#2}{\@anim@box}% } \else \def\@anim@ximage#1#2#3{% @@ -149,80 +146,42 @@ }% %store file in a box \edef\@anim@curfile{{#3}}% - \global\setbox\@anim@@box=\hbox{\expandafter\includegraphics\@anim@curfile}% + \global\setbox\@anim@box=\hbox{\expandafter\includegraphics\@anim@curfile}% %delegate Form XObject creation - \@anim@xinline{#1}{#2}{\@anim@@box}% + \@anim@xinline{#1}{#2}{\@anim@box}% } \fi -%creates Form XObject from box contents and associates it with a newly created -%OCG +\newboolean{@anim@timeline} %true if `timeline' option was set + +%creates Form XObject from box contents and associates it with a newly +%created OCG \ifpdf - \newbox\@anim@box %stores all graphics of a sequence \def\@anim@xinline#1#2#3{%#1:@anim@num, #2:@anim@curframe@zb, #3:box number - %new ocg - \immediate\pdfobj{<</Type/OCG /Name (#1.#2)>>}% - \xdef\@anim@curocg{\the\pdflastobj\space 0 R}% - %append to ocg array - \xdef\@anim@ocgs{\@anim@ocgs\space\@anim@curocg}% - %store ref to ocg if it's a poster - \ifnum#2=0% - \def\@anim@posterframe{first}% - \else% - \def\@anim@posterframe{last}% - \fi% - \ifx\@anim@poster\@anim@posterframe% - \xdef\@anim@posterocg{\@anim@curocg}% - \fi% - %new XObject - \immediate\pdfxform attr {% - /OC <</Type/OCMD /OCGs \@anim@curocg>>% - }#3% - \ifnum#2=0% - \global\setbox\@anim@box=\hbox{\pdfrefxform\pdflastxform}% - % size (measuring the first frame only) - \xdef\@anim@animwidth{\strip@pt\wd\@anim@box}% - \xdef\@anim@animheight{\strip@pt\ht\@anim@box}% - \xdef\@anim@animdepth{\strip@pt\dp\@anim@box}% - \setlength{\@anim@tmpdima}{\ht\@anim@box}% - \addtolength{\@anim@tmpdima}{\dp\@anim@box}% + \ifnum#2=0% measuring the size of the box (first frame only) + \xdef\@anim@animwidth{\strip@pt\wd#3}% + \xdef\@anim@animheight{\strip@pt\ht#3}% + \xdef\@anim@animdepth{\strip@pt\dp#3}% + \setlength{\@anim@tmpdima}{\ht#3}% + \addtolength{\@anim@tmpdima}{\dp#3}% \xdef\@anim@animtotalheight{\strip@pt\@anim@tmpdima}% - \else% overlay current XObject over previous content - \def\@anim@oldunitlength{\the\unitlength}% make backup - \setlength{\unitlength}{1pt}% - \global\setbox\@anim@box=\hbox{% - \begin{picture}(% - \@anim@animwidth,\@anim@animtotalheight% - )(% - 0,-\@anim@animdepth% - )% - \put(0,0){\box\@anim@box}% - \put(0,0){\pdfrefxform\pdflastxform}% - \end{picture}% + \fi% + %put graphics into XObject + \immediate\pdfxform #3% + %XObject resource entry of container XObject + \xdef\@anim@xobject{% + \@anim@xobject\space/im#2\space\the\pdflastxform\space 0 R% + }% + \if@anim@timeline\else% + \@anim@newocg{#1}{#2}%new ocg + %compose content stream of container XObject + \xdef\@anim@content{% + \@anim@content\space /OC/oc#2\space BDC q /im#2\space Do Q EMC% }% - \setlength{\unitlength}{\@anim@oldunitlength}% restore previous unitlen \fi% - } + } \else \def\@anim@xinline#1#2#3{% - \special{ps: - %new ocg - mark /_objdef {@anim@ocg@\the\@anim@occnt} /type/dict /OBJ pdfmark - mark {@anim@ocg@\the\@anim@occnt} << - /Type/OCG /Name (#1.#2) - >> /PUT pdfmark - %append to ocg array - mark {@anim@ocgs} {@anim@ocg@\the\@anim@occnt} /APPEND pdfmark - }% - %store ref to ocg if it is a poster - \ifnum#2=0% - \def\@anim@posterframe{first}% - \else% - \def\@anim@posterframe{last}% - \fi% - \ifx\@anim@poster\@anim@posterframe% - \xdef\@anim@posterocg{@anim@ocg@\the\@anim@occnt}% - \fi% \ifnum#2=0% \xdef\@anim@animwidth{\strip@pt\wd#3}% \xdef\@anim@animheight{\strip@pt\ht#3}% @@ -230,11 +189,8 @@ \setlength{\@anim@tmpdima}{\ht#3}% \addtolength{\@anim@tmpdima}{\dp#3}% \xdef\@anim@animtotalheight{\strip@pt\@anim@tmpdima}% - \gdef\@anim@properties{}% - \gdef\@anim@xobject{}% - \gdef\@anim@content{}% \fi% - \def\@anim@oldunitlength{\the\unitlength}% make backup + \edef\@anim@oldunitlength{\the\unitlength}% make backup \setlength{\unitlength}{1pt}% %mark BBox of the graphics \begin{picture}(0,0)% @@ -254,7 +210,7 @@ \special{ps: gsave mark - /_objdef {@anim@frm@\the\@anim@occnt} + /_objdef {@anim@frm@#1@#2} /BBox [frame@llx frame@lly frame@urx frame@ury] /BP pdfmark %flip around horizontal axis @@ -267,30 +223,88 @@ mark /EP pdfmark grestore }% - %compose resources for use in container XObject + %XObject resource entry of container XObject + \xdef\@anim@xobject{% + \@anim@xobject\space/im#2\space + {@anim@frm@#1@#2}% + }% + \if@anim@timeline\else% + \@anim@newocg{#1}{#2}% new ocg + %compose content stream of container XObject + \xdef\@anim@content{% + \@anim@content\space /OC/oc#2\space BDC q /im#2\space Do Q EMC% + }% + \fi% + } +\fi + +%creates OCG and builds Properties entry for use in container XObject +\ifpdf + \def\@anim@newocg#1#2{%#1:@anim@num, #2:@anim@curframe@zb + \immediate\pdfobj{<</Type/OCG /Name (#1.#2)>>}% new ocg + \xdef\@anim@curocg{\the\pdflastobj\space 0 R}% + %append to ocg array + \xdef\@anim@ocgs{\@anim@ocgs\space\@anim@curocg}% + %store ref to ocg if it's a poster + \ifnum#2=0% + \def\@anim@posterframe{first}% + \else% + \def\@anim@posterframe{last}% + \fi% + \ifx\@anim@poster\@anim@posterframe% + \xdef\@anim@posterocg{\@anim@curocg}% + \fi% + %compose Properties entry for use in container XObject \xdef\@anim@properties{% - \@anim@properties\space/oc\the\@anim@resnum\space - {@anim@ocg@\the\@anim@occnt}% + \@anim@properties\space/oc#2\space\@anim@curocg% }% - \xdef\@anim@xobject{% - \@anim@xobject\space/im\the\@anim@resnum\space - {@anim@frm@\the\@anim@occnt}% + } +\else + \def\@anim@newocg#1#2{%#1:@anim@num, #2:@anim@curframe@zb + \special{ps: + mark /_objdef {@anim@ocg@#1@#2} /type/dict /OBJ pdfmark %new ocg + mark {@anim@ocg@#1@#2} << + /Type/OCG /Name (#1.#2) + >> /PUT pdfmark + %append to ocg array + mark {@anim@ocgs} {@anim@ocg@#1@#2} /APPEND pdfmark }% - %compose content stream of container XObject - \xdef\@anim@content{% - \@anim@content\space - /OC/oc\the\@anim@resnum\space - BDC q /im\the\@anim@resnum\space Do Q EMC% + %store ref to ocg if it is a poster + \ifnum#2=0% + \def\@anim@posterframe{first}% + \else% + \def\@anim@posterframe{last}% + \fi% + \ifx\@anim@poster\@anim@posterframe% + \xdef\@anim@posterocg{@anim@ocg@#1@#2}% + \fi% + %compose Properties entry for use in container XObject + \xdef\@anim@properties{% + \@anim@properties\space/oc#2\space {@anim@ocg@#1@#2}% }% - \global\advance\@anim@occnt by 1% increment ocg counter - \global\advance\@anim@resnum by 1% increment resource number } \fi %create XObject which contains all frames of the sequence \ifpdf - \def\@anim@makecontainer#1{% - \immediate\pdfxform\@anim@box% make it from box + \def\@anim@makecontainer#1{% #1:@anim@num + \edef\@anim@oldunitlength{\the\unitlength}% make backup + \setlength{\unitlength}{1pt}% + \global\setbox\@anim@box=\hbox{% + \pdfliteral{q}% + \begin{picture}(% + \@anim@animwidth,\@anim@animtotalheight% + )(% + 0,-\@anim@animdepth% + )% + \end{picture}% + \pdfliteral{Q\@anim@content}% + }% + \setlength{\unitlength}{\@anim@oldunitlength}% restore previous unitlen + \immediate\pdfxform resources {% + /Properties <<\@anim@properties>> + /XObject <<\@anim@xobject>> + }\@anim@box% \xdef\@anim@container{\the\pdflastxform\space 0 R}% } \else @@ -307,7 +321,6 @@ >> >> /PUT pdfmark }% - \global\@anim@resnum=0% reset resource number } \fi @@ -803,8 +816,8 @@ % #1: options % #2: frame rate (fps) % #3: basename of graphics file sequence (without frame number and extension) -% #4: first frame (zero padded integer of same width as #5) -% #5: last frame (zero padded integer of same width as #4) +% #4: first frame (integer) +% #5: last frame (integer) \newcommand{\animategraphics}[5][]{% \leavevmode% \ifpdf\else% @@ -822,12 +835,14 @@ \@anim@makebuttons% \setboolean{@anim@buttonsmade}{true}% \fi% - %combine Pause & Play button faces into one XObject - \@anim@makeppcontainer{\the\@anim@num}{Right}% - \@anim@makeppcontainer{\the\@anim@num}{Left}% + \if@anim@step\else% + %combine Pause & Play button faces into one XObject + \@anim@makeppcontainer{\the\@anim@num}{Right}% + \@anim@makeppcontainer{\the\@anim@num}{Left}% + \fi% \fi% \xdef\@anim@fps{#2}% current frame rate - \xdef\@anim@nfps{#2}% not used, actually, with `animategraphics' + \xdef\@anim@nfps{#2}% \xdef\@anim@pauseat{}% \xdef\@anim@nfpsat{}% \xdef\@anim@pfpsat{}% @@ -846,43 +861,48 @@ }% \advance\@anim@curframe by 1% \advance\@anim@curframe@zb by 1% - \xdef\@anim@frames{\the\@anim@curframe@zb}% total number \repeat% + \xdef\@anim@frames{\the\@anim@curframe@zb}% total number + %build timeline from optional timeline file + \if@anim@timeline\@anim@buildtmln{\the\@anim@num}\fi% \@anim@makecontainer{\the\@anim@num}% create container XObject %insert animation widget & controls + \@anim@insertwidgets{\the\@anim@num}% + \global\advance\@anim@num by 1% +}% + +%insert the animation and control button widgets +\def\@anim@insertwidgets#1{%#1:@anim@num \vtop{% \offinterlineskip% - \hbox{\@anim@animwidget{\the\@anim@num}}% + \hbox{\@anim@animwidget{#1}}% \if@anim@controls% \setlength{\@anim@tmpdima}{\@anim@btnsize}% \setlength{\@anim@tmpdima}{0.1\@anim@tmpdima}% \vskip \@anim@tmpdima% \hbox to \@anim@animwidth\@anim@pt {% \hss% - \@anim@buttonwidget{\the\@anim@num}{EndLeft}{EndLeft}% - \@anim@buttonwidget{\the\@anim@num}{StepLeft}{StepLeft}% + \@anim@buttonwidget{#1}{EndLeft}{EndLeft}% + \@anim@buttonwidget{#1}{StepLeft}{StepLeft}% \if@anim@step\else% - \@anim@buttonwidget{\the\@anim@num}{PlayPauseLeft}{% - \the\@anim@num.PlayPauseLeft}% - \@anim@buttonwidget{\the\@anim@num}{PlayPauseRight}{% - \the\@anim@num.PlayPauseRight}% + \@anim@buttonwidget{#1}{PlayPauseLeft}{#1.PlayPauseLeft}% + \@anim@buttonwidget{#1}{PlayPauseRight}{#1.PlayPauseRight}% \fi% - \@anim@buttonwidget{\the\@anim@num}{StepRight}{StepRight}% - \@anim@buttonwidget{\the\@anim@num}{EndRight}{EndRight}% + \@anim@buttonwidget{#1}{StepRight}{StepRight}% + \@anim@buttonwidget{#1}{EndRight}{EndRight}% \if@anim@step\else% \setlength{\@anim@tmpdima}{\@anim@btnsize}% \setlength{\@anim@tmpdima}{0.3\@anim@tmpdima}% \hskip \@anim@tmpdima% - \@anim@buttonwidget{\the\@anim@num}{Minus}{Minus}% - \@anim@buttonwidget{\the\@anim@num}{Reset}{Reset}% - \@anim@buttonwidget{\the\@anim@num}{Plus}{Plus}% + \@anim@buttonwidget{#1}{Minus}{Minus}% + \@anim@buttonwidget{#1}{Reset}{Reset}% + \@anim@buttonwidget{#1}{Plus}{Plus}% \fi% \hss% }% \fi% }% - \global\advance\@anim@num by 1% -}% +} %calculates widget dimensions from natural ones, taking resizing options %into account @@ -956,7 +976,7 @@ \def\@anim@posterframe{none}% \ifx\@anim@poster\@anim@posterframe\else% \xdef\@anim@posterocgs{\@anim@posterocgs\space\@anim@posterocg}% - \fi + \fi% \pdfannot width \@anim@animwidth\@anim@pt height \@anim@animheight\@anim@pt @@ -988,7 +1008,7 @@ \else \def\@anim@animwidget#1{% \@anim@rescale% - \def\@anim@oldunitlength{\the\unitlength}% + \edef\@anim@oldunitlength{\the\unitlength}% \setlength{\unitlength}{1pt}% %mark annotation rectangle \begin{picture}(0,0)% @@ -1074,7 +1094,7 @@ \def\@anim@buttonwidget#1#2#3{% \@anim@upjscript{#1}{#2}% \setlength{\@anim@tmpdima}{\@anim@btnsize}% - \def\@anim@oldunitlength{\the\unitlength}% + \edef\@anim@oldunitlength{\the\unitlength}% \setlength{\unitlength}{1pt}% \begin{picture}(0,0)% \put(0,0){% @@ -1133,9 +1153,11 @@ \@anim@makebuttons% \setboolean{@anim@buttonsmade}{true}% \fi% - %combine Pause & Play button faces into one XObject - \@anim@makeppcontainer{\the\@anim@num}{Right}% - \@anim@makeppcontainer{\the\@anim@num}{Left}% + \if@anim@step\else% + %combine Pause & Play button faces into one XObject + \@anim@makeppcontainer{\the\@anim@num}{Right}% + \@anim@makeppcontainer{\the\@anim@num}{Left}% + \fi% \fi% \xdef\@anim@fps{#2}% \xdef\@anim@nfps{#2}% current frame rate (for use in \newframe) @@ -1147,39 +1169,11 @@ \@anim@endframe{\the\@anim@num}{\the\@anim@curframe@zb}% \global\advance\@anim@curframe@zb by 1% \xdef\@anim@frames{\the\@anim@curframe@zb}% total number + %build timeline from optional timeline file + \if@anim@timeline\@anim@buildtmln{\the\@anim@num}\fi% \@anim@makecontainer{\the\@anim@num}% create container XObject %insert animation widget & controls - \vtop{% - \offinterlineskip% - \hbox{\@anim@animwidget{\the\@anim@num}}% - \if@anim@controls% - \setlength{\@anim@tmpdima}{\@anim@btnsize}% - \setlength{\@anim@tmpdima}{0.1\@anim@tmpdima}% - \vskip \@anim@tmpdima% - \hbox to \@anim@animwidth\@anim@pt {% - \hss% - \@anim@buttonwidget{\the\@anim@num}{EndLeft}{EndLeft}% - \@anim@buttonwidget{\the\@anim@num}{StepLeft}{StepLeft}% - \if@anim@step\else% - \@anim@buttonwidget{\the\@anim@num}{PlayPauseLeft}{% - \the\@anim@num.PlayPauseLeft}% - \@anim@buttonwidget{\the\@anim@num}{PlayPauseRight}{% - \the\@anim@num.PlayPauseRight}% - \fi% - \@anim@buttonwidget{\the\@anim@num}{StepRight}{StepRight}% - \@anim@buttonwidget{\the\@anim@num}{EndRight}{EndRight}% - \if@anim@step\else% - \setlength{\@anim@tmpdima}{\@anim@btnsize}% - \setlength{\@anim@tmpdima}{0.3\@anim@tmpdima}% - \hskip \@anim@tmpdima% - \@anim@buttonwidget{\the\@anim@num}{Minus}{Minus}% - \@anim@buttonwidget{\the\@anim@num}{Reset}{Reset}% - \@anim@buttonwidget{\the\@anim@num}{Plus}{Plus}% - \fi% - \hss% - }% - \fi% - }% + \@anim@insertwidgets{\the\@anim@num}% \global\advance\@anim@num by 1% \setboolean{@anim@inside}{false}% } @@ -1199,27 +1193,32 @@ } \newcommand{\@anim@newframestar}[1][]{% starred variant to pause animation \if@anim@step\else% % #1: new frame rate - %build JavaScript commands to fill the `pauseAt' array - \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{#1}% - \ifx\@anim@nfps\@empty% - \xdef\@anim@nfps{\@anim@pfps}% - \else% - %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);% + \if@anim@timeline\else% + %build JavaScript commands to fill the `pauseAt' array + \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}% + \xdef\@anim@pfps{\@anim@nfps}% + \xdef\@anim@nfps{#1}% + \ifx\@anim@nfps\@empty% + \xdef\@anim@nfps{\@anim@pfps}% + \else% + \ifnum\@anim@curframe@zb=0% + \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@curframe@zb by 1% @@ -1228,21 +1227,26 @@ } \newcommand{\@anim@newframe}[1][]{% #1: new frame rate \if@anim@step\else% - \edef\@anim@pfps{\@anim@nfps}% - \edef\@anim@nfps{#1}% - \ifx\@anim@nfps\@empty% - \edef\@anim@nfps{\@anim@pfps}% - \else% - %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 + \if@anim@timeline\else% + \edef\@anim@pfps{\@anim@nfps}% + \edef\@anim@nfps{#1}% + \ifx\@anim@nfps\@empty% + \edef\@anim@nfps{\@anim@pfps}% + \else% + \ifnum\@anim@curframe@zb=0% + \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@curframe@zb by 1% @@ -1252,17 +1256,19 @@ %starts a new frame \def\@anim@beginframe{% - \begin{lrbox}{\@anim@@box}% store the graphics in a box + \begin{lrbox}{\@anim@box}% store the graphics in a box + \the\@anim@begin% } %terminates current frame \def\@anim@endframe#1#2{% + \the\@anim@end% \end{lrbox}% \message{< a#1, fr#2}% %determine size of graphics \ifnum #2=0% - \xdef\@anim@animwidth{\strip@pt\wd\@anim@@box}% - \ifdim\wd\@anim@@box=0pt% + \xdef\@anim@animwidth{\strip@pt\wd\@anim@box}% + \ifdim\wd\@anim@box=0pt% \PackageError{animate}{% Contents of first frame must not have zero width% }{% @@ -1270,10 +1276,10 @@ immediately followed by \protect\newframe% }% \fi% - \xdef\@anim@animheight{\strip@pt\ht\@anim@@box}% - \xdef\@anim@animdepth{\strip@pt\dp\@anim@@box}% - \ifdim\ht\@anim@@box=0pt% - \ifdim\dp\@anim@@box=0pt% + \xdef\@anim@animheight{\strip@pt\ht\@anim@box}% + \xdef\@anim@animdepth{\strip@pt\dp\@anim@box}% + \ifdim\ht\@anim@box=0pt% + \ifdim\dp\@anim@box=0pt% \PackageError{animate}{% Contents of first frame must not have zero height% }{}% @@ -1281,12 +1287,12 @@ \fi% \fi% %now create Form XObject of box contents - \@anim@xinline{#1}{#2}{\@anim@@box}% + \@anim@xinline{#1}{#2}{\@anim@box}% \message{>}% } %prints zero padded integers -% #1: arbitrary, non-zero integer number as template specifying the +% #1: arbitrary integer number as template specifying the % width, e. g. `987654' for a width of 6 digits % #2: the number to be formatted (zero padded) \def\@anim@pad#1#2{% @@ -1312,6 +1318,152 @@ \fi% }% +%building timeline from timeline file +\newread\@anim@@tmlnfile +\newboolean{@anim@eof} +\def\@anim@buildtmln#1{% #1:@anim@num + \edef\@anim@endlinechar{\the\endlinechar}% + \endlinechar=-1% suppress trailing space at input line end + \global\@anim@curframe@zb=0% + %read timeline file a first time to get number lines (= number of frames) + \openin\@anim@@tmlnfile=\@anim@tmlnfile% + \read\@anim@@tmlnfile to \@anim@inputline% + \edef\@anim@inputline{\@anim@inputline\space}% + %remove all spaces from input line + \edef\@anim@inputline{\expandafter\zap@space\@anim@inputline\@empty}% + \ifeof\@anim@@tmlnfile\setboolean{@anim@eof}{true}\else% + \setboolean{@anim@eof}{false}\fi% + \whiledo{\NOT\boolean{@anim@eof}}{% + \ifthenelse{\equal{\@anim@inputline}{}}{}{% + %initialise contents of each frame (to be filled with refs to XObjects + \@anim@newkey{@anim@content@\the\@anim@curframe@zb}{}% to be drawn) + \global\advance\@anim@curframe@zb by 1% + }% + \read\@anim@@tmlnfile to \@anim@inputline% + \edef\@anim@inputline{\@anim@inputline\space}% + \edef\@anim@inputline{\expandafter\zap@space\@anim@inputline\@empty}% + \ifeof\@anim@@tmlnfile\setboolean{@anim@eof}{true}\else% + \setboolean{@anim@eof}{false}\fi% + }% + \closein\@anim@@tmlnfile% + \xdef\@anim@images{\@anim@frames}% total number of images + \xdef\@anim@frames{\the\@anim@curframe@zb}% total number of anim positions + \global\@anim@curframe@zb=0% + %reopen timeline file and build timeline + \openin\@anim@@tmlnfile=\@anim@tmlnfile% + \read\@anim@@tmlnfile to \@anim@inputline% + \edef\@anim@inputline{\@anim@inputline\space}% + \edef\@anim@inputline{\expandafter\zap@space\@anim@inputline\@empty}% + \ifeof\@anim@@tmlnfile\setboolean{@anim@eof}{true}\else% + \setboolean{@anim@eof}{false}\fi% + \whiledo{\NOT\boolean{@anim@eof}}{% + \ifthenelse{\equal{\@anim@inputline}{}}{}{% + \expandafter\@anim@parseline\@anim@inputline;% + %create OCG and compose Properties entry + \@anim@newocg{#1}{\the\@anim@curframe@zb}% + %compose content stream of container XObject + \xdef\@anim@content{% + \@anim@content\space% + /OC/oc\the\@anim@curframe@zb\space% + BDC\@anim@getkeyval{@anim@content@\the\@anim@curframe@zb} EMC% + }% + \global\advance\@anim@curframe@zb by 1% + }% + \read\@anim@@tmlnfile to \@anim@inputline% + \edef\@anim@inputline{\@anim@inputline\space}% + \edef\@anim@inputline{\expandafter\zap@space\@anim@inputline\@empty}% + \ifeof\@anim@@tmlnfile\setboolean{@anim@eof}{true}\else% + \setboolean{@anim@eof}{false}\fi% + }% + \closein\@anim@@tmlnfile% + \endlinechar=\@anim@endlinechar% reset endlinechar +} + +%reads one line of timeline file and splits into its colon separated parts +\def\@anim@parseline#1:#2:#3;{% + \if@anim@step\else% + \ifx #1*% first column is a star (pause frame) + \xdef\@anim@pauseat{% + \@anim@pauseat% + a\the\@anim@num.pauseAt[\the\@anim@curframe@zb]=1;% + }% + \setboolean{@anim@pauseframes}{true}% + \fi% + \xdef\@anim@pfps{\@anim@nfps}% + \xdef\@anim@nfps{#2}% + \ifx\@anim@nfps\@empty% second column contains a number (new frame rate) + \xdef\@anim@nfps{\@anim@pfps}% + \else% + \ifnum\@anim@curframe@zb=0% + \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);% + }% + \setboolean{@anim@chfps}{true}% change fps + \fi% + \fi% + %parse the third column + \@anim@parsethird#3,:;% +} + +%parses 3rd column of timeline file (comma separated list of image specs) +\def\@anim@parsethird#1,#2;{% + \def\@anim@firstarg{#1}% + \ifx\@anim@firstarg\@empty\else% + \@anim@process#1x:;% process one image spec + \fi% + \ifx #2:\else% + \@anim@parsethird#2;% + \fi% +} + +\newcount\@anim@tmpcnt %scratch counter for different uses +%process image spec, such as 123 or 456x78 or 9x0 +\def\@anim@process#1x#2;{% + %determine number of repetitions of current image + \ifx #2:% + \gdef\@anim@repeats{1}% + \else% + \@anim@processsecond#2;% + \fi% + \ifnum\@anim@repeats=0% 0= means: repeat until end of timeline + \edef\@anim@repeatuntil{\@anim@frames}% + \else% + \@anim@tmpcnt=\@anim@curframe@zb% + \advance\@anim@tmpcnt by \@anim@repeats% + \ifnum\@anim@frames<\@anim@tmpcnt% + \edef\@anim@repeatuntil{\@anim@frames}% + \else% + \edef\@anim@repeatuntil{\the\@anim@tmpcnt}% + \fi% + \fi% + %build contents of animation frames according to image specifications + \ifnum\@anim@images<#1\else% ignore image specifications which do not exist + \ifnum\@anim@images=#1\else% + \@anim@tmpcnt=\@anim@curframe@zb% + \loop\ifnum\@anim@repeatuntil>\@anim@tmpcnt% + \@anim@newkey{@anim@content@\the\@anim@tmpcnt}{% + \@anim@getkeyval{@anim@content@\the\@anim@tmpcnt} + q /im#1\space Do Q% + }% + \advance\@anim@tmpcnt by 1% + \repeat% + \fi% + \fi% +} + +%get number of repetitions of frame +\def\@anim@processsecond#1x:;{% + \gdef\@anim@repeats{#1}% +} + %command options %setting the widget size \define@key{anim@user}{width}{% @@ -1349,7 +1501,7 @@ \define@key{anim@user}{loop}[true]{% \setboolean{@anim@loop}{#1}% } -\newboolean{@anim@autoplay} %doen't work anymore in AR8 +\newboolean{@anim@autoplay} \setboolean{@anim@autoplay}{false} \define@key{anim@user}{autoplay}[true]{% \setboolean{@anim@autoplay}{#1}% @@ -1389,6 +1541,25 @@ \define@key{anim@user}{step}[true]{% \setboolean{@anim@step}{#1}% } +\define@key{anim@user}{timeline}{% + \IfFileExists{#1}{% + \gdef\@anim@tmlnfile{#1}% + \setboolean{@anim@timeline}{true}% + }{% + \PackageError{animate}{timeline file `#1' cannot be opened for reading% + }{% + Make sure file `#1' exists and is readable!% + }% + }% +} +\newtoks\@anim@begin +\define@key{anim@user}{begin}{% + \@anim@begin{#1}% +} +\newtoks\@anim@end +\define@key{anim@user}{end}{% + \@anim@end{#1}% +} %macro to reset macros and booleans \def\@anim@reset{% @@ -1408,11 +1579,18 @@ \let\if@anim@palindrome=\if@anim@@palindrome% \let\if@anim@step=\if@anim@@step% \gdef\@anim@posterocg{}% + \gdef\@anim@properties{}% + \gdef\@anim@xobject{}% + \gdef\@anim@content{}% \setboolean{@anim@pauseframes}{false}% \gdef\@anim@pauseat{}% \setboolean{@anim@chfps}{false}% \gdef\@anim@nfpsat{}% \gdef\@anim@pfpsat{}% + \gdef\@anim@tmlnfile{}% + \setboolean{@anim@timeline}{false}% + \@anim@begin={}% + \@anim@end={}% } %package options |