如何在 tikz 中绘制半阴影节点

如何在 tikz 中绘制半阴影节点

在此处输入图片描述

我想要绘制上面的图形,我有下面的初步代码,我该如何编辑下面的代码以实现半阴影节点的效果?

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes}
\usetikzlibrary{fit,positioning,automata,calc}
\begin{document}
\begin{tikzpicture} 
\tikzstyle{main}=[circle, minimum size = 10mm, thick, draw =black!80, node distance = 16mm]
\node[main] (pzd) [label=below:$y$] { }; 
\end{tikzpicture}
\end{document}

答案1

请参阅我对重复问题的回答:https://tex.stackexchange.com/a/551380/201158

\documentclass[tikz, border=1cm]{standalone}
\usetikzlibrary{calc}
\makeatletter
\tikzset{
  prefix after node/.style={
    prefix after command={\pgfextra{#1}}
  },
  /semifill/ang/.store in=\semi@ang,
  /semifill/ang=0,
  semifill/.style={
    circle, draw,
    prefix after node={
      \typeout{aaa \semi@ang}
      \let\nodename\tikz@last@fig@name
      \fill[/semifill/.cd, /semifill/.search also={/tikz}, #1]
        let \p1 = (\nodename.north), \p2 = (\nodename.center) in
        let \n1 = {\y1 - \y2} in
        (\nodename.\semi@ang) arc [radius=\n1, start angle=\semi@ang, delta angle=180];
    },
  }
}
\makeatother

\begin{document}
\begin{tikzpicture}
  \node[semifill={gray,ang=60}] {$y$};
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

正如 @feraheza 指出的那样,可以使用背景库,并添加

\begin{scope}[on background layer]
\fill[fill=gray!25] (y.225) arc [start angle=225, end angle=405, radius=5mm];
\end{scope} 

位于相关定义节点下方。

相关内容