使用动画包隐藏图像

使用动画包隐藏图像

我正在旋转一个三角形,我只希望出现最后两帧的第一个和最后一个三角形。

我想要隐藏第一个三角形和最后一个三角形之间的三角形。

附加乳胶代码。

    \documentclass[12pt]{article}
    \usepackage{animate}
    \usepackage{graphicx}
    \usepackage{pgf,tikz}
    \usepackage{color}

\begin{filecontents}{time.txt}
    ::0x0 
    ::1 
    ::2
    ::3
\end{filecontents}    

    \begin{document}

    \begin{center}

    \begin{animateinline}[
    begin={
    \begin{tikzpicture}[line cap=round,line join=round,x=1.0cm,y=1.0cm]
    \clip(-4.7,-3.7)  rectangle (4.7,3.7);
    },
    end={\end{tikzpicture}},
    controls,timeline=time.txt]{1}

    \draw [color=gray] (-4.5,-3.2) grid (4.5,3.2);

    \foreach \x in {-4,...,4}
    \draw [very thick] (\x,0.1) -- (\x,-0.1) node[below] {\x};
    \foreach \y in {-3,...,3}
    \draw [very thick] (0.1,\y) -- (-0.1,\y) node[left] {\y};

    \draw [<->, very thick] (-4.5,0) -- (4.5,0) node [below] {$x$};
    \draw [<->, very thick] (0,-3.5) -- (0,3.5) node [right] {$y$};

    \draw [line width=1.5pt] (0,1) -- (1,3) -- (3,1) -- cycle;

    \newframe % GIRO 90°

    \draw [color=blue,line width=1.5pt] (-1,0) -- (-3,1) -- (-1,3)-- cycle;

    \draw[color=black] (3.,2.7) node[anchor=north west] {\colorbox{white}{$\alpha=90$}};
    \draw [->,line width=1.5pt](0.5,0) arc (0:90:0.5cm);

    \newframe % GIRO 180°

    \draw [color=blue,line width=1.5pt] (0,-1) -- (-1,-3) -- (-3,-1)-- cycle;

    \draw[color=black] (3.,2.7) node[anchor=north west] {\colorbox{white}{$\alpha=180$}};
    \draw [->,line width=1.5pt](0.5,0) arc (0:180:0.5cm);

    \newframe % GIRO 270°

    \draw [color=blue, line width=1.5pt] (1,0) -- (3,-1) -- (1,-3)-- cycle;

    \draw[color=black] (3.,2.7) node[anchor=north west] {\colorbox{white}{$\alpha=270$}};
    \draw [->,line width=1.5pt](0.5,0) arc (0:270:0.5cm);

    \newframe % GIRO 360°

    \draw [color=blue,line width=1.5pt] (0,1) -- (1,3) -- (3,1)-- cycle;

    \draw[color=black] (3.,2.7) node[anchor=north west] {\colorbox{white}{$\alpha=360$}};
    \draw [->,line width=1.5pt](0.5,0) arc (0:360:0.5cm);

    \end{animateinline}
    \end{center}

    \end{document}

答案1

只需将原始的黑色三角形放在动画上透明度自己的。然后在第一个和最后一个动画中使用它框架根据time.txt下面列出的时间线文件。还请注意,最后一个透明胶片中旋转了 360° 的三角形被移除了。

  • 六部动画透明胶片“0 到 5: 在此处输入图片描述

  • 五动画框架0 至 4,组装自透明胶片根据时间线文件

\begin{filecontents}{time.txt}
  ::0x0, 1 % axes+grid, black triangle
  ::2
  ::3
  ::4
  ::5, 1 % black triangle re-used
\end{filecontents}

在此处输入图片描述

完整示例:

\documentclass[12pt]{article}
\usepackage{animate}
\usepackage{graphicx}
\usepackage{pgf,tikz}
\usepackage{color}

\usepackage{filecontents}
\begin{filecontents}{time.txt}
  ::0x0, 1 % axes+grid, black triangle
  ::2
  ::3
  ::4
  ::5, 1 % black triangle re-used
\end{filecontents}    

\begin{document}

\begin{center}

\begin{animateinline}[
  begin={%
    \begin{tikzpicture}[line cap=round,line join=round,x=1.0cm,y=1.0cm]
    \clip(-4.7,-3.7)  rectangle (4.7,3.7);
  },
  end={\end{tikzpicture}},
  controls,
  timeline=time.txt
]{1}
  % axes + grid
  \draw [color=gray] (-4.5,-3.2) grid (4.5,3.2);

  \foreach \x in {-4,...,4}
  \draw [very thick] (\x,0.1) -- (\x,-0.1) node[below] {\x};
  \foreach \y in {-3,...,3}
  \draw [very thick] (0.1,\y) -- (-0.1,\y) node[left] {\y};

  \draw [<->, very thick] (-4.5,0) -- (4.5,0) node [below] {$x$};
  \draw [<->, very thick] (0,-3.5) -- (0,3.5) node [right] {$y$};

\newframe % starting triangle
  \draw [line width=1.5pt] (0,1) -- (1,3) -- (3,1) -- cycle;

\newframe % GIRO 90°
  \draw [color=blue,line width=1.5pt] (-1,0) -- (-3,1) -- (-1,3)-- cycle;
  \draw[color=black] (3.,2.7) node[anchor=north west] {\colorbox{white}{$\alpha=90$}};
  \draw [->,line width=1.5pt](0.5,0) arc (0:90:0.5cm);

\newframe % GIRO 180°
  \draw [color=blue,line width=1.5pt] (0,-1) -- (-1,-3) -- (-3,-1)-- cycle;
  \draw[color=black] (3.,2.7) node[anchor=north west] {\colorbox{white}{$\alpha=180$}};
  \draw [->,line width=1.5pt](0.5,0) arc (0:180:0.5cm);

\newframe % GIRO 270°
  \draw [color=blue, line width=1.5pt] (1,0) -- (3,-1) -- (1,-3)-- cycle;
  \draw[color=black] (3.,2.7) node[anchor=north west] {\colorbox{white}{$\alpha=270$}};
  \draw [->,line width=1.5pt](0.5,0) arc (0:270:0.5cm);

\newframe % GIRO 360°, last transparency without triangle
  \draw[color=black] (3.,2.7) node[anchor=north west] {\colorbox{white}{$\alpha=360$}};
  \draw [->,line width=1.5pt](0.5,0) arc (0:360:0.5cm);

\end{animateinline}
\end{center}

\end{document}

答案2

非常感谢 AlexG,你的帮助非常重要。我分享了我的设计。

\documentclass[12pt]{standalone}
\usepackage{animate}
\usepackage{graphicx}
\usepackage{pgf,tikz}
\usepackage{color}

\usepackage{filecontents}
\newcommand{\grad}{^{\circ}} 



\begin{filecontents}{time.txt}
  ::0x0 
  ::1
  ::2
  ::3
  ::4 
\end{filecontents}    

\begin{document}

\begin{animateinline}[
  begin={%
    \begin{tikzpicture}[line cap=round,line join=round,x=1.0cm,y=1.0cm]
    \clip(-4.7,-3.7)  rectangle (4.8,3.7);
  },
  end={\end{tikzpicture}},
  controls,
  timeline=time.txt
]{1}
  % axes + grid
  \draw [color=gray] (-4.5,-3.2) grid (4.5,3.2);

  \foreach \x in {-4,...,4}
  \draw [very thick] (\x,0.1) -- (\x,-0.1) node[below] {\x};
  \foreach \y in {-3,...,3}
  \draw [very thick] (0.1,\y) -- (-0.1,\y) node[left] {\y};

  \draw [<->, very thick] (-4.5,0) -- (4.5,0) node [below] {$x$};
  \draw [<->, very thick] (0,-3.5) -- (0,3.5) node [right] {$y$};

  \draw [line width=1.5pt] (0,1) -- (1,3) -- (3,1) -- cycle;

    \begin{scriptsize}
        \draw[color=black] (0.2,0.7) node {{\large $A$}};
        \draw[color=black] (3.2,0.7) node {{\large$B$}};
        \draw[color=black] (1.5,3) node {{\large$C$}};
    \end{scriptsize}

\newframe % GIRO 90°
  \draw [color=blue,line width=1.5pt] (-1,0) -- (-3,1) -- (-1,3)-- cycle;
  \draw[color=black] (2.9,2.7) node[anchor=north west] {\colorbox{white}{$\alpha=90 \grad $}};
  \draw [->,color=green, line width=1.5pt](0.5,0) arc (0:90:0.5cm);

    \begin{scriptsize}
    \draw[color=black] (-0.7,0.3) node {{\large $A'$}};
    \draw[color=black] (-0.7,3.2) node {{\large$B'$}};
    \draw[color=black] (-3,1.5) node {{\large$C'$}};
  \end{scriptsize}

\newframe % GIRO 180°
  \draw [color=blue,line width=1.5pt] (0,-1) -- (-1,-3) -- (-3,-1)-- cycle;
  \draw[color=black] (2.9,2.7) node[anchor=north west] {\colorbox{white}{$\alpha=180 \grad $}};
  \draw [->,color=green, line width=1.5pt](0.5,0) arc (0:180:0.5cm);

    \begin{scriptsize}
    \draw[color=black] (-0.3,-0.7) node {{\large $A'$}};
    \draw[color=black] (-3.2,-0.7) node {{\large$B'$}};
    \draw[color=black] (-1.5,-3) node {{\large$C'$}};
  \end{scriptsize}

\newframe % GIRO 270°
  \draw [color=blue, line width=1.5pt] (1,0) -- (3,-1) -- (1,-3)-- cycle;
  \draw[color=black] (2.9,2.7) node[anchor=north west] {\colorbox{white}{$\alpha=270 \grad $}};
  \draw [->,color=green, line width=1.5pt](0.5,0) arc (0:270:0.5cm);

        \begin{scriptsize}
    \draw[color=black] (0.7,-0.2) node {{\large $A'$}};
    \draw[color=black] (0.7,-3.2) node {{\large$B'$}};
    \draw[color=black] (3,-1.5) node {{\large$C'$}};
  \end{scriptsize}

\newframe % GIRO 360°
  \draw [color=blue, line width=1.5pt] (0,1) -- (1,3) -- (3,1) -- cycle;
  \draw[color=black] (2.9,2.7) node[anchor=north west] {\colorbox{white}{$\alpha=360 \grad $}};
  \draw [->,color=green, line width=1.5pt](0.5,0) arc (0:360:0.5cm);

\end{animateinline}

\end{document}

相关内容