[latex]PGF and Tikz 设置填充透明效果(Transparency):
可以通过设置:
/tikz/fill opacity=<value>
%设置填充透明度为:fill opacity=0.5
\begin{tikzpicture}[thick,fill opacity=0.5]
\filldraw[fill=red] (0:1cm) circle (12mm);
\filldraw[fill=green] (120:1cm) circle (12mm);
\filldraw[fill=blue] (-120:1cm) circle (12mm);
\end{tikzpicture}
效果如下:
对于node中的文字,一样可以设置填充透明度:
%设置node中文字的填充透明度为:fill opacity=0.5
\begin{tikzpicture}
\fill[red] (0,0) rectangle (3,2);
\node at (0,0) {\huge A};
\node[fill opacity=0.5] at (3,2) {\huge B};
\end{tikzpicture}
效果如下:
还有几个选项可以设置透明度%设置draw opacity,fill opacity,text opacity,
其中text opacity会覆盖文本中fill opacity效果,即对文本同时设置fill opacity和text opacity,
那么至于text opacity起作用:
%设置draw opacity,fill opacity,text opacity,
\begin{tikzpicture}[every node/.style={fill,draw}]
\draw[line width=2mm,blue!50,line cap=round] (0,0) grid (3,2);
\node[opacity=0.5] at (1.5,2) {Upper node};
\node[draw opacity=0.8,fill opacity=0.2,text opacity=1]
at (1.5,0) {Lower node};
\end{tikzpicture}
效果如下:
如果设置fill opacity的的区域出现同色叠加,那么效果如下:
%设置fill opacity的叠加效果
\begin{tikzpicture}[fill opacity=0.5]
\fill[red] (0,0) circle (1);
\fill[red] (1,0) circle (1);
\end{tikzpicture}
图形: