使用 tikzpicture 进行动画

使用 tikzpicture 进行动画

我目前有一个带有 tikzpicture 和节点的框架。但我不知道如何只显示一个节点,其他节点显示为灰色,下一帧将包含一些文本,下一帧将使第一个和第二个节点可见,其他节点保持灰色,等等...我已经尝试了“暂停”选项,但这不是我想要的...

前任:

frame1 节点 1 可见,其他节点为灰色

frame2 啦啦啦啦啦

frame3 节点 1 和 2 可见,其他为灰色..等等...

frame4 啦啦啦啦啦

我的代码是:

\documentclass{beamer}
\usepackage{tikz}
\tikzstyle{m_rectangle} = [rectangle, align=center, rounded corners, minimum width=2cm, minimum height=1.5cm, draw=black]
\tikzstyle{arrow} = [thick,->,>=stealth]

\begin{document}

\begin{frame}{Test frame}
\begin{figure}
\centering
\vspace{-.3cm}
\begin{tikzpicture}[node distance=2cm]
    \hspace{-.5cm}
    \node (in) [m_rectangle, fill=red!30] {1};
    \node (chapeau) [m_rectangle, right of=in, xshift=1cm, fill=blue!30] {2};
    \node (fortran) [m_rectangle, below of=chapeau, yshift=-.1cm, fill=yellow!30] {3};
    \node (all) [m_rectangle,  right of=chapeau, xshift=1.5cm, fill=green!30] {4};
    \node (fiab) [m_rectangle, above of=all, yshift=.1cm, fill=green!30] {5};
    \node (moy) [m_rectangle, below of=all, yshift=-.1cm, fill=green!30] {6};
    \node (out) [m_rectangle, right of=all, xshift=1cm, fill=red!30] {7};
    \draw [arrow] (in) -- (chapeau);
    \draw [arrow] (in) -- (fortran);
    \draw [arrow] (chapeau) -- (fortran);
    \draw [arrow] (chapeau) -- (fiab);
    \draw [arrow] (chapeau) -- (all);
    \draw [arrow] (chapeau) -- (moy);
    \draw [arrow] (out) -- (fiab);
    \draw [arrow] (out) -- (all);
    \draw [arrow] (out) -- (moy);
\end{tikzpicture}
\caption{Figure caption}
\end{figure}
\end{frame}

\end{document}

提前谢谢大家,

懒猴

答案1

我不太清楚你到底想要什么,但你大概可以通过使用来实现你想要的

\setbeamercovered{transparent}

这将使覆盖的项目变得透明,并且

\uncover<>{}

围绕不总是完全可见的节点

\documentclass{beamer}
\usepackage{tikz}

\tikzstyle{m_rectangle} = [rectangle, align=center, rounded corners, minimum width=2cm, minimum height=1.5cm, draw=black]
\tikzstyle{arrow} = [thick,->,>=stealth]

\begin{document}

\begin{frame}{Test frame}
\setbeamercovered{transparent}
\begin{figure}
\centering
\vspace{-.3cm}
\begin{tikzpicture}[node distance=2cm]
    \hspace{-.5cm}
    \node (in) [m_rectangle, fill=red!30] {1};
    \uncover<2>{\node (chapeau) [m_rectangle, right of=in, xshift=1cm, fill=blue!30] {2};}
    \node (fortran) [m_rectangle, below of=chapeau, yshift=-.1cm, fill=yellow!30] {3};
    \node (all) [m_rectangle,  right of=chapeau, xshift=1.5cm, fill=green!30] {4};
    \node (fiab) [m_rectangle, above of=all, yshift=.1cm, fill=green!30] {5};
    \uncover<3>{\node (moy) [m_rectangle, below of=all, yshift=-.1cm, fill=green!30] {6};}
    \node (out) [m_rectangle, right of=all, xshift=1cm, fill=red!30] {7};
    \draw [arrow] (in) -- (chapeau);
    \draw [arrow] (in) -- (fortran);
    \draw [arrow] (chapeau) -- (fortran);
    \draw [arrow] (chapeau) -- (fiab);
    \draw [arrow] (chapeau) -- (all);
    \draw [arrow] (chapeau) -- (moy);
    \draw [arrow] (out) -- (fiab);
    \draw [arrow] (out) -- (all);
    \draw [arrow] (out) -- (moy);
\end{tikzpicture}
\caption{Figure caption}
\end{figure}
\end{frame}

\end{document}

答案2

我使用 tikz 的不透明度功能解决了这个问题。

比照:

\documentclass[10pt]{beamer}
\mode<presentation>
{
    \usetheme{Warsaw}
    \setbeamercovered{transparent}
}

\usepackage{tikz}

\tikzset{invisible/.style={opacity=0.1},
                    visible on/.style={alt={#1{}{invisible}}},
                        alt/.code args={<#1>#2#3}{%
                            \alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}} 
                        },
}

\tikzstyle{m_rectangle} = [rectangle, align=center, rounded corners, minimum width=2cm, minimum height=1.5cm, draw=black, visible on=<1->]
\tikzstyle{i_rectangle} = [rectangle, align=center, rounded corners, minimum width=2cm, minimum height=1.5cm, draw=black, invisible]
\tikzstyle{arrow} = [thick,->,>=stealth, visible on=<1->]
\tikzstyle{i_arrow} = [thick,->,>=stealth, invisible]

\begin{document}
\begin{frame}{Test}
        \begin{figure}
            \centering
            \vspace{-.3cm}
            \begin{tikzpicture}[node distance=2cm]
                \hspace{-.5cm}
                \node (in) [m_rectangle, fill=red!30] {1};
                \node (chapeau) [i_rectangle, right of=in, xshift=1cm, fill=blue!30] {2};
                \node (fortran) [i_rectangle, below of=chapeau, yshift=-.1cm, fill=yellow!30] {3};
                \node (all) [i_rectangle,  right of=chapeau, xshift=1.5cm, fill=green!30] {4};
                \node (fiab) [i_rectangle, above of=all, yshift=.1cm, fill=green!30] {5};
                \node (moy) [i_rectangle, below of=all, yshift=-.1cm, fill=green!30] {6};
                \node (out) [i_rectangle, right of=all, xshift=1cm, fill=red!30] {7};
                \draw [i_arrow] (in) -- (chapeau);
                \draw [i_arrow] (in) -- (fortran);
                \draw [i_arrow] (chapeau) -- (fortran);
                \draw [i_arrow] (chapeau) -- (fiab);
                \draw [i_arrow] (chapeau) -- (all);
                \draw [i_arrow] (chapeau) -- (moy);
                \draw [i_arrow] (out) -- (fiab);
                \draw [i_arrow] (out) -- (all);
                \draw [i_arrow] (out) -- (moy);
            \end{tikzpicture}
        \caption{Block diagram}
        \end{figure}
    \end{frame}

    \begin{frame}{Test}
        \begin{itemize}
        \Large{
            \item BlaBlaBla
            \item BlaBlaBla
            \item BlaBlaBla
        }
        \end{itemize}
    \end{frame}

    \begin{frame}{Test}
        \begin{figure}
            \centering
            \vspace{-.3cm}
            \begin{tikzpicture}[node distance=2cm]
                \hspace{-.5cm}
                \node (in) [m_rectangle, fill=red!30] {1};
                \node (chapeau) [m_rectangle, right of=in, xshift=1cm, fill=blue!30] {2};
                \node (fortran) [i_rectangle, below of=chapeau, yshift=-.1cm, fill=yellow!30] {3};
                \node (all) [i_rectangle,  right of=chapeau, xshift=1.5cm, fill=green!30] {4};
                \node (fiab) [i_rectangle, above of=all, yshift=.1cm, fill=green!30] {5};
                \node (moy) [i_rectangle, below of=all, yshift=-.1cm, fill=green!30] {6};
                \node (out) [i_rectangle, right of=all, xshift=1cm, fill=red!30] {7};
                \draw [arrow] (in) -- (chapeau);
                \draw [i_arrow] (in) -- (fortran);
                \draw [i_arrow] (chapeau) -- (fortran);
                \draw [i_arrow] (chapeau) -- (fiab);
                \draw [i_arrow] (chapeau) -- (all);
                \draw [i_arrow] (chapeau) -- (moy);
                \draw [i_arrow] (out) -- (fiab);
                \draw [i_arrow] (out) -- (all);
                \draw [i_arrow] (out) -- (moy);
            \end{tikzpicture}
        \caption{Block diagram}
        \end{figure}
    \end{frame}

        \begin{frame}{Test}
        \begin{itemize}
        \Large{
            \item BlaBlaBla
            \item BlaBlaBla
            \item BlaBlaBla
        }
        \end{itemize}
    \end{frame}

    \begin{frame}{Test}
        \begin{figure}
            \centering
            \vspace{-.3cm}
            \begin{tikzpicture}[node distance=2cm]
                \hspace{-.5cm}
                \node (in) [m_rectangle, fill=red!30] {1};
                \node (chapeau) [m_rectangle, right of=in, xshift=1cm, fill=blue!30] {2};
                \node (fortran) [m_rectangle, below of=chapeau, yshift=-.1cm, fill=yellow!30] {3};
                \node (all) [i_rectangle,  right of=chapeau, xshift=1.5cm, fill=green!30] {4};
                \node (fiab) [i_rectangle, above of=all, yshift=.1cm, fill=green!30] {5};
                \node (moy) [i_rectangle, below of=all, yshift=-.1cm, fill=green!30] {6};
                \node (out) [i_rectangle, right of=all, xshift=1cm, fill=red!30] {7};
                \draw [arrow] (in) -- (chapeau);
                \draw [arrow] (in) -- (fortran);
                \draw [arrow] (chapeau) -- (fortran);
                \draw [i_arrow] (chapeau) -- (fiab);
                \draw [i_arrow] (chapeau) -- (all);
                \draw [i_arrow] (chapeau) -- (moy);
                \draw [i_arrow] (out) -- (fiab);
                \draw [i_arrow] (out) -- (all);
                \draw [i_arrow] (out) -- (moy);
            \end{tikzpicture}
        \caption{Block diagram}
        \end{figure}
    \end{frame}
\end{document}

问候

相关内容