2

I am rotating a triangle, I want only the first and last triangle of the last two frames to appear.

I want the triangles that are between the first and last triangle to be hidden.

Attached latex code.

    \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}
  • 2
    Welcome to TeX.SE! In order to mark code as code, just put it in the selection and press the {} button while editing your question. (I did that here, but this is to explain what happened.) More importantly, your code does not compile for me because I do not have the file time2.txt. To hide some part, you can just put it into \begin{scope}[opacity=0] ... \end{scope}. – user121799 Oct 21 '18 at 22:44
4

Just put the original, black triangle on an animation transparency of its own. Then, use it in the first and last animation frames according to the timeline file time.txt listed below. Also note that the final triangle rotated by 360° was removed from the last transparency.

  • Six animation "transparencies" 0 through 5: enter image description here

  • Five animation frames 0 through 4, assembled from transparencies according to the timeline file

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

enter image description here

Complete example:

\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}
0

Thank you very much AlexG, your help was of great importance. I share my design.

\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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.