0

I need to scale a structure in for my animation. I used scale option for this purpose, but it is causing the structure to move to new position. I want the cross shapes to scale but have the same center position. Here is my code, help is apreciated.

\documentclass[pdf]{beamer}
\mode<presentation>{\usetheme{Warsaw}} 
\usepackage{animate}
\usepackage{amsmath}
\usepackage{tikz}
\title[]{My Presentation}
\author[Raghuram Dharmavarapu]{Raghu}
\date{}
\usepackage{ifthen}

\begin{document}

\begin{frame}[fragile]{Animated Integral}

\begin{animateinline}[loop, poster = first,controls]{3}
    \multiframe{11}{i=0+1}{%
    \begin{tikzpicture}[scale = 0.8]
    \useasboundingbox (-4,-5) rectangle (10,5);
    \onslide<1->
    \filldraw[blue!40!black] (0,0) -- (2,0) -- (2.35,1) --(-0.35,1)--cycle;
    \filldraw[blue!40!white] (-0.35,1) --(0.25,1.6) -- (1.75,1.6) -- (2.35,1) --cycle;

    \filldraw[gray!30!white,scale = 0.08] (10,16) -- (13,16) -- (12.9,17) -- (14.5,17) --(14.2,18.25)--(12.7,18.25)--(12.6,19)--(10.4,19)--(10.3,18.25)--(8.8,18.25)--(8.5,17)--(10.1,17)--cycle;
    \filldraw[gray!90!white,scale = 0.08] (8.5,17)--(8.6,14.5)--(10.05,14.5)--(10,16)--(10.1,17)--cycle;
    \filldraw[gray!90!black,scale = 0.08] (10,16) -- (10.1,14) -- (12.9,14) -- (13,16)-- cycle;
    \filldraw[gray!90!white,scale = 0.08] (14.5,17) --(14.4,14.5) --(12.95,14.5) --(13,16) -- (12.9,17) --cycle;

\onslide<2->
    \filldraw[blue!40!black] (0,0) -- (2,0) -- (2.35,1) --(-0.35,1)--cycle;
    \filldraw[blue!40!white] (-0.35,1) --(0.25,1.6) -- (1.75,1.6) -- (2.35,1) --cycle;

    \filldraw[gray!30!white,scale = 0.08+\i/100] (10,16) -- (13,16) -- (12.9,17) -- (14.5,17) --(14.2,18.25)--(12.7,18.25)--(12.6,19)--(10.4,19)--(10.3,18.25)--(8.8,18.25)--(8.5,17)--(10.1,17)--cycle;
    \filldraw[gray!90!white,scale = 0.08+\i/100] (8.5,17)--(8.6,14.5)--(10.05,14.5)--(10,16)--(10.1,17)--cycle;
    \filldraw[gray!90!black,scale = 0.08+\i/100] (10,16) -- (10.1,14) -- (12.9,14) -- (13,16)-- cycle;
    \filldraw[gray!90!white,scale = 0.08+\i/100] (14.5,17) --(14.4,14.5) --(12.95,14.5) --(13,16) -- (12.9,17) --cycle;


      \draw[->] (-3,-4) -- (10,-4) node[right] {$\lambda$};
      \draw[->] (-3,0) -- (10,0) node[right] {$\lambda$};
      \draw[->] (-2.5,-4.5) -- (-2.5,4) node[above] {$|E|$};
      \draw[->] (4,-4.5) -- (4,4) node[above] {$\angle E$};
      \draw[thick, dashed,domain=-1.5:3,samples = 100,smooth,variable=\x,blue] plot ({\x},{-4+3*pow(2.71,-(pow(\x+1-(\i/10*1.5),2))/0.05)});
      \draw[thick,domain=-1.5:3,smooth,samples = 100,variable=\x,red] plot ({\x},{-4+3*pow(2.71,-(pow(\x-2+(\i/10*1.5),2))/0.05)}); 

      \draw[thick, dashed,domain=-2:2,smooth,samples = 100,variable=\x,green] plot ({\x+6+(\i/10*1)},{-2.5+rad(atan(\x*3.5))});
      \draw[thick,domain=-2:2,smooth,samples = 100,variable=\x,magenta] plot ({\x+8 
      -(\i/10*1)},{-2.5+rad(atan(\x*3.5))});
    \end{tikzpicture}
    }
\end{animateinline}
\end{frame}

\end{document}

enter image description here enter image description here

  • Actually, I didn't understand your request. – AndréC Feb 17 at 17:00
  • Could you please explain more what you want to achieve? I am particulary wondering about the \onslide commands in the tikzpicture. If I remove them, I get a nice animation. The number 2 in \onslide<2-> is not the frame number of \multiframe. – marmot Feb 17 at 17:31
  • If I replace the \onslide commands by \ifnum\i>0 \filldraw[blue!40!black] (0,0) -- (2,0) -- (2.35,1) --(-0.35,1)--cycle; \fi and \ifnum\i>1 \filldraw[blue!40!black] (0,0) -- (2,0) -- (2.35,1) --(-0.35,1)--cycle; \fi I obtain a beautiful animation. The ifthen package is not needed in your code. And beamer has its own means to animate things, if you go for it, you could find \usetikzlibrary{overlay-beamer-styles} useful. – marmot Feb 17 at 17:45
  • I want to show the blue block with cross on top first. Then on the next slide I want to show the animation where the cross of the blue block gets bigger and bigger But my problem is that the cross is not sitting on the blue block as it gets bigger. – RD1153 Feb 18 at 1:45

Your Answer

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

Browse other questions tagged or ask your own question.