11

I made a handout on which are drawn parallelograms of the same area.

polycop

\documentclass[]{article}
\usepackage[np]{numprint} 
\usepackage{tikz}
\usetikzlibrary{arrows.meta}

\begin{document}
\begin{tikzpicture}
\draw[dashed] (0,0)--(13,0);
\draw[dashed] (0,3)--(13,3);
\draw[<->,>={Latex}](.5,0)--(.5,3)node[midway,fill=white]{\numprint[cm]{3}};
\draw[fill=green!30] (4.5,0)--(5.5,3)--(9.5,3)--(8.5,0)--cycle ;% parallelo 1
\draw[<->,>={Latex}](4.5,-.3)--(8.5,-.3)node[midway,fill=white]{\numprint[cm]{4}};

\begin{scope}
\draw[dashed] (0,-4)--(13,-4);
\draw[dashed] (0,-1)--(13,-1);
\draw[<->,>={Latex}](.5,-4)--(.5,-1)node[midway,fill=white]{\numprint[cm]{3}};
\draw[fill=green!30] (8,-4)--(2,-1)--(6,-1)--(12,-4)--cycle;% parallelo 4
\draw[<->,>={Latex}](8,-4.3)--(12,-4.3)node[midway,fill=white]{\numprint[cm]{4}};
\end{scope}
\end{tikzpicture}
\end{document}

When the students have finished working, I want to project on the board the same document in the form of a slide beamer, but composed of the two following animations that will be activated at the click of the mouse.

parallelogramme_un

parallelogramme_deux

First animation:

\documentclass[tikz]{standalone}
\usetikzlibrary{arrows.meta,patterns}
\usepackage[np]{numprint}
\usepackage{animate}
\usepackage{fontawesome}
\begin{document}

\foreach \y  in {0,.2,...,3}{% découper le parallélogramme - images 1 - 16
    \begin{tikzpicture}
        \useasboundingbox (-6.5,-.5) rectangle (6.5,4);
        \draw[dashed] (-6.5,0)--(6.5,0);
        \draw[dashed] (-6.5,3)--(6.5,3);
        \draw[<->,>={Latex}](-6,0)--(-6,3)node[midway,fill=white]{\numprint[cm]{3}};
        \draw[<->,>={Latex}](-2,-.3)--(2,-.3)node[midway,fill=white]{\numprint[cm]{4}};     

        \fill[green!50](-2,0)--(-1,3)--(3,3)--(2,0)--cycle; 
        \fill[pattern=north east  lines,pattern color=blue!30](2,0)--(2,\y)--(2+\y/3,\y)--cycle;
        \draw[dashed](2,0)--(2,\y);
        \draw[dashed](2,0)--(2+\y/3,\y);
    \end{tikzpicture}
 }   

 \foreach \iangle in {2,4,...,180}{% déplacer le triangle
    \begin{tikzpicture}
        \fill[white] (-6.5,-.5) rectangle (6.5,4);
        \draw[dashed] (-6.5,0)--(6.5,0);
        \draw[dashed] (-6.5,3)--(6.5,3);
        \draw[<->,>={Latex}](-6,0)--(-6,3)node[midway,fill=white]{\numprint[cm]{3}};
        \draw[<->,>={Latex}](-2,-.3)--(2,-.3)node[midway,fill=white]{\numprint[cm]{4}}; 
        \fill[green!50](-2,0)--(-1,3)--(2,3)--(2,0)--cycle;
        \fill[green,opacity=.5] (\iangle:20mm and 8mm)--([shift={(0,3)}]\iangle:20mm and 8mm)--([shift={(1,3)}]\iangle:20mm and 8mm)--cycle;
        \draw[thin,dashed,pattern=north east  lines,pattern color=blue!30](2,3)--(2,0)--(3,3)--cycle;
        \draw[thin,dashed,pattern=north east  lines,pattern color=blue!30] (\iangle:20mm and 8mm)--([shift={(0,3)}]\iangle:20mm and 8mm)--([shift={(1,3)}]\iangle:20mm and 8mm)--cycle;
        \node at ([shift={(.4,1.5)}]\iangle:20mm and 8mm)[black]{\faHandPointerO};                      
     \end{tikzpicture}
    }
\end{document}

Second animation:

\documentclass[tikz]{standalone}
\usepackage{animate}
\usepackage{pgf}
\usepackage{multido}
\usepackage{numprint}
\usetikzlibrary{patterns,decorations,arrows.meta}

\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{lineto}
    }
    \state{final}{\decoration{ignore}}
}

\tikzset{
    start segment/.style={decoration={start,raise=1mm},decorate, segment length=#1},
}
\tikzset{every path/.style={>={Straight Barb[]}}}
\begin{document}
\def\couleur{white}

\begin{tikzpicture}% fond écran vert - triangles 1 et 2 - image 1
    \useasboundingbox (0,3.1) rectangle (13,-.5);
    \fill[green!40](2,3) rectangle (12,0);
    \draw[dashed] (0,0)--(13,0);
    \draw[dashed] (0,3)--(13,3);
    \draw[<->](.5,0)--(.5,3)node[midway,fill=white]{\numprint[cm]{3}};
    \draw[<->](8,-.3)--(12,-.3)node[midway,fill=white]{\numprint[cm]{4}};   
    \fill[\couleur] (12,0)--(12,3)--(6,3)--cycle;
    \fill[\couleur] (2,0)--(2,3)--(8,0)--cycle;
\end{tikzpicture}

\foreach \rpos  in {.02,.04,...,1}{% inscrire le parallélogramme dans un rectangle - images 2-51
            \begin{tikzpicture}
                \useasboundingbox (0,3.1) rectangle (13,-.5); 
                \fill[green!40](2,3) rectangle (12,0);
                \draw[dashed] (0,0)--(13,0);
                \draw[dashed] (0,3)--(13,3);
                \draw[<->](.5,0)--(.5,3)node[midway,fill=white]{\numprint[cm]{3}};
                \draw[<->](8,-.3)--(12,-.3)node[midway,fill=white]{\numprint[cm]{4}};   
                \fill[\couleur] (12,0)--(12,3)--(6,3)--cycle;
                \fill[\couleur] (2,0)--(2,3)--(8,0)--cycle;
                \draw[start segment=\rpos,blue,semithick] (2,3) -- (2,0) -- (12,0) -- (12,3) --cycle ;
            \end{tikzpicture} 
 } 

\foreach \rpos  in {.1,.2,...,3}{% colorer le triangle 2 progressivement - 30 images: 52-81
            \begin{tikzpicture}
                \useasboundingbox (0,3.1) rectangle (13,-.5); 
                \fill[green!40](2,3) rectangle (12,0);
                \draw[dashed] (0,0)--(13,0);
                \draw[dashed] (0,3)--(13,3);
                \draw[<->,](.5,0)--(.5,3)node[midway,fill=white]{\numprint[cm]{3}};
                \draw[<->](8,-.3)--(12,-.3)node[midway,fill=white]{\numprint[cm]{4}};   
                \fill[\couleur] (12,0)--(12,3)--(6,3)--cycle;
                \fill[\couleur] (2,0)--(2,3)--(8,0)--cycle;
                \draw[blue,thin] (2,3) -- (2,0) -- (12,0) -- (12,3) --cycle ;
                \draw[blue,thin] (2,3) -- (2+2*\rpos,3-\rpos);
                \fill[pattern color=blue,pattern=north east lines](2,3)--(2+2*\rpos,3-\rpos)--(2,3-\rpos)--cycle;
            \end{tikzpicture} 
 } 

\foreach \rpos  in {.1,.2,...,3}{% colorer le triangle 1 progressivement - 30 images: 82-111
            \begin{tikzpicture}
                \useasboundingbox (0,3.1) rectangle (13,-.5); 
                \fill[green!40](2,3) rectangle (12,0);
                \draw[dashed] (0,0)--(13,0);
                \draw[dashed] (0,3)--(13,3);
                \draw[<->](.5,0)--(.5,3)node[midway,fill=white]{\numprint[cm]{3}};
                \draw[<->](8,-.3)--(12,-.3)node[midway,fill=white]{\numprint[cm]{4}};   
                \fill[\couleur] (12,0)--(12,3)--(6,3)--cycle;
                \fill[\couleur] (2,0)--(2,3)--(8,0)--cycle;
                \draw[blue,thin] (2,3) -- (2,0) -- (12,0) -- (12,3) --cycle ;
                \draw[blue,thin] (2,3) -- (8,0);
                \fill[pattern color=blue,pattern=north east lines](2,3)--(8,0)--(2,0)--cycle;
                \draw[blue,thin] (12,0) -- (12-2*\rpos,\rpos);
                \fill[pattern color=blue,thin,pattern=north east lines](12,0)--(12,\rpos)--(12-2*\rpos,\rpos);
            \end{tikzpicture} 
 } 

\foreach \x in {11.95,11.9,...,8}{% translation du triangle 1 - 80 images: 112-191
    \begin{tikzpicture}
        \useasboundingbox (0,3.1) rectangle (13,-.5);
        \fill[green!40](2,3) rectangle (12,0);
        \draw[dashed] (0,0)--(13,0);
        \draw[dashed] (0,3)--(13,3);
        \draw[<->](.5,0)--(.5,3)node[midway,fill=white]{\numprint[cm]{3}};
        \draw[<->](8,-.3)--(12,-.3)node[midway,fill=white]{\numprint[cm]{4}};   
        \fill[\couleur] (2,0)--(2,3)--(8,0)--cycle;
        \draw[blue,thin] (2,3) -- (2,0) -- (12,0) -- (12,3) --cycle ;
        \draw[blue,thin] (2,3) -- (8,0);
        \fill[pattern color=blue,pattern=north east lines](2,3)--(8,0)--(2,0)--cycle;
        \draw[blue,thin,fill=white](\x,0)--(\x,3)--(\x-6,3)--cycle; 
        \fill[pattern color=blue,pattern=north east lines] (\x,0)--(\x,3)--(\x-6,3)--cycle; 
    \end{tikzpicture}
    }   
\end{document}

I tried to use the beamer's Movie command, but I couldn't.

\documentclass[aspectratio=1610]{beamer}
\usepackage{animate}
\usepackage{multimedia}
\usepackage{media9}

\begin{document}
\begin{frame}{Aire du parallélogramme}
\movie[]{}{para1.pdf}
%\includemedia[]{}{para1.pdf}

\movie[]{}{para4.pdf}
%\includemedia[]{}{para4.pdf}
\end{frame}
\end{document}
  • Is it possible to place two animations in the same beamer frame?
  • If so, how?
  • Should I change the format of animations: gif, swf, mp4, ... instead of pdf?
7
  • @marmot My goal is to be able to animate each one separately according to the progress of the students.
    – AndréC
    Commented Aug 10, 2018 at 18:00
  • @marmot This is what I have always done until now, if it is impossible to do otherwise, I will do as before: only one animation per frame.
    – AndréC
    Commented Aug 10, 2018 at 18:57
  • I am not saying it is impossible to have two animations. Rather, I think it should be possible, precisely in the way you describe: produce movies and embed them. However, I am not sure I myself would want to do that. Why? What will happen realistically? You will play one animation, then the second, and then both. So just define macros for each, say \animationOne and \animationTwo, on the first slide do \animationOne{\X} \animationTwo{0}, then \animationOne{0} \animationTwo{\X} and finally ``\animationOne{\X} \animationTwo{\X}` where \X is the variable that gets animated.
    – user121799
    Commented Aug 10, 2018 at 19:02
  • @marmot What should be the file extension of these movies? .mp4? .gif? another?
    – AndréC
    Commented Aug 10, 2018 at 19:12
  • 1
    Since you seem to be French, maybe this could be an option? (Needless to say that I never tried it.)
    – user121799
    Commented Aug 10, 2018 at 20:09

2 Answers 2

9

Two animations in one frame. Buttons used for simultaneous playback control. The JavaScript interface of animate is used for defining the button actions.

Animations can be played back individually by clicking them directly.

enter image description here

\documentclass{beamer}
\usepackage{animate}
\usepackage{media9} %\mediabutton
\usepackage{fontawesome}

\begin{document}

\begin{frame}[t]{Two animations}
\animategraphics[label=anim1,width=\linewidth]{12}{para1}{}{}\\[1ex]
\animategraphics[label=anim2,width=\linewidth]{12}{para4}{}{}

\mediabutton[
  jsaction={anim.anim1.stopFirst();anim.anim2.stopFirst();}
]{\fbox{\faStop}}
\mediabutton[
  jsaction={anim.anim1.pause();anim.anim2.pause();}
]{\fbox{\faPause}}
\mediabutton[
  jsaction={anim.anim1.playFwd();anim.anim2.playFwd();}
]{\fbox{\faPlay}}
\end{frame}

\end{document}
4

I must have been tired (the heat wave?) because it's quite possible to insert two animations created with the \animategraphics command from the animate package this way:

\documentclass[aspectratio=1610]{beamer} % Présentation générale et mise en page
\usepackage{animate}

\begin{document}
\begin{frame}{Aire du parallélogramme}
\animategraphics[]{24}{para1image}{}{}

\animategraphics[]{24}{para4image}{}{}
\end{frame}
\end{document}

I thank marmot and AlexG for the new tracks proposed which will allow me to conceive even prettier animations.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .