diff options
author | Karl Berry <karl@freefriends.org> | 2007-08-24 18:26:42 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2007-08-24 18:26:42 +0000 |
commit | 7e5d4a6894005a55af8ca409356fff320be6dde3 (patch) | |
tree | aa0144262f353f5dc67f4538edcce09fc70033b0 /Master/texmf-dist/tex/latex/animate | |
parent | f7ddc9080facd61f95673362b5af441285d284fc (diff) |
animate update (23aug07)
git-svn-id: svn://tug.org/texlive/trunk@4788 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 | 732 |
1 files changed, 512 insertions, 220 deletions
diff --git a/Master/texmf-dist/tex/latex/animate/animate.sty b/Master/texmf-dist/tex/latex/animate/animate.sty index 6001e2f51aa..98bfe2d76bb 100644 --- a/Master/texmf-dist/tex/latex/animate/animate.sty +++ b/Master/texmf-dist/tex/latex/animate/animate.sty @@ -13,10 +13,11 @@ % Supports LaTeX->dvips->ps2pdf or pdfLaTeX workflows. \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{animate}[2007/07/04] +\ProvidesPackage{animate}[2007/08/23] \RequirePackage{keyval} \RequirePackage{ifthen} \RequirePackage{ifpdf} +\RequirePackage{ifdraft} \RequirePackage{calc} \DeclareOption*{}\ProcessOptions*\relax %allow anything as option @@ -119,15 +120,13 @@ \fi \newbox\@anim@box %stores animation frames -\newdimen\@anim@tmpdima %length register for occasional use +\newdimen\@anim@tmpdima %length registers for occasional use +\newdimen\@anim@tmpdimb %creates Form XObject from graphics file \def\@anim@pt{pt} \ifpdf \def\@anim@ximage#1#2#3{%#1:@anim@num, #2:@anim@curframe@zb, #3:filename - \IfFileExists{#3}{}{% - \PackageError{animate}{File `#3' cannot be opened for embedding.}{}% - }% %store file in a box \def\@anim@mps{.mps}% \ifx\@anim@ext\@anim@mps% @@ -135,15 +134,12 @@ \else% \immediate\pdfximage{#3}% \global\setbox\@anim@box=\hbox{\pdfrefximage\pdflastximage}% - \fi + \fi% %delegate Form XObject creation \@anim@xinline{#1}{#2}{\@anim@box}% } \else \def\@anim@ximage#1#2#3{% - \IfFileExists{#3}{}{% - \PackageError{animate}{File `#3' cannot be opened for embedding.}{}% - }% %store file in a box \edef\@anim@curfile{{#3}}% \global\setbox\@anim@box=\hbox{\expandafter\includegraphics\@anim@curfile}% @@ -292,11 +288,7 @@ \setlength{\unitlength}{1pt}% \global\setbox\@anim@box=\hbox{% \pdfliteral{q}% - \begin{picture}(% - \@anim@animwidth,\@anim@animtotalheight% - )(% - 0,-\@anim@animdepth% - )% + \begin{picture}(\@anim@animwidth,\@anim@animtotalheight)% \end{picture}% \pdfliteral{Q\@anim@content}% }% @@ -326,8 +318,8 @@ %create container XObjects for play & pause button faces; \ifpdf - \def\@anim@makeppcontainer#1#2{% #1: @anim@num, #2: Right or Left - %OCGs + \def\@anim@makeppcontainer#1#2#3{% #1: @anim@num, #2: Right or Left, + %OCGs #3: index of existing button face colour combination \immediate\pdfobj{<</Type/OCG /Name (#1.Play#2)>>}% \edef\@anim@playocg{\the\pdflastobj\space 0 R}% \immediate\pdfobj{<< /Type/OCG /Name (#1.Pause#2)>>}% @@ -342,8 +334,8 @@ /Resources <<% /Properties <</oc0 \@anim@playocg /oc1 \@anim@pauseocg>>% /XObject <<% - /im0 \@anim@getkeyval{btnPlay#2} - /im1 \@anim@getkeyval{btnPause#2}% + /im0 \@anim@getkeyval{btnPlay#2:#3} + /im1 \@anim@getkeyval{btnPause#2:#3}% >>% >>% }{% @@ -352,7 +344,7 @@ \@anim@newkey{btn#1.PlayPause#2}{\the\pdflastobj\space 0 R}% } \else - \def\@anim@makeppcontainer#1#2{% + \def\@anim@makeppcontainer#1#2#3{% \special{ps: %OCGs mark /_objdef {#1.Play#2} /type/dict /OBJ pdfmark @@ -379,8 +371,8 @@ /Resources <<% /Properties <</oc0 {#1.Play#2} /oc1 {#1.Pause#2}>>% /XObject <<% - /im0 {btnPlay#2} - /im1 {btnPause#2}% + /im0 {btnPlay#2:#3} + /im1 {btnPause#2:#3}% >>% >>% >> /PUT pdfmark @@ -392,10 +384,11 @@ \ifpdf %stroking commands \def\@anim@btnend{% + \@anim@bg\space 2.5 w 1 J 1 j - 0 G + \@anim@fg\space 10 10 130 130 re S 10 w @@ -409,10 +402,11 @@ S } \def\@anim@btnstep{% + \@anim@bg\space 2.5 w 1 J 1 j - 0 G + \@anim@fg\space 10 10 130 130 re S 10 w @@ -422,10 +416,11 @@ S } \def\@anim@btnplay{% + \@anim@bg\space 2.5 w 1 J 1 j - 0 G + \@anim@fg\space 10 10 130 130 re S 10 w @@ -436,9 +431,10 @@ S } \def\@anim@btnpause{% + \@anim@bg\space 2.5 w 1 j - 0 G + \@anim@fg\space 0 10 m 140 10 l 140 140 l @@ -450,10 +446,11 @@ S } \def\@anim@btnminus{% + \@anim@bg\space 2.5 w 1 J 1 j - 0 G + \@anim@fg\space 10 10 130 130 re S 10 w @@ -463,10 +460,11 @@ S } \def\@anim@btnplus{% + \@anim@bg\space 2.5 w 1 J 1 j - 0 G + \@anim@fg\space 10 10 130 130 re S 10 w @@ -478,17 +476,18 @@ S } \def\@anim@btnreset{% + \@anim@bg\space 2.5 w 1 J 1 j - 0 G + \@anim@fg\space 10 10 130 130 re S 10 w 75 40 m 75 110 l S - 0 g + \@anim@@@fg\space 35 50 m 70 75 l 35 100 l @@ -505,62 +504,63 @@ 115 75 l S } - \def\@anim@makebuttons{% + \def\@anim@makebuttons#1{% \@anim@xbutton{EndLeft}{% q -0.1 0 0 0.1 15 0 cm \@anim@btnend\space Q% - }% + }{#1}% \@anim@xbutton{EndRight}{% q 0.1 0 0 0.1 0 0 cm \@anim@btnend\space Q% - }% + }{#1}% \@anim@xbutton{Minus}{% q 0.1 0 0 0.1 0 0 cm \@anim@btnminus\space Q% - }% + }{#1}% \@anim@xbutton{PauseLeft}{% q -0.1 0 0 0.1 15 0 cm \@anim@btnpause\space Q% - }% + }{#1}% \@anim@xbutton{PauseRight}{% q 0.1 0 0 0.1 0 0 cm \@anim@btnpause\space Q% - }% + }{#1}% \@anim@xbutton{PlayLeft}{% q -0.1 0 0 0.1 15 0 cm \@anim@btnplay\space Q% - }% + }{#1}% \@anim@xbutton{PlayRight}{% q 0.1 0 0 0.1 0 0 cm \@anim@btnplay\space Q% - }% + }{#1}% \@anim@xbutton{Plus}{% q 0.1 0 0 0.1 0 0 cm \@anim@btnplus\space Q% - }% + }{#1}% \@anim@xbutton{Reset}{% q 0.1 0 0 0.1 0 0 cm \@anim@btnreset\space Q% - }% + }{#1}% \@anim@xbutton{StepLeft}{% q -0.1 0 0 0.1 15 0 cm \@anim@btnstep\space Q% - }% + }{#1}% \@anim@xbutton{StepRight}{% q 0.1 0 0 0.1 0 0 cm \@anim@btnstep\space Q% - }% + }{#1}% } %XObject creation - \def\@anim@xbutton#1#2{% #1 name, #2 stroking commands + \def\@anim@xbutton#1#2#3{% #1 name, #2 stroking commands, #3 @anim@num \immediate\pdfobj stream attr{% /Type/XObject/Subtype/Form/BBox [0 0 15 15]% }{#2}% - \@anim@newkey{btn#1}{\the\pdflastobj\space 0 R}% + \@anim@newkey{btn#1:#3}{\the\pdflastobj\space 0 R}% } \else \def\@anim@btnend{% - 0 setgray + \@anim@bg\space + \@anim@fg\space 0.25 setlinewidth 1 setlinecap 1 setlinejoin @@ -581,7 +581,8 @@ stroke } \def\@anim@btnstep{% - 0 setgray + \@anim@bg\space + \@anim@fg\space 0.25 setlinewidth 1 setlinecap 1 setlinejoin @@ -598,7 +599,8 @@ stroke } \def\@anim@btnplay{% - 0 setgray + \@anim@bg\space + \@anim@fg\space 0.25 setlinewidth 1 setlinecap 1 setlinejoin @@ -616,7 +618,8 @@ stroke } \def\@anim@btnpause{% - 0 setgray + \@anim@bg\space + \@anim@fg\space 0.25 setlinewidth 0 setlinecap 1 setlinejoin @@ -631,7 +634,8 @@ stroke } \def\@anim@btnminus{% - 0 setgray + \@anim@bg\space + \@anim@fg\space 0.25 setlinewidth 1 setlinecap 1 setlinejoin @@ -648,7 +652,8 @@ stroke } \def\@anim@btnplus{% - 0 setgray + \@anim@bg\space + \@anim@fg\space 0.25 setlinewidth 1 setlinecap 1 setlinejoin @@ -667,7 +672,8 @@ stroke } \def\@anim@btnreset{% - 0 setgray + \@anim@bg\space + \@anim@fg\space 0.25 setlinewidth 1 setlinecap 1 setlinejoin @@ -700,50 +706,50 @@ 11.5 7.5 lineto stroke } - \def\@anim@makebuttons{% + \def\@anim@makebuttons#1{% #1: @anim@num \@anim@xbutton{EndLeft}{% [-1 0 0 1 15 0] concat \@anim@btnend% - }% + }{#1}% \@anim@xbutton{EndRight}{% \@anim@btnend% - }% + }{#1}% \@anim@xbutton{Minus}{% \@anim@btnminus% - }% + }{#1}% \@anim@xbutton{PauseLeft}{% [-1 0 0 1 15 0] concat \@anim@btnpause% - }% + }{#1}% \@anim@xbutton{PauseRight}{% \@anim@btnpause% - }% + }{#1}% \@anim@xbutton{PlayLeft}{% [-1 0 0 1 15 0] concat \@anim@btnplay% - }% + }{#1}% \@anim@xbutton{PlayRight}{% \@anim@btnplay% - }% + }{#1}% \@anim@xbutton{Plus}{% \@anim@btnplus% - }% + }{#1}% \@anim@xbutton{Reset}{% \@anim@btnreset% - }% + }{#1}% \@anim@xbutton{StepLeft}{% [-1 0 0 1 15 0] concat \@anim@btnstep% - }% + }{#1}% \@anim@xbutton{StepRight}{% \@anim@btnstep% - }% + }{#1}% } - \def\@anim@xbutton#1#2{% #1: name; #2: stroking commands + \def\@anim@xbutton#1#2#3{% #1: name; #2: stroking commands, #3 @anim@num \special{ps: gsave mark - /_objdef {btn#1} + /_objdef {btn#1:#3} /BBox [0 0 15 15] /BP pdfmark { #2 } ?pdfmark mark /EP pdfmark grestore @@ -809,8 +815,98 @@ \newcount\@anim@curframe \newcount\@anim@curframe@zb% zero based -\newboolean{@anim@buttonsmade} %true if button faces have been made -\setboolean{@anim@buttonsmade}{false} +%draftbox from file +\ifpdf + \def\@anim@filedraftbox#1{% #1: filename + %store file in a box + \def\@anim@mps{.mps}% + \ifx\@anim@ext\@anim@mps% + \global\setbox\@anim@box=\hbox{\convertMPtoPDF{#1}{1}{1}}% + \else% + \immediate\pdfximage{#1}% + \global\setbox\@anim@box=\hbox{\pdfrefximage\pdflastximage}% + \fi% + \@anim@draftbox{\@anim@box}% draw draft box with controls (if set) + } +\else + \def\@anim@filedraftbox#1{% + \edef\@anim@curfile{{#1}}% + \global\setbox\@anim@box=\hbox{\expandafter\includegraphics\@anim@curfile}% + \@anim@draftbox{\@anim@box}% + } +\fi + +%draftbox from savebox (lowlevel macro) +\def\@anim@draftbox#1{% #1: box number + %get size + \xdef\@anim@animwidth{\strip@pt\wd#1}% + \xdef\@anim@animheight{\strip@pt\ht#1}% + \xdef\@anim@animdepth{\strip@pt\dp#1}% + \setlength{\@anim@tmpdima}{\ht#1}% + \addtolength{\@anim@tmpdima}{\dp#1}% + \xdef\@anim@animtotalheight{\strip@pt\@anim@tmpdima}% + \@anim@rescale% rescale box + \edef\@anim@oldunitlength{\the\unitlength}% + \setlength{\unitlength}{1pt}% + \vtop{% draw boxes + \offinterlineskip% + \hbox{% + \raisebox{-\@anim@animdepth\@anim@pt}{% + \begin{picture}(\@anim@animwidth,\@anim@animtotalheight)% + \put(0,0){\framebox(\@anim@animwidth,\@anim@animtotalheight){}}% + \end{picture}% + }% + }% + \if@anim@controls% + \setlength{\@anim@tmpdima}{\@anim@btnsize}% + \vskip 0.1\@anim@tmpdima% + \hbox to \@anim@animwidth\@anim@pt {% + \hss% + \setlength{\@anim@tmpdimb}{2\@anim@tmpdima}% + \begin{picture}(\strip@pt\@anim@tmpdimb,\strip@pt\@anim@tmpdima)% + \put(0,0){\line(1,0){\strip@pt\@anim@tmpdimb}}% + \put(0,\strip@pt\@anim@tmpdima){% + \line(1,0){\strip@pt\@anim@tmpdimb}% + }% + \put(0,0){\line(0,1){\strip@pt\@anim@tmpdima}}% + \end{picture}% + \if@anim@step\else% + \begin{picture}(\strip@pt\@anim@tmpdimb,\strip@pt\@anim@tmpdima)% + \put(0,0){\line(1,0){\strip@pt\@anim@tmpdimb}}% + \put(0,\strip@pt\@anim@tmpdima){% + \line(1,0){\strip@pt\@anim@tmpdimb}% + }% + \end{picture}% + \fi% + \begin{picture}(\strip@pt\@anim@tmpdimb,\strip@pt\@anim@tmpdima)% + \put(0,0){\line(1,0){\strip@pt\@anim@tmpdimb}}% + \put(0,\strip@pt\@anim@tmpdima){% + \line(1,0){\strip@pt\@anim@tmpdimb}% + }% + \put(\strip@pt\@anim@tmpdimb,0){% + \line(0,1){\strip@pt\@anim@tmpdima}% + }% + \end{picture}% + \if@anim@step\else% + \hskip 0.3\@anim@tmpdima% + \setlength{\@anim@tmpdimb}{3\@anim@tmpdima}% + \begin{picture}(\strip@pt\@anim@tmpdimb,\strip@pt\@anim@tmpdima)% + \put(0,0){\line(0,1){\strip@pt\@anim@tmpdima}}% + \put(0,0){\line(1,0){\strip@pt\@anim@tmpdimb}}% + \put(0,\strip@pt\@anim@tmpdima){% + \line(1,0){\strip@pt\@anim@tmpdimb}% + }% + \put(\strip@pt\@anim@tmpdimb,0){% + \line(0,1){\strip@pt\@anim@tmpdima}% + }% + \end{picture}% + \fi% + \hss% + }% + \fi% + \setlength{\unitlength}{\@anim@oldunitlength}% + }% +} %user command for embedding animation sequence % #1: options @@ -829,74 +925,86 @@ \def\@anim@first{#4}% \def\@anim@last{#5}% % - \if@anim@controls% - %create button faces if necessary - \if@anim@buttonsmade\else% - \@anim@makebuttons% - \setboolean{@anim@buttonsmade}{true}% - \fi% - \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}% - \xdef\@anim@pauseat{}% - \xdef\@anim@nfpsat{}% - \xdef\@anim@pfpsat{}% - % - %read all frames of the sequence \@anim@curframe=\@anim@first% \@anim@curframe@zb=0% - \loop\ifnum\@anim@curframe>\@anim@last\else% - %get file name extension of current file - \@anim@getext{% - \@anim@base\@anim@pad{\@anim@first}{\the\@anim@curframe}% - }% - %embed graphics - \@anim@ximage{\the\@anim@num}{\the\@anim@curframe@zb}{% - \@anim@base\@anim@pad{\@anim@first}{\the\@anim@curframe}\@anim@ext% - }% - \advance\@anim@curframe by 1% - \advance\@anim@curframe@zb by 1% - \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}% + \if@anim@draft% + %test for existence of all files of the sequence + \loop\ifnum\@anim@curframe>\@anim@last\else% + %get file name extension of current file (also tests for existence) + \@anim@getext{% + \@anim@base\@anim@pad{\@anim@first}{\the\@anim@curframe}% + }% + \advance\@anim@curframe by 1% + \advance\@anim@curframe@zb by 1% + \repeat% + %draw draftbox according to dimensions of the first frame + \@anim@filedraftbox{\@anim@base\@anim@first\@anim@ext}% + \else% + \if@anim@controls% + %create button faces only once in the current colour combination + \expandafter\ifx\csname + btncol:\@anim@bgcolour:\@anim@fgcolour\endcsname\relax% + \@anim@makebuttons{\the\@anim@num}% + \@anim@newkey{btncol:\@anim@bgcolour:\@anim@fgcolour}{\the\@anim@num}% + \fi% + \if@anim@step\else% + %combine Pause & Play button faces into one XObject + \@anim@makeppcontainer{\the\@anim@num}{Right}{% + \@anim@getkeyval{btncol:\@anim@bgcolour:\@anim@fgcolour}}% + \@anim@makeppcontainer{\the\@anim@num}{Left}{% + \@anim@getkeyval{btncol:\@anim@bgcolour:\@anim@fgcolour}}% + \fi% + \fi% + \xdef\@anim@fps{#2}% current frame rate + \xdef\@anim@nfps{#2}% + % + %read all frames of the sequence + \loop\ifnum\@anim@curframe>\@anim@last\else% + %get file name extension of current file + \@anim@getext{% + \@anim@base\@anim@pad{\@anim@first}{\the\@anim@curframe}% + }% + %embed graphics + \@anim@ximage{\the\@anim@num}{\the\@anim@curframe@zb}{% + \@anim@base\@anim@pad{\@anim@first}{\the\@anim@curframe}\@anim@ext% + }% + \advance\@anim@curframe by 1% + \advance\@anim@curframe@zb by 1% + \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}{% + \@anim@getkeyval{btncol:\@anim@bgcolour:\@anim@fgcolour}}% + \fi% \global\advance\@anim@num by 1% }% -%insert the animation and control button widgets -\def\@anim@insertwidgets#1{%#1:@anim@num +%inserts animation and control button widgets +\def\@anim@insertwidgets#1#2{%#1:@anim@num, #2 existing btn colour combination \vtop{% \offinterlineskip% \hbox{\@anim@animwidget{#1}}% \if@anim@controls% \setlength{\@anim@tmpdima}{\@anim@btnsize}% - \setlength{\@anim@tmpdima}{0.1\@anim@tmpdima}% - \vskip \@anim@tmpdima% + \vskip 0.1\@anim@tmpdima% \hbox to \@anim@animwidth\@anim@pt {% \hss% - \@anim@buttonwidget{#1}{EndLeft}{EndLeft}% - \@anim@buttonwidget{#1}{StepLeft}{StepLeft}% + \@anim@buttonwidget{#1}{EndLeft}{EndLeft:#2}% + \@anim@buttonwidget{#1}{StepLeft}{StepLeft:#2}% \if@anim@step\else% \@anim@buttonwidget{#1}{PlayPauseLeft}{#1.PlayPauseLeft}% \@anim@buttonwidget{#1}{PlayPauseRight}{#1.PlayPauseRight}% \fi% - \@anim@buttonwidget{#1}{StepRight}{StepRight}% - \@anim@buttonwidget{#1}{EndRight}{EndRight}% + \@anim@buttonwidget{#1}{StepRight}{StepRight:#2}% + \@anim@buttonwidget{#1}{EndRight}{EndRight:#2}% \if@anim@step\else% - \setlength{\@anim@tmpdima}{\@anim@btnsize}% - \setlength{\@anim@tmpdima}{0.3\@anim@tmpdima}% - \hskip \@anim@tmpdima% - \@anim@buttonwidget{#1}{Minus}{Minus}% - \@anim@buttonwidget{#1}{Reset}{Reset}% - \@anim@buttonwidget{#1}{Plus}{Plus}% + \hskip 0.3\@anim@tmpdima% + \@anim@buttonwidget{#1}{Minus}{Minus:#2}% + \@anim@buttonwidget{#1}{Reset}{Reset:#2}% + \@anim@buttonwidget{#1}{Plus}{Plus:#2}% \fi% \hss% }% @@ -963,6 +1071,9 @@ \setlength{\@anim@tmpdima}{\@anim@animdepth\@anim@pt}% \setlength{\@anim@tmpdima}{\@anim@boxscale\@anim@tmpdima}% \xdef\@anim@animdepth{\strip@pt\@anim@tmpdima}% + \setlength{\@anim@tmpdima}{\@anim@animheight\@anim@pt}% + \addtolength{\@anim@tmpdima}{\@anim@animdepth\@anim@pt}% + \xdef\@anim@animtotalheight{\strip@pt\@anim@tmpdima}% } %creates animation widget @@ -991,7 +1102,6 @@ /T (anm@#1)% /MK <<% /TP 1% icon, no caption - /BG [\@anim@bg]% /IF <</SW/A/S/A>>% scale icon freely within widget >>% /AA <<% bind JavaScripts to trigger events @@ -1044,7 +1154,6 @@ /T (anm@#1)% /MK <<% /TP 1 - /BG [\@anim@bg]% /IF <</SW/A/S/A>>% >>% /AA <<% @@ -1081,7 +1190,6 @@ /T (btn@#1@#2)% /MK <<% /TP 1% - /BG [\@anim@btnbg]% /IF <</SW/A/S/A>>% scale button face icon freely within widget >>% /A <</S/JavaScript/JS (\@anim@upjscriptstring)>>% @@ -1120,7 +1228,6 @@ /T (btn@#1@#2)% /MK << /TP 1 - /BG [\@anim@btnbg] /IF <</SW/A/S/A>> >>% /A <</S/JavaScript/JS (\@anim@upjscriptstring)>>% @@ -1147,20 +1254,24 @@ \setboolean{@anim@inside}{true}% \@anim@reset% to default settings \setkeys{anim@user}{#1}% - %create button faces if necessary - \if@anim@controls% - \if@anim@buttonsmade\else% - \@anim@makebuttons% - \setboolean{@anim@buttonsmade}{true}% - \fi% - \if@anim@step\else% - %combine Pause & Play button faces into one XObject - \@anim@makeppcontainer{\the\@anim@num}{Right}% - \@anim@makeppcontainer{\the\@anim@num}{Left}% + \if@anim@draft\else% + %create button faces if necessary + \if@anim@controls% + \expandafter\ifx\csname + btncol:\@anim@bgcolour:\@anim@fgcolour\endcsname\relax% + \@anim@makebuttons{\the\@anim@num}% + \@anim@newkey{btncol:\@anim@bgcolour:\@anim@fgcolour}{\the\@anim@num}% + \fi% + \if@anim@step\else% + \@anim@makeppcontainer{\the\@anim@num}{Right}{% + \@anim@getkeyval{btncol:\@anim@bgcolour:\@anim@fgcolour}}% + \@anim@makeppcontainer{\the\@anim@num}{Left}{% + \@anim@getkeyval{btncol:\@anim@bgcolour:\@anim@fgcolour}}% + \fi% \fi% + \xdef\@anim@fps{#2}% + \xdef\@anim@nfps{#2}% current frame rate (for use in \newframe) \fi% - \xdef\@anim@fps{#2}% - \xdef\@anim@nfps{#2}% current frame rate (for use in \newframe) \global\@anim@curframe@zb=0% \@anim@beginframe% \ignorespaces% @@ -1168,12 +1279,15 @@ \unskip% \@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 - \@anim@insertwidgets{\the\@anim@num}% + \if@anim@draft\else% + \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}{% + \@anim@getkeyval{btncol:\@anim@bgcolour:\@anim@fgcolour}}% + \fi% \global\advance\@anim@num by 1% \setboolean{@anim@inside}{false}% } @@ -1191,33 +1305,30 @@ \@anim@endframe{\the\@anim@num}{\the\@anim@curframe@zb}% \@ifstar\@anim@newframestar\@anim@newframe% } -\newcommand{\@anim@newframestar}[1][]{% starred variant to pause animation - \if@anim@step\else% % #1: new frame rate - \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@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}% +\newcommand{\@anim@newframe}[1][]{% #1: new frame rate + \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% + \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% - %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% @@ -1225,27 +1336,36 @@ \@anim@beginframe% \ignorespaces% } -\newcommand{\@anim@newframe}[1][]{% #1: new frame rate - \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% - \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);% +\newcommand{\@anim@newframestar}[1][]{% starred variant for pauseing animation + \if@anim@draft\else% #1: new frame rate + \if@anim@step\else% + \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% \fi% @@ -1254,9 +1374,9 @@ \ignorespaces% } -%starts a new frame +%starts new frame \def\@anim@beginframe{% - \begin{lrbox}{\@anim@box}% store the graphics in a box + \begin{lrbox}{\@anim@box}% store graphics in a box \the\@anim@begin% } @@ -1264,7 +1384,7 @@ \def\@anim@endframe#1#2{% \the\@anim@end% \end{lrbox}% - \message{< a#1, fr#2}% + \if@anim@draft\else\message{< a#1, fr#2}\fi% %determine size of graphics \ifnum #2=0% \xdef\@anim@animwidth{\strip@pt\wd\@anim@box}% @@ -1285,10 +1405,11 @@ }{}% \fi% \fi% + %draw draftbox according to dimensions of the first frame + \if@anim@draft\@anim@draftbox{\@anim@box}\fi% \fi% %now create Form XObject of box contents - \@anim@xinline{#1}{#2}{\@anim@box}% - \message{>}% + \if@anim@draft\else\@anim@xinline{#1}{#2}{\@anim@box}\message{>}\fi% } %prints zero padded integers @@ -1325,7 +1446,7 @@ \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) + %read timeline file a first time to get number of lines (= number of frames) \openin\@anim@@tmlnfile=\@anim@tmlnfile% \read\@anim@@tmlnfile to \@anim@inputline% \edef\@anim@inputline{\@anim@inputline\space}% @@ -1346,7 +1467,7 @@ \setboolean{@anim@eof}{false}\fi% }% \closein\@anim@@tmlnfile% - \xdef\@anim@images{\@anim@frames}% total number of images + \xdef\@anim@transp{\@anim@frames}% total number of transp \xdef\@anim@frames{\the\@anim@curframe@zb}% total number of anim positions \global\@anim@curframe@zb=0% %reopen timeline file and build timeline @@ -1413,11 +1534,11 @@ \@anim@parsethird#3,:;% } -%parses 3rd column of timeline file (comma separated list of image specs) +%parses 3rd column of timeline file (comma separated list of transp. specs) \def\@anim@parsethird#1,#2;{% \def\@anim@firstarg{#1}% \ifx\@anim@firstarg\@empty\else% - \@anim@process#1x:;% process one image spec + \@anim@process#1x:;% process one transparency spec \fi% \ifx #2:\else% \@anim@parsethird#2;% @@ -1425,9 +1546,10 @@ } \newcount\@anim@tmpcnt %scratch counter for different uses -%process image spec, such as 123 or 456x78 or 9x0 + +%process transparency spec, such as 123 or 456x78 or 9x0 \def\@anim@process#1x#2;{% - %determine number of repetitions of current image + %determine number of repetitions of current transparency \ifx #2:% \gdef\@anim@repeats{1}% \else% @@ -1444,9 +1566,9 @@ \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% + %build contents of animation frames according to transparency specifications + \ifnum\@anim@transp<#1\else% ignore non-existing transparencies + \ifnum\@anim@transp=#1\else% \@anim@tmpcnt=\@anim@curframe@zb% \loop\ifnum\@anim@repeatuntil>\@anim@tmpcnt% \@anim@newkey{@anim@content@\the\@anim@tmpcnt}{% @@ -1481,15 +1603,97 @@ \define@key{anim@user}{scale}{% \gdef\@anim@boxscale{#1}% } - -\define@key{anim@user}{screenbg}{%background colour - \gdef\@anim@bg{#1}% -} \define@key{anim@user}{buttonsize}{% \gdef\@anim@btnsize{#1}% } -\define@key{anim@user}{buttonbg}{%background of buttons - \gdef\@anim@btnbg{#1}% +\def\@anim@colours#1:#2;{% helper macro to get number of colour components and + \xdef\@anim@colour{\@anim@colour\space #1}% to replace : by ` ' in the arg + \ifx #2!\else% + \global\advance\@anim@tmpcnt by 1% + \@anim@colours#2;% + \fi% +} +\ifpdf %background frame of buttons + \def\@anim@@@bg{% + 0 j + 0 0 150 150 re + f% + } +\else + \def\@anim@@@bg{% + 0 setlinejoin + 0 0 moveto + 15 0 lineto + 15 15 lineto + 0 15 lineto + closepath + fill% + } +\fi +\define@key{anim@user}{buttonbg}{%background colour of buttons + \global\@anim@tmpcnt=1% + \gdef\@anim@colour{}% + \@anim@colours#1:!;% + \xdef\@anim@bgcolour{\@anim@colour}% + \ifpdf% + \ifnum\@anim@tmpcnt=1 + \xdef\@anim@bg{\@anim@colour\space g\space\@anim@@@bg}% + \else% + \ifnum\@anim@tmpcnt=3 + \xdef\@anim@bg{\@anim@colour\space rg\space\@anim@@@bg}% + \else% + \ifnum\@anim@tmpcnt=4 + \xdef\@anim@bg{\@anim@colour\space k\space\@anim@@@bg}% + \fi% + \fi% + \fi% + \else% + \ifnum\@anim@tmpcnt=1 + \xdef\@anim@bg{\@anim@colour\space setgray\space\@anim@@@bg}% + \else% + \ifnum\@anim@tmpcnt=3 + \xdef\@anim@bg{\@anim@colour\space setrgbcolor\space\@anim@@@bg}% + \else% + \ifnum\@anim@tmpcnt=4 + \xdef\@anim@bg{\@anim@colour\space setcmykcolor\space\@anim@@@bg}% + \fi% + \fi% + \fi% + \fi% +} +\define@key{anim@user}{buttonfg}{%stroking colour of buttons + \global\@anim@tmpcnt=1% + \gdef\@anim@colour{}% + \@anim@colours#1:!;% + \xdef\@anim@fgcolour{\@anim@colour}% + \ifpdf% + \ifthenelse{\the\@anim@tmpcnt=1}{% + \xdef\@anim@fg{\@anim@colour\space G}% + \xdef\@anim@@@fg{\@anim@colour\space g}% + }{% + \ifthenelse{\the\@anim@tmpcnt=3}{% + \xdef\@anim@fg{\@anim@colour\space RG}% + \xdef\@anim@@@fg{\@anim@colour\space rg}% + }{% + \ifthenelse{\the\@anim@tmpcnt=4}{% + \xdef\@anim@fg{\@anim@colour\space K}% + \xdef\@anim@@@fg{\@anim@colour\space k}% + }{}% + }% + }% + \else% + \ifthenelse{\the\@anim@tmpcnt=1}{% + \xdef\@anim@fg{\@anim@colour\space setgray}% + }{% + \ifthenelse{\the\@anim@tmpcnt=3}{% + \xdef\@anim@fg{\@anim@colour\space setrgbcolor}% + }{% + \ifthenelse{\the\@anim@tmpcnt=4}{% + \xdef\@anim@fg{\@anim@colour\space setcmykcolor}% + }{}% + }% + }% + \fi% } \newboolean{@anim@controls} \setboolean{@anim@controls}{false} @@ -1505,9 +1709,7 @@ \setboolean{@anim@autoplay}{false} \define@key{anim@user}{autoplay}[true]{% \setboolean{@anim@autoplay}{#1}% - \if@anim@autoplay - \setboolean{@anim@autoresume}{false} - \fi% + \if@anim@autoplay\setboolean{@anim@autoresume}{false}\fi% } \newboolean{@anim@autoresume} \setboolean{@anim@autoresume}{false} @@ -1541,6 +1743,18 @@ \define@key{anim@user}{step}[true]{% \setboolean{@anim@step}{#1}% } +\newboolean{@anim@draft} +\setboolean{@anim@draft}{false} +\define@key{anim@user}{draft}[true]{% + \setboolean{@anim@draft}{#1}% +} +\define@key{anim@user}{final}[true]{% + \ifthenelse{\equal{#1}{true}}{% + \setboolean{@anim@draft}{false}% + }{% + \setboolean{@anim@draft}{true}% + }% +} \define@key{anim@user}{timeline}{% \IfFileExists{#1}{% \gdef\@anim@tmlnfile{#1}% @@ -1568,7 +1782,10 @@ \gdef\@anim@boxheight{}% \gdef\@anim@boxwidth{}% \xdef\@anim@bg{\@anim@@bg}% - \xdef\@anim@btnbg{\@anim@@btnbg}% + \xdef\@anim@fg{\@anim@@fg}% + \ifpdf\xdef\@anim@@@fg{\@anim@@@@fg}\fi% + \xdef\@anim@bgcolour{\@anim@@bgcolour}% default button colours + \xdef\@anim@fgcolour{\@anim@@fgcolour}% \xdef\@anim@btnsize{\@anim@@btnsize}% \xdef\@anim@poster{\@anim@@poster}% \let\if@anim@controls=\if@anim@@controls% @@ -1578,6 +1795,7 @@ \let\if@anim@autopause=\if@anim@@autopause% \let\if@anim@palindrome=\if@anim@@palindrome% \let\if@anim@step=\if@anim@@step% + \let\if@anim@draft=\if@anim@@draft% \gdef\@anim@posterocg{}% \gdef\@anim@properties{}% \gdef\@anim@xobject{}% @@ -1594,18 +1812,79 @@ } %package options -\def\@anim@@bg{}% -\define@key{anim@pkg}{screenbg}{% - \gdef\@anim@@bg{#1}% +\def\@anim@@bg{} +\def\@anim@@bgcolour{} +\define@key{anim@pkg}{buttonbg}{%background colour of buttons + \global\@anim@tmpcnt=1% + \gdef\@anim@colour{}% + \@anim@colours#1:!;% + \xdef\@anim@@bgcolour{\@anim@colour}% + \ifpdf% + \ifnum\@anim@tmpcnt=1 + \xdef\@anim@@bg{\@anim@colour\space g\space\@anim@@@bg}% + \else% + \ifnum\@anim@tmpcnt=3 + \xdef\@anim@@bg{\@anim@colour\space rg\space\@anim@@@bg}% + \else% + \ifnum\@anim@tmpcnt=4 + \xdef\@anim@@bg{\@anim@colour\space k\space\@anim@@@bg}% + \fi% + \fi% + \fi% + \else% + \ifnum\@anim@tmpcnt=1 + \xdef\@anim@@bg{\@anim@colour\space setgray\space\@anim@@@bg}% + \else% + \ifnum\@anim@tmpcnt=3 + \xdef\@anim@@bg{\@anim@colour\space setrgbcolor\space\@anim@@@bg}% + \else% + \ifnum\@anim@tmpcnt=4 + \xdef\@anim@@bg{\@anim@colour\space setcmykcolor\space\@anim@@@bg}% + \fi% + \fi% + \fi% + \fi% +} +\ifpdf\def\@anim@@fg{0 G}\def\@anim@@@@fg{0 g}\else\def\@anim@@fg{0 setgray}\fi +\def\@anim@@fgcolour{} +\define@key{anim@pkg}{buttonfg}{%stroking colour of buttons + \global\@anim@tmpcnt=1% + \gdef\@anim@colour{}% + \@anim@colours#1:!;% + \xdef\@anim@@fgcolour{\@anim@colour}% + \ifpdf% + \ifthenelse{\the\@anim@tmpcnt=1}{% + \xdef\@anim@@fg{\@anim@colour\space G}% + \xdef\@anim@@@@fg{\@anim@colour\space g}% + }{% + \ifthenelse{\the\@anim@tmpcnt=3}{% + \xdef\@anim@@fg{\@anim@colour\space RG}% + \xdef\@anim@@@@fg{\@anim@colour\space rg}% + }{% + \ifthenelse{\the\@anim@tmpcnt=4}{% + \xdef\@anim@@fg{\@anim@colour\space K}% + \xdef\@anim@@@@fg{\@anim@colour\space k}% + }{}% + }% + }% + \else% + \ifthenelse{\the\@anim@tmpcnt=1}{% + \xdef\@anim@@fg{\@anim@colour\space setgray}% + }{% + \ifthenelse{\the\@anim@tmpcnt=3}{% + \xdef\@anim@@fg{\@anim@colour\space setrgbcolor}% + }{% + \ifthenelse{\the\@anim@tmpcnt=4}{% + \xdef\@anim@@fg{\@anim@colour\space setcmykcolor}% + }{}% + }% + }% + \fi% } \def\@anim@@btnsize{1.44em}% \define@key{anim@pkg}{buttonsize}{% \gdef\@anim@@btnsize{#1}% } -\def\@anim@@btnbg{}% -\define@key{anim@pkg}{buttonbg}{% - \gdef\@anim@@btnbg{#1}% -} \newboolean{@anim@@controls} \setboolean{@anim@@controls}{false}% \define@key{anim@pkg}{controls}[true]{% @@ -1654,6 +1933,22 @@ \define@key{anim@pkg}{step}[true]{% \setboolean{@anim@@step}{#1}% } +\newboolean{@anim@@draft} +\ifdraft{%globally set by document class + \setboolean{@anim@@draft}{true}% +}{% + \setboolean{@anim@@draft}{false}% +}% +\define@key{anim@pkg}{draft}[true]{% + \setboolean{@anim@@draft}{#1}% +} +\define@key{anim@pkg}{final}[true]{% + \ifthenelse{\equal{#1}{true}}{% + \setboolean{@anim@@draft}{false}% + }{% + \setboolean{@anim@@draft}{true}% + }% +} %process package options \def\@anim@setpkgkeys#1{\setkeys{anim@pkg}{#1}} @@ -1664,21 +1959,18 @@ %animation widget's PageOpen event \ifpdf \def\@anim@pojscript#1{% - \gdef\@anim@posterlast{last}% - \gdef\@anim@posternone{none}% \immediate\pdfobj stream {\@anim@@pojscript{#1}}% \xdef\@anim@pojscriptobj{\the\pdflastobj\space 0 R}% } \else \def\@anim@pojscript#1{% - \gdef\@anim@posterlast{last}% - \gdef\@anim@posternone{none}% \special{ps: mark /_objdef {a#1@pojscript} /type/stream /OBJ pdfmark mark {a#1@pojscript} (\@anim@@pojscript{#1}) /PUT pdfmark }% } \fi +\def\@anim@posterlast{last}% helper macro \def\@anim@@pojscript#1{% #1: @anim@num % console.show();% % console.clear();% |