重叠动画

重叠动画

我有一个动画

\documentclass{beamer}
\usepackage{tikz}
\usetheme{CambridgeUS}
\usepackage[utf8]{inputenc}
\usepackage[english,russian]{babel}
\usepackage{ifthen}
\usepackage{animate}
\usepackage{pgffor}
\usetikzlibrary{calc}

 \makeatletter
 \newcommand*{\dothis}[1]{%
 \stringcases
 {#1}%
 {%
  {1}{
  \fill[blue] (-3,0)  circle[radius=3pt] node[below] {$110$};

  }%
  {2}{%
  \fill[red] (-1,0)  circle[radius=3pt] node[below] {$120$}; %
     }% 
  {3}{%
  \fill[green] (1,0)  circle[radius=3pt] node[below] {$130$};%
     }%
  }%
  }
  \newcommand{\stringcases}[3]{%
  \romannumeral
  \str@case{#1}#2{#1}{#3}\q@stop
  }
  \newcommand{\str@case}[3]{%
  \ifnum\pdf@strcmp{\unexpanded{#1}}{\unexpanded{#2}}=\z@
  \expandafter\@firstoftwo
  \else
  \expandafter\@secondoftwo
  \fi
  {\str@case@end{#3}}
 {\str@case{#1}}%
 }
 \newcommand{\str@case@end}{}
 \long\def\str@case@end#1#2\q@stop{\z@#1}
 \makeatother

\begin{document}
\begin{frame}[t]
 \begin{center}
\begin{animateinline}[controls,autoplay,loop]{2}
\multiframe{3}{n=1+1}{
\begin{tikzpicture}
\coordinate (O) at (-2,0);
\coordinate (OO) at (3.5,0);
\draw[fill=orange!50,thick] (O) circle [radius=2.5cm];
\fill (O)  circle[radius=2pt] node[below left] {$00000$};
\draw[fill=orange!50,thick] (OO) circle [radius=2.5cm];
\fill (OO)  circle[radius=2pt] node[below left] {$11111$};
\expandafter\dothis\n
\end{tikzpicture} 
}
\end{animateinline}
\end{center}
\end{frame}
\end{document}

问题是点 (110,120,130) 是按顺序显示的。请告诉我如何做才能使框架重叠。

答案1

这可以通过timeline的特征animate

我们将背景(两个橙色圆圈)与要叠加的点分开:

\begin{animateinline}[...]{2}
  %background
  \coordinate (O) at (-2,0);
  \coordinate (OO) at (3.5,0);
  \draw[fill=orange!50,thick] (O) circle [radius=2.5cm];
  \fill (O)  circle[radius=2pt] node[below left] {$00000$};
  \draw[fill=orange!50,thick] (OO) circle [radius=2.5cm];
  \fill (OO)  circle[radius=2pt] node[below left] {$11111$};
\newframe
  %to-be-overlaid points
  \multiframe{3}{n=1+1}{
    \expandafter\dothis\n
  }
\end{animateinline}

并通过文本文件中定义的时间线组合(叠加)这些图像timeline.txt

%write timeline file to hard disk
\usepackage{filecontents}
\begin{filecontents}{timeline.txt} 
  :: 0x0 %background (image `0') to be repeated until the end ( `x0' )
  :: 1x0 %overlaid point 110 (image `1') to be repeated til end ( `x0' )
  :: 2x0 %overlaid point 120 (image `2') to be repeated til end ( `x0' )
  :: 3x0 %overlaid point 130 (image `3') to be repeated til end ( `x0' )
\end{filecontents}  

完整示例

\documentclass{beamer}
\usepackage{tikz}
\usetheme{CambridgeUS}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{ifthen}
\usepackage{animate}
\usepackage{pgffor}
\usetikzlibrary{calc}

 \makeatletter
 \newcommand*{\dothis}[1]{%
 \stringcases
 {#1}%
 {%
  {1}{
  \fill[blue] (-3,0)  circle[radius=3pt] node[below] {$110$};

  }%
  {2}{%
  \fill[red] (-1,0)  circle[radius=3pt] node[below] {$120$}; %
     }% 
  {3}{%
  \fill[green] (1,0)  circle[radius=3pt] node[below] {$130$};%
     }%
  }%
  }
  \newcommand{\stringcases}[3]{%
  \romannumeral
  \str@case{#1}#2{#1}{#3}\q@stop
  }
  \newcommand{\str@case}[3]{%
  \ifnum\pdf@strcmp{\unexpanded{#1}}{\unexpanded{#2}}=\z@
  \expandafter\@firstoftwo
  \else
  \expandafter\@secondoftwo
  \fi
  {\str@case@end{#3}}
 {\str@case{#1}}%
 }
 \newcommand{\str@case@end}{}
 \long\def\str@case@end#1#2\q@stop{\z@#1}
 \makeatother

%write timeline file to hard disk
\usepackage{filecontents}
\begin{filecontents}{timeline.txt} 
  :: 0x0 %background (image `0') to be repeated until the end ( `x0' )
  :: 1x0 %overlaid point 110 (image `1') to be repeated til end ( `x0' )
  :: 2x0 %overlaid point 120 (image `2') to be repeated til end ( `x0' )
  :: 3x0 %overlaid point 130 (image `3') to be repeated til end ( `x0' )
\end{filecontents}  

\begin{document}
\begin{frame}[t]
 \begin{center}
\begin{animateinline}[
  timeline=timeline.txt,
  controls,autoplay,loop,
  begin={\begin{tikzpicture} \useasboundingbox (-4.52,-2.52) rectangle (6.02,2.52);},
  end={\end{tikzpicture}},
]{2}
  %background
  \coordinate (O) at (-2,0);
  \coordinate (OO) at (3.5,0);
  \draw[fill=orange!50,thick] (O) circle [radius=2.5cm];
  \fill (O)  circle[radius=2pt] node[below left] {$00000$};
  \draw[fill=orange!50,thick] (OO) circle [radius=2.5cm];
  \fill (OO)  circle[radius=2pt] node[below left] {$11111$};
\newframe  
  \multiframe{3}{n=1+1}{
    %to-be-overlaid points
    \expandafter\dothis\n
  }
\end{animateinline}
\end{center}
\end{frame}
\end{document}

相关内容