Next code uses Jake's answer to How to animate a path or how to draw starting fraction of a complex but linear path? adapted to your path form A to B. It draws the start segment
of a path with an arrow
at the end and moving along the animation.
As soon as I can understand how to convert the animation to an animated gif, I'll upload the image. I know it's explained here, but I've never tried it.
\documentclass{beamer}
\usepackage{animate}
\usepackage{tikz}
\usetikzlibrary{calc,decorations,arrows,positioning,matrix}
% A simple empty decoration, that is used to ignore the last bit of the path
\pgfdeclaredecoration{ignore}{final}
{
\state{final}{}
}
\pgfdeclaremetadecoration{start}{initial}{
\state{initial}[
width={0pt},
next state=middle
]
{\decoration{moveto}}
\state{middle}[
width={\pgfmetadecoratedpathlength*\pgfdecorationsegmentlength},
next state=final
]
{\decoration{curveto}}
\state{final}
{\decoration{ignore}}
}
\tikzset{%
start segment/.style={decoration={start,raise=2mm},decorate, segment length=#1},
}
\begin{document}
\begin{frame}
\begin{animateinline}[autoplay,loop]{3}
\multiframe{10}{rPos=0.15+0.1}{
\begin{tikzpicture}[]
\node (s){A}; \node (r) at (1,0) {};
\node (t) at (1,-2) {};
\node (v) at (0,-2) {B};
\draw[start segment=\rPos,->,black!70, line width=2.5] (s) -- (r.center) -- (t.center)--(v); \end{tikzpicture}
}
\end{animateinline}
\end{frame}
\end{document}
Character for character
The usage of the xstring
macros is taken from the linked question.
The width of the text (in \Huge
style) is saved to \mytextwidth
.
As \StrLen
counts from 0
to, in this case, 27
, \multiframe
needs to animate 28
frames, which is why \mylen+1
is calculated and saved to \frames
.
This example uses the \multiframe
macro because we can use variables (the other question used PGF
's \foreach
for this) and don't need to type every frame individually.
The \vphantom
is needed because we start with no text (\icounter=0
) and we need vertical height for. If you want to start with A
use icounter=1+1
and re-replace \frames
with \mylen
in the \multiframe
command.
\makebox
makes everytime a box of the full text's width so that animate
doesn't stretch the text. (We could have used also \StrRight
, but this needs less calculation.)
Code (char for char)
\documentclass{article}
\usepackage[latin1]{inputenc}
\usepackage{animate}
\usepackage{calc}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{animateinline}
\usepackage{xstring}
\def\mytext{Alles Gute zum Geburtstag!}
\StrLen{\mytext}[\mylen]
\newlength{\mytextwidth}
\setlength{\mytextwidth}{\widthof{\Huge\mytext}}
\def\frames{\number\numexpr\mylen+1\relax} % \frames = \mylen + 1
\begin{document}
\begin{center}
\begin{animateinline}[autoplay,loop]{2}
\multiframe{\frames}{icounter=0+1}{
\makebox[\mytextwidth][l]{\Huge\vphantom{\mytext}\StrLeft{\mytext}{\icounter}}
}
\end{animateinline}
\end{center}
\end{document}
Looks a lot like … (a.k.a. Output)
Word for word
Code
\documentclass{article}
\usepackage[latin1]{inputenc}
\usepackage{animate}
\usepackage{calc}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{animateinline}
\usepackage{xstring}
\def\mytext{Alles Gute zum Geburtstag!}
\StrCount{\mytext}{ }[\countSpaces]
\newlength{\mytextwidth}
\setlength{\mytextwidth}{\widthof{\Huge\mytext}}
\def\frames{\number\numexpr\countSpaces+2\relax} % \frames = \countSpaces + 2
\begin{document}
\begin{center}
\begin{animateinline}[autoplay,loop]{2}
\multiframe{\frames}{icounter=0+1,icounterr=1+1}{%
\makebox[\mytextwidth][l]{%
\Huge\vphantom{\mytext}%
\ifnum\icounter=0\relax\else
\ifnum\icounterr=\frames\relax\mytext\else%
\StrBefore[\icounter]{\mytext}{ }%
\fi
\fi
}%
}
\end{animateinline}
\end{center}
\end{document}
Best Answer
Collecting information from comments:
The package does contain an own documentation, available on all important TeX distributions.
User zeroth provided an answer in TeX.SX with a complete example: How to use autoplay (within animate package) together with a pause at the end of every playing?.
A presentation by Tobias Nähring: A Glance at Animate (PDF file).
A tutorial for people who understand French or know, how to use an on-line translator: MathemaTeX – animate.