Some time ago I wanted to create a half-circle node and I used the solution below. However, this solution has one drawback that if you fill the node, the whole circle is filled, not only a half. Is it possible to make sure that only half of the node that is drawn is filled?
MWE:
\documentclass{minimal}
\usepackage{tikz}
\begin{document}
\makeatletter
\tikzset{arc style/.initial={}}
\pgfdeclareshape{half circle}{
\inheritsavedanchors[from=circle]
\inheritanchorborder[from=circle]
\inheritanchor[from=circle]{center}
\inheritanchor[from=circle]{south}
\inheritanchor[from=circle]{west}
\inheritanchor[from=circle]{north}
\inheritanchor[from=circle]{east}
\inheritbackgroundpath[from=circle]
\beforebackgroundpath{
\pgfkeys{/tikz/arc style/.get=\tmp}
\expandafter\tikzset\expandafter{\tmp}
\tikz@options
\radius \pgf@xa=\pgf@x
\centerpoint \pgf@xb=\pgf@x \pgf@yb=\pgf@y
\advance\pgf@xb by \pgf@xa
\pgfpathmoveto{\pgfpoint{\pgf@xb}{\pgf@yb}}
\pgfpatharc{0}{-180}{\pgf@xa}
\pgfusepath{draw}
}
}
\makeatother
\begin{tikzpicture}
\fill[fill=black!10] (0,0) rectangle (6,4);
\node[half circle,inner sep=9pt] (a) at (2,2) {};
\node[half circle,inner sep=9pt,fill=white] (b) at (4,2) {};
\end{tikzpicture}
\end{document}
semicircle
shape in theshapes.geometric
library. (Which doesn't answer your question, but might be of interest.)shape border rotate=180
center
, you might be afteranchor=north
, which is the center of the full circle.