如何从 beamer 中的 includegraphics 中为图像着色?

如何从 beamer 中的 includegraphics 中为图像着色?

在投影仪框架中,我显示了三幅图像,使用

\includegraphics[width=\textwidth]{fig/moore.jpg}

当第二张图像出现时,如何为第一张图像着色,而当最后一张图像显示时,如何为前两张图像着色?

答案1

像这样?

在此处输入图片描述

代码(将opacityfrom更改0.2为所需值):

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{positioning}

\tikzset{
    opinvisible/.style={opacity=0.2},
    visible on/.style={alt={#1{}{opinvisible}}},
    alt/.code args={<#1>#2#3}{%
      \alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}} % \pgfkeysalso doesn't change the path
    },
  }

\begin{document}

\begin{frame}
\centering

\begin{tikzpicture}[node distance=0.5cm]
\node[visible on=<1>] (upper)
 {\includegraphics[height=2cm]{example-image-a}};

\node[visible on=<2>,below=of upper] (middle)
 {\includegraphics[height=2cm]{example-image-b}};

\node[visible on=<3>,below=of middle] (lower)
 {\includegraphics[height=2cm]{example-image-c}};
\end{tikzpicture}

\end{frame}

\end{document}

答案2

例如,可以通过在图片上叠加半透明的灰色形状来实现。

\documentclass{beamer}
\usepackage{tikz}

\begin{document}

\begin{frame}
\begin{tikzpicture}

    \only<1->{
        \node[anchor=south west,inner sep=0] (A) at (0,0) {\includegraphics[width=.3\textwidth]{example-grid-100x100bp}};
    }

    \only<2->{
        \node[anchor=south west,inner sep=0] (B) at (4,0) {\includegraphics[width=.3\textwidth]{example-grid-100x100bp}};
        \fill [draw=none, fill=white, fill opacity=0.7] (A.north west) -- (A.north east) -- (A.south east) -- (A.south west) -- (A.north west) -- cycle;
    }

    \only<3->{
        \node[anchor=south west,inner sep=0] (C) at (8,0) {\includegraphics[width=.3\textwidth]{example-grid-100x100bp}};
        \fill [draw=none, fill=white, fill opacity=0.7] (B.north west) -- (B.north east) -- (B.south east) -- (B.south west) -- (B.north west) -- cycle;
    }

\end{tikzpicture}
\end{frame} 

\end{document}

在此处输入图片描述

相关内容