[Tex/LaTex] Tikz node form as open half circle

tikz-pgf

A typical form for a node in TikZ is a circle around the text of the node. The shapes packages provides lot of other forms. What I couldn't find is an open half circle (or ellipse) under the node. Any ideas or hints on that?
Cheers
Renger

Best Answer

This is mainly inspired from: Creating node shapes

However it is just oriented in one direction here. I'm sure one can improve it to make it easily rotatable.

\documentclass{article}
\usepackage{tikz}

\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}
  % can add more anchors if necessary

  \inheritbackgroundpath[from=circle]

  \beforebackgroundpath{
    % get and set options
    \pgfkeys{/tikz/arc style/.get=\tmp}
    \expandafter\tikzset\expandafter{\tmp}
    \tikz@options

    % get radius length and center coordinates
    \radius \pgf@xa=\pgf@x
    \centerpoint \pgf@xb=\pgf@x \pgf@yb=\pgf@y

    % draw arc
    \advance\pgf@yb by \pgf@xa
    \pgfpathmoveto{\pgfpoint{\pgf@xb}{\pgf@yb}}
    \pgfpatharc{90}{-90}{\pgf@xa}
    % change the last line to the following line if you want the half circle rotated in the other direction
    % \pgfpatharc{90}{270}{\pgf@xa}

    \pgfusepath{draw}
  }
}
\makeatother

\begin{document}
\begin{tikzpicture}
  \node[
    half circle,
    fill=red!10,  % can fill the circle if needed
    minimum width=2cm,
    arc style={red,thick}
    ] (c) {my half circle};

\end{tikzpicture}
\end{document}

output