我这里有三个球。中间的球不透明。我该如何控制该球的透明度?
\documentclass[11pt, margin=15mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc,fadings,decorations.pathreplacing}
\begin{document}
\begin{tikzpicture}
\tikzfading[name=fade inside,
inner color=transparent!50,
outer color=transparent!50]
\pgfdeclareradialshading{ballshading}{\pgfpoint{-10bp}{10bp}}
{color(0bp)=(orange!40!white);
color(9bp)=(orange!75!white);
color(18bp)=(orange!70!white);
color(25bp)=(orange!50!white);
color(50bp)=(orange)}
\shade[ball color=orange,path fading=fade inside] (3,7) circle (1);
\begin{scope}
\pgfpathcircle{\pgfpoint{3cm}{5cm}}{2cm}
\pgfshadepath{ballshading}{20}
\pgfusepath{}
\end{scope}
\shade[ball color=orange,path fading=fade inside] (3,2) circle (2.5);
\end{tikzpicture}
\end{document}
答案1
如果我正确理解了您的问题,那么透明度可以通过 opacity=.5 选项来管理。
\documentclass[11pt, margin=15mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc,fadings,decorations.pathreplacing}
\begin{document}
\begin{tikzpicture}
\tikzfading[name=fade inside,
inner color=transparent!50,
outer color=transparent!50]
\pgfdeclareradialshading{ballshading}{\pgfpoint{-10bp}{10bp}}
{color(0bp)=(orange!40!white);
color(9bp)=(orange!75!white);
color(18bp)=(orange!70!white);
color(25bp)=(orange!50!white);
color(50bp)=(orange)}
\shade[ball color=orange,path fading=fade inside,opacity=.5] (3,7) circle (1);
\begin{scope}[opacity=.5]
\pgfpathcircle{\pgfpoint{3cm}{5cm}}{2cm}
\pgfshadepath{ballshading}{20}
\pgfusepath{}
\end{scope}
\shade[ball color=orange,path fading=fade inside] (3,2) circle (2.5);
\end{tikzpicture}
\end{document}