使用多个 Tikz 阴影角度变换图像

使用多个 Tikz 阴影角度变换图像

考虑一下代码

\documentclass{book}
\textheight=10in
\usepackage{tikz,graphicx}

\begin{document}
\thispagestyle{empty}
\begin{tikzpicture}
    \node[opacity=0.5, inner sep=0pt](A) at (0, 0) {\includegraphics[scale=0.5]{example-image}};
    \shade [left color=blue, right color=white, shading angle=45, opacity=0.5]
           (A.south west) rectangle (A.north east);
\end{tikzpicture} \, Shading Angle=45

\begin{tikzpicture}
    \node[opacity=0.5, inner sep=0pt](A) at (0, 0) {\includegraphics[scale=0.5]{example-image}};
    \shade [left color=blue, right color=white, shading angle=135, opacity=0.5]
           (A.south west) rectangle (A.north east);
\end{tikzpicture} \, Shading Angle=135

\begin{tikzpicture}
    \node[opacity=0.5, inner sep=0pt](A) at (0, 0) {\includegraphics[scale=0.5]{example-image}};
    \shade [left color=blue, right color=white, shading angle=225, opacity=0.5]
           (A.south west) rectangle (A.north east);
\end{tikzpicture} \, Shading Angle=225

\begin{tikzpicture}
    \node[opacity=0.5, inner sep=0pt](A) at (0, 0) {\includegraphics[scale=0.5]{example-image}};
    \shade [left color=blue, right color=white, shading angle=315, opacity=0.5]
           (A.south west) rectangle (A.north east);
\end{tikzpicture} \, Shading Angle=315
\end{document}

产生四幅图像

在此处输入图片描述

实际上,我希望将四幅图像合并为一幅;也就是说,我希望生成一幅具有shading angle=45shading angle=135shading angle=225和效果的图像,shading angle=315但该命令似乎\shade一次只能处理一个阴影角度。如果可能的话,我怎样才能将所有四个阴影角度效果合并为一幅tikzpicture

谢谢。

答案1

我不知道您想象的结果应该是什么样的!?一种方法是混合几种色调。混合模式有很多种 - 请参阅手册第 357-359 页。

\documentclass[tikz, border=1cm]{standalone}
\begin{document}
\begin{tikzpicture}
\node[opacity=0.5, inner sep=0pt] (A) at (0,0) {\includegraphics[scale=0.5]{example-image}};
\begin{scope}[blend mode=lighten]
\shade [left color=blue, right color=white, shading angle=45 , opacity=0.5] (A.south west) rectangle (A.north east);
\shade [left color=blue, right color=white, shading angle=135, opacity=0.5] (A.south west) rectangle (A.north east);
\shade [left color=blue, right color=white, shading angle=225, opacity=0.5] (A.south west) rectangle (A.north east);
\shade [left color=blue, right color=white, shading angle=315, opacity=0.5] (A.south west) rectangle (A.north east);
\end{scope}
\end{tikzpicture}
\begin{tikzpicture}
\node[opacity=0.5, inner sep=0pt] (A) at (0,0) {\includegraphics[scale=0.5]{example-image}};
\shade [inner color=blue, outer color=white, shading angle=45 , opacity=0.5] (A.south west) rectangle (A.north east);
\end{tikzpicture}
\end{document}

两张阴影图像

\documentclass[tikz, border=1cm]{standalone}
\begin{document}
\begin{tikzpicture}
\node[opacity=0.5, inner sep=0pt] (A) at (0,0) {\includegraphics[scale=0.5]{example-image}};
\shade [left color=blue, right color=white, shading angle=45 , opacity=0.5] (A.center) rectangle (A.south east);
\shade [left color=blue, right color=white, shading angle=135, opacity=0.5] (A.center) rectangle (A.north east);
\shade [left color=blue, right color=white, shading angle=225, opacity=0.5] (A.center) rectangle (A.north west);
\shade [left color=blue, right color=white, shading angle=315, opacity=0.5] (A.center) rectangle (A.south west);
\end{tikzpicture}
\end{document}

阴影图像

您还可以声明自己的功能阴影。

相关内容