[Tex/LaTex] Transparent node with opaque text

tikz-pgf

Is there a simple way to create a transparent node with opaque text? Preferably without having to use a postaction or redraw the node.

In the example below I'd like to achieve the effect of the first three nodes, without redrawing the second node to create the opaque text:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
    % desired effect:
    \node [fill=red,circle,minimum size=6mm,inner sep=0mm] {};
    \node [right,fill=green,opacity=.2] {Node};
    \node [right] {Node};

    % undesired effect:
    \node at(2,0) [fill=red,circle,minimum size=6mm,inner sep=0mm] {};
    \node at(2,0) [right,fill=green,opacity=.2] {Node};
\end{tikzpicture}
\end{document}

example

Best Answer

After setting the opacity, you have to reset the text opacity=1 to get opaque text. The opacity key is a shorthand for setting the draw opacity and the fill opacity at the same time, and the fill opacity in turn automatically applies to the text opacity.

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
    % undesired effect:
    \node at(2,0) [fill=red,circle,minimum size=6mm,inner sep=0mm] {};
    \node at(2,0) [right,fill=green,opacity=.2,text opacity=1] {Node};
\end{tikzpicture}
\end{document}