diff options
author | Karl Berry <karl@freefriends.org> | 2008-07-14 22:18:15 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2008-07-14 22:18:15 +0000 |
commit | 3dbde31e7c26ef198ab0939714f3a513049a9afb (patch) | |
tree | 19b19d1a22f5bf28ba6f7894836f5e173dbc3fc2 /Master/texmf-dist/tex/latex | |
parent | 23c7f66c5212d122c76342854f2fe85653365a75 (diff) |
animate update (14jul08)
git-svn-id: svn://tug.org/texlive/trunk@9558 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r-- | Master/texmf-dist/tex/latex/animate/animate.sty | 114 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/animate/animfp.sty | 313 |
2 files changed, 426 insertions, 1 deletions
diff --git a/Master/texmf-dist/tex/latex/animate/animate.sty b/Master/texmf-dist/tex/latex/animate/animate.sty index 1b93c6bf46d..4aba5937cab 100644 --- a/Master/texmf-dist/tex/latex/animate/animate.sty +++ b/Master/texmf-dist/tex/latex/animate/animate.sty @@ -12,7 +12,7 @@ \NeedsTeXFormat{LaTeX2e} -\def\@anim@version{2008/07/04} +\def\@anim@version{2008/07/14} \ProvidesPackage{animate}[\@anim@version] %test for e-TeX @@ -30,6 +30,7 @@ \RequirePackage{ifpdf} \RequirePackage{ifdraft} \RequirePackage{calc} +\RequirePackage{animfp} %driver options (the only package options we process immediately) \newboolean{@anim@@dvips} @@ -2109,6 +2110,117 @@ \fi% } +%user command for building loops around parameterized frame content, just like +%\multido (package multido) with embedded \newframe +\newcount\@anim@mulframecnt %takes current loop No. of \multiframe +\newboolean{@anim@insidemulti} % for checking whether we are inside \multiframe +\setboolean{@anim@insidemulti}{false} +\newcommand{\multiframe}[3]{% #1: #repetitions, #2: vars, #3: frame content + \unskip% + \if@anim@inside\else% + \PackageError{animate}{% + \protect\multiframe\space cannot be used outside `animateinline'% + \MessageBreak environment% + }{}% + \fi% + \if@anim@insidemulti% + \PackageError{animate}{\protect\multiframe\space cannot be nested}{}% + \fi% + \setboolean{@anim@insidemulti}{true}% + %reset macro for updating variables + \gdef\@anim@updatevars{}% + %reset loop counter + \global\@anim@mulframecnt=\z@% + %remove spaces from variable declaration list (2nd arg) + \xdef\@anim@vardecls{#2\space}% + \xdef\@anim@vardecls{\expandafter\zap@space\@anim@vardecls\@empty}% + %parse list of variable declarations and build macro for updating them + \expandafter\@anim@parsevars\@anim@vardecls,!\@nil% + \whiledo{\@anim@mulframecnt<#1}{% + \ifnum\@anim@mulframecnt>0 + \newframe% + \@anim@updatevars% update variables + \fi% + \global\advance\@anim@mulframecnt by \@ne% + \ignorespaces + #3% execute loop body + \unskip% + }% + \setboolean{@anim@insidemulti}{false}% + \ignorespaces% +} + +%splits list of variable declarations +\def\@anim@parsevars#1,#2\@nil{% + \ifthenelse{\equal{#1}{}}{}{\@anim@parsedecl#1\@nil}% + \ifthenelse{\equal{#2}{!}}{}{\@anim@parsevars#2\@nil}% +} +%parser for single variable declaration +\def\@anim@parsedecl#1=#2+#3\@nil{% + \edef\@anim@vartype{\@anim@getvartype#1\@nil}% + \ifthenelse{\equal{\@anim@vartype}{d}\OR\equal{\@anim@vartype}{D}}{% + % dimensions, prefix d, D + %initialize variable + \setlength{\@anim@tmpdima}{#2}% + \expandafter\edef\csname#1\endcsname{\number\@anim@tmpdima sp}% + %global copy that saves current variable value between loops + \expandafter\gdef\csname#1@old\endcsname{\number\@anim@tmpdima sp}% + %append script for updating variable to \@anim@updatevars macro + \g@addto@macro\@anim@updatevars{% + %new value + \setlength{\@anim@tmpdima}{\csname#1@old\endcsname}% + \addtolength{\@anim@tmpdima}{#3}% + \expandafter\edef\csname#1\endcsname{\number\@anim@tmpdima}% + %global copy + \expandafter\xdef\csname#1@old\endcsname{\number\@anim@tmpdima}% + }% + }{% + \ifthenelse{% + \equal{\@anim@vartype}{n}\OR\equal{\@anim@vartype}{N}% + \OR\equal{\@anim@vartype}{r}\OR\equal{\@anim@vartype}{R}% + }{% real numbers, prefix n, N, r, R + %initialize variable + \expandafter\@anim@add\csname#1\endcsname{#2}{0.0}% + %global copy that saves current variable value between loops + \expandafter\gdef\csname#1@old\endcsname{#2}% + %append script for updating variable to \@anim@updatevars macro + \g@addto@macro\@anim@updatevars{% + %new value + \expandafter\@anim@add\csname#1\endcsname{\csname#1@old\endcsname}{#3}% + %global copy + \expandafter\xdef\csname#1@old\endcsname{\csname#1\endcsname}% + }% + }{% + \ifthenelse{\equal{\@anim@vartype}{i}\OR\equal{\@anim@vartype}{I}}{% + % integers, prefix i, I + %initialize variable + \expandafter\edef\csname#1\endcsname{#2}% + %global copy that saves current variable value between loops + \expandafter\gdef\csname#1@old\endcsname{#2}% + %append script for updating variable to \@anim@updatevars macro + \g@addto@macro\@anim@updatevars{% + %new value + \expandafter\global\expandafter\@anim@tmpcnt\csname#1@old\endcsname% + \global\advance\@anim@tmpcnt by #3% + \expandafter\edef\csname#1\endcsname{\the\@anim@tmpcnt}% + %global copy + \expandafter\xdef\csname#1@old\endcsname{\the\@anim@tmpcnt}% + }% + }{% + \PackageError{animate}{% + \protect\multiframe: wrong name prefix `\@anim@vartype' in% + \MessageBreak variable `#1'.\MessageBreak% + Use any of d, D (dimensions), i, I (integer numbers)\MessageBreak% + or n, N, r, R (real numbers) as the first letter to\MessageBreak% + specify the variable type.% + }{}% + }% + }% + }% +} +%get initial letter from variable name (the variable type, as with \multido) +\def\@anim@getvartype#1#2\@nil{#1}% + %prints zero padded integers % #1: arbitrary integer number as template specifying the % width, e. g. `987654' for a width of 6 digits diff --git a/Master/texmf-dist/tex/latex/animate/animfp.sty b/Master/texmf-dist/tex/latex/animate/animfp.sty new file mode 100644 index 00000000000..92f9946f135 --- /dev/null +++ b/Master/texmf-dist/tex/latex/animate/animfp.sty @@ -0,0 +1,313 @@ +% This material is subject to the LaTeX Project Public License. See +% http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html +% for the details of that license. + +% This package is loaded by animate.sty. It defines \@anim@add for fixed point +% addition + +% Copyright notice: +% The code relavant to fixed point addition was taken with virtually no +% modification from Michael Mehlich's fp-basic[1996/05/13] package + +% Copyright 2008 Alexander Grahn + +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{animfp}[2008/07/14] + +%adding two values +\def\@anim@add#1#2#3{\afp@callc\afp@add#1{#2}{#3}+\relax} % #1 := #2+#3 + +\def\afp@errmessage#1{\errmessage{FP error: #1!}} + +%allocation of registers +\newcount\afp@xs %sign of 1st value +\newcount\afp@xia%integer part of 1st value +\newcount\afp@xib%integer part of 1st value +\newcount\afp@xfa%fractional part of 1st value +\newcount\afp@xfb%fractional part of 1st value +\countdef\afp@ys=5 %sign of 2nd value +\countdef\afp@yia=6%integer part of 2nd value +\countdef\afp@yib=7%integer part of 2nd value +\countdef\afp@yfa=8%fractional part of 2nd value +\countdef\afp@yfb=9%fractional part of 2nd value + +\newcount\afp@rega %auxiliary registers +\newcount\afp@regb +\countdef\afp@regc=36 + +\newcount\afp@regs %local auxiliary registers +\countdef\afp@count=45 + +%auxiliary macros which may be used in all of the following macros +\def\afp@ignorenext#1{} +\def\afp@first#1#2\relax{#1} +\def\afp@swallow#1\relax{} + +\def\ifafp@zero#1{% + \ifnum% + \expandafter\ifnum\csname afp@#1ia\endcsname=0 0\else1\fi% + \expandafter\ifnum\csname afp@#1ib\endcsname=0 0\else1\fi% + \expandafter\ifnum\csname afp@#1fa\endcsname=0 0\else1\fi% + \expandafter\ifnum\csname afp@#1fb\endcsname=0 0\else1\fi% + =0\relax% +} + +%read value +\def\afp@correctintcounter#1\relax{% + {\edef\afp@tmp{#1}% + \afp@count=0\relax% + \loop% + \edef\afp@tmpa{\expandafter\afp@first\afp@tmp\noexpand\relax}% + \expandafter\ifx\afp@tmpa0\relax% + \advance\afp@count1\relax% + \edef\afp@tmp{\expandafter\afp@ignorenext\afp@tmp}% + \repeat% + \ifnum\afp@count>18\relax% + \afp@errmessage{Overflow}% + \fi% + \expandafter\if!\afp@tmp!% + \advance\afp@count-18\relax% + \afp@count=-\afp@count% + \loop% + \ifnum\afp@count>0\relax% + \afp@regc=\afp@rega% + \divide\afp@rega10\relax\multiply\afp@rega10\relax% + \advance\afp@regc-\afp@rega\multiply\afp@regc100000000\relax% + \divide\afp@rega10\relax% + \divide\afp@regb10\relax\advance\afp@regb\afp@regc% + \advance\afp@count-1\relax% + \repeat% + \global\afp@rega=\afp@rega% + \global\afp@regb=\afp@regb% + \else% + \afp@errmessage{Number too big}% + \fi% + }% +} +\def\afp@@setintcounter#1#2#3#4#5#6#7#8#9{% + \afp@regb=#1#2#3#4#5#6#7#8#9\relax% + \afp@correctintcounter% +} +\def\afp@setintcounter#1#2#3#4#5#6#7#8#9{% + \afp@rega=#1#2#3#4#5#6#7#8#9\relax% + \afp@@setintcounter% +} + +\def\afp@@setfractcounter#1#2#3#4#5#6#7#8#9{% + \afp@regb=#1#2#3#4#5#6#7#8#9\relax% + \afp@swallow% +} +\def\afp@setfractcounter#1#2#3#4#5#6#7#8#9{% + \afp@rega=#1#2#3#4#5#6#7#8#9\relax% + \afp@@setfractcounter% +} + +\def\afp@getsign#1\relax{% + {\afp@regs=1\relax% + \edef\afp@tmp{#1}% + \loop% + \edef\afp@tmpa{\expandafter\afp@first\afp@tmp\noexpand\relax}% + \expandafter\ifx\afp@tmpa-\relax% + \multiply\afp@regs-1\relax% + \fi% + \ifnum\expandafter\ifx\afp@tmpa-1\else0\fi\expandafter\ifx\afp@tmpa+1\else0\fi>0% + \edef\afp@tmp{\expandafter\afp@ignorenext\afp@tmp}% + \repeat% + \global\let\afp@tmp\afp@tmp% + \global\afp@regs=\afp@regs% + }% +} + +\def\afp@removeleadingzeros#1\relax{% + {\edef\afp@tmp{#1}% + \loop% + \edef\afp@tmpa{\expandafter\afp@first\afp@tmp\noexpand\relax}% + \expandafter\ifx\afp@tmpa0\relax% + \edef\afp@tmp{\expandafter\afp@ignorenext\afp@tmp}% + \repeat% + \global\let\afp@tmp\afp@tmp% + }% +} + +\newif\ifafp@nonstop +\def\afp@strip#1{% + {\edef\afp@tmp{#1}% + \edef\afp@tmpb{}% + \ifx\afp@tmp\@empty\else% + \afp@nonstoptrue% + \loop% + \edef\afp@tmpa{\expandafter\afp@first\afp@tmp\noexpand\relax}% + \expandafter\ifx\afp@tmpa-\relax\edef\afp@tmpb{\afp@tmpb\afp@tmpa}\else% + \expandafter\ifx\afp@tmpa+\relax\edef\afp@tmpb{\afp@tmpb\afp@tmpa}\else% + \expandafter\ifx\afp@tmpa0\relax\edef\afp@tmpb{\afp@tmpb\afp@tmpa}\else% + \expandafter\ifx\afp@tmpa1\relax\edef\afp@tmpb{\afp@tmpb\afp@tmpa}\else% + \expandafter\ifx\afp@tmpa2\relax\edef\afp@tmpb{\afp@tmpb\afp@tmpa}\else% + \expandafter\ifx\afp@tmpa3\relax\edef\afp@tmpb{\afp@tmpb\afp@tmpa}\else% + \expandafter\ifx\afp@tmpa4\relax\edef\afp@tmpb{\afp@tmpb\afp@tmpa}\else% + \expandafter\ifx\afp@tmpa5\relax\edef\afp@tmpb{\afp@tmpb\afp@tmpa}\else% + \expandafter\ifx\afp@tmpa6\relax\edef\afp@tmpb{\afp@tmpb\afp@tmpa}\else% + \expandafter\ifx\afp@tmpa7\relax\edef\afp@tmpb{\afp@tmpb\afp@tmpa}\else% + \expandafter\ifx\afp@tmpa8\relax\edef\afp@tmpb{\afp@tmpb\afp@tmpa}\else% + \expandafter\ifx\afp@tmpa9\relax\edef\afp@tmpb{\afp@tmpb\afp@tmpa}\else% + \ifx\afp@tmpa\@empty\afp@nonstopfalse\else% + \ifx\afp@tmpa\space\afp@nonstopfalse\else% + \afp@errmessage{Illegal character \afp@tmpa\space found in float number}% + \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi% + \edef\afp@tmp{\expandafter\afp@ignorenext\afp@tmp}% + \ifx\afp@tmp\@empty\afp@nonstopfalse\fi% + \ifafp@nonstop% + \repeat% + \fi% + \global\let\afp@tmp\afp@tmpb% + }% +} + +\def\afp@readvalue#1#2#3{% + % #1 macro family to catch the value + % #2.#3 value + % + % regular expression [+|-]*[d]_0^18.[d]* + % + \afp@strip{#2}% + %sign + \expandafter\afp@getsign\afp@tmp\relax% + \csname afp@#1s\endcsname=\afp@regs% + % + %integer part + \afp@removeleadingzeros\afp@tmp\relax% + \expandafter\afp@setintcounter\afp@tmp000000000000000000\relax% + \csname afp@#1ia\endcsname=\afp@rega% + \csname afp@#1ib\endcsname=\afp@regb% + % + %fractional part + \afp@strip{#3}% + \expandafter\afp@setfractcounter\afp@tmp000000000000000000\relax% + \csname afp@#1fa\endcsname=\afp@rega% + \csname afp@#1fb\endcsname=\afp@regb% + % + %correct sign + \ifnum\afp@rega=0\relax% + \ifnum\afp@regb=0\relax% + \expandafter\ifnum\csname afp@#1ib\endcsname=0\relax% + \expandafter\ifnum\csname afp@#1ia\endcsname=0\relax% + \csname afp@#1s\endcsname=1\relax% + \fi% + \fi% + \fi% + \fi% +} + +%store value in macro +\def\afp@store#1#2{% + % #1 macro + % #2 macro family (value) to store + % + \ifafp@zero{#2}% + \csname afp@#2s\endcsname=1\relax% + \fi% + \expandafter\ifnum\csname afp@#2s\endcsname<0\relax% + \edef#1{-}% + \else% + \edef#1{}% + \fi% + \expandafter\ifnum\csname afp@#2ia\endcsname=0\relax% + \expandafter\ifnum\csname afp@#2ib\endcsname=0\relax% + \edef#1{#10}% + \else% + \edef#1{#1\expandafter\the\csname afp@#2ib\endcsname}% + \fi% + \else% + \expandafter\advance\csname afp@#2ib\endcsname1000000000\relax% + \edef#1{#1\expandafter\the\csname afp@#2ia\endcsname\expandafter\afp@ignorenext\the\csname afp@#2ib\endcsname}% + \fi% + \expandafter\advance\csname afp@#2fa\endcsname1000000000\relax% + \expandafter\advance\csname afp@#2fb\endcsname1000000000\relax% + \edef#1{#1\noexpand.\expandafter\afp@ignorenext\the\csname afp@#2fa\endcsname\expandafter\afp@ignorenext\the\csname afp@#2fb\endcsname}% +} + +%macros to expand some arguments +\def\afp@callc#1#2#3#4{% + % #1 macro to call + % #2 macro, which gets the result + % #3 1st value + % #4 2nd value + % expand the values and split them into the integer and the fractional parts + \edef\next{\noexpand#1\noexpand#2#3..\noexpand\relax#4..\noexpand\relax}% + \next% +} + +%add two values +\def\afp@add#1#2.#3.#4\relax#5.#6.#7\relax#8\relax{% + % #1 macro, which gets the result + % #2 integer part of 1st value + % #3 fractional part of 1st value + % #4 dummy to swallow everthing after the 2nd '.' + % #5 integer part of 2nd value + % #6 fractional part of 2nd value + % #7 dummy to swallow everthing after the 2nd '.' + % + {% + \afp@readvalue{x}{#2}{#3}% + \afp@readvalue{y}{#5}{#6}% + % + \ifnum\afp@xs=\afp@ys% + \advance\afp@xfb\afp@yfb% + \advance\afp@xfa\afp@yfa% + \ifnum\afp@xfb<1000000000\relax\else% + \advance\afp@xfb-1000000000\relax% + \advance\afp@xfa1\relax% + \fi% + \advance\afp@xib\afp@yib% + \ifnum\afp@xfa<1000000000\relax\else% + \advance\afp@xfa-1000000000\relax% + \advance\afp@xib1\relax% + \fi% + \advance\afp@xia\afp@yia% + \ifnum\afp@xib<1000000000\relax\else% + \advance\afp@xib-1000000000\relax% + \advance\afp@xia1\relax% + \fi% + \ifnum\afp@xia<1000000000\relax\else% + \afp@errmessage{Overflow}% + \fi% + \afp@store\afp@tmp{x}% + \else% + \advance\afp@xfb-\afp@yfb% + \ifnum\afp@xfb<0\relax% + \advance\afp@yfa1\relax% + \advance\afp@xfb1000000000\relax% + \fi% + \advance\afp@xfa-\afp@yfa% + \ifnum\afp@xfa<0\relax% + \advance\afp@yib1\relax% + \advance\afp@xfa1000000000\relax% + \fi% + \advance\afp@xib-\afp@yib% + \ifnum\afp@xib<0\relax% + \advance\afp@yia1\relax% + \advance\afp@xib1000000000\relax% + \fi% + \advance\afp@xia-\afp@yia% + \ifnum\afp@xia<0\relax% + \afp@xs=-\afp@xs% + \ifnum\afp@xfb=0\relax\else% + \advance\afp@xfb-1000000000\relax\afp@xfb=-\afp@xfb% + \advance\afp@xfa1\relax% + \fi% + \ifnum\afp@xfa=0\relax\else% + \advance\afp@xfa-1000000000\relax\afp@xfa=-\afp@xfa% + \advance\afp@xib1\relax% + \fi% + \ifnum\afp@xib=0\relax\else% + \advance\afp@xib-1000000000\relax\afp@xib=-\afp@xib% + \advance\afp@xia1\relax% + \fi% + \relax\afp@xia=-\afp@xia% + \fi% + \afp@store\afp@tmp{x}% + \fi% + % + \global\let\afp@tmp\afp@tmp% + }% + \let#1\afp@tmp% +} |