diff options
Diffstat (limited to 'Master')
-rw-r--r-- | Master/texmf-dist/doc/latex/animate/ChangeLog | 13 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/animate/README | 21 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/animate/animate.pdf | bin | 3689232 -> 3724678 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/animate/animate.tex | 63 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/animate/animate.sty | 2320 |
5 files changed, 995 insertions, 1422 deletions
diff --git a/Master/texmf-dist/doc/latex/animate/ChangeLog b/Master/texmf-dist/doc/latex/animate/ChangeLog index d40312302b7..acc04eb1983 100644 --- a/Master/texmf-dist/doc/latex/animate/ChangeLog +++ b/Master/texmf-dist/doc/latex/animate/ChangeLog @@ -1,3 +1,12 @@ +2014-09-23 + * Change: Ghostscript 9.15+ now required for PS to PDF conversion; + `depth' option now deprecated and ignored + * New: options `totalheight', `keepaspectratio', `nomouse' added; `width', + `height', `totalheight', `keepaspectratio', `scale' added as package options + * Fix: OCG and XObject-related code rewritten, mostly thanks to recent + Ghostscript additions and fixes (BDC, EMC, SP pdfmarks); code reorganized + in order to reduce driver dependent code + 2014-08-07 * Fix: improved fix from 2014-08-06, removing need for global catcode changes @@ -18,7 +27,7 @@ 2014-03-25 * fix: bugs related to AcroForm and OCProperties catalog entries; - documenation + documentation 2014-03-12 * Fix: incompatibility with pgf-3.0 @@ -30,7 +39,7 @@ * Change: Dependency of controls on OCGs removed; better LuaLaTeX support 2014-02-06 - * New: JavaScript API for animation control + * New: JavaScript API for animation control added * Fix: broken PDF-XChange Viewer support due to [2013-07-19] changes 2013-09-24 diff --git a/Master/texmf-dist/doc/latex/animate/README b/Master/texmf-dist/doc/latex/animate/README index b522816f591..85943467d4c 100644 --- a/Master/texmf-dist/doc/latex/animate/README +++ b/Master/texmf-dist/doc/latex/animate/README @@ -17,8 +17,8 @@ Description: It supports the usual PDF making workflows, i. e. pdfLaTeX, LaTeX -> dvips -> ps2pdf (Ghostscript)/Distiller and (Xe)LaTeX -> (x)dvipdfmx. - The resulting PDF can be viewed in current Adobe Readers on all supported - platforms. + The resulting PDF can be viewed in current Adobe Readers on supported + platforms (except mobile devices). Note, this file only gives a summary of usage and available package and command options. Please refer to the documentation `animate.pdf' for details @@ -34,10 +34,12 @@ Usage: \usepackage[<package options>]{animate} - * Package options: autopause, autoplay, autoresume, controls, final, draft, - buttonsize=<size>, buttonbg=<colour>, buttonfg=<colour>, - loop, palindrome, step, poster[=first | none | last], - useocg, dvipdfmx, xetex + * Package options: width=<h-size>, height=<v-size>, totalheight=<v-size>, + keepaspectratio, scale=<factor>, nomouse, + autopause, autoplay, autoresume, controls, final, draft, + buttonsize=<size>, buttonbg=<colour>, buttonfg=<colour>, + loop, palindrome, step, poster[=first | none | last], + useocg, dvipdfmx, xetex \animategraphics[<options>]{<frame rate>}{<file basename>}{<first>}{<last>} @@ -54,8 +56,9 @@ Usage: } \end{animateinline} - * Command options: width=<width>, height=<height>, depth=<depth>, - scale=<factor>, autopause, autoplay, autoresume, final, + * Command options: width=<h-size>, height=<v-size>, totalheight=<v-size>, + keepaspectratio, scale=<factor>, nomouse, + autopause, autoplay, autoresume, final, draft, controls, buttonsize=<size>, buttonbg=<colour>, buttonfg=<colour>, loop, palindrome, step, measure, poster[=first | none | last], begin={<begin text>}, @@ -69,7 +72,7 @@ Requirements: e-TeX pdfTeX, version >= 1.20 - Ghostscript, version >= 8.31 or Adobe Distiller + Ghostscript, version >= 9.15 or Adobe Distiller dvipdfmx, version >= 20080607 Adobe Reader, version >= 7 diff --git a/Master/texmf-dist/doc/latex/animate/animate.pdf b/Master/texmf-dist/doc/latex/animate/animate.pdf Binary files differindex 8df430904ef..510d0092273 100644 --- a/Master/texmf-dist/doc/latex/animate/animate.pdf +++ b/Master/texmf-dist/doc/latex/animate/animate.pdf diff --git a/Master/texmf-dist/doc/latex/animate/animate.tex b/Master/texmf-dist/doc/latex/animate/animate.tex index 3f1e902f64a..a826ae8703b 100644 --- a/Master/texmf-dist/doc/latex/animate/animate.tex +++ b/Master/texmf-dist/doc/latex/animate/animate.tex @@ -1,4 +1,4 @@ -% Copyright 2007--2010 Alexander Grahn +% Copyright 2007--\today Alexander Grahn % % This material is subject to the LaTeX Project Public License. See % http://mirrors.ctan.org/help/Catalogue/licenses.lppl.html @@ -10,6 +10,7 @@ \usepackage{pst-3dplot} \usepackage{pst-node,pst-plot,pst-tools,pst-text,pst-ode} \usepackage{media9} +%\usepackage[useocg]{animate} \usepackage{animate} \usepackage{intcalc} \usepackage{graphicx} @@ -67,6 +68,8 @@ % pdfpagelayout=SinglePage } +%\usepackage[scaled=0.85]{luximono} + \def\XeLaTeX{X\kern-.1667em\lower.5ex\hbox{\reflectbox{E}}\kern-.125em\LaTeX} \def\pXepLaTeX{(X\kern-.1667em\lower.5ex\hbox{\reflectbox{E}})\kern-.125em\LaTeX} @@ -84,7 +87,7 @@ \def\@anim@sanitize{}\def\@anim@endsanitize{} \expandafter\parsedate\@anim@version\relax %set current date to package date \makeatother -\author{Alexander Grahn \animategraphics[autoplay,loop,height=1.8ex]{8}{bye_}{0}{3}\protect\footnote{Animated GIF taken from \href{http://www.phpBB.com}{phpBB} forum software and burst into a set of EPS files using \href{http://www.imagemagick.org}{ImageMagick} before embedding.} \protect\footnote{Animations may run slowly if viewed in the Adobe Reader browser plugin.}\\[1ex]\includegraphics[height=2.7ex]{mailto}} +\author{Alexander Grahn \animategraphics[autoplay,loop,height=1.8ex,nomouse]{8}{bye_}{0}{3}\protect\footnote{Animated GIF taken from \href{http://www.phpBB.com}{phpBB} forum software and burst into a set of EPS files using \href{http://www.imagemagick.org}{ImageMagick} before embedding.} \protect\footnote{Animations may run slowly if viewed in the Adobe Reader browser plugin.}\\[1ex]\includegraphics[height=2.7ex]{mailto}} \maketitle \endgroup \begin{abstract} @@ -112,8 +115,8 @@ The final PDF can be viewed in current Adobe Readers on all supported platforms \begin{trivlist} \item $\varepsilon$-\TeX \item pdf\TeX{}, version $\ge1.20$ or Lua\TeX{} for direct PDF output -\item Ghostscript, version $\ge8.31$ or Adobe Distiller for PS to PDF conversion -% \item Ghostscript, version $\ge9.15$ or Adobe Distiller for PS to PDF conversion +%\item Ghostscript, version $\ge9.31$ or Adobe Distiller for PS to PDF conversion +\item Ghostscript, version $\ge9.15$ or Adobe Distiller for PS to PDF conversion \item dvipdfmx, version $\ge20080607$ for DVI to PDF conversion \item Adobe Reader, version $\ge7$ or PDF-XChange Viewer \end{trivlist} @@ -144,16 +147,21 @@ palindrome draft final controls +width=<h-size> +height=<v-size> | totalheight=<v-size> +keepaspectratio +scale=<factor> buttonsize=<size> buttonbg=<colour> buttonfg=<colour> step +nomouse useocg poster[=first | none | last] \end{verbatim} Except for `\verb+dvipdfmx+' and `\verb+xetex+', the options above are also available (among others) as command options and will be explained shortly. However, if used as package options they have global scope, taking effect on all animations in the document. In turn, command options locally override global settings. Options without an argument are boolean options and can be negated, with the exception of package-only options `\verb+dvipdfmx+' and `\verb+xetex+', by appending `\verb+=false+'. -If PDF is generated via DVI and Postscript by the command sequence \verb+latex+ $\rightarrow$ \verb+dvips+ $\rightarrow$ \verb+ps2pdf+, the `graphicx' package is required. \begin{animateinline}[autoplay,loop]{1}\strut\emph{Important:}\newframe[3]\end{animateinline} The \verb+dvips+ option `\verb+-Ppdf+' should \emph{not} be set when converting the intermediate DVI into Postscript. If you cannot do without, put `\verb+-D 1200+' \emph{after} `\verb+-Ppdf+' on the command line. Users of \LaTeX-aware text editors with menu-driven toolchain invocation, such as \TeX{}nicCenter, should check the configuration of the \verb+dvips+ call. +If PDF is generated via DVI and Postscript by the command sequence \verb+latex+ $\rightarrow$ \verb+dvips+ $\rightarrow$ \verb+ps2pdf+, the `graphicx' package is required. \begin{animateinline}[autoplay,loop,nomouse]{1}\strut\emph{Important:}\newframe[3]\end{animateinline} The \verb+dvips+ option `\verb+-Ppdf+' should \emph{not} be set when converting the intermediate DVI into Postscript. If you cannot do without, put `\verb+-D 1200+' \emph{after} `\verb+-Ppdf+' on the command line. Users of \LaTeX-aware text editors with menu-driven toolchain invocation, such as \TeX{}nicCenter, should check the configuration of the \verb+dvips+ call. %Sometimes, if the same animation sequence made from graphics files is to be embedded multiple times into the document, more compact PDF output may be obtained by passing option `\verb+-dMaxInlineImageSize=0+' to \verb+ps2pdf+. @@ -161,6 +169,7 @@ If PDF is generated via DVI and Postscript by the command sequence \verb+latex+ Occasionally, a second \LaTeX{} run may be necessary to resolve internally created object references. An appropriate warning will be issued in such a case. +\clearpage \section{The user interface} Package `animate' provides the command \begin{verbatim} @@ -254,11 +263,11 @@ step \end{verbatim} Step through the animation one frame at a time per mouse-click. The \verb+<frame rate>+ argument will be ignored. \begin{verbatim} -width=<width> -height=<height> -depth=<depth> +width=<h-size> +height=<v-size> | totalheight=<v-size>, +keepaspectratio \end{verbatim} -Resize the animation widget. Option `\verb+depth+' specifies how far the animation widget should extend below the base line of the running text. If only one or two of these options are given, the remaining, unspecified dimensions are scaled to maintain the aspect ratio. Any valid \TeX{} dimension is accepted as a parameter. In addition, the length commands \verb+\width+, \verb+\height+, \verb+\depth+ and \verb+\totalheight+ can be used to refer to the original dimensions of the animation widget which correspond to the size of the first frame of the animated sequence. +Resize the animation widget. If only one of `\verb+width+' or `\verb+[total]height+' is given, the other dimension of the animation widget is scaled to maintain the aspect ratio of the first frame's content. If both `\verb+width+' and `\verb+[total]height+' are given together with `\verb+keepaspectratio+', the first frame's content is resized to fit within \verb+<h-size>+ and \verb+<v-size>+ while maintaining its original aspect ratio. Any valid \TeX{} dimension is accepted as a parameter. In addition, the length commands \verb+\width+, \verb+\height+, \verb+\depth+ and \verb+\totalheight+ can be used to refer to the original dimensions of the first frame of the animated sequence. \begin{verbatim} scale=<factor> \end{verbatim} @@ -294,9 +303,13 @@ final \end{verbatim} With `\verb+draft+' the animation is not embedded. Instead, a box with the exact dimensions of the animation is inserted. Option `\verb+final+' does the opposite as it forces the animation to be built and embedded. Both options can be used to reduce compilation time during authoring of a document. To get the most out of them it is recommended to set `\verb+draft+' globally as a package or class option and to set `\verb+final+' locally as a command option of the animation that is currently worked on. After the document has been finished, the global `\verb+draft+' option can be removed to embed all animations. \begin{verbatim} +nomouse +\end{verbatim} +Animation widget will not respond to mouse clicks. Unless the JavaScript interface, Sect.~\ref{sect:api}, p.~\pageref{sect:api}, is used to control the animation, it is recommended to also set at least one of the `\verb+autoplay+' or `\verb+controls+' options. +\begin{verbatim} useocg \end{verbatim} -Use an alternative animation method based on Optional Content Groups (OCGs, also known as PDF Layers). May result in slower animations. +Use an alternative animation method based on Optional Content Groups (OCGs, also known as PDF Layers). In rare cases this may lead to better animation performance. Moreover, it allows overlaying animations with other typeset material, that is, playing animations in the page background. \begin{verbatim} measure \end{verbatim} @@ -319,7 +332,7 @@ A short note on the `\verb+tikzpicture+' environment: Unlike `\verb+pspicture+', end={\end{tikzpicture}} \end{verbatim} -\clearpage +%\clearpage \subsection{The `{\tt timeline}' option}\label{sect:timeline} \begin{verbatim} timeline=<timeline file> @@ -353,7 +366,7 @@ The letter `\verb+c+', if put into \verb+<transparencies>+, clears an animation \myparagraph*{Timeline example with a single animation stack} Table~\ref{tab:single} is an example of a single-stack animation. It lists the contents of a timeline file together with the resulting stack of transparencies. Note how the stack is strictly built from the bottom up as transparency specifications are read from left to right and line by line from the timeline file. In frame No. 4, the stack is first cleared before new transparencies are deposited on it. Also note that the stack is viewed from above and transparencies in higher stack position overprint the lower ones. -\begin{table}[ht]\centering +\begin{table}[hb]\centering \caption{Timeline example of a single-stack animation}\label{tab:single} \begin{tabular}[t]{c|l|c}\hline frame No. & timeline file & transparency stack\\\hline\hline @@ -371,11 +384,11 @@ frame No. & timeline file & transparency stack\\\hline\hline Figures~\ref{fig:taylor} and \ref{fig:lorenz} in Section~\ref{sect:examples} are animation examples with a single transparency stack. \myparagraph*{Grouping objects into layers (= sub-stacks) using `{\tt;}'} -Due to the stack-like nature of the animation, the position of a transparency specification in the timeline file determines its \emph{depth} level in relation to other transparencies. The timeline file is processed line by line and from left to right. In a single-stack animation, the stack is strictly built from the bottom up, such that earlier transparencies are overprinted by more recent ones. This may turn out to be inconvenient in certain situations. For example, it might be desirable to change the background image in the middle of an animation without affecting objects that are located in the foreground. For this purpose, transparency specifications can be grouped into layers or sub-stacks using the semicolon (\verb+;+) as a separator. New transparencies can now be put on top of the individual sub-stacks. After a line of the timeline file has been processed, the global stack is built by placing the sub-stacks on top of the other. Again, the left-to-right rule applies when determining the height of the sub-stacks in relation to each other within the global stack. +Due to the stack-like nature of the animation, the position of a transparency specification in the timeline file determines its \emph{depth} level in relation to other transparencies. The timeline file is processed line by line and from left to right. In a single-stack animation, the stack is strictly built from the bottom up, such that earlier transparencies are overprinted by more recent ones. This may turn out to be inconvenient in certain situations. For example, it might be desirable to change the background image in the middle of an animation without affecting objects that are located in the foreground. For this purpose, transparency specifications can be grouped into layers (sub-stacks) using the semicolon (\verb+;+) as a separator. New transparencies can now be put on top of the individual sub-stacks. After a line of the timeline file has been processed, the global stack is built by placing the sub-stacks on top of the other. Again, the left-to-right rule applies when determining the height of the sub-stacks in relation to each other within the global stack. The layer concept is best illustrated by an example. In the timeline of Table~\ref{tab:multi}, transparencies are grouped into two sub-stacks only. One is reserved for the background images, transparencies No. 0 \& 1, to be exchanged in frame No. 3, as well as for two other transparencies, No. 7 \& 8, to be interspersed in frame No. 1. A second sub-stack takes the foreground objects that are successively added to the scene. The dotted lines in the third column of the table just mark the border between the two sub-stacks. In frame No. 3, `\verb+c+' first clears the bottom sub-stack before the new background image is inserted. (Instead, `\verb+x3+' could have been used with transparency No. 0 in frame No. 0.) As can be seen in the specifications of frames No. 2 \& 4, sub-stacks need not be explicitly populated; the leading semicolons just ensure the proper assignment of transparencies to animation sub-stacks. -\begin{table}[hb]\centering +\begin{table}[ht]\centering \caption{Timeline example with two sub-stacks}\label{tab:multi} \begin{tabular}[t]{c|l|c}\hline frame No. & timeline file & transparency stack\\\hline\hline @@ -476,7 +489,7 @@ Also, the programming interface can be used to create custom buttons for playbac \begin{tabularx}{\linewidth}[t]{lllX}\hline name & type & access & description\\\hline\hline {\tt numFrames} & Integer & read-only & Holds the total number of animation frames.\\ -{\tt frameNum} & Integer & read+write & Gets or sets the current frame being/to\,be displayed. Note that the values are zero-based. Assigning values less than zero or greater than {\tt numFrames-1} results in an error.\\ +{\tt frameNum} & Integer & read+write & Gets or sets the current frame being/to\,be displayed. Note that frame numbers are zero-based. Assigning values less than zero or greater than {\tt numFrames-1} results in an error.\\ {\tt fps} & Number & read+write & Gets or sets the animation frame rate (frames per second). Assigning values less than zero results in an error.\\ {\tt dt} & Number & read-only & Holds the time span (milliseconds) for display of the current frame.\\ {\tt isPlaying} & Boolean & read-only & Holds the value {\tt true} if the animation is currently playing, {\tt false} otherwise.\\ @@ -485,7 +498,7 @@ name & type & access & description\\\hline\hline \end{tabularx} \end{table} -\begin{table}[hbp] +\begin{table}[htbp] \centering \caption{Animation object methods}\label{tab:methods} \begin{tabularx}{\linewidth}[t]{lX}\hline @@ -499,7 +512,7 @@ name & description\\\hline\hline \end{tabularx} \end{table} -\clearpage +%\clearpage \section{Examples} \subsection[Animations from sets of files, using `animategraphics' command]{Animations from sets of files, using {\tt \string\animategraphics} command}\label{sect:examples} Animations in this section are made from graphics files that were prepared with \MP. Run `\verb+mpost --tex=latex+' on the files ending in `.mp' in the `files' directory to generate the graphics files. Both examples make use of the `\verb+timeline+' option to reduce the resulting PDF file size. @@ -560,7 +573,11 @@ The first example, Fig.~\ref{fig:taylor}, originally written by Jan Hole\v{c}ek~ ::7 ::8 \end{VerbatimOut} -\animategraphics[label=taylor,controls,loop,timeline=timeline.txt]{4}{exp_}{0}{8} +\animategraphics[ + label=taylor, + controls, loop, + timeline=timeline.txt +]{4}{exp_}{0}{8} \mediabutton[ jsaction={ @@ -1248,9 +1265,9 @@ dt dt Tm nT mul { % pop \item The \verb+dvips+ option `\verb+-Ppdf+' should be avoided entirely or followed by something like `\verb+-D 1200+' on the command line in order to set a sensible DVI resolution. This does \emph{not} degrade the output quality! The configuration file `config.pdf' loaded by option `\verb+-Ppdf+' specifies an excessively high DVI resolution that will be passed on to the final PDF. Eventually, Adobe Reader gets confused and will not display the frames within the animation widget. -% \item Animations do not work if the PDF has been produced with Ghostscript versions older than 9.15. + \item Animations do not work if the PDF has been produced with Ghostscript versions older than 9.15. - \item If the \LaTeX{} $\rightarrow$ \verb+dvips+ $\rightarrow$ \verb+ps2pdf+/Distiller route is being taken, make sure that the original graphics size (i.\,e. not scaled by any of the `{\tt scale}', `{\tt width}', `{\tt height}' or `{\tt depth}' options) does not exceed the page size of the final document. During PS to PDF conversion every graphic of the animation is temporarily moved to the upper left page corner. Those parts of the graphics that do not fit onto the document page will be clipped in the resulting PDF. Fortunately, graphics files for building animations may be resized easily to fit into a given bounding box by means of the `{\tt epsffit}' command line tool: + \item If the \LaTeX{} $\rightarrow$ \verb+dvips+ $\rightarrow$ \verb+ps2pdf+/Distiller route is being taken, make sure that the original graphics size (i.\,e. not scaled by any of the `{\tt scale}', `{\tt width}', `{\tt height}' or `{\tt totalheight}' options) does not exceed the page size of the final document. During PS to PDF conversion every graphic of the animation is temporarily moved to the upper left page corner. Those parts of the graphics that do not fit onto the document page will be clipped in the resulting PDF. Fortunately, graphics files for building animations may be resized easily to fit into a given bounding box by means of the `{\tt epsffit}' command line tool: \quad{\tt epsffit -c <llx> <lly> <urx> <ury> infile.eps outfile.eps} @@ -1287,9 +1304,11 @@ Note that the name of the Ghostscript executable may vary between operating syst {\tt fmtutil-sys -{}-byfmt xelatex} \end{enumerate} - \item If you are postprocessing the created PDF file with tools such as pdftk to split the document into different parts, then the animation may fail. To work around this, do not use the `{\tt useocg}' (OCGs, PDF layers) option. In addition, the control buttons also use OCGs to change their appearance to provide feedback about the running state, independent of the `{\tt useocg}' option. The workaround for this is not to use the `{\tt controls}' option. + \item If a PDF containing animations is postprocessed using tools like PDFtk to split the document into separate files, then animations in the output documents may not work. + + \item PDFs with animations cannot be embedded (via {\tt \string\includegraphics, \string\includepdf}) into other documents as the animation capability gets lost. - \item Animations should not be placed on \emph{multilayered} slides created with presentation making classes such as Beamer or Powerdot. Although possible (on the last overlay of a slide, at best), the result might be disappointing. Put animations on flat slides only. (Of course, slides without animations may still have overlays.) + \item Animations should not be placed on \emph{multilayered} slides, also known as overlays, created with presentation making classes such as Beamer or Powerdot. Although possible (on the last overlay of a slide, at best), the result might be disappointing. Put animations on flat slides only. (Of course, slides without animations may still have overlays.) \end{itemize} \section{Acknowledgements} diff --git a/Master/texmf-dist/tex/latex/animate/animate.sty b/Master/texmf-dist/tex/latex/animate/animate.sty index 688b99babb1..6e386e6fe19 100644 --- a/Master/texmf-dist/tex/latex/animate/animate.sty +++ b/Master/texmf-dist/tex/latex/animate/animate.sty @@ -13,7 +13,7 @@ \NeedsTeXFormat{LaTeX2e} -\def\@anim@version{2014/08/07} +\def\@anim@version{2014/09/23} \ProvidesPackage{animate} [\@anim@version\space PDF animations from files and inline graphics] @@ -30,43 +30,45 @@ \RequirePackage{keyval} \RequirePackage{ifthen} \RequirePackage{ifpdf} +\RequirePackage{atbegshi} \RequirePackage{ifluatex} \RequirePackage{ifdraft} \RequirePackage{calc} \RequirePackage{atenddvi}%to really get certain \specials into the dvi \RequirePackage{animfp} +\RequirePackage{graphics} \newboolean{@anim@powerdot} %to cope with some powerdot oddity \setboolean{@anim@powerdot}{false} \@ifclassloaded{powerdot}{\setboolean{@anim@powerdot}{true}}{}% %driver options (the only package options we process immediately) -\newboolean{@anim@@dvips} -\setboolean{@anim@@dvips}{false} -\newboolean{@anim@@dvipdfmx} -\setboolean{@anim@@dvipdfmx}{false} +\newboolean{@anim@dvips} +\setboolean{@anim@dvips}{false} +\newboolean{@anim@dvipdfmx} +\setboolean{@anim@dvipdfmx}{false} \ifpdf\else - \setboolean{@anim@@dvips}{true}% default dvi mode - \setboolean{@anim@@dvipdfmx}{false} + \setboolean{@anim@dvips}{true}% default dvi mode + \setboolean{@anim@dvipdfmx}{false} \DeclareOption{dvips}{% - \setboolean{@anim@@dvips}{true} - \setboolean{@anim@@dvipdfmx}{false} + \setboolean{@anim@dvips}{true} + \setboolean{@anim@dvipdfmx}{false} } \DeclareOption{dvipdfmx}{% - \setboolean{@anim@@dvipdfmx}{true} - \setboolean{@anim@@dvips}{false} + \setboolean{@anim@dvipdfmx}{true} + \setboolean{@anim@dvips}{false} } \DeclareOption{xetex}{% - \setboolean{@anim@@dvipdfmx}{true} - \setboolean{@anim@@dvips}{false} + \setboolean{@anim@dvipdfmx}{true} + \setboolean{@anim@dvips}{false} } \fi \newboolean{@anim@xetex} \setboolean{@anim@xetex}{false} \expandafter\ifx\csname XeTeXrevision\endcsname\relax\else \setboolean{@anim@xetex}{true} - \setboolean{@anim@@dvipdfmx}{true} - \setboolean{@anim@@dvips}{false} + \setboolean{@anim@dvipdfmx}{true} + \setboolean{@anim@dvips}{false} \fi \DeclareOption*{}\ProcessOptions*\relax %allow anything as an option @@ -95,9 +97,9 @@ } }} \else - \if@anim@@dvipdfmx\else % dvips + \if@anim@dvipdfmx\else % dvips %if geometry package is loaded, execute `\geometry{dvips}' right before - % `\begin{document}' + % `\begin{document}'; not sure whether needed at all any more \let\@anim@document\document \def\document{% \endgroup% @@ -120,24 +122,22 @@ }% \fi% } - %determine DVI resolution and output warning message if too big - \AtBeginDocument{% - \special{ps:\@anim@dpiwarning}% - } + \AtEndDvi{\special{ps:\@anim@gsoldwarning}}% \fi \fi -%\edef\@anim@catcode{\the\catcode`\_}\catcode`\_=13 \begingroup \catcode`\_=13 \let_\space \xdef\@anim@dpiwarning{% {Resolution 1200 gt VResolution 1200 gt or product (Ghostscript) search {pop pop pop true}{pop false}ifelse and {% - (@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\string\n% + (\string\n% + @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\string\n% @@____Warning:_DVI_resolution_greater_than_1200_dpi!_____@@\string\n% @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\string\n% @@_______________________________________________________@@\string\n% - @@_Animations_may_be_distorted_or_invisible._____________@@\string\n% + @@_Animation_frames_may_be_clipped_or_invisible._________@@\string\n% + @@_______________________________________________________@@\string\n% @@_Dvips_should_be_called_either_without_option_`-Ppdf':_@@\string\n% @@_______________________________________________________@@\string\n% @@___dvips_\jobname\string\n @@ -149,8 +149,24 @@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\string\n) print} if} ?pdfmark } +\xdef\@anim@gsoldwarning{% + {product (Ghostscript) search {pop pop pop true}{pop false}ifelse + revision 915 lt and {% + (\string\n% + @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\string\n% + @@____________Warning:_Ghostscript_too_old!______________@@\string\n% + @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\string\n% + @@_______________________________________________________@@\string\n% + @@_Ghostscript_version_>=_9.15_required._________________@@\string\n% + @@_Otherwise,_animations_will_not_work.__________________@@\string\n% + @@_______________________________________________________@@\string\n% + @@_Get_current_version_from______________________________@@\string\n% + @@_http://www.ghostscript.com/download___________________@@\string\n% + @@_______________________________________________________@@\string\n% + @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\string\n) + print} if} ?pdfmark +} \endgroup -%\catcode`\%=14\catcode`\#=6\catcode`\_=\@anim@catcode %\pdfmdfivesum is used for hashing object references of embedded files based %on their MD5 digest (in order to avoid multiple inclusion); if it is not @@ -229,6 +245,7 @@ \ifdefined\@anim@fields\else\def\@anim@fields{}\fi %takes Field object refs \ifdefined\@anim@ocgs\else\def\@anim@ocgs{}\fi %takes ocg object refs \ifdefined\@anim@offocgs\else\def\@anim@offocgs{}\fi + \ifpdf %AcroForm dict \def\@anim@acroform{% @@ -274,7 +291,7 @@ \else %counts inserted widget annots \newcount\@anim@fieldnum\@anim@fieldnum=\z@ - \if@anim@@dvipdfmx + \if@anim@dvipdfmx \def\@anim@acroform{% \ifdefined\Acro@Form@added\else% \AtEndDvi{% @@ -300,7 +317,7 @@ \special{pdf:put @catalog <<% /OCProperties <<% /OCGs @anim@ocgs - /D << + /D <<% /BaseState/ON /OFF @anim@offocgs% /AS[% <</Event/View /Category[/View] /OCGs @anim@ocgs>>% @@ -364,6 +381,7 @@ \fi \newbox\@anim@box %stores animation frames +\newbox\@anim@measbox % for measuring purposes \newdimen\@anim@tmpdima %length registers for occasional use \newdimen\@anim@tmpdimb @@ -374,8 +392,24 @@ \ifcsname file:\@anim@pdfmdfivesum{#1}.#2\endcsname% \@anim@getkeyval{file:\@anim@pdfmdfivesum{#1}.#2}\else!\fi% } -\def\@anim@makefileknown#1#2#3{%#1 file name, pdf: #2 page No. ps: #2 @anim@num, - \@anim@newkey{file:\@anim@pdfmdfivesum{#1}.#2}{#3}% #3 Form XObj ID +\def\@anim@makefileknown#1#2#3{% + %#1 file name, pdf: #2 page No. ps: #2 @anim@num %#3 Form XObj ID, + \@anim@newkey{file:\@anim@pdfmdfivesum{#1}.#2}{#3}% +} +%retrieve nat. dimensions from XObjects +\def\@anim@xobjnatwd#1{% #1 Form XObj ID + \@anim@getkeyval{natwidth:#1}\p@% +} +\def\@anim@xobjnatht#1{% #1 Form XObj ID + \@anim@getkeyval{natheight:#1}\p@% +} +\def\@anim@xobjnatdp#1{% #1 Form XObj ID + \@anim@getkeyval{natdepth:#1}\p@% +} +\def\@anim@xobjnatdims#1#2#3#4{% Form XObj ID, wd, ht, dp + \@anim@newkey{natwidth:#1}{#2}% + \@anim@newkey{natheight:#1}{#3}% + \@anim@newkey{natdepth:#1}{#4}% } %helper macro that typesets graphics file into savebox @@ -411,97 +445,118 @@ \fi \fi -%create Form XObject from graphics file -\ifthenelse{\boolean{pdf}\OR\boolean{@anim@xetex}}{ - \def\@anim@ximage#1#2#3#4{%#1:@anim@num, #2:@anim@curframe@zb, #3:filename, - %#4: page number of multipage file - \ifthenelse{\equal{\@anim@fileknown{#3}{#4}}{!}}{% new file to be embedded - \@anim@filebox{#3}{#4}% store file in a box - \@anim@getsize{\@anim@box}% - \ifnum#2=\z@% - \@anim@scale{\@anim@box}% scale animation widget - \fi% - \@anim@xinline{#1}{#2}{\@anim@box}{!}% delegate Form XObject creation - \ifx\@anim@gropts\@empty\if@anim@multipage\message{<#4>}\fi\fi% - \@anim@makefileknown{#3}{#4}{\@anim@lastxform}% keep form xobject number - }{% file known, re-use existing form xobject - \ifnum#2=\z@% - \@anim@filebox{#3}{#4}% for size determination of first frame - \@anim@getsize{\@anim@box}% - \@anim@scale{\@anim@box}% - \fi% - \@anim@xinline{#1}{#2}{}{\@anim@fileknown{#3}{#4}}% +\def\@anim@checkboxsize#1#2{% #1: box number, #2: file + \ifdim\wd#1=\z@% + \PackageError{animate}{% + Graphics to be used for first frame% + \MessageBreak must not have zero width% + }{% + Check content of file #2% }% - } -}{ - \if@anim@@dvipdfmx - \def\@anim@ximage#1#2#3#4{% #4: not used - \ifthenelse{\equal{\@anim@fileknown{#3}{1}}{!}}{%new file to be embedded - \@anim@filebox{#3}{}% - \@anim@getsize{\@anim@box}% - \ifnum#2=\z@% - \@anim@scale{\@anim@box}% - \fi% - \@anim@xinline{#1}{#2}{\@anim@box}{!}% - \@anim@makefileknown{#3}{1}{\@anim@lastxform}% - }{% - \ifnum#2=\z@% - \@anim@filebox{#3}{}% - \@anim@getsize{\@anim@box}% - \@anim@scale{\@anim@box}% - \fi% - \@anim@xinline{#1}{#2}{}{\@anim@fileknown{#3}{1}}% - }% - } - \else - \def\@anim@ximage#1#2#3#4{% #4: not used - \ifthenelse{\equal{\@anim@fileknown{#3}{#1}}{!}}{%file is new to current - \@anim@filebox{#3}{}% animation - \@anim@getsize{\@anim@box}% - \ifnum#2=\z@% - \@anim@scale{\@anim@box}% - \fi% - \@anim@xinline{#1}{#2}{\@anim@box}{!}% - \@anim@makefileknown{#3}{#1}{\@anim@lastxform}% - }{%file already used in the current animation, re-use existing xobject - \ifnum#2=\z@% - \@anim@filebox{#3}{}% - \@anim@getsize{\@anim@box}% - \@anim@scale{\@anim@box}% - \fi% - \@anim@xinline{#1}{#2}{}{\@anim@fileknown{#3}{#1}}% + \fi% + \ifdim\ht#1=\z@\ifdim\dp#1=\z@% + \PackageError{animate}{% + Graphics to be used for first frame% + \MessageBreak must not have zero height% + }{% + Check content of file #2% + }% + \fi\fi% +} + +%create Form XObject from graphics file +\def\@anim@ximage#1#2#3#4{%#1:@anim@num, #2:@anim@curframe@zb, #3:filename, + %#4: page number of multipage file + \ifthenelse{\equal{\@anim@fileknown{#3}{#4}}{!}}{% + \@anim@filebox{#3}{#4}% store file in a box + \@anim@xinline{#1}{#2}{\@anim@box}{!}% delegate Form XObject creation + \ifx\@anim@gropts\@empty\if@anim@multipage\message{<#4>}\fi\fi% + \@anim@makefileknown{#3}{#4}{\@anim@@lastxform}% + }{% file known, re-use existing form xobject + \setbox\@anim@box=% + \hbox to \@anim@xobjnatwd{\@anim@fileknown{#3}{#4}}{% + \vrule width \z@ + height \@anim@xobjnatht{\@anim@fileknown{#3}{#4}} + depth \@anim@xobjnatdp{\@anim@fileknown{#3}{#4}}% + \hss% }% - } - \fi + \@anim@xinline{#1}{#2}{% + \@anim@box}{\@anim@fileknown{#3}{#4}}% + }% } -%creates Form XObject from box contents -\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{% - \ifthenelse{\equal{#4}{!}}{% - %put graphics into XObject - %\global\setbox\@anim@box=\hbox{% - % \raisebox{-\dp#3}[\@anim@frameheight\p@][\@anim@framedepth\p@]{\box#3}% - %}% - \immediate\pdfxform resources {\the\pdfpageresources}\@anim@box% - \xdef\@anim@lastxform{\the\pdflastxform}% - %keep a record of XObject number - \@anim@newkey{img@#2}{\@anim@lastxform\space 0 R}% - }{% - \@anim@newkey{img@#2}{#4\space 0 R}% - }% - \if@anim@timeline\else\@anim@makeframe{#1}{#2}\fi% +%low level operations (driver level) +\ifpdf + \def\@anim@dictobj#1{% + \immediate\pdfobj{<<#1>>}% + \xdef\@anim@lastobj{\the\pdflastobj\space 0 R}% + } + + \def\@anim@streamobj#1#2{% #1: attrs, #2 content + \immediate\pdfobj stream attr {#1}{#2}% + \xdef\@anim@lastobj{\the\pdflastobj\space 0 R}% + } + + \def\@anim@refobj#1{#1 0 R} + + \def\@anim@xform#1#2#3{%#1: not used, #2: not used, #3 boxnum + \immediate\pdfxform resources {\the\pdfpageresources}#3% + \xdef\@anim@lastxform{\the\pdflastxform}% } + \def\@anim@refxform#1{% #1: xform obj ID + \rlap{\pdfrefxform#1}% + %\begin{picture}(0,0)\put(0,0){\pdfrefxform#1}\end{picture}% + } + + \def\@anim@pdfannot#1#2#3#4{%width, height, depth, dict + \pdfannot width #1\p@ height #2\p@ depth #3\p@ {#4}% + \xdef\@anim@fields{\@anim@fields\the\pdflastannot\space 0 R\space}% + } + + %marked content BDC/EMC operators + \newcount\@anim@ocnum + \def\@anim@bdc#1#2{% #1: tag, #2 prop. dict obj ID + \pdfliteral direct {#1/a@oc\the\@anim@ocnum\space BDC}% + \ifx\@empty\@anim@ocmap\@empty% + \xdef\@anim@ocmap{/a@oc\the\@anim@ocnum\space#2}% + \else% + \xdef\@anim@ocmap{\@anim@ocmap\space/a@oc\the\@anim@ocnum\space#2}% + \fi% + \begingroup% + \edef\x{\endgroup% /Properties dict must be added manually to page resources + \global\pdfpageresources{\the\pdfpageresources% + /Properties<<\@anim@ocmap>>% + }% + }\x% + \global\advance\@anim@ocnum by \@ne% + } + \ifdefined\@anim@ocmap\else + \gdef\@anim@ocmap{} + \AtBeginShipout{\gdef\@anim@ocmap{}} + \fi + \def\@anim@emc{\pdfliteral direct {EMC}}% \else - \if@anim@@dvipdfmx - \def\@anim@xinline#1#2#3#4{% - \ifthenelse{\equal{#4}{!}}{% - %put graphics into XObject - \special{pdf:bxobj @anim@frm@#1@#2 width \@anim@framewidth pt - height \@anim@frameheight pt depth \@anim@framedepth pt}% - \begin{picture}(0,0)\put(0,0){\box#3}\end{picture}% + \newcount\@anim@objnum + \if@anim@dvipdfmx + \def\@anim@dictobj#1{% + \special{pdf:obj @anm@obj\the\@anim@objnum <<#1>>}% + \xdef\@anim@lastobj{@anm@obj\the\@anim@objnum}% + \global\advance\@anim@objnum by \@ne% + } + + \def\@anim@streamobj#1#2{% #1 attrs, #2 content + \special{pdf:stream @anm@obj\the\@anim@objnum\space (#2) <<#1>>}% + \xdef\@anim@lastobj{@anm@obj\the\@anim@objnum}% + \global\advance\@anim@objnum by \@ne% + } + + \def\@anim@refobj#1{#1} + + \def\@anim@xform#1#2#3{%#1 add. pgf resources?1:0, #2 not used, #3 boxnum + \special{pdf:bxobj @anm@obj\the\@anim@objnum\space width \strip@pt\wd#3pt + height \strip@pt\ht#3pt depth \strip@pt\dp#3pt}% + \begin{picture}(0,0)\put(0,0){\box#3}\end{picture}% + \ifx1#1% \ifthenelse{\boolean{@anim@pgfloaded}}{% \def\@anim@resources{}% \ifthenelse{\boolean{pgf@sys@pdf@extgs@exists}}{% @@ -519,328 +574,156 @@ \special{pdf:put @resources <<\@anim@resources>>}% }{}% }{}% - \special{pdf:exobj}% - \xdef\@anim@lastxform{@anim@frm@#1@#2}% - \@anim@newkey{img@#2}{\@anim@lastxform}% - }{% - \@anim@newkey{img@#2}{#4}% - }% - \if@anim@timeline\else\@anim@makeframe{#1}{#2}\fi% + \fi% + \special{pdf:exobj}% + \xdef\@anim@lastxform{@anm@obj\the\@anim@objnum}% + \global\advance\@anim@objnum by \@ne% } - \else - \def\@anim@xinline#1#2#3#4{% - \ifthenelse{\equal{#4}{!}}{% - \begingroup% - \setlength{\unitlength}{1pt}% - \begin{picture}(0,0)% - %mark BBox of the graphics - \put(0,-\@anim@framedepth){% - \special{ps: - currentpoint /frame@lly exch def /frame@llx exch def - }% - }% - \put(\@anim@framewidth,\@anim@frameheight){% - \special{ps: - currentpoint /frame@ury exch def /frame@urx exch def - }% - }% - %define some length values in current PS coordinate units - \put(0,0){% - \special{ps: - currentpoint /origin@y exch def /origin@x exch def - }% - }% - \put(72.27,72.27){% - \special{ps: - currentpoint origin@y exch sub /one@inch@y exch def - origin@x sub /one@inch@x exch def - }% - }% - \end{picture}% - \endgroup% - \special{ps: - gsave - %translate graphics to upper left page corner - \if@anim@powerdot\else% - {% - frame@llx neg frame@ury neg translate - one@inch@x DVImag div neg one@inch@y DVImag div neg translate% - }?pdfmark - \fi% - %distill graphics into XObject - 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% - }% - \begin{picture}(0,0)\put(0,0){\box#3}\end{picture}% - \special{ps: - mark /EP pdfmark - grestore% - }% - \xdef\@anim@lastxform{@anim@frm@#1@#2}% - \@anim@newkey{img@#2}{{@anim@frm@#1@#2}}% - }{% - \@anim@newkey{img@#2}{{#4}}% - }% - \if@anim@timeline\else\@anim@makeframe{#1}{#2}\fi% + \def\@anim@refxform#1{\special{pdf:uxobj #1}}% #1: xform obj ID + + \def\@anim@pdfannot#1#2#3#4{%width, height, depth, dict + \special{pdf:annot @anm@obj\the\@anim@objnum\space + width #1pt height #2pt + depth #3pt <<#4>>}% + \xdef\@anim@fields{\@anim@fields @anm@obj\the\@anim@objnum\space}% + \global\advance\@anim@objnum by \@ne% } - \fi -\fi -\def\@anim@posterlast{last}% helper macros -\def\@anim@posterfirst{first}% -\def\@anim@posternone{none}% - -%creates OCG -\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}% - } -\else - \if@anim@@dvipdfmx - \def\@anim@newocg#1#2{% - \special{pdf:obj @anim@ocg@#1@#2 <</Type/OCG /Name (#1.#2)>>}% - \xdef\@anim@ocgs{\@anim@ocgs\space @anim@ocg@#1@#2}% + %marked content BDC/EMC operators + \newcount\@anim@ocnum + \def\@anim@bdc#1#2{% #1: tag, #2 prop. dict obj ID + \special{pdf:code #1/a@oc\the\@anim@ocnum\space BDC}% + %Properties must be added manually + \special{pdf:put @resources + <</Properties <</a@oc\the\@anim@ocnum\space#2>>>>}% + \global\advance\@anim@ocnum by \@ne% } - \else - \def\@anim@newocg#1#2{% + \def\@anim@emc{\special{pdf:code EMC}}% + \else % dvips + \def\@anim@dictobj#1{% \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 /_objdef {@anm@obj\the\@anim@objnum} /type/dict /OBJ pdfmark + mark {@anm@obj\the\@anim@objnum} <<#1>> /PUT pdfmark }% - \xdef\@anim@ocgs{\@anim@ocgs\space {@anim@ocg@#1@#2}}% + \xdef\@anim@lastobj{{@anm@obj\the\@anim@objnum}}% + \global\advance\@anim@objnum by \@ne% } - \fi -\fi -%non-interactive Widget annotation, representing one frame of the animation -\ifpdf - \def\@anim@makeframe#1#2{% #1:@anim@num, #2:@anim@curframe@zb - \if@anim@timeline% - %container XObject for all transparencies that compose the frame + \def\@anim@streamobj#1#2{% + \special{ps::[nobreak] %don't break long (strings) at embedded spaces + mark /_objdef {@anm@obj\the\@anim@objnum} /type/stream /OBJ pdfmark + mark {@anm@obj\the\@anim@objnum} (#2) /PUT pdfmark + mark {@anm@obj\the\@anim@objnum} <<#1>> /PUT pdfmark + }% + \xdef\@anim@lastobj{{@anm@obj\the\@anim@objnum}}% + \global\advance\@anim@objnum by \@ne% + } + + \def\@anim@refobj#1{#1} + + \def\@anim@xform#1#2#3{%#1 not used, #2 used as appearance?1:0, #3 boxnum + \if@anim@useocg\else% + \ifdefined\@anim@@dpiwarning\else% + %determine DVI resolution and output warning message if too high + \AtEndDvi{\special{ps:\@anim@dpiwarning}}% + \gdef\@anim@@dpiwarning{}% + \fi% + \fi% \begingroup% \setlength{\unitlength}{1pt}% - \global\setbox\@anim@box=\hbox{% - \pdfliteral{q}% - \begin{picture}(\@anim@framewidth,\@anim@frametotalheight)% - \end{picture}% - \pdfliteral{Q\@anim@getkeyval{frmcontent@#2}}% + \begin{picture}(0,0)% + %mark BBox of the graphics + \put(0,-\strip@pt\dp#3){% + \special{ps: + currentpoint /frame@lly exch def /frame@llx exch def + }% }% - \endgroup% - \immediate\pdfxform resources {% - /XObject <<\@anim@getkeyval{frmxobject@#2}>>}\@anim@box% - \fi% - \if@anim@useocg% - \@anim@newocg{#1}{#2}% - \ifx\@anim@poster\@anim@posterlast% - \@anim@keytoaux{a#1.poster}{#2}% - \ifthenelse{\equal{\@anim@getkeyval{a#1.poster}}{#2}}{}{% - \xdef\@anim@offocgs{\@anim@offocgs\space\@anim@curocg}% + \put(\strip@pt\wd#3,\strip@pt\ht#3){% + \special{ps: + currentpoint /frame@ury exch def /frame@urx exch def + }% }% - \else% - \ifnum#2=\z@% - \ifx\@anim@poster\@anim@posternone% - \xdef\@anim@offocgs{\@anim@offocgs\space\@anim@curocg}% - \fi% - \else% - \xdef\@anim@offocgs{\@anim@offocgs\space\@anim@curocg}% - \fi% - \fi% - \def\@anim@annotflag{/F 4}%, print, visibility set by OCG - \else% - %widget visibility state - \def\@anim@annotflag{/F 2}%default: hidden (no view, no print) - \ifx\@anim@poster\@anim@posternone\else% - \ifnum#2=\z@% - \ifx\@anim@poster\@anim@posterfirst% - \def\@anim@annotflag{/F 4}% visible, print - \fi% - \fi% - \ifx\@anim@poster\@anim@posterlast% - \@anim@keytoaux{a#1.poster}{#2}% - \ifthenelse{\equal{\@anim@getkeyval{a#1.poster}}{#2}}{% - \def\@anim@annotflag{/F 4}% - }{}% - \fi% - \fi% - \fi% - %frame widget, using an XObject (timeline: container, else: single image) - %as its Appearance - \pdfannot - width \@anim@animwidth\p@ height \@anim@animheight\p@ - depth \@anim@animdepth\p@ - {% - /Subtype/Widget% - \@anim@annotflag - \if@anim@useocg% - /OC \@anim@curocg %associate widget with the just created OCG - \fi% - /FT/Btn/Ff 65537% non-interactive push button - /BS <</W 0>>% - \if@anim@timeline% - /AP <</N \the\pdflastxform\space 0 R>>% - /MK <</TP 1/I \the\pdflastxform\space 0 R/IF<</S/A/FB true>>>>% - \else% - /AP <</N \@anim@getkeyval{img@#2}>>% - /MK <</TP 1/I \@anim@getkeyval{img@#2}/IF<</S/A/FB true>>>>% - \fi% - /T (#1.#2)% - }% - \xdef\@anim@fields{\@anim@fields\the\pdflastannot\space 0 R\space}% - } -\else - \if@anim@@dvipdfmx - \def\@anim@makeframe#1#2{% - \if@anim@timeline% - %container XObject - \global\setbox\@anim@box=\hbox{% - \special{pdf:content \@anim@getkeyval{frmcontent@#2}}% + %define some length values in current PS coordinate units + \put(0,0){% + \special{ps: + currentpoint /origin@y exch def /origin@x exch def + }% }% - \special{pdf:bxobj @anim@anmfrm@#1@#2 width \@anim@framewidth pt - height \@anim@frameheight pt depth \@anim@framedepth pt}% - \begin{picture}(0,0)\put(0,0){\box\@anim@box}\end{picture}% - \special{pdf:put @resources << - /XObject <<\@anim@getkeyval{frmxobject@#2}>>% - >>}% - \special{pdf:exobj}% - \fi% - \if@anim@useocg% - \@anim@newocg{#1}{#2}% - \ifx\@anim@poster\@anim@posterlast% - \@anim@keytoaux{a#1.poster}{#2}% - \ifthenelse{\equal{\@anim@getkeyval{a#1.poster}}{#2}}{}{% - \xdef\@anim@offocgs{\@anim@offocgs\space @anim@ocg@#1@#2}% + \put(72.27,72.27){% + \special{ps: + currentpoint origin@y exch sub /one@inch@y exch def + origin@x sub /one@inch@x exch def }% - \else% - \ifnum#2=\z@% - \ifx\@anim@poster\@anim@posternone% - \xdef\@anim@offocgs{\@anim@offocgs\space @anim@ocg@#1@#2}% - \fi% - \else% - \xdef\@anim@offocgs{\@anim@offocgs\space @anim@ocg@#1@#2}% - \fi% + }% + \end{picture}% + \endgroup% + \@anim@newkey{origin:{@anm@obj\the\@anim@objnum}}{origin@\the\@anim@objnum}% + \special{ps: + gsave + %keep record of lower left corner coordinates + true setglobal globaldict + /origin@\the\@anim@objnum [currentpoint] cvx put false setglobal + %translate graphics to upper left page corner + \if@anim@powerdot\else% + {% + frame@llx neg frame@ury neg translate + one@inch@x DVImag div neg one@inch@y DVImag div neg translate% + }?pdfmark \fi% - \def\@anim@annotflag{/F 4}% - \else% - \def\@anim@annotflag{/F 2}% - \ifx\@anim@poster\@anim@posternone\else% - \ifnum#2=\z@% - \ifx\@anim@poster\@anim@posterfirst% - \def\@anim@annotflag{/F 4}% - \fi% - \fi% - \ifx\@anim@poster\@anim@posterlast% - \@anim@keytoaux{a#1.poster}{#2}% - \ifthenelse{\equal{\@anim@getkeyval{a#1.poster}}{#2}}{% - \def\@anim@annotflag{/F 4}% - }{}% - \fi% + %distill graphics into XObject + mark + /_objdef {@anm@obj\the\@anim@objnum} + /BBox [frame@llx frame@lly frame@urx frame@ury] + /BP pdfmark + \ifx1#2% operations needed if used as annotation appearance + {% + 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% \fi% - \fi% - %frame widget - \special{pdf:annot @annot@\the\@anim@fieldnum\space - width \@anim@animwidth pt height \@anim@animheight pt - depth \@anim@animdepth pt <<% - /Subtype/Widget% - \@anim@annotflag - \if@anim@useocg/OC @anim@ocg@#1@#2\fi% - /FT/Btn/Ff 65537% - /BS <</W 0>>% - \if@anim@timeline% - /AP <</N @anim@anmfrm@#1@#2>>% - /MK <</TP 1/I @anim@anmfrm@#1@#2/IF<</S/A/FB true>>>>% - \else% - /AP <</N \@anim@getkeyval{img@#2}>>% - /MK <</TP 1/I \@anim@getkeyval{img@#2}/IF<</S/A/FB true>>>>% - \fi% - /T (#1.#2)% - >>% }% - \xdef\@anim@fields{\@anim@fields @annot@\the\@anim@fieldnum\space}% - \global\advance\@anim@fieldnum by \@ne% + \begin{picture}(0,0)\put(0,0){\box#3}\end{picture}% + \special{ps: + mark /EP pdfmark + grestore% + }% + \xdef\@anim@lastxform{{@anm@obj\the\@anim@objnum}}% + \global\advance\@anim@objnum by \@ne% } - \else - \def\@anim@makeframe#1#2{% - \if@anim@timeline% - %container XObject - \special{ps: - mark /_objdef {@anim@anmfrm@#1@#2} /type/stream /OBJ pdfmark - mark {@anim@anmfrm@#1@#2} (\@anim@getkeyval{frmcontent@#2}) /PUT - pdfmark - mark {@anim@anmfrm@#1@#2} << - /Type/XObject/Subtype/Form/FormType 1 - /BBox [frame@llx frame@lly frame@urx frame@ury] - /Resources <</XObject <<\@anim@getkeyval{frmxobject@#2}>>>> - >> /PUT pdfmark% - }% - \fi% - \if@anim@useocg% - \@anim@newocg{#1}{#2}% - \ifx\@anim@poster\@anim@posterlast% - \@anim@keytoaux{a#1.poster}{#2}% - \ifthenelse{\equal{\@anim@getkeyval{a#1.poster}}{#2}}{}{% - \xdef\@anim@offocgs{\@anim@offocgs\space {@anim@ocg@#1@#2}}% - }% - \else% - \ifnum#2=\z@% - \ifx\@anim@poster\@anim@posternone% - \xdef\@anim@offocgs{\@anim@offocgs\space {@anim@ocg@#1@#2}}% - \fi% - \else% - \xdef\@anim@offocgs{\@anim@offocgs\space {@anim@ocg@#1@#2}}% - \fi% - \fi% - \def\@anim@annotflag{/F 4}% - \else% - \def\@anim@annotflag{/F 2}% - \ifx\@anim@poster\@anim@posternone\else% - \ifnum#2=\z@% - \ifx\@anim@poster\@anim@posterfirst% - \def\@anim@annotflag{/F 4}% - \fi% - \fi% - \ifx\@anim@poster\@anim@posterlast% - \@anim@keytoaux{a#1.poster}{#2}% - \ifthenelse{\equal{\@anim@getkeyval{a#1.poster}}{#2}}{% - \def\@anim@annotflag{/F 4}% - }{}% - \fi% - \fi% - \fi% - %frame widget + \def\@anim@refxform#1{% #1: xform obj ID + \special{ps: + currentpoint pop \@anim@getkeyval{origin:#1} pop sub + currentpoint exch pop \@anim@getkeyval{origin:#1} exch pop sub translate + mark #1 /SP pdfmark% + }% + } + + \def\@anim@pdfannot#1#2#3#4{%width, height, depth, dict \begingroup% \setlength{\unitlength}{1pt}% \begin{picture}(0,0)% mark annotation rectangle - \put(0,-\@anim@animdepth){% + \put(0,-#3){% \special{ps: currentpoint /wid@lly exch def /wid@llx exch def }% }% - \put(\@anim@animwidth,\@anim@animheight){% + \put(#1,#2){% \special{ps: currentpoint /wid@ury exch def /wid@urx exch def }% @@ -849,399 +732,343 @@ \endgroup% \special{ps: mark - /_objdef {annot@\the\@anim@fieldnum}% + /_objdef {@anm@obj\the\@anim@objnum}% /Rect [wid@llx wid@lly wid@urx wid@ury]% - /Subtype/Widget% - \@anim@annotflag - \if@anim@useocg/OC {@anim@ocg@#1@#2}\fi% - /FT/Btn/Ff 65537 - /BS <</W 0>>% - \if@anim@timeline% - /AP <</N {@anim@anmfrm@#1@#2}>>% - /MK <</TP 1/I {@anim@anmfrm@#1@#2}/IF<</S/A/FB true>>>>% - \else% - /AP <</N \@anim@getkeyval{img@#2}>>% - /MK <</TP 1/I \@anim@getkeyval{img@#2}/IF<</S/A/FB true>>>>% - \fi% - /T (#1.#2)% - /ANN pdfmark% + #4% + /ANN pdfmark }% - \xdef\@anim@fields{\@anim@fields{annot@\the\@anim@fieldnum}\space}% - \global\advance\@anim@fieldnum by \@ne% + \xdef\@anim@fields{\@anim@fields{@anm@obj\the\@anim@objnum}\space}% + \global\advance\@anim@objnum by \@ne% } + + \def\@anim@bdc#1#2{\special{ps: mark #1 #2 /BDC pdfmark}}% + \def\@anim@emc{\special{ps: mark /EMC pdfmark}}% \fi \fi -%create XObjects of all button faces -\if@anim@@dvips - \def\@anim@btnend{% - \@anim@bg\space - \@anim@fg\space - 0.25 setlinewidth - 1 setlinecap - 1 setlinejoin - 1 1 moveto - 14 1 lineto - 14 14 lineto - 1 14 lineto - closepath - stroke - 1 setlinewidth - 4.5 4 moveto - 9.5 7.5 lineto - 4.5 11 lineto - stroke - 0 setlinejoin - 10.5 4.4 moveto - 10.5 10.6 lineto - stroke - } - \def\@anim@btnstep{% - \@anim@bg\space - \@anim@fg\space - 0.25 setlinewidth - 1 setlinecap - 1 setlinejoin - 1 1 moveto - 14 1 lineto - 14 14 lineto - 1 14 lineto - closepath - stroke - 1 setlinewidth - 5 4 moveto - 10 7.5 lineto - 5 11 lineto - stroke - } - \def\@anim@btnplay{% - \@anim@bg\space - \@anim@fg\space - 0.25 setlinewidth - 1 setlinecap - 1 setlinejoin - 1 1 moveto - 14 1 lineto - 14 14 lineto - 1 14 lineto - closepath - stroke - 1 setlinewidth - 5 4 moveto - 5 11 lineto - 10 7.5 lineto - closepath - stroke - } - \def\@anim@btnpause{% - \@anim@bg\space - \@anim@fg\space - 0.25 setlinewidth - 0 setlinecap - 1 setlinejoin - 0 1 moveto - 14 1 lineto - 14 14 lineto - 0 14 lineto - stroke - 2 setlinewidth - 2.2 4 moveto - 2.2 11 lineto - stroke - } - \def\@anim@btnminus{% - \@anim@bg\space - \@anim@fg\space - 0.25 setlinewidth - 1 setlinecap - 1 setlinejoin - 1 1 moveto - 14 1 lineto - 14 14 lineto - 1 14 lineto - closepath - stroke - 1.0 setlinewidth - 0 setlinecap - 4 7.5 moveto - 11 7.5 lineto - stroke - } - \def\@anim@btnplus{% - \@anim@bg\space - \@anim@fg\space - 0.25 setlinewidth - 1 setlinecap - 1 setlinejoin - 1 1 moveto - 14 1 lineto - 14 14 lineto - 1 14 lineto - closepath - stroke - 1.0 setlinewidth - 0 setlinecap - 4 7.5 moveto - 11 7.5 lineto - 7.5 4 moveto - 7.5 11 lineto - stroke - } - \def\@anim@btnreset{% - \@anim@bg\space - \@anim@fg\space - 0.25 setlinewidth - 1 setlinecap - 1 setlinejoin - 1 1 moveto - 14 1 lineto - 14 14 lineto - 1 14 lineto - closepath - stroke - 1 setlinewidth - 7.5 4 moveto - 7.5 11 lineto - stroke - 0 setlinejoin - 3.5 5 moveto - 7 7.5 lineto - 3.5 10 lineto - closepath - fill - 11.5 5 moveto - 8 7.5 lineto - 11.5 10 lineto - closepath - fill - 1 setlinewidth - 2 setlinecap - 3 7.5 moveto - 3.5 7.5 lineto - 12 7.5 moveto - 11.5 7.5 lineto - stroke - } - \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#3{% #1: name; #2: stroking commands, #3 @anim@num - \special{ps: - gsave - %[1 0 0 1 0 0] setmatrix - mark - /_objdef {btn#1:#3} - /BBox [0 0 15 15] - /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 - % this avoids the `[1 0 0 1 0 0] setmatrix' and `isls{}{}if' codes above - mark {btn#1:#3} <</Matrix null>> /PUT pdfmark - grestore% +%creates Form XObject from box contents +\def\@anim@xinline#1#2#3#4{% + \edef\@anim@curwd{\strip@pt\wd#3}% + \edef\@anim@curht{\strip@pt\ht#3}% + \edef\@anim@curdp{\strip@pt\dp#3}% + \ifnum#2=\z@% + %nat. dims of zeroth frame + \xdef\@anim@zframewd{\@anim@curwd}% + \xdef\@anim@zframeht{\@anim@curht}% + \xdef\@anim@zframedp{\@anim@curdp}% + %determine size of animation widget + \setbox\@anim@measbox=\hbox to \wd#3{% + \vrule width \z@ height \ht#3 depth \dp#3\hss}% + \@anim@scale{\@anim@measbox}% + \else% + \def\@anim@needresize{0}% + \ifdim\wd#3=\@anim@zframewd\p@\else\def\@anim@needresize{1}\fi% + \ifdim\ht#3=\@anim@zframeht\p@\else\def\@anim@needresize{1}\fi% + \ifdim\dp#3=\@anim@zframedp\p@\else\def\@anim@needresize{1}\fi% + \fi% + %create form xobject from box argument + \ifthenelse{\equal{#4}{!}}{% %%%% new graphics %%%% + %put graphics into XObject + \@anim@xform{1}{0}{#3}% + \xdef\@anim@@lastxform{\@anim@lastxform}% + \@anim@xobjnatdims{\@anim@lastxform}{% + \@anim@curwd}{\@anim@curht}{\@anim@curdp}% + }{% + \xdef\@anim@lastxform{#4}% + }% + \ifnum#2>\z@% + %adjust size of current frame to zeroth frame's dims, if necessary + \ifnum\@anim@needresize>\z@% + \global\setbox#3=\hbox to \@anim@curwd\p@{% + \vrule width \z@ height \@anim@curht\p@ depth \@anim@curdp\p@% + \@anim@refxform{\@anim@lastxform}% + \hss% + }% + \global\setbox#3=\hbox{% + \raisebox{-\@anim@zframedp\p@}{% + \resizebox*{\@anim@zframewd\p@}{% + \dimexpr\@anim@zframeht\p@+\@anim@zframedp\p@\relax% + }{\raisebox{\depth}{\box#3}}% + }% + }% + \@anim@xform{0}{0}{#3}% + \fi% + \fi% + %keep a record of XObject number + \@anim@newkey{img@#2}{\@anim@lastxform}% + \if@anim@timeline\else% + \@anim@newkey{frmcontent@#2}{% + \@anim@refxform{\@anim@getkeyval{img@#2}}% }% - } -\else - %stroking commands - \def\@anim@btnend{% - \@anim@bg\space - 2.5 w - 1 J - 1 j - \@anim@fg\space - 10 10 130 130 re - S - 10 w - 45 40 m - 95 75 l - 45 110 l - S - 0 j - 105 44 m - 105 106 l - S - } - \def\@anim@btnstep{% - \@anim@bg\space - 2.5 w - 1 J - 1 j - \@anim@fg\space - 10 10 130 130 re - S - 10 w - 50 40 m - 100 75 l - 50 110 l - S - } - \def\@anim@btnplay{% - \@anim@bg\space - 2.5 w - 1 J - 1 j - \@anim@fg\space - 10 10 130 130 re - S - 10 w - 50 40 m - 50 110 l - 100 75 l - h - S - } - \def\@anim@btnpause{% - \@anim@bg\space - 2.5 w - 1 j - \@anim@fg\space - 0 10 m - 140 10 l - 140 140 l - 0 140 l - S - 20 w - 22 40 m - 22 110 l - S - } - \def\@anim@btnminus{% - \@anim@bg\space - 2.5 w - 1 J - 1 j - \@anim@fg\space - 10 10 130 130 re - S - 10 w - 0 J - 40 75 m - 110 75 l - S - } - \def\@anim@btnplus{% - \@anim@bg\space - 2.5 w - 1 J - 1 j - \@anim@fg\space - 10 10 130 130 re - S - 10 w - 0 J - 40 75 m - 110 75 l - 75 40 m - 75 110 l - S - } - \def\@anim@btnreset{% - \@anim@bg\space - 2.5 w - 1 J - 1 j - \@anim@fg\space - 10 10 130 130 re - S - 10 w - 75 40 m - 75 110 l - S - \@anim@@@fg\space - 35 50 m - 70 75 l - 35 100 l - f - 115 50 m - 80 75 l - 115 100 l - f - 2 J - 0 j - 30 75 m - 35 75 l - 120 75 m - 115 75 l - S - } - \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 - \ifpdf - \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:#3}{\the\pdflastobj\space 0 R}% - } - \else% dvipdfmx - \def\@anim@xbutton#1#2#3{% - \special{pdf:stream @btn#1:#3\space (#2) <<% - /Type/XObject/Subtype/Form/BBox [0 0 15 15] >>% + \@anim@makeframe{#1}{#2}% + \fi% +} + +\def\@anim@posterlast{last}% helper macros +\def\@anim@posterfirst{first}% +\def\@anim@posternone{none}% + +%creates OCG +\def\@anim@newocg#1#2{%#1:@anim@num, #2:@anim@curframe@zb + \@anim@dictobj{/Type/OCG /Name (#1.#2)}% + \xdef\@anim@curocg{\@anim@lastobj}% + %append to ocg array + \xdef\@anim@ocgs{\@anim@ocgs\space\@anim@curocg}% +} + +%inserts one animation frame into the output, either as a non-interactive Widget +%annotation, or directly into the content stream of the page object for OCG-based +%animation +\def\@anim@makeframe#1#2{% + %visibility + \if@anim@useocg% + \@anim@newocg{#1}{#2}% + \ifx\@anim@poster\@anim@posterlast% + \@anim@keytoaux{a#1.poster}{#2}% + \ifthenelse{\equal{\@anim@getkeyval{a#1.poster}}{#2}}{}{% + \xdef\@anim@offocgs{\@anim@offocgs\space\@anim@curocg}% }% - } - \fi -\fi + \else% + \ifnum#2=\z@% + \ifx\@anim@poster\@anim@posternone% + \xdef\@anim@offocgs{\@anim@offocgs\space\@anim@curocg}% + \fi% + \else% + \xdef\@anim@offocgs{\@anim@offocgs\space\@anim@curocg}% + \fi% + \fi% + \else% + \def\@anim@annotflag{/F 2}% + \ifx\@anim@poster\@anim@posternone\else% + \ifnum#2=\z@% + \ifx\@anim@poster\@anim@posterfirst% + \def\@anim@annotflag{/F 4}% + \fi% + \fi% + \ifx\@anim@poster\@anim@posterlast% + \@anim@keytoaux{a#1.poster}{#2}% + \ifthenelse{\equal{\@anim@getkeyval{a#1.poster}}{#2}}{% + \def\@anim@annotflag{/F 4}% + }{}% + \fi% + \fi% + \fi% + %container box + \global\setbox\@anim@box=\hbox to \@anim@zframewd\p@{% + \vrule width \z@ height \@anim@zframeht\p@ depth \@anim@zframedp\p@% + \@anim@getkeyval{frmcontent@#2}% + \hss% + }% + %frame insertion + \if@anim@useocg% + \def\@anim@needresize{0}% + \ifdim\@anim@animwidth\p@=\@anim@zframewd\p@\else% + \def\@anim@needresize{1}\fi% + \ifdim\@anim@animheight\p@=\@anim@zframeht\p@\else% + \def\@anim@needresize{1}\fi% + \ifdim\@anim@animdepth\p@=\@anim@zframedp\p@\else% + \def\@anim@needresize{1}\fi% + \ifnum\@anim@needresize>\z@% + \global\setbox\@anim@box=\hbox{% + \raisebox{-\@anim@animdepth\p@}{% + \resizebox*{\@anim@animwidth\p@}{% + \dimexpr\@anim@animheight\p@+\@anim@animdepth\p@\relax% + }{\raisebox{\depth}{\box\@anim@box}}% + }% + }% + \fi% + \@anim@xform{0}{0}{\@anim@box}% + \@anim@bdc{/OC}{\@anim@curocg}% + \@anim@refxform{\@anim@lastxform}% + \@anim@emc% + \else% + \@anim@xform{0}{1}{\@anim@box}% + \@anim@pdfannot{\@anim@animwidth}{\@anim@animheight}{\@anim@animdepth}{% + /Subtype/Widget% + \@anim@annotflag% + /FT/Btn/Ff 65537% + /BS <</W 0>>% + /AP <</N \@anim@refobj{\@anim@lastxform}>>% + /MK <</TP 1/I \@anim@refobj{\@anim@lastxform}/IF<</S/A/FB true>>>>% + /T (#1.#2)% + }% + \fi% +} + +%create XObjects of all button faces +%stroking commands +\def\@anim@btnend{% + \@anim@bg\space + 2.5 w + 1 J + 1 j + \@anim@fg\space + 10 10 130 130 re + S + 10 w + 45 40 m + 95 75 l + 45 110 l + S + 0 j + 105 44 m + 105 106 l + S +} +\def\@anim@btnstep{% + \@anim@bg\space + 2.5 w + 1 J + 1 j + \@anim@fg\space + 10 10 130 130 re + S + 10 w + 50 40 m + 100 75 l + 50 110 l + S +} +\def\@anim@btnplay{% + \@anim@bg\space + 2.5 w + 1 J + 1 j + \@anim@fg\space + 10 10 130 130 re + S + 10 w + 50 40 m + 50 110 l + 100 75 l + h + S +} +\def\@anim@btnpause{% + \@anim@bg\space + 2.5 w + 1 j + \@anim@fg\space + 0 10 m + 140 10 l + 140 140 l + 0 140 l + S + 20 w + 22 40 m + 22 110 l + S +} +\def\@anim@btnminus{% + \@anim@bg\space + 2.5 w + 1 J + 1 j + \@anim@fg\space + 10 10 130 130 re + S + 10 w + 0 J + 40 75 m + 110 75 l + S +} +\def\@anim@btnplus{% + \@anim@bg\space + 2.5 w + 1 J + 1 j + \@anim@fg\space + 10 10 130 130 re + S + 10 w + 0 J + 40 75 m + 110 75 l + 75 40 m + 75 110 l + S +} +\def\@anim@btnreset{% + \@anim@bg\space + 2.5 w + 1 J + 1 j + \@anim@fg\space + 10 10 130 130 re + S + 10 w + 75 40 m + 75 110 l + S + \@anim@@@fg\space + 35 50 m + 70 75 l + 35 100 l + f + 115 50 m + 80 75 l + 115 100 l + f + 2 J + 0 j + 30 75 m + 35 75 l + 120 75 m + 115 75 l + S +} +\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#3{% #1 name, #2 stroking commands, #3 @anim@num + \@anim@streamobj{/Type/XObject/Subtype/Form/BBox [0 0 15 15]}{#2}% + \@anim@newkey{btn#1:#3}{\@anim@lastobj}% +} %determines file type of the sequence \def\zap@finalspace#1 \@nil{#1} @@ -1286,7 +1113,7 @@ \xdef\@anim@pathtofile{\expandafter\zap@finalspace\@filef@und\@nil}% }% \else - \if@anim@@dvipdfmx %XeLaTeX, dvipdfmx + \if@anim@dvipdfmx %XeLaTeX, dvipdfmx \def\@anim@getpath#1{% \gdef\@anim@ext{.pdf}% we start with `pdf' \IfFileExists{#1\@anim@ext}{}{% @@ -1497,7 +1324,8 @@ \fi% }% \else - \def\@anim@checkmultipage#1{}% no-op in dvips & dvipdfmx mode + %no multipage support in dvips and dvipdfmx + \def\@anim@checkmultipage#1{\setboolean{@anim@multipage}{false}}% \fi \fi @@ -1519,7 +1347,7 @@ \if@anim@xetex% \@anim@missing[xetex]{graphicx}% \else% - \if@anim@@dvipdfmx% + \if@anim@dvipdfmx% \@anim@missing[dvipdfmx]{graphicx}% \else% \@anim@missing{graphicx}% @@ -1582,7 +1410,6 @@ \@anim@getpath{\@anim@base\@anim@first}% \@anim@filebox{\@anim@pathtofile}{1}% \fi% - \@anim@getsize{\@anim@box}% \@anim@scale{\@anim@box}% %draw draftbox according to dimensions of the first frame \@anim@draftbox% @@ -1627,12 +1454,12 @@ \global\advance\@anim@tmpcnt by -\@ne% \xdef\@anim@maxframe{\the\@anim@tmpcnt}% highest frame index %build timeline from optional timeline file - \if@anim@timeline% - \@anim@sanitize\@anim@buildtmln{\the\@anim@num}\@anim@endsanitize% - \fi% + \@anim@sanitize% + \if@anim@timeline\@anim@buildtmln{\the\@anim@num}\fi% %insert animation widget & controls \@anim@insertwidgets{\the\@anim@num}{% \@anim@getkeyval{btncol:\@anim@bgcolour:\@anim@fgcolour}}% + \@anim@endsanitize% \fi% \endgroup% \global\advance\@anim@num by \@ne% @@ -1679,349 +1506,147 @@ }% } -%measures natural dimensions of its box argument -\def\@anim@getsize#1{% - \xdef\@anim@framewidth{\strip@pt\wd#1}% - \xdef\@anim@frameheight{\strip@pt\ht#1}% - \xdef\@anim@framedepth{\strip@pt\dp#1}% - \setlength{\@anim@tmpdima}{\ht#1}% - \addtolength{\@anim@tmpdima}{\dp#1}% - \xdef\@anim@frametotalheight{\strip@pt\@anim@tmpdima}% -} - -%calculates widget dimensions from natural ones, taking resizing options -%into account -\newcount\@anim@resize% resizing flags according to options given -\def\@anim@scale#1{% +\newcount\@anim@resizeflags% resizing flags according to options given. +% +%set animation widget dimensions +\def\@anim@scale#1{% #1: box number \begingroup% - %natural dimensions \width, \height, \depth, \totalheight - \def\width{\wd#1}% - \def\height{\ht#1}% - \def\depth{\dp#1}% - \let\totalheight\@anim@tmpdimb% - \setlength{\totalheight}{\height}% - \addtolength{\totalheight}{\depth}% - %evaluate resizing options - \setlength{\@anim@tmpdima}{\@anim@widtharg}% - \xdef\@anim@animwidth{\strip@pt\@anim@tmpdima}% - \setlength{\@anim@tmpdima}{\@anim@heightarg}% - \xdef\@anim@animheight{\strip@pt\@anim@tmpdima}% - \setlength{\@anim@tmpdima}{\@anim@deptharg}% - \xdef\@anim@animdepth{\strip@pt\@anim@tmpdima}% - \setlength{\@anim@tmpdima}{\@anim@heightarg}% - \addtolength{\@anim@tmpdima}{\@anim@deptharg}% - \xdef\@anim@animtotalheight{\strip@pt\@anim@tmpdima}% - %resize unspecified dimensions to keep aspect ratio - \ifcase\@anim@resize% bit 2^2=width, 2^1=height, 2^0=depth option given + %natural dimensions \width, \height, \depth, \totalheight + \def\width{\wd#1}% + \def\height{\ht#1}% + \def\depth{\dp#1}% + \let\totalheight\@anim@tmpdimb% + \setlength{\totalheight}{\dimexpr\height+\depth\relax}% + %evaluate resizing options + \xdef\@anim@animwidth{\strip@pt\dimexpr\@anim@widtharg\relax}% + \xdef\@anim@animheight{\strip@pt\dimexpr\@anim@heightarg\relax}% + \xdef\@anim@animtotalheight{\strip@pt\dimexpr\@anim@totheightarg\relax}% + \endgroup% + %correct wrong option combination; totalheight overrides height + \ifnum\@anim@resizeflags=3% height+totalheight->totalheight + \global\@anim@resizeflags=\@ne% + \fi% + \ifnum\@anim@resizeflags=7% height+totalheight+width->totalheight+width + \global\@anim@resizeflags=5% + \fi% + %now resize + \ifcase\@anim@resizeflags% bit 2^2=width, 2^1=height, 2^0=totalhight given \or% 1 - \setlength{\@anim@tmpdima}{% - \width*\ratio{\@anim@animtotalheight\p@}{\height+\depth}% - }\xdef\@anim@animwidth{\strip@pt\@anim@tmpdima}% + \global\setbox#1=\hbox{\resizebox*{!}{\@anim@animtotalheight\p@}{\box#1}}% \or% 2 - \setlength{\@anim@tmpdima}{% - \width*\ratio{\@anim@animtotalheight\p@}{\height+\depth}% - }\xdef\@anim@animwidth{\strip@pt\@anim@tmpdima}% - \or% 3 - \setlength{\@anim@tmpdima}{% - \width*\ratio{\@anim@animtotalheight\p@}{\height+\depth}% - }\xdef\@anim@animwidth{\strip@pt\@anim@tmpdima}% - \or% 4 - \setlength{\@anim@tmpdima}{% - \height*\ratio{\@anim@animwidth\p@}{\width}% - }\xdef\@anim@animheight{\strip@pt\@anim@tmpdima}% - \setlength{\@anim@tmpdima}{% - \depth*\ratio{\@anim@animwidth\p@}{\width}% - }\xdef\@anim@animdepth{\strip@pt\@anim@tmpdima}% + \global\setbox#1=\hbox{\resizebox{!}{\@anim@animheight\p@}{\box#1}}% + \or\or% 4 + \global\setbox#1=\hbox{\resizebox{\@anim@animwidth\p@}{!}{\box#1}}% \or% 5 - \ifdim\height=\z@\else% resize height only if original height .ne. zero + \if@anim@iso% \setlength{\@anim@tmpdima}{% - \totalheight*\ratio{\@anim@animwidth\p@}{\width}-\@anim@animdepth\p@}% - \xdef\@anim@animheight{\strip@pt\@anim@tmpdima}% + \totalheightof{\usebox#1}*\ratio{\@anim@animwidth\p@}{\wd#1}}% + \ifdim\@anim@tmpdima<\z@\@anim@tmpdima=-\@anim@tmpdima\fi% + \setlength{\@anim@tmpdimb}{\@anim@animtotalheight\p@}% + \ifdim\@anim@tmpdimb<\z@\@anim@tmpdimb=-\@anim@tmpdimb\fi% + \ifdim\@anim@tmpdima<\@anim@tmpdimb% + \global\setbox#1=\hbox{\resizebox*{\@anim@animwidth\p@}{!}{\box#1}}% + \else% + \global\setbox#1=\hbox{% + \resizebox*{!}{\@anim@animtotalheight\p@}{\box#1}}% + \fi% + \else% + \global\setbox#1=\hbox{% + \resizebox*{\@anim@animwidth\p@}{\@anim@totheightarg}{\box#1}}% \fi% \or% 6 - \ifdim\depth=\z@\else% resize depth only if original depth .ne. zero - \setlength{\@anim@tmpdima}{% - \totalheight*\ratio{\@anim@animwidth\p@}{\width}-\@anim@animheight\p@}% - \xdef\@anim@animdepth{\strip@pt\@anim@tmpdima}% + \if@anim@iso% + \setlength{\@anim@tmpdima}{\ht#1*\ratio{\@anim@animwidth\p@}{\wd#1}}% + \ifdim\@anim@tmpdima<\z@\@anim@tmpdima=-\@anim@tmpdima\fi% + \setlength{\@anim@tmpdimb}{\@anim@animheight\p@}% + \ifdim\@anim@tmpdimb<\z@\@anim@tmpdimb=-\@anim@tmpdimb\fi% + \ifdim\@anim@tmpdima<\@anim@tmpdimb% + \global\setbox#1=\hbox{\resizebox{\@anim@animwidth\p@}{!}{\box#1}}% + \else% + \global\setbox#1=\hbox{\resizebox{!}{\@anim@animheight\p@}{\box#1}}% + \fi% + \else% + \global\setbox#1=\hbox{% + \resizebox{\@anim@animwidth\p@}{\@anim@animheight\p@}{\box#1}}% \fi% \fi% - %apply scaling factor, totalheight - \setlength{\@anim@tmpdima}{\@anim@animwidth\p@}% - \setlength{\@anim@tmpdima}{\@anim@boxscale\@anim@tmpdima}% - \xdef\@anim@animwidth{\strip@pt\@anim@tmpdima}% - \setlength{\@anim@tmpdima}{\@anim@animheight\p@}% - \setlength{\@anim@tmpdima}{\@anim@boxscale\@anim@tmpdima}% - \xdef\@anim@animheight{\strip@pt\@anim@tmpdima}% - \setlength{\@anim@tmpdima}{\@anim@animdepth\p@}% - \setlength{\@anim@tmpdima}{\@anim@boxscale\@anim@tmpdima}% - \xdef\@anim@animdepth{\strip@pt\@anim@tmpdima}% - \setlength{\@anim@tmpdima}{\@anim@animheight\p@}% - \addtolength{\@anim@tmpdima}{\@anim@animdepth\p@}% - \xdef\@anim@animtotalheight{\strip@pt\@anim@tmpdima}% - \endgroup% -} - -%interactive Widget annotation that is overlayed on the non-interactive -%frame Widgets -\ifpdf - \def\@anim@animwidget#1{% - %create JavaScript objects - \@anim@pojscript{#1}% to be executed on PO event - \@anim@otherjscript{#1}% on other events in the AA dict - \pdfannot - width \@anim@animwidth\p@ height \@anim@animheight\p@ - depth \@anim@animdepth\p@ - {% - /Subtype/Widget% - /FT/Btn/Ff 65536% interactive push button - /BS <</W 0>>% - /H/N% - /T (anm#1)% - /Contents (animation by animate[\@anim@version])% - /AA <<% bind actions to trigger events - /PO <<% - /S/JavaScript/JS \@anim@pojscriptobj% - >>% - \@anim@otherjscriptkey% + %apply scale + \ifdim\@anim@boxscale\p@=\@ne\p@\else% + \global\setbox#1=\hbox{\scalebox{\@anim@boxscale}{\box#1}}% + \fi% + %dimensions after resizing + \xdef\@anim@animwidth{\strip@pt\wd#1}% + \xdef\@anim@animheight{\strip@pt\ht#1}% + \xdef\@anim@animdepth{\strip@pt\dp#1}% + \xdef\@anim@animtotalheight{\strip@pt\dimexpr\ht#1+\dp#1\relax}% +} + +%interactive Widget annotation that is overlayed on the +%non-interactive frame Widgets +\def\@anim@animwidget#1{% + \@anim@pojscript{#1}% + \@anim@otherjscript{#1}% + \@anim@pdfannot{\@anim@animwidth}{\@anim@animheight}{\@anim@animdepth}{% + /Subtype/Widget% + /FT/Btn/Ff \@anim@btnflag% + /BS <</W 0>>% + /H/N% + /T (anm#1)% + /Contents (animation by animate[\@anim@version])% + /AA <<% + /PO <<% + /S/JavaScript/JS \@anim@pojscriptobj% >>% - }% - \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% - }% + \@anim@otherjscriptkey% + >>% }% -\else - \if@anim@@dvipdfmx - \def\@anim@animwidget#1{% - \@anim@pojscript{#1}% - \@anim@otherjscript{#1}% - \special{pdf:annot @annot@\the\@anim@fieldnum\space - width \@anim@animwidth pt height \@anim@animheight pt - depth \@anim@animdepth pt <<% - /Subtype/Widget% - /FT/Btn/Ff 65536% - /BS <</W 0>>% - /H/N% - /T (anm#1)% - /Contents (animation by animate[\@anim@version])% - /AA <<% - /PO <<% - /S/JavaScript/JS @a#1@pojscript% - >>% - \@anim@otherjscriptkey% - >> - >>% - }% - \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@% - \hss% - }% - }% - \else - \def\@anim@animwidget#1{% - \begingroup% - \setlength{\unitlength}{1pt}% - %mark annotation rectangle - \begin{picture}(0,0)% - \put(0,-\@anim@animdepth){% - \special{ps: - currentpoint /wid@lly exch def /wid@llx exch def - }% - }% - \put(\@anim@animwidth,\@anim@animheight){% - \special{ps: - currentpoint /wid@ury exch def /wid@urx exch def - }% - }% - \end{picture}% - \endgroup% - \@anim@pojscript{#1}% - \@anim@otherjscript{#1}% - \special{ps: - mark - /_objdef {annot@\the\@anim@fieldnum}% - /Rect [wid@llx wid@lly wid@urx wid@ury]% - /Subtype/Widget% - /FT/Btn/Ff 65536% - /BS <</W 0>>% - /H/N% - /T (anm#1)% - /Contents (animation by animate[\@anim@version])% - /AA <<% - /PO <<% - /S/JavaScript/JS {a#1@pojscript}% - >>% - \@anim@otherjscriptkey% - >>% - /ANN pdfmark% - }% - \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@% - \hss% - }% - } - \fi -\fi + \hbox to \@anim@animwidth\p@ {% + \vrule width 0pt height \@anim@animheight\p@ depth \@anim@animdepth\p@% + \hss% + }% +} %creates control button widget \newboolean{@anim@js} \newboolean{@anim@mk} -\ifpdf - \def\@anim@buttonwidget#1#2#3{%#1:@anim@num, #2:action, #3:button face XObject - \def\@anim@annotflag{/F 0}% visible, but don't print - \def\@anim@buttonname{#2}\@anim@jstrue\@anim@mktrue% - \def\@anim@arg{PlayLeft}% - \ifx\@anim@arg\@anim@buttonname\@anim@jsfalse\fi% _ - \def\@anim@arg{PauseLeft}% %hidden, don't print | - \ifx\@anim@arg\@anim@buttonname\@anim@jsfalse\def\@anim@annotflag{/F 2}\fi%_| - \def\@anim@arg{PlayRight}% - \ifx\@anim@arg\@anim@buttonname\@anim@jsfalse\fi% - \def\@anim@arg{PauseRight}% - \ifx\@anim@arg\@anim@buttonname\@anim@jsfalse\def\@anim@annotflag{/F 2}\fi% - \def\@anim@arg{PlayPauseLeft}% - \ifx\@anim@arg\@anim@buttonname\@anim@mkfalse\fi% - \def\@anim@arg{PlayPauseRight}% - \ifx\@anim@arg\@anim@buttonname\@anim@mkfalse\fi% - \if@anim@js\@anim@upjscript{#1}{#2}\fi% JavaScript actions for ButtonUp events - \setlength{\@anim@tmpdima}{\@anim@btnsize}% - \pdfannot - width \@anim@tmpdima - height \@anim@tmpdima - depth 0pt - {% - /Subtype/Widget% - \@anim@annotflag% - /FT/Btn/Ff \if@anim@js 65536\else 65537\fi% - /H\if@anim@js/I\else/N\fi% - /BS <</W 0>>% - \if@anim@mk% - /AP <</N \@anim@getkeyval{btn#3}>>% - /MK <</TP 1/I \@anim@getkeyval{btn#3}/IF<</S/A/FB true>>>>% - \fi% - /T (#1.#2)% - \@anim@tooltip% - \if@anim@js/A <</S/JavaScript/JS (\@anim@upjscriptstring)>>\fi% - }% - \xdef\@anim@fields{\@anim@fields\the\pdflastannot\space 0 R\space}% - \if@anim@js% - \hbox to \@anim@tmpdima {% - \vrule width 0pt height \@anim@tmpdima depth 0pt% - \hss% - }% +\def\@anim@buttonwidget#1#2#3{%#1:@anim@num, #2:action, #3:button face XObject + \def\@anim@annotflag{/F 0}% visible, but don't print + \def\@anim@buttonname{#2}\@anim@jstrue\@anim@mktrue% + \def\@anim@arg{PlayLeft}% + \ifx\@anim@arg\@anim@buttonname\@anim@jsfalse\fi% _ + \def\@anim@arg{PauseLeft}% %hidden, don't print | + \ifx\@anim@arg\@anim@buttonname\@anim@jsfalse\def\@anim@annotflag{/F 2}\fi%_| + \def\@anim@arg{PlayRight}% + \ifx\@anim@arg\@anim@buttonname\@anim@jsfalse\fi% + \def\@anim@arg{PauseRight}% + \ifx\@anim@arg\@anim@buttonname\@anim@jsfalse\def\@anim@annotflag{/F 2}\fi% + \def\@anim@arg{PlayPauseLeft}% + \ifx\@anim@arg\@anim@buttonname\@anim@mkfalse\fi% + \def\@anim@arg{PlayPauseRight}% + \ifx\@anim@arg\@anim@buttonname\@anim@mkfalse\fi% + \if@anim@js\@anim@upjscript{#1}{#2}\fi% JavaScript actions for ButtonUp events + \setlength{\@anim@tmpdima}{\@anim@btnsize}% + \@anim@pdfannot{\strip@pt\@anim@tmpdima}{\strip@pt\@anim@tmpdima}{0}{% + /Subtype/Widget% + \@anim@annotflag% + /FT/Btn/Ff \if@anim@js 65536\else 65537\fi% + /H\if@anim@js/I\else/N\fi% + /BS <</W 0>>% + \if@anim@mk% + /AP <</N \@anim@getkeyval{btn#3}>>% + /MK <</TP 1/I \@anim@getkeyval{btn#3}/IF<</S/A/FB true>>>>% \fi% + /T (#1.#2)% + \@anim@tooltip% + \if@anim@js/A <</S/JavaScript/JS (\@anim@upjscriptstring)>>\fi% }% -\else - \if@anim@@dvipdfmx - \def\@anim@buttonwidget#1#2#3{% - \def\@anim@annotflag{/F 0}% visible, but don't print - \def\@anim@buttonname{#2}\@anim@jstrue\@anim@mktrue% - \def\@anim@arg{PlayLeft}% - \ifx\@anim@arg\@anim@buttonname\@anim@jsfalse\fi% _ - \def\@anim@arg{PauseLeft}% %hidden, don't print | - \ifx\@anim@arg\@anim@buttonname\@anim@jsfalse\def\@anim@annotflag{/F 2}\fi%_| - \def\@anim@arg{PlayRight}% - \ifx\@anim@arg\@anim@buttonname\@anim@jsfalse\fi% - \def\@anim@arg{PauseRight}% - \ifx\@anim@arg\@anim@buttonname\@anim@jsfalse\def\@anim@annotflag{/F 2}\fi% - \def\@anim@arg{PlayPauseLeft}% - \ifx\@anim@arg\@anim@buttonname\@anim@mkfalse\fi% - \def\@anim@arg{PlayPauseRight}% - \ifx\@anim@arg\@anim@buttonname\@anim@mkfalse\fi% - \if@anim@js\@anim@upjscript{#1}{#2}\fi% JavaScript actions for ButtonUp events - \setlength{\@anim@tmpdima}{\@anim@btnsize}% - \special{pdf:annot @annot@\the\@anim@fieldnum\space - width \the\@anim@tmpdima\space height \the\@anim@tmpdima\space - depth 0pt <<% - /Subtype/Widget% - \@anim@annotflag% - /FT/Btn/Ff \if@anim@js 65536\else 65537\fi% - /H\if@anim@js/I\else/N\fi% - /BS <</W 0>>% - \if@anim@mk% - /AP <</N @btn#3>>% - /MK <</TP 1/I @btn#3/IF<</S/A/FB true>>>>% - \fi% - /T (#1.#2)% - \@anim@tooltip% - \if@anim@js/A <</S/JavaScript/JS (\@anim@upjscriptstring)>>\fi% - >>% - }% - \xdef\@anim@fields{\@anim@fields @annot@\the\@anim@fieldnum\space}% - \global\advance\@anim@fieldnum by \@ne% - \if@anim@js% - \hbox to \@anim@tmpdima {% - \vrule width 0pt height \@anim@tmpdima depth 0pt% - \hss% - }% - \fi% + \if@anim@js% + \hbox to \@anim@tmpdima {% + \vrule width 0pt height \@anim@tmpdima depth 0pt% + \hss% }% - \else - \def\@anim@buttonwidget#1#2#3{% - \def\@anim@annotflag{/F 0}% visible, but don't print - \def\@anim@buttonname{#2}\@anim@jstrue\@anim@mktrue% - \def\@anim@arg{PlayLeft}% - \ifx\@anim@arg\@anim@buttonname\@anim@jsfalse\fi% _ - \def\@anim@arg{PauseLeft}% %hidden, don't print | - \ifx\@anim@arg\@anim@buttonname\@anim@jsfalse\def\@anim@annotflag{/F 2}\fi%_| - \def\@anim@arg{PlayRight}% - \ifx\@anim@arg\@anim@buttonname\@anim@jsfalse\fi% - \def\@anim@arg{PauseRight}% - \ifx\@anim@arg\@anim@buttonname\@anim@jsfalse\def\@anim@annotflag{/F 2}\fi% - \def\@anim@arg{PlayPauseLeft}% - \ifx\@anim@arg\@anim@buttonname\@anim@mkfalse\fi% - \def\@anim@arg{PlayPauseRight}% - \ifx\@anim@arg\@anim@buttonname\@anim@mkfalse\fi% - \if@anim@js\@anim@upjscript{#1}{#2}\fi% JavaScript actions for ButtonUp events - \setlength{\@anim@tmpdima}{\@anim@btnsize}% - \begingroup% - \setlength{\unitlength}{1pt}% - \begin{picture}(0,0)% - \put(0,0){% - \special{ps: - currentpoint /wid@lly exch def /wid@llx exch def - }% - }% - \put(\strip@pt\@anim@tmpdima,\strip@pt\@anim@tmpdima){% - \special{ps: - currentpoint /wid@ury exch def /wid@urx exch def - }% - }% - \end{picture}% - \endgroup% - \special{ps: - mark - /_objdef {annot@\the\@anim@fieldnum} - /Rect [wid@llx wid@lly wid@urx wid@ury] - /Subtype/Widget% - \@anim@annotflag% - /FT/Btn/Ff \if@anim@js 65536\else 65537\fi% - /H\if@anim@js/I\else/N\fi% - /BS <</W 0>>% - \if@anim@mk% - /AP <</N {btn#3}>>% - /MK <</TP 1/I {btn#3}/IF<</S/A/FB true>>>>% - \fi% - /T (#1.#2)% - \@anim@tooltip% - \if@anim@js/A <</S/JavaScript/JS (\@anim@upjscriptstring)>>\fi% - /ANN pdfmark% - }% - \xdef\@anim@fields{\@anim@fields{annot@\the\@anim@fieldnum}\space}% - \global\advance\@anim@fieldnum by \@ne% - \if@anim@js% - \hbox to \@anim@tmpdima {% - \vrule width 0pt height \@anim@tmpdima depth 0pt% - \hss% - }% - \fi% - } - \fi -\fi + \fi% +} \newboolean{@anim@inside} % for checking whether we are inside the \setboolean{@anim@inside}{false} % `animateinline' environment @@ -2088,12 +1713,12 @@ \global\advance\@anim@tmpcnt by -\@ne% \xdef\@anim@maxframe{\the\@anim@tmpcnt}% highest frame index %build timeline from optional timeline file - \if@anim@timeline% - \@anim@sanitize\@anim@buildtmln{\the\@anim@num}\@anim@endsanitize% - \fi% + \@anim@sanitize% + \if@anim@timeline\@anim@buildtmln{\the\@anim@num}\fi% %insert animation widget & controls \@anim@insertwidgets{\the\@anim@num}{% \@anim@getkeyval{btncol:\@anim@bgcolour:\@anim@fgcolour}}% + \@anim@endsanitize% \fi% \endgroup% \global\advance\@anim@num by \@ne% @@ -2194,7 +1819,6 @@ \the\@anim@end% \end{lrbox}% \ifnum\@anim@skipfram=\z@% - \@anim@getsize{\@anim@box}%determine size of graphics \ifnum#2=\z@% \ifdim\wd\@anim@box=\z@% \PackageError{animate}{% @@ -2204,20 +1828,23 @@ immediately followed by \protect\newframe% }% \fi% - \ifdim\ht\@anim@box=\z@% - \ifdim\dp\@anim@box=\z@% + \ifdim\ht\@anim@box=\z@\ifdim\dp\@anim@box=\z@% \PackageError{animate}{% Contents of first frame must not have zero height% }{}% - \fi% - \fi% - \@anim@scale{\@anim@box}% + \fi\fi% %draw draftbox according to dimensions of the first frame - \if@anim@draft\@anim@draftbox\fi% + \if@anim@draft\@anim@scale{\@anim@box}\@anim@draftbox\fi% + \else% remaining frames + %deal with zero width or totalheight boxes + \ifdim\wd\@anim@box=\z@\global\setbox\@anim@box=\hbox{\phantom{X}}\fi% + \ifdim\ht\@anim@box=\z@\ifdim\dp\@anim@box=\z@% + \global\setbox\@anim@box=\hbox{\phantom{X}}% + \fi\fi% \fi% %now create Form XObject of box contents \if@anim@draft\else% - \@anim@xinline{#1}{#2}{\@anim@box}{!}\message{<a#1,fr#2>}% + \@anim@xinline{#1}{#2}{\@anim@box}{!}{}\message{<a#1,fr#2>}% \fi% \fi% \global\advance\@anim@skipfram by \@ne% @@ -2370,20 +1997,15 @@ #2% \fi% }% -\def\@anim@template#1#2{% create template (stringed zeros) from given num - \ifnum10#1<1#2 - \@anim@template{0#1}{#2}% +\def\@anim@template#1#2{% create template (string of zeros) from given num + \ifnum10#1>1#2 + #1% \else% - \ifnum10#1=1#2 - \@anim@template{0#1}{#2}% - \else% - #1% - \fi% + \@anim@template{0#1}{#2}% \fi% }% -\edef\@anim@catcode{\the\catcode`\_}\catcode`\_=13 -\begingroup\let_\space +\begingroup\catcode`\_=13\let_\space \xdef\@anim@nusewarning{% @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\MessageBreak% @_There_were_unused_animation_transparencies._______@\MessageBreak% @@ -2393,57 +2015,23 @@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@% } \endgroup -\catcode`\_=\@anim@catcode %macros for sanitizing characters read from timeline file -\ifpdf - \begingroup - \catcode`\$=0 $catcode`$\=12 - $gdef$@anim@nln{\} - $endgroup -\else - \begingroup - \catcode`\$=0 $catcode`$\=12 - $gdef$@anim@nln{\\} - $endgroup -\fi -\begingroup -\catcode`\<=1 \catcode`\>=2 -\catcode`\{=12 \catcode`\}=12 -\catcode`\%=12 -\gdef\@anim@lbr<{> \gdef\@anim@rbr<}> -\gdef\@anim@per<%> -\endgroup - \def\@anim@@sanitize#1#2\@nil{% - \expandafter\xdef\csname @anim@\number`#1\endcsname{\the\catcode`#1}% \catcode`#1=12% - \ifx\@empty#2\@empty% - \else% + \ifx\@empty#2\@empty\else% \@anim@@sanitize#2\@nil% \fi% } -\def\@anim@@endsanitize#1#2\@nil{% - \catcode`#1=\csname @anim@\number`#1\endcsname% - \ifx\@empty#2\@empty% - \else% - \@anim@@endsanitize#2\@nil% - \fi% -} \def\@anim@sanitize{% + \begingroup% \@anim@@sanitize.:;?!/"'*+,->=<$\&@][)(^_`|~\#\@nil% - \let\@anim@newline=\\\let\\=\@anim@nln% - \let\@anim@leftbrace=\{\let\{=\@anim@lbr% - \let\@anim@rightbrace=\}\let\}=\@anim@rbr% - \let\@anim@percent=\%\let\%=\@anim@per% -}% -\def\@anim@endsanitize{% - \@anim@@endsanitize.:;?!/"'*+,->=<$\&@][)(^_`|~\#\@nil% - \let\%=\@anim@percent% - \let\}=\@anim@rightbrace% - \let\{=\@anim@leftbrace% - \let\\=\@anim@newline% -}% + \def\\{\string\\}% + \def\{{\string\{}% + \def\}{\string\}}% + \def\%{\string\%}% +} +\let\@anim@endsanitize\endgroup %building timeline from timeline file \newread\@anim@@tmlnfile @@ -2467,9 +2055,8 @@ \setboolean{@anim@eof}{false}\fi% \whiledo{\NOT\boolean{@anim@eof}}{% \ifthenelse{\equal{\@anim@inputline}{}}{}{% - %initialise contents, resource & transparency lists for each frame + %initialise contents & transparency lists for each frame \@anim@newkey{trlst@\the\@anim@curframe@zb}{}% - \@anim@newkey{frmxobject@\the\@anim@curframe@zb}{}% \@anim@newkey{frmcontent@\the\@anim@curframe@zb}{}% \global\advance\@anim@curframe@zb by \@ne% }% @@ -2511,11 +2098,6 @@ \@anim@getkeyval{% layercontent@\the\@anim@curframe@zb.\the\@anim@curlayer}% }% - \@anim@newkey{frmxobject@\the\@anim@curframe@zb}{% - \@anim@getkeyval{frmxobject@\the\@anim@curframe@zb}% - \@anim@getkeyval{% - layerxobject@\the\@anim@curframe@zb.\the\@anim@curlayer}% - }% \@anim@newkey{trlst@\the\@anim@curframe@zb}{% \@anim@getkeyval{trlst@\the\@anim@curframe@zb}% \@anim@getkeyval{% @@ -2524,8 +2106,6 @@ \@anim@newkey{% layercontent@\the\@anim@curframe@zb.\the\@anim@curlayer}{}% \@anim@newkey{% - layerxobject@\the\@anim@curframe@zb.\the\@anim@curlayer}{}% - \@anim@newkey{% layertrlst@\the\@anim@curframe@zb.\the\@anim@curlayer}{}% \global\advance\@anim@curlayer by \@ne% \repeat% @@ -2538,7 +2118,6 @@ %clean-up \expandafter\@anim@resetmult\@anim@trlst,\@nil% \@anim@newkey{trlst@\the\@anim@curframe@zb}{}% - \@anim@newkey{frmxobject@\the\@anim@curframe@zb}{}% \@anim@newkey{frmcontent@\the\@anim@curframe@zb}{}% \message{.}% \global\advance\@anim@curframe@zb by \@ne% @@ -2670,8 +2249,6 @@ \ifthenelse{\equal{#1}{c}\OR\equal{#1}{C}}{% \global\@anim@tmpcnt=\@anim@curframe@zb% \loop\ifnum\@anim@frames>\@anim@tmpcnt% - %clear ressource list - \@anim@newkey{layerxobject@\the\@anim@tmpcnt.\the\@anim@curlayer}{}% %clear layer content \@anim@newkey{layercontent@\the\@anim@tmpcnt.\the\@anim@curlayer}{}% %clear list of transparencies used in the current layer @@ -2679,23 +2256,16 @@ \global\advance\@anim@tmpcnt by \@ne% \repeat% }{% - %build contents of animation layer and update layer xobject resource - %list according to transparency specifications + %build contents of animation layer according to transparency specifications \ifnum\@anim@transp<#1\else% ignore non-existing \ifnum\@anim@transp=#1\else% transparencies \global\@anim@tmpcnt=\@anim@curframe@zb% \loop\ifnum\@anim@repeatuntil>\@anim@tmpcnt% - %ressource list - \edef\@anim@tmpvar{\@anim@getkeyval{% - layerxobject@\the\@anim@tmpcnt.\the\@anim@curlayer}}% - \@anim@newkey{layerxobject@\the\@anim@tmpcnt.\the\@anim@curlayer}{% - \@anim@tmpvar\space/im#1\space\@anim@getkeyval{img@#1}% - }% %layer content \edef\@anim@tmpvar{\@anim@getkeyval{% layercontent@\the\@anim@tmpcnt.\the\@anim@curlayer}}% \@anim@newkey{layercontent@\the\@anim@tmpcnt.\the\@anim@curlayer}{% - \@anim@tmpvar\space q /im#1\space Do Q% + \@anim@tmpvar\@anim@refxform{\@anim@getkeyval{img@#1}}% }% %append transp. to list of transparencies used in the current layer \edef\@anim@tmpvar{\@anim@getkeyval{% @@ -2709,21 +2279,19 @@ }% } -\edef\@anim@catcode{\the\catcode`\_}\catcode`\_=13 -\begingroup\let_\space +\begingroup\catcode`\_=13\let_\space \xdef\@anim@multwarning{% - @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\MessageBreak% - @_In_certain_animation_frames,_transparencies_were__@\MessageBreak% - @_multiply_included._This_may_considerably_slow_____@\MessageBreak% - @_down_animation_speed._Revise_the_timeline_file_of_@\MessageBreak% - @_the_corresponding_animation!_See_the_transcript___@\MessageBreak% - @_file______________________________________________@\MessageBreak% + @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\MessageBreak% + @_In_certain_animation_frames,_transparencies_were_@\MessageBreak% + @_included_multiple_times._This_may_considerably___@\MessageBreak% + @_slow__down_animation_speed._Revise_the_timeline__@\MessageBreak% + @_file_of_the_corresponding_animation!_See_the_____@\MessageBreak% + @_transcript_file__________________________________@\MessageBreak% @___``\jobname.log''\MessageBreak% - @_for_additional_information!_______________________@\MessageBreak% - @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@% + @_for_additional_information!______________________@\MessageBreak% + @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@% }% \endgroup -\catcode`\_=\@anim@catcode %detects multiple inclusion of the same transparency \def\@anim@findmult#1.#2,#3\@nil{% @@ -2731,7 +2299,7 @@ \@anim@newkey{u@tr#2}{}% mark current transp. as `used' \ifcsname m@tr#2\endcsname% \PackageWarning{animate}{% - Transparency #2 multiply included in frame #1.% + Transparency #2 more than once included in frame #1.% \MessageBreak% Timeline ``\@anim@tmlnfile'' on input line \the\@anim@lineno,% \MessageBreak\jobname.tex% @@ -2785,15 +2353,31 @@ %setting the widget size \define@key{anim@user}{width}{% \gdef\@anim@widtharg{#1}% - \global\advance\@anim@resize by 4% + \ifdefined\@anim@usrwd\else% + \global\advance\@anim@resizeflags by 4% + \def\@anim@usrwd{}% + \fi% } \define@key{anim@user}{height}{% \gdef\@anim@heightarg{#1}% - \global\advance\@anim@resize by 2% + \ifdefined\@anim@usrht\else% + \global\advance\@anim@resizeflags by 2% + \def\@anim@usrht{}% + \fi% +} +\define@key{anim@user}{totalheight}{% + \gdef\@anim@totheightarg{#1}% + \ifdefined\@anim@usrtht\else% + \global\advance\@anim@resizeflags by \@ne% + \def\@anim@usrtht{}% + \fi% } \define@key{anim@user}{depth}{% - \gdef\@anim@deptharg{#1}% - \global\advance\@anim@resize by \@ne% + \PackageWarning{animate}{Ignoring obsolete `depth' option.}% +} +\newboolean{@anim@iso} +\define@key{anim@user}{keepaspectratio}[true]{% + \setboolean{@anim@iso}{#1}% } \define@key{anim@user}{scale}{% \gdef\@anim@boxscale{#1}% @@ -2808,50 +2392,24 @@ \@anim@colours#2\@nil% }% } -\if@anim@@dvips %background frame of buttons - \def\@anim@@@bg{% - 0 setlinejoin - 0 0 moveto - 15 0 lineto - 15 15 lineto - 0 15 lineto - closepath - fill% - } -\else% pdftex and dvipdfmx - \def\@anim@@@bg{% - 0 j - 0 0 150 150 re - f% - } -\fi +\def\@anim@@@bg{% + 0 j + 0 0 150 150 re + f% +} \define@key{anim@user}{buttonbg}{%background colour of buttons \global\@anim@tmpcnt=\@ne% \gdef\@anim@colour{}% \@anim@colours#1:\@nil% \xdef\@anim@bgcolour{\@anim@colour}% - \if@anim@@dvips - \ifnum\@anim@tmpcnt=\@ne% - \xdef\@anim@bg{\@anim@colour\space setgray\space\@anim@@@bg}% - \else% - \ifnum\@anim@tmpcnt=3\relax% - \xdef\@anim@bg{\@anim@colour\space setrgbcolor\space\@anim@@@bg}% - \else% - \ifnum\@anim@tmpcnt=4\relax% - \xdef\@anim@bg{\@anim@colour\space setcmykcolor\space\@anim@@@bg}% - \fi% - \fi% - \fi% - \else% pdftex and dvipdfmx - \ifnum\@anim@tmpcnt=\@ne% - \xdef\@anim@bg{\@anim@colour\space g\space\@anim@@@bg}% + \ifnum\@anim@tmpcnt=\@ne% + \xdef\@anim@bg{\@anim@colour\space g\space\@anim@@@bg}% + \else% + \ifnum\@anim@tmpcnt=3\relax% + \xdef\@anim@bg{\@anim@colour\space rg\space\@anim@@@bg}% \else% - \ifnum\@anim@tmpcnt=3\relax% - \xdef\@anim@bg{\@anim@colour\space rg\space\@anim@@@bg}% - \else% - \ifnum\@anim@tmpcnt=4\relax% - \xdef\@anim@bg{\@anim@colour\space k\space\@anim@@@bg}% - \fi% + \ifnum\@anim@tmpcnt=4\relax% + \xdef\@anim@bg{\@anim@colour\space k\space\@anim@@@bg}% \fi% \fi% \fi% @@ -2861,31 +2419,17 @@ \gdef\@anim@colour{}% \@anim@colours#1:\@nil% \xdef\@anim@fgcolour{\@anim@colour}% - \if@anim@@dvips - \ifnum\@anim@tmpcnt=\@ne% - \xdef\@anim@fg{\@anim@colour\space setgray}% - \else% - \ifnum\@anim@tmpcnt=3\relax% - \xdef\@anim@fg{\@anim@colour\space setrgbcolor}% - \else% - \ifnum\@anim@tmpcnt=4\relax% - \xdef\@anim@fg{\@anim@colour\space setcmykcolor}% - \fi% - \fi% - \fi% - \else% pdftex and dvipdfmx - \ifnum\@anim@tmpcnt=\@ne% - \xdef\@anim@fg{\@anim@colour\space G}% - \xdef\@anim@@@fg{\@anim@colour\space g}% + \ifnum\@anim@tmpcnt=\@ne% + \xdef\@anim@fg{\@anim@colour\space G}% + \xdef\@anim@@@fg{\@anim@colour\space g}% + \else% + \ifnum\@anim@tmpcnt=3\relax% + \xdef\@anim@fg{\@anim@colour\space RG}% + \xdef\@anim@@@fg{\@anim@colour\space rg}% \else% - \ifnum\@anim@tmpcnt=3\relax% - \xdef\@anim@fg{\@anim@colour\space RG}% - \xdef\@anim@@@fg{\@anim@colour\space rg}% - \else% - \ifnum\@anim@tmpcnt=4\relax% - \xdef\@anim@fg{\@anim@colour\space K}% - \xdef\@anim@@@fg{\@anim@colour\space k}% - \fi% + \ifnum\@anim@tmpcnt=4\relax% + \xdef\@anim@fg{\@anim@colour\space K}% + \xdef\@anim@@@fg{\@anim@colour\space k}% \fi% \fi% \fi% @@ -2944,6 +2488,11 @@ \setboolean{@anim@draft}{true}% }% } +\define@key{anim@user}{nomouse}[true]{% + \ifthenelse{\equal{#1}{true}}{% + \gdef\@anim@btnflag{65537}% + }{}% +} \define@key{anim@user}{timeline}{% \IfFileExists{#1}{% \xdef\@anim@tmlnfile{\expandafter\zap@finalspace\@filef@und\@nil}% @@ -3002,14 +2551,18 @@ %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}% - \gdef\@anim@heightarg{\height}% - \gdef\@anim@deptharg{\depth}% + \xdef\@anim@boxscale{\@anim@@boxscale}% + \global\let\if@anim@iso=\if@anim@@iso% + \global\@anim@resizeflags\@anim@@resizeflags% + \global\let\@anim@widtharg\@anim@@widtharg% + \global\let\@anim@heightarg\@anim@@heightarg% + \global\let\@anim@totheightarg\@anim@@totheightarg% + \let\@anim@usrwd\@anim@pkgwd% + \let\@anim@usrht\@anim@pkght% + \let\@anim@usrtht\@anim@pkgtht% \xdef\@anim@bg{\@anim@@bg}% \xdef\@anim@fg{\@anim@@fg}% - \if@anim@@dvips\else\xdef\@anim@@@fg{\@anim@@@@fg}\fi% + \xdef\@anim@@@fg{\@anim@@@@fg}% \xdef\@anim@bgcolour{\@anim@@bgcolour}% default button colours \xdef\@anim@fgcolour{\@anim@@fgcolour}% \xdef\@anim@btnsize{\@anim@@btnsize}% @@ -3023,6 +2576,7 @@ \global\let\if@anim@step=\if@anim@@step% \global\let\if@anim@draft=\if@anim@@draft% \global\let\if@anim@useocg=\if@anim@@useocg% + \global\let\@anim@btnflag=\@anim@@btnflag% \gdef\@anim@properties{}% \setboolean{@anim@pauseframes}{false}% \gdef\@anim@pauseat{}% @@ -3075,72 +2629,73 @@ \gdef\@anim@colour{}% \@anim@colours#1:\@nil% \xdef\@anim@@bgcolour{\@anim@colour}% - \if@anim@@dvips - \ifnum\@anim@tmpcnt=\@ne% - \xdef\@anim@@bg{\@anim@colour\space setgray\space\@anim@@@bg}% - \else% - \ifnum\@anim@tmpcnt=3\relax% - \xdef\@anim@@bg{\@anim@colour\space setrgbcolor\space\@anim@@@bg}% - \else% - \ifnum\@anim@tmpcnt=4\relax% - \xdef\@anim@@bg{\@anim@colour\space setcmykcolor\space\@anim@@@bg}% - \fi% - \fi% - \fi% - \else% pdftex and dvipdfmx - \ifnum\@anim@tmpcnt=\@ne% - \xdef\@anim@@bg{\@anim@colour\space g\space\@anim@@@bg}% + \ifnum\@anim@tmpcnt=\@ne% + \xdef\@anim@@bg{\@anim@colour\space g\space\@anim@@@bg}% + \else% + \ifnum\@anim@tmpcnt=3\relax% + \xdef\@anim@@bg{\@anim@colour\space rg\space\@anim@@@bg}% \else% - \ifnum\@anim@tmpcnt=3\relax% - \xdef\@anim@@bg{\@anim@colour\space rg\space\@anim@@@bg}% - \else% - \ifnum\@anim@tmpcnt=4\relax% - \xdef\@anim@@bg{\@anim@colour\space k\space\@anim@@@bg}% - \fi% + \ifnum\@anim@tmpcnt=4\relax% + \xdef\@anim@@bg{\@anim@colour\space k\space\@anim@@@bg}% \fi% \fi% \fi% } -\if@anim@@dvips - \def\@anim@@fg{0 setgray}% -\else% pdftex and dvipdfmx - \def\@anim@@fg{0 G}\def\@anim@@@@fg{0 g}% -\fi +\def\@anim@@fg{0 G}\def\@anim@@@@fg{0 g}% \def\@anim@@fgcolour{} \define@key{anim@pkg}{buttonfg}{%stroking colour of buttons \global\@anim@tmpcnt=\@ne% \gdef\@anim@colour{}% \@anim@colours#1:\@nil% \xdef\@anim@@fgcolour{\@anim@colour}% - \if@anim@@dvips% - \ifnum\@anim@tmpcnt=\@ne% - \xdef\@anim@@fg{\@anim@colour\space setgray}% - \else% - \ifnum\@anim@tmpcnt=3\relax% - \xdef\@anim@@fg{\@anim@colour\space setrgbcolor}% - \else% - \ifnum\@anim@tmpcnt=4\relax% - \xdef\@anim@@fg{\@anim@colour\space setcmykcolor}% - \fi% - \fi% - \fi% - \else% pdftex and dvipdfmx - \ifnum\@anim@tmpcnt=\@ne% - \xdef\@anim@@fg{\@anim@colour\space G}% - \xdef\@anim@@@@fg{\@anim@colour\space g}% + \ifnum\@anim@tmpcnt=\@ne% + \xdef\@anim@@fg{\@anim@colour\space G}% + \xdef\@anim@@@@fg{\@anim@colour\space g}% + \else% + \ifnum\@anim@tmpcnt=3\relax% + \xdef\@anim@@fg{\@anim@colour\space RG}% + \xdef\@anim@@@@fg{\@anim@colour\space rg}% \else% - \ifnum\@anim@tmpcnt=3\relax% - \xdef\@anim@@fg{\@anim@colour\space RG}% - \xdef\@anim@@@@fg{\@anim@colour\space rg}% - \else% - \ifnum\@anim@tmpcnt=4\relax% - \xdef\@anim@@fg{\@anim@colour\space K}% - \xdef\@anim@@@@fg{\@anim@colour\space k}% - \fi% + \ifnum\@anim@tmpcnt=4\relax% + \xdef\@anim@@fg{\@anim@colour\space K}% + \xdef\@anim@@@@fg{\@anim@colour\space k}% \fi% \fi% \fi% } +\newcount\@anim@@resizeflags +\def\@anim@@widtharg{\width}% +\define@key{anim@pkg}{width}{% + \def\@anim@@widtharg{#1}% + \ifdefined\@anim@pkgwd\else% + \advance\@anim@@resizeflags by 4% + \def\@anim@pkgwd{}% + \fi% +} +\def\@anim@@heightarg{\height}% +\define@key{anim@pkg}{height}{% + \def\@anim@@heightarg{#1}% + \ifdefined\@anim@pkght\else% + \advance\@anim@@resizeflags by 2% + \def\@anim@pkght{}% + \fi% +} +\def\@anim@@totheightarg{\totalheight}% +\define@key{anim@pkg}{totalheight}{% + \def\@anim@@totheightarg{#1}% + \ifdefined\@anim@pkgtht\else% + \advance\@anim@@resizeflags by \@ne% + \def\@anim@pkgtht{}% + \fi% +} +\newboolean{@anim@@iso} +\define@key{anim@pkg}{keepaspectratio}[true]{% + \setboolean{@anim@@iso}{#1}% +} +\def\@anim@@boxscale{1}% +\define@key{anim@pkg}{scale}{% + \def\@anim@@boxscale{#1}% +} \def\@anim@@btnsize{1.44em}% \define@key{anim@pkg}{buttonsize}{% \gdef\@anim@@btnsize{#1}% @@ -3208,6 +2763,12 @@ \setboolean{@anim@@draft}{true}% }% } +\def\@anim@@btnflag{65536}% +\define@key{anim@pkg}{nomouse}[true]{% + \ifthenelse{\equal{#1}{true}}{% + \gdef\@anim@@btnflag{65537}% + }{}% +} \newboolean{@anim@@useocg} \setboolean{@anim@@useocg}{false} \define@key{anim@pkg}{useocg}[true]{% @@ -3221,25 +2782,10 @@ %JavaScript objects %animation widget's PageOpen event -\ifpdf - \def\@anim@pojscript#1{% - \immediate\pdfobj stream {\@anim@@pojscript{#1}}% - \xdef\@anim@pojscriptobj{\the\pdflastobj\space 0 R}% - } -\else - \if@anim@@dvipdfmx - \def\@anim@pojscript#1{% - \special{pdf:stream @a#1@pojscript (\@anim@@pojscript{#1})}% - } - \else - \def\@anim@pojscript#1{% - \special{ps: - mark /_objdef {a#1@pojscript} /type/stream /OBJ pdfmark - mark {a#1@pojscript} (\@anim@@pojscript{#1}) /PUT pdfmark% - }% - } - \fi -\fi +\def\@anim@pojscript#1{% + \@anim@streamobj{}{\@anim@@pojscript{#1}}% + \xdef\@anim@pojscriptobj{\@anim@lastobj}% +} \def\@anim@@pojscript#1{% #1: @anim@num % console.show();% % console.clear();% @@ -3314,12 +2860,11 @@ \fi% %actions a#1.seekFrame=function(f){% - if(f>\@anim@maxframe||f<0){return(-1);}% + 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 cmd='try{a#1.usrJSat['+f+']();}catch(e){% - console.show();console.println(e);}';% + var cmd='try{a#1.usrJSat['+f+']();}catch(e){console.println(e);}';% var ret=app.setTimeOut(cmd,1);% }% \fi% @@ -3343,7 +2888,7 @@ \fi% \fi% \if@anim@step\else\if@anim@meas a#1.frcnt++;\fi\fi - return(old);% + return old;% };% a#1.stopFirst=function(){% \if@anim@step\else @@ -3361,13 +2906,13 @@ };% a#1.gotoNext=function(){% if(a#1.seekFrame(a#1.idx+1)<0){% + \if@anim@step\else\if@anim@meas a#1.stopMeas();\fi\fi% \if@anim@palindrome% \if@anim@step a#1.stopLast();% a#1.playsRight=false;% \else if(a#1.playing){% - \if@anim@meas a#1.stopMeas();\fi a#1.seekFrame(a#1.idx-1);% a#1.playLeft();% }% @@ -3378,7 +2923,6 @@ \else% \if@anim@loop if(a#1.playing){% - \if@anim@meas a#1.stopMeas();\fi a#1.seekFrame(0);% a#1.setFps(\@anim@fps);% }else{a#1.stopLast();}% @@ -3397,13 +2941,13 @@ \if@anim@morejs a#1.gotoPrev=function(){% if(a#1.seekFrame(a#1.idx-1)<0){% + \if@anim@step\else\if@anim@meas a#1.stopMeas();\fi\fi% \if@anim@palindrome% \if@anim@step a#1.stopFirst();% a#1.playsRight=true;% \else if(a#1.playing){% - \if@anim@meas a#1.stopMeas();\fi a#1.seekFrame(a#1.idx+1);% a#1.playRight();% }% @@ -3414,7 +2958,6 @@ \else% \if@anim@loop if(a#1.playing){% - \if@anim@meas a#1.stopMeas();\fi a#1.seekFrame(\@anim@maxframe);% }else{a#1.stopFirst();}% \else @@ -3531,26 +3074,25 @@ 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);},% + 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');% - }% + if(f<0||isNaN(f)){% + throw new RangeError('Frame_rate_not_in_allowed_range');% + }else{a#1.setFps(f);}% },% - get dt(){return(1000/(1e-6+a#1.fps)/a#1.sm);},% + 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);},% + 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;% + throw new RangeError('Frame_number_not_in_allowed_range');% }% \if@anim@step a#1.seekFrame(f);% @@ -3561,8 +3103,8 @@ }else{a#1.seekFrame(f);}% \fi% },% - stopFirst: a#1.stopFirst,% - stopLast: a#1.stopLast% + stopFirst:a#1.stopFirst,% + stopLast:a#1.stopLast% };% }% \fi% |