TransWikia.com

Frames to animation using animate

TeX - LaTeX Asked on May 11, 2021

I have this code that generates frames and I want to animate it using begin{animateinline}, so I tried the following
first I removed foreach,
second I modified the code to

  newcounter{theangle}
    setcounter{theangle}{0}
    begin{animateinline}[loop, poster = first,controls]{40}
    %
    whiledo{angle<359}{
     
     begin{tikzpicture}
        defangle{45};
        fill[fill=red] (0,0) -- plot [domain=0:pi/180*angle] (x,{sin(x r)}) -- (pi/180*angle,0) -- cycle;
    end{tikzpicture}
    begin{tikzpicture}
        %fill[blue!50] (-1,0) arc (0:angle:1) -- (-2,0) -- cycle;
        %fill[blue!50] plot[smooth,domain=0:angle] (pi/180*x,{sin(x)}) |- (0,0);
        defradangle{pi/180*angle};

        fill[blue!50] (-1,0) arc (0:angle:1) -- (-2,0) -- cycle;
        %fill[fill=red] (0,0) -- plot [domain=0:radangle] (x,{sin(x r)}) -- (radangle,0) -- cycle;
        
        draw (-2,0) +(angle:1) circle (2pt) -- (pi/180*angle,{sin(angle)}) circle (2pt);
        draw (-3.5,0) -- (7,0);
        foreach deg in {90, 180, 270, 360}
            draw (pi/180*deg,2pt) -- (pi/180*deg,-2pt) node[below] {$deg^circ$};
        draw (0,-1.2) -- (0,1.2);
        foreach y in {-1,-0.5,0.5,1}
        draw (2pt,y) -- (-2pt,y) node[left] {$y$};
        draw plot[smooth,domain=0:360] (pi/180*x,{sin(x)});
        draw (-2,0) circle (1);
        end{tikzpicture}
    stepcounter{theangle}
    ifthenelse{theangle<359}{newframe}{
            end{animateinline}}
}

but it didn’t work, any help is appreciated.

documentclass[tikz]{standalone}
usepackage{tikz}

begin{document}

    begin{tikzpicture}
        defangle{45};
        fill[fill=red] (0,0) -- plot [domain=0:pi/180*angle] (x,{sin(x r)}) -- (pi/180*angle,0) -- cycle;
    end{tikzpicture}

    foreach angle in {0,10,...,360}
    {
        begin{tikzpicture}
        %fill[blue!50] (-1,0) arc (0:angle:1) -- (-2,0) -- cycle;
        %fill[blue!50] plot[smooth,domain=0:angle] (pi/180*x,{sin(x)}) |- (0,0);
        defradangle{pi/180*angle};

        fill[blue!50] (-1,0) arc (0:angle:1) -- (-2,0) -- cycle;
        %fill[fill=red] (0,0) -- plot [domain=0:radangle] (x,{sin(x r)}) -- (radangle,0) -- cycle;
        
        draw (-2,0) +(angle:1) circle (2pt) -- (pi/180*angle,{sin(angle)}) circle (2pt);
        draw (-3.5,0) -- (7,0);
        foreach deg in {90, 180, 270, 360}
            draw (pi/180*deg,2pt) -- (pi/180*deg,-2pt) node[below] {$deg^circ$};
        draw (0,-1.2) -- (0,1.2);
        foreach y in {-1,-0.5,0.5,1}
        draw (2pt,y) -- (-2pt,y) node[left] {$y$};
        draw plot[smooth,domain=0:360] (pi/180*x,{sin(x)});
        draw (-2,0) circle (1);
        end{tikzpicture}
    }

end{document}

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP