summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/animate
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2007-09-18 00:04:03 +0000
committerKarl Berry <karl@freefriends.org>2007-09-18 00:04:03 +0000
commit0bd3fcc7f83fc42a387d3b767020eb03edef4ddf (patch)
tree30735efc98587786b2b6391657bbae7bf8cdb71f /Master/texmf-dist/tex/latex/animate
parentb3ba06bdd353c1ba04d3b02cd88eb67e8c55a409 (diff)
animate update (17sep07)
git-svn-id: svn://tug.org/texlive/trunk@4964 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/animate')
-rw-r--r--Master/texmf-dist/tex/latex/animate/animate.sty269
1 files changed, 176 insertions, 93 deletions
diff --git a/Master/texmf-dist/tex/latex/animate/animate.sty b/Master/texmf-dist/tex/latex/animate/animate.sty
index 98bfe2d76bb..19cceb22321 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/08/23]
+\ProvidesPackage{animate}[2007/09/17]
\RequirePackage{keyval}
\RequirePackage{ifthen}
\RequirePackage{ifpdf}
@@ -123,37 +123,73 @@
\newdimen\@anim@tmpdima %length registers for occasional use
\newdimen\@anim@tmpdimb
-%creates Form XObject from graphics file
+\ifx\pdfmdfivesum\@undefined%
+ %tests whether file is known, if so it returns identifier of form xobj
+ %otherwise `!'
+ \def\@anim@fileknown#1{% #1 filename
+ %identify file by name
+ \expandafter\ifx\csname file:#1\endcsname\relax!%
+ \else\@anim@getkeyval{file:#1}\fi%
+ }
+ %helper macro that associates filename with identifier of xobject
+ \def\@anim@makefileknown#1#2{% #1 file name, #2 obj identifier
+ \@anim@newkey{file:#1}{#2}%
+ }
+\else
+ \def\@anim@fileknown#1{% #1 file name
+ %identify file by md5sum
+ \expandafter\ifx\csname file:\pdfmdfivesum file {#1}\endcsname\relax!%
+ \else\@anim@getkeyval{file:\pdfmdfivesum file {#1}}\fi%
+ }%
+ \def\@anim@makefileknown#1#2{%
+ \@anim@newkey{file:\pdfmdfivesum file {#1}}{#2}%
+ }
+\fi
+
\def\@anim@pt{pt}
+
\ifpdf
- \def\@anim@ximage#1#2#3{%#1:@anim@num, #2:@anim@curframe@zb, #3:filename
- %store file in a box
+ %helper macro that typesets graphics file into savebox
+ \def\@anim@filebox#1{% #1 filename
\def\@anim@mps{.mps}%
\ifx\@anim@ext\@anim@mps%
- \global\setbox\@anim@box=\hbox{\convertMPtoPDF{#3}{1}{1}}%
+ \global\setbox\@anim@box=\hbox{\convertMPtoPDF{#1}{1}{1}}%
\else%
- \immediate\pdfximage{#3}%
+ \pdfximage{#1}%
\global\setbox\@anim@box=\hbox{\pdfrefximage\pdflastximage}%
\fi%
- %delegate Form XObject creation
- \@anim@xinline{#1}{#2}{\@anim@box}%
}
\else
- \def\@anim@ximage#1#2#3{%
- %store file in a box
- \edef\@anim@curfile{{#3}}%
+ \def\@anim@filebox#1{% #1 filename
+ \edef\@anim@curfile{{#1}}%
\global\setbox\@anim@box=\hbox{\expandafter\includegraphics\@anim@curfile}%
- %delegate Form XObject creation
- \@anim@xinline{#1}{#2}{\@anim@box}%
}
\fi
+%create Form XObject from graphics file
+\def\@anim@ximage#1#2#3{%#1:@anim@num, #2:@anim@curframe@zb, #3:filename
+ \ifthenelse{\equal{\@anim@fileknown{#3}}{!}}{% new file to be embedded
+ \@anim@filebox{#3}% store file in a box
+ \@anim@xinline{#1}{#2}{\@anim@box}{!}% delegate Form XObject creation
+ \@anim@makefileknown{#3}{\@anim@lastxform}% keep form xobject number
+ }{% file known, re-use existing form xobject
+ \ifnum#2=0%
+ \@anim@filebox{#3}% for size determination of first frame
+ \@anim@xinline{#1}{#2}{\@anim@box}{\@anim@fileknown{#3}}%
+ \else%
+ \@anim@xinline{#1}{#2}{}{\@anim@fileknown{#3}}%
+ \fi%
+ }%
+}
+
\newboolean{@anim@timeline} %true if `timeline' option was set
%creates Form XObject from box contents and associates it with a newly
%created OCG
-\ifpdf
- \def\@anim@xinline#1#2#3{%#1:@anim@num, #2:@anim@curframe@zb, #3:box number
+\ifpdf%
+ %#1: @anim@num, #2:@anim@curframe@zb, #3: empty (`') or box number,
+ %#4: `!' or form xobj identifier
+ \def\@anim@xinline#1#2#3#4{%
\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}%
@@ -162,12 +198,20 @@
\addtolength{\@anim@tmpdima}{\dp#3}%
\xdef\@anim@animtotalheight{\strip@pt\@anim@tmpdima}%
\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%
- }%
+ \ifx #4!%
+ %put graphics into XObject
+ \setbox\@anim@box=\hbox{%
+ \raisebox{-\dp#3}[\@anim@animheight\@anim@pt]%
+ [\@anim@animdepth\@anim@pt]{\box#3}%
+ }%
+ \immediate\pdfxform\@anim@box%
+ \xdef\@anim@lastxform{\the\pdflastxform}%
+ \xdef\@anim@xobject{%XObject resource entry of container XObject
+ \@anim@xobject\space/im#2\space\@anim@lastxform\space 0 R%
+ }%
+ \else%
+ \xdef\@anim@xobject{\@anim@xobject\space/im#2\space #4\space 0 R}%
+ \fi%
\if@anim@timeline\else%
\@anim@newocg{#1}{#2}%new ocg
%compose content stream of container XObject
@@ -175,9 +219,9 @@
\@anim@content\space /OC/oc#2\space BDC q /im#2\space Do Q EMC%
}%
\fi%
- }
+ }
\else
- \def\@anim@xinline#1#2#3{%
+ \def\@anim@xinline#1#2#3#4{%
\ifnum#2=0%
\xdef\@anim@animwidth{\strip@pt\wd#3}%
\xdef\@anim@animheight{\strip@pt\ht#3}%
@@ -186,44 +230,68 @@
\addtolength{\@anim@tmpdima}{\dp#3}%
\xdef\@anim@animtotalheight{\strip@pt\@anim@tmpdima}%
\fi%
- \edef\@anim@oldunitlength{\the\unitlength}% make backup
- \setlength{\unitlength}{1pt}%
- %mark BBox of the graphics
- \begin{picture}(0,0)%
- \put(0,-\@anim@animdepth){%
+ \ifx #4!%
+ \begingroup%
+ \setlength{\unitlength}{1pt}%
+ %mark BBox of the graphics
+ \begin{picture}(0,0)%
+ \put(0,-\@anim@animdepth){%
+ \special{ps:
+ currentpoint /frame@lly exch def /frame@llx exch def
+ }%
+ }%
+ \put(\@anim@animwidth,\@anim@animheight){%
+ \special{ps:
+ currentpoint /frame@ury exch def /frame@urx exch def
+ }%
+ }%
+ \end{picture}%
+ \endgroup%
+ %distill graphics into XObject
\special{ps:
- currentpoint /frame@lly exch def /frame@llx exch def
+ gsave
+ mark
+ /_objdef {@anim@frm@#1@#2}
+ /BBox [frame@llx frame@lly frame@urx frame@ury]
+ /BP pdfmark
+ {%
+ isls{%landscape mode (powerdot, geometry /w landscape option)
+ /frame@dxdy {%
+ frame@urx frame@llx sub abs
+ frame@ury frame@lly sub abs div%
+ } bind def
+ /frame@dydx {1 frame@dxdy div} bind def
+ /frame@cx {frame@urx frame@llx add 2 div} bind def
+ /frame@cy {frame@ury frame@lly add 2 div} bind def
+ [% graphics needs to be rescaled for some reason ...
+ frame@dxdy 0 0 frame@dydx 1 frame@dxdy sub frame@cx mul
+ 1 frame@dydx sub frame@cy mul%
+ ] concat
+ %... rotated by 270 degrees ...
+ [0 -1 1 0 frame@cx frame@cy sub frame@cx frame@cy add] concat
+ %... and flipped around vertical axis
+ [-1 0 0 1 frame@llx frame@urx add 0] concat%
+ }{% flip around horizontal axis in portrait mode
+ [1 0 0 -1 0 frame@lly frame@ury add] concat%
+ }ifelse
+ } ?pdfmark
}%
- }%
- \put(\@anim@animwidth,\@anim@animheight){%
+ \begin{picture}(0,0)%
+ \put(0,0){\box#3}%
+ \end{picture}%
\special{ps:
- currentpoint /frame@ury exch def /frame@urx exch def
+ mark /EP pdfmark
+ grestore
}%
- }%
- \end{picture}%
- \setlength{\unitlength}{\@anim@oldunitlength}% restore previous unitlength
- %distill graphics into XObject
- \special{ps:
- gsave
- mark
- /_objdef {@anim@frm@#1@#2}
- /BBox [frame@llx frame@lly frame@urx frame@ury]
- /BP pdfmark
- %flip around horizontal axis
- { [1 0 0 -1 0 frame@lly frame@ury add ] concat } ?pdfmark
- }%
- \begin{picture}(0,0)%
- \put(0,0){\box#3}%
- \end{picture}%
- \special{ps:
- mark /EP pdfmark
- grestore
- }%
- %XObject resource entry of container XObject
- \xdef\@anim@xobject{%
- \@anim@xobject\space/im#2\space
- {@anim@frm@#1@#2}%
- }%
+ \xdef\@anim@lastxform{@anim@frm@#1@#2}%
+ \xdef\@anim@xobject{% XObject resource entry of container XObject
+ \@anim@xobject\space/im#2\space {@anim@frm@#1@#2}%
+ }%
+ \else%
+ \xdef\@anim@xobject{% XObject resource entry of container XObject
+ \@anim@xobject\space/im#2\space {#4}%
+ }%
+ \fi%
\if@anim@timeline\else%
\@anim@newocg{#1}{#2}% new ocg
%compose content stream of container XObject
@@ -262,10 +330,8 @@
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
}%
- %store ref to ocg if it is a poster
\ifnum#2=0%
\def\@anim@posterframe{first}%
\else%
@@ -274,7 +340,6 @@
\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}%
}%
@@ -284,7 +349,6 @@
%create XObject which contains all frames of the sequence
\ifpdf
\def\@anim@makecontainer#1{% #1:@anim@num
- \edef\@anim@oldunitlength{\the\unitlength}% make backup
\setlength{\unitlength}{1pt}%
\global\setbox\@anim@box=\hbox{%
\pdfliteral{q}%
@@ -292,7 +356,6 @@
\end{picture}%
\pdfliteral{Q\@anim@content}%
}%
- \setlength{\unitlength}{\@anim@oldunitlength}% restore previous unitlen
\immediate\pdfxform resources {%
/Properties <<\@anim@properties>>
/XObject <<\@anim@xobject>>
@@ -747,11 +810,19 @@
}
\def\@anim@xbutton#1#2#3{% #1: name; #2: stroking commands, #3 @anim@num
\special{ps:
- gsave
+ gsave [1 0 0 1 0 0] setmatrix
mark
/_objdef {btn#1:#3}
/BBox [0 0 15 15]
- /BP pdfmark { #2 } ?pdfmark mark /EP pdfmark
+ /BP pdfmark
+ {%
+ %landscape mode (powerdot, geometry /w landscape option)
+ isls{%
+ [0 -1 1 0 0 15] concat % rotate by 270 degrees
+ [-1 0 0 1 15 0] concat% flip around vertical axis
+ }if
+ #2
+ } ?pdfmark mark /EP pdfmark
grestore
}%
}
@@ -774,6 +845,12 @@
\IfFileExists{#1\@anim@ext}{}{%
\gdef\@anim@ext{.jb2}%
\IfFileExists{#1\@anim@ext}{}{%
+ \gdef\@anim@ext{.jp2}%
+ \IfFileExists{#1\@anim@ext}{}{%
+ \gdef\@anim@ext{.j2k}%
+ \IfFileExists{#1\@anim@ext}{}{%
+ \gdef\@anim@ext{.jpx}%
+ \IfFileExists{#1\@anim@ext}{}{%
\PackageError{animate}{%
Neither of the files\MessageBreak%
`#1.pdf',\MessageBreak%
@@ -781,12 +858,15 @@
`#1.png',\MessageBreak%
`#1.jpg',\MessageBreak%
`#1.jpeg',\MessageBreak%
- `#1.jbig2' or\MessageBreak%
+ `#1.jbig2',\MessageBreak%
`#1.jb2',\MessageBreak%
+ `#1.jp2',\MessageBreak%
+ `#1.j2k', or\MessageBreak%
+ `#1.jpx',\MessageBreak%
could be found.\MessageBreak%
Wrong file type? Mis-spelled file name?%
}{}%
- }}}}}}}%
+ }}}}}}}}}}%
}%
\else
\def\@anim@getext#1{%
@@ -823,7 +903,7 @@
\ifx\@anim@ext\@anim@mps%
\global\setbox\@anim@box=\hbox{\convertMPtoPDF{#1}{1}{1}}%
\else%
- \immediate\pdfximage{#1}%
+ \pdfximage{#1}%
\global\setbox\@anim@box=\hbox{\pdfrefximage\pdflastximage}%
\fi%
\@anim@draftbox{\@anim@box}% draw draft box with controls (if set)
@@ -846,7 +926,6 @@
\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%
@@ -904,7 +983,6 @@
\hss%
}%
\fi%
- \setlength{\unitlength}{\@anim@oldunitlength}%
}%
}
@@ -916,6 +994,7 @@
% #5: last frame (integer)
\newcommand{\animategraphics}[5][]{%
\leavevmode%
+ \begingroup%
\ifpdf\else%
\ifx\includegraphics\@undefined\@anim@missing{graphics}\fi%
\fi%
@@ -980,6 +1059,7 @@
\@anim@getkeyval{btncol:\@anim@bgcolour:\@anim@fgcolour}}%
\fi%
\global\advance\@anim@num by 1%
+ \endgroup%
}%
%inserts animation and control button widgets
@@ -1044,6 +1124,29 @@
}%
}%
\ifthenelse{\NOT\equal{\@anim@boxwidth}{}}{%rescale width
+ \ifthenelse{% depth missing
+ \NOT\equal{\@anim@boxheight}{}\AND%
+ \equal{\@anim@boxdepth}{}%
+ }{%
+ \setlength{\@anim@tmpdima}{%
+ \@anim@animtotalheight\@anim@pt%
+ *\ratio{\@anim@boxwidth\@anim@pt}{\@anim@animwidth\@anim@pt}%
+ }%
+ \setlength{\@anim@tmpdimb}{\@anim@tmpdima-\@anim@boxheight\@anim@pt}%
+ \xdef\@anim@animdepth{\strip@pt\@anim@tmpdimb}%
+ }{%
+ \ifthenelse{% height missing
+ \equal{\@anim@boxheight}{}\AND%
+ \NOT\equal{\@anim@boxdepth}{}%
+ }{%
+ \setlength{\@anim@tmpdima}{%
+ \@anim@animtotalheight\@anim@pt%
+ *\ratio{\@anim@boxwidth\@anim@pt}{\@anim@animwidth\@anim@pt}%
+ }%
+ \setlength{\@anim@tmpdimb}{\@anim@tmpdima-\@anim@boxdepth\@anim@pt}%
+ \xdef\@anim@animheight{\strip@pt\@anim@tmpdimb}%
+ }{}%
+ }%
\xdef\@anim@animwidth{\@anim@boxwidth}%
}{%
%if width is not given, but either height or depth are, scale
@@ -1100,10 +1203,6 @@
/H/N%
/AP <</N \@anim@container>>%
/T (anm@#1)%
- /MK <<%
- /TP 1% icon, no caption
- /IF <</SW/A/S/A>>% scale icon freely within widget
- >>%
/AA <<% bind JavaScripts to trigger events
/PO <</S/JavaScript/JS \@anim@pojscriptobj>>%
\@anim@otherjscriptkey%
@@ -1118,7 +1217,6 @@
\else
\def\@anim@animwidget#1{%
\@anim@rescale%
- \edef\@anim@oldunitlength{\the\unitlength}%
\setlength{\unitlength}{1pt}%
%mark annotation rectangle
\begin{picture}(0,0)%
@@ -1133,7 +1231,6 @@
}%
}%
\end{picture}%
- \setlength{\unitlength}{\@anim@oldunitlength}%
\@anim@pojscript{#1}%
\@anim@otherjscript{#1}%
\def\@anim@posterframe{none}%
@@ -1152,10 +1249,6 @@
/H/N%
/AP <</N {@anim@xobj#1}>>%
/T (anm@#1)%
- /MK <<%
- /TP 1
- /IF <</SW/A/S/A>>%
- >>%
/AA <<%
/PO <</S/JavaScript/JS {a#1@pojscript}>>%
\@anim@otherjscriptkey%
@@ -1188,10 +1281,6 @@
/H/I%
/AP <</N \@anim@getkeyval{btn#3}>>%
/T (btn@#1@#2)%
- /MK <<%
- /TP 1%
- /IF <</SW/A/S/A>>% scale button face icon freely within widget
- >>%
/A <</S/JavaScript/JS (\@anim@upjscriptstring)>>%
}%
\vrule width 0pt height \@anim@tmpdima depth 0pt%
@@ -1202,7 +1291,6 @@
\def\@anim@buttonwidget#1#2#3{%
\@anim@upjscript{#1}{#2}%
\setlength{\@anim@tmpdima}{\@anim@btnsize}%
- \edef\@anim@oldunitlength{\the\unitlength}%
\setlength{\unitlength}{1pt}%
\begin{picture}(0,0)%
\put(0,0){%
@@ -1216,7 +1304,6 @@
}%
}%
\end{picture}%
- \setlength{\unitlength}{\@anim@oldunitlength}%
\special{ps:
mark
/Rect [wid@llx wid@lly wid@urx wid@ury]
@@ -1226,10 +1313,6 @@
/H/I
/AP <</N {btn#3}>>%
/T (btn@#1@#2)%
- /MK <<
- /TP 1
- /IF <</SW/A/S/A>>
- >>%
/A <</S/JavaScript/JS (\@anim@upjscriptstring)>>%
/ANN pdfmark
}%
@@ -1251,6 +1334,7 @@
% #2: frame rate (fps)
\newenvironment{animateinline}[2][]{%
\leavevmode%
+ \begingroup%
\setboolean{@anim@inside}{true}%
\@anim@reset% to default settings
\setkeys{anim@user}{#1}%
@@ -1290,6 +1374,7 @@
\fi%
\global\advance\@anim@num by 1%
\setboolean{@anim@inside}{false}%
+ \endgroup%
}
%usercommand for use within `animateinline' environment;
@@ -1409,7 +1494,7 @@
\if@anim@draft\@anim@draftbox{\@anim@box}\fi%
\fi%
%now create Form XObject of box contents
- \if@anim@draft\else\@anim@xinline{#1}{#2}{\@anim@box}\message{>}\fi%
+ \if@anim@draft\else\@anim@xinline{#1}{#2}{\@anim@box}{!}\message{>}\fi%
}
%prints zero padded integers
@@ -1443,7 +1528,6 @@
\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 of lines (= number of frames)
@@ -1497,7 +1581,6 @@
\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
@@ -2202,7 +2285,7 @@
a#1.btn['PauseRight'].state=true;%
a#1.btn['PlayRight'].state=false;%
\fi
- a#1_int=app.setInterval('a#1.actnPrev()', a#1.dt);%
+ a#1_int=app.setInterval('a#1.actnPrev()',a#1.dt);%
};%
\if@anim@controls
a#1.actnIncr=function(){% speed up animation