为我的标签制作动画,就像在 Beamer 中回答这个问题一样

为我的标签制作动画,就像在 Beamer 中回答这个问题一样

我想标记这是我的 tikz 图片

就像

[tikz 图像

在第一个答案中问题。

\documentclass[compress]{beamer}
\usetheme{Warsaw}

\usepackage{amssymb}
\usepackage{tikz}
\usetikzlibrary{math}

\usetikzlibrary{arrows,shapes}
\tikzstyle{na} = [baseline=-.5ex]
\tikzstyle{every picture}+=[remember picture]

\xdefinecolor{O}{rgb}{0.85, 1.0, 0.3}
\xdefinecolor{OO}{rgb}{0.67, 1.0, 0.3}
\xdefinecolor{OOO}{rgb}{0.43, 1.0, 0.3}
\xdefinecolor{OOOO}{rgb}{0.27, 1.0, 0.3}
\begin{document}


    \begin{frame}
        \frametitle{Test with bricks}
        \centering
        \tikzmath{
            real \e1, \e2, \e3, \e4, \w1, \w2, \w3, \w4;
            \e1 = 5;
            \e2 = 4;
            \e3 = 3;
            \e4 = 1.6;
            \w1 = 1.7;
            \w2 = \w1*\e2/\e1;
            \w3 = \w1*\e3/\e1;
            \w4 = \w1*\e4/\e1;
        }
        \hspace{-2cm}
        \begin{tikzpicture}[baseline=3cm, overlay, scale=.9]
        \draw<1-5> (-3, -2.5) rectangle (5.5, 5.5);
        
            % first tile
            \draw<5>[fill=OOOO!70!black] (0, 0, \e1) -- (\w1, 0, \e1)
            -- (\w1, \e1, \e1) -- (0, \e1, \e1) -- cycle;
            \draw<5>[fill=OOOO!70] (0, \e1, \e1) -- (\w1, \e1, \e1)
            -- (\w1, \e1, 0) -- (0, \e1, 0) -- cycle;
            \draw<5>[fill=OOOO] (\w1, 0, \e1) -- (\w1, \e1, \e1)
            -- (\w1, \e1, 0) -- (\w1, 0, 0) -- cycle;

        
            % second tile
            \draw<4-5>[fill=OOO!70!black] (\w1+0, 0, \e2) -- (\w1+\w2, 0, \e2)
            -- (\w1+\w2, \e2, \e2) -- (\w1+0, \e2, \e2) -- cycle;
            \draw<4-5>[fill=OOO!70] (\w1+0, \e2, \e2) -- (\w1+\w2, \e2, \e2)
            -- (\w1+\w2, \e2, 0) -- (\w1+0, \e2, 0) -- cycle;
            \draw<4-5>[fill=OOO] (\w1+\w2, 0, \e2) -- (\w1+\w2, \e2, \e2)
            -- (\w1+\w2, \e2, 0) -- (\w1+\w2, 0, 0) -- cycle;
        
            % third tile
            \draw<3-5>[fill=OO!70!black] (\w1+\w2+0, 0, \e3) -- (\w1+\w2+\w3, 0, \e3)
            -- (\w1+\w2+\w3, \e3, \e3) -- (\w1+\w2+0, \e3, \e3) -- cycle;
            \draw<3-5>[fill=OO!70] (\w1+\w2+0, \e3, \e3) -- (\w1+\w2+\w3, \e3, \e3)
            -- (\w1+\w2+\w3, \e3, 0) -- (\w1+\w2+0, \e3, 0) -- cycle;
            \draw<3-5>[fill=OO] (\w1+\w2+\w3, 0, \e3) -- (\w1+\w2+\w3, \e3, \e3)
            -- (\w1+\w2+\w3, \e3, 0) -- (\w1+\w2+\w3, 0, 0) -- cycle;
        
            % fourth tile
            \draw<2-5>[fill=O!70!black] (\w1+\w2+\w3+0, 0, \e4)
            -- (\w1+\w2+\w3+\w4, 0, \e4)
            -- (\w1+\w2+\w3+\w4, \e4, \e4)
            -- (\w1+\w2+\w3+0, \e4, \e4) -- cycle;
            \draw<2-5>[fill=O!70] (\w1+\w2+\w3+0, \e4, \e4)
            -- (\w1+\w2+\w3+\w4, \e4, \e4)
            -- (\w1+\w2+\w3+\w4, \e4, 0)
            -- (\w1+\w2+\w3+0, \e4, 0) -- cycle;
            \draw<2-5>[fill=O] (\w1+\w2+\w3+\w4, 0, \e4)
            -- (\w1+\w2+\w3+\w4, \e4, \e4)
            -- (\w1+\w2+\w3+\w4, \e4, 0)
            -- (\w1+\w2+\w3+\w4, 0, 0) -- cycle;
        
            \node <5> [below] at (-1.25,3.1) (d1) {\huge R};
            \node <5> [below] at (-1.25,2.05) {\huge A};
            \node <5> [below] at (-1.25,1.0) {\huge T};
            \node <5> [below] at (-1.25,-0.05) {\huge I};
            \node <5> [below] at (-1.25,-1.1) {\huge O};
        
            \node <4-5> [below] at (0.75,2.45) (d2) {\large I};
            \node <4-5> [below] at (0.75,2.05) {\large N};
            \node <4-5> [below] at (0.75,1.55) {\large T};
            \node <4-5> [below] at (0.75,1.05) {\large E};
            \node <4-5> [below] at (0.75,0.55) {\large R};
            \node <4-5> [below] at (0.75,0.05) {\large V};
            \node <4-5> [below] at (0.75,-0.45) {\large A};
            \node <4-5> [below] at (0.75,-0.9) {\large L};
        
            \node <3-5> [below] at (2.3,1.8) (d3) {\normalsize O};
            \node <3-5> [below] at (2.3,1.4) {\normalsize R};
            \node <3-5> [below] at (2.3,1.0) {\normalsize D};
            \node <3-5> [below] at (2.3,0.6) {\normalsize I};
            \node <3-5> [below] at (2.3,0.2) {\normalsize N};
            \node <3-5> [below] at (2.3,-0.2) {\normalsize A};
            \node <3-5> [below] at (2.3,-0.6) {\normalsize L};
        
            \node <2-5> [below] at (3.7,1.1) (d4) {\tiny N};
            \node <2-5> [below] at (3.7,0.85) {\tiny O};
            \node <2-5> [below] at (3.7,0.63) {\tiny M};
            \node <2-5> [below] at (3.7,0.4) {\tiny I};
            \node <2-5> [below] at (3.7,0.2) {\tiny N};
            \node <2-5> [below] at (3.7,0.0) {\tiny A};
            \node <2-5> [below] at (3.7,-0.225) {\tiny L};
            
        \end{tikzpicture}

    %%\begin{itemize}
        %%\item Description $1$ \tikz[na] \node[coordinate] (s2) {};
        %%\item Description $2$ \tikz[na] \node[coordinate] (s2) {};
        %%\item Description $3$ \tikz[na] \node[coordinate] (s3) {};
        %%\item Description $4$ \tikz[na] \node[coordinate] (s4) {};
    %%\end{itemize}

    %%\begin{tikzpicture}[overlay]
        %%\path[->] (s1) edge [bend left] (d1);
        %%\path[->] (s2) edge [bend right] (d2);
        %%\path[->] (s3) edge [out=0, in=-90] (d3);
        %%\path[->] (s4) edge [out=0, in=-90] (d4);
    %%\end{tikzpicture}

    \end{frame}
\end{document}

我已按自己的喜好更改了颜色。我想要的只是指向的箭头Descriptions

答案1

我不确定您想把描述放在哪里,是在 itemize 环境中还是如图所示放在图片内?我认为在 itemize 环境中一切都会有点紧凑,所以我更喜欢另一种选择。如果是这样的话,有一个解决方案。

我改变了所有的代码,但我认为这种方式更简单:

\documentclass[compress]{beamer}
\usepackage    {tikz}
\usetheme      {Warsaw}
\usetikzlibrary{3d}

\xdefinecolor{O}   {rgb}{0.85, 1.0, 0.3}
\xdefinecolor{OO}  {rgb}{0.67, 1.0, 0.3}
\xdefinecolor{OOO} {rgb}{0.43, 1.0, 0.3}
\xdefinecolor{OOOO}{rgb}{0.27, 1.0, 0.3}

\newcommand{\tile}[7] % position (x axis), width, height, color, front label, number of letters, description
{%
  \begin{scope}[canvas is xy plane at z=#3]
    \draw[fill=#4!70!black] (#1,0) rectangle (#1-#2,#3);
    \foreach[count=\xi] \i in{#5} % for each letter in the word
    {%
      \pgfmathsetmacro\h{#3*(#6+0.5-\xi)/#6} % height for the letter
      \node[scale=0.3*#3] at (#1-0.5*#2,\h)  {\i}; 
    }
  \end{scope}
  \draw[canvas is xz plane at y=#3,fill=#4!70] (#1,0) rectangle (#1-#2,#3);
  \draw[canvas is yz plane at x=#1,fill=#4]    (0,0)  rectangle (#3,#3);
  \draw[thick,red,rounded corners,->] (#1-0.5*#2,#3,0.7*#3) |- (5,#3+0.5) node [right] {#7};
}

\begin{document}
  \begin{frame}{Test with bricks}
  \centering
  \begin{tikzpicture}[scale=0.8, line join=round]%,trim left={(-3,0)}, trim right={(5.5,0)}]
    \draw<1-5> (-3, -2.5) rectangle (9, 6);
    \only<5>   {\tile{1.7}{1.7}{5}  {OOOO}{R,A,T,I,O}      {5}{Description 4}}
    \only<4-5> {\tile{3.1}{1.4}{4}  {OOO} {I,N,T,E,R,V,A,L}{8}{Description 3}}
    \only<3-5> {\tile{4.1}{1}  {3}  {OO}  {O,R,D,I,N,A,L}  {7}{Description 2}}
    \only<2-5> {\tile{4.6}{0.5}{1.6}{O}   {N,O,M,I,N,A,L}  {7}{Description 1}}
  \end{tikzpicture}
  \end{frame}
\end{document}

在此处输入图片描述

相关内容