使用陰影設定節點的不透明度

使用陰影設定節點的不透明度

如何opacity=0.2在帶有陰影的節點中正確地將不透明度設為半透明(例如 )?似乎用“天真的”方法,陰影通過半透明填充顯示出來,這在某種程度上是有道理的。

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shadows.blur}

\begin{document}
    \begin{figure}
        \begin{tikzpicture}
            \node [
                draw,
                fill=white,
                circle,
                blur shadow={
                    shadow blur steps=5
                },
                minimum size=1cm,
            ] at (0,0) {X};
            \node [
                draw,
                fill=white,
                circle,
                blur shadow={
                    shadow blur steps=5
                },
                minimum size=1cm,
                opacity=0.2,
            ] at (2,0) {X};
        \end{tikzpicture}
    \end{figure}
\end{document}

在此輸入影像描述

如何獲得左側節點的半透明副本?

編輯:

我已經嘗試過設置draw opacity,而text opacity不僅僅是設置opacity,結果要好一些

在此輸入影像描述

但看起來陰影現在完全不透明了(因為fill我猜它是一個 ),所以它仍然不是 100% 我想要的。

答案1

也許 atransparency group就是您正在尋找的:

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{shadows.blur}

\begin{document}
    \begin{tikzpicture}
        \draw[cyan] (-1,-1) grid (3,1);
        \node [
            draw,
            fill=white,
            circle,
            blur shadow={
                shadow blur steps=5
            },
            minimum size=1cm,
        ] at (0,0) {X};
        \begin{scope}[transparency group, opacity=0.2]
        \node [
            draw,
            fill=white,
            circle,
            blur shadow={
                shadow blur steps=5
            },
            minimum size=1cm,
        ] at (2,0) {X};
        \end{scope}
    \end{tikzpicture}
\end{document}

在此輸入影像描述

答案2

我認為這已經是正確的不透明性了。不確定您的預期結果是什麼。這是做什麼用的?

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shadows.blur}

\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\draw [help lines,step=0.5cm] (-2,-2) grid (2,2);
\node [
font=\huge,
circle,
line width=3pt,
draw,
draw opacity=0.4,
fill=white,
fill opacity=0.7,
text opacity=0.4,
blur shadow={
shadow blur steps=5,
shadow blur radius=1.5ex,
},
minimum size=2cm,
] at (0,0) {test};
\end{tikzpicture}
\end{figure}
\end{document}

在此輸入影像描述

相關內容