How do I make partially shaded nodes with tikz without hardcoding coordinates?
You can load backgrounds
library and use the node anchors like a.225
. The radius should be half of minimum size
. Also, use \fill
instead of \filldraw
.
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{backgrounds}
\begin{document}
\begin{tikzpicture}[mynode/.style={circle,draw=black,minimum size=10mm}]
\node (a) at (0,0) [mynode] {\Large $x$};
\begin{scope}[on background layer]
\fill[fill=gray!25] (a.225) arc [start angle=225, end angle=405, radius=5mm];
\end{scope}
\end{tikzpicture}
\end{document}