% Copyright 2018 by Till Tantau and Mark Wibrow
%
% This file may be distributed and/or modified
%
% 1. under the LaTeX Project Public License and/or
% 2. under the GNU Public License.
%
% See the file doc/generic/pgf/licenses/LICENSE for more details.

\ProvidesFileRCS{pgflibraryshapes.multipart.code.tex}

\newbox\pgfnodepartlowerbox

%
% A circle that is split in the middle into an upper and a lower part.
%
% This node consists of two parts: The upper (main) part is shown in
% the upper half of the circle. The second part is the (optional)
% lower part.
%
% Parts: text, lower

\pgfdeclareshape{circle split}
{%
  %
  % Node parts
  %
  \nodeparts{text,lower}%

  %
  % Anchors
  %
  \savedanchor\centerpoint{%
    \pgf@x=.5\wd\pgfnodeparttextbox%
    \pgfmathsetlength{\pgf@y}{\pgfkeysvalueof{/pgf/inner ysep}}%
    \pgf@y=-\pgf@y%
    \advance\pgf@y by-\dp\pgfnodeparttextbox%
    \advance\pgf@y by-.5\pgflinewidth%
  }%
  \savedanchor\loweranchor{%
    \pgf@x=-.5\wd\pgfnodepartlowerbox%
    \advance\pgf@x by.5\wd\pgfnodeparttextbox%
    \pgfmathsetlength{\pgf@y}{\pgfkeysvalueof{/pgf/inner ysep}}%
    \pgf@y=-2\pgf@y%
    \advance\pgf@y by-\ht\pgfnodepartlowerbox%
    \advance\pgf@y by-.5\pgflinewidth%
    \advance\pgf@y by-\dp\pgfnodeparttextbox%
    \advance\pgf@y by-.5\pgflinewidth%
  }%

  \saveddimen\radius{%
    %
    % Calculate ``height radius''
    %
    %\pgf@ya=.5\ht\pgfnodeparttextbox%
%    \advance\pgf@ya by.5\dp\pgfnodeparttextbox%
%    \advance\pgf@ya by.5\ht\pgfnodepartlowerbox%
%    \advance\pgf@ya by.5\dp\pgfnodepartlowerbox%
%    \advance\pgf@ya by.5\pgflinewidth%
        %
        % MW: Suggested correction for above calculation:    Use the tallest box * 2.
        %
        \pgf@ya=.5\ht\pgfnodeparttextbox%
        \advance\pgf@ya by.5\dp\pgfnodeparttextbox%
        \pgf@yb=.5\ht\pgfnodepartlowerbox%
        \advance\pgf@yb by.5\dp\pgfnodepartlowerbox%
        \ifdim\pgf@ya>\pgf@yb\relax%
            \pgf@ya2.0\pgf@ya\relax%
        \else%
            \pgf@ya2.0\pgf@yb\relax%
        \fi%
        \advance\pgf@ya by.5\pgflinewidth%
    \pgfmathsetlength\pgf@yb{\pgfkeysvalueof{/pgf/inner ysep}}%
    \advance\pgf@ya by2\pgf@yb%
    %
    % Calculate ``width radius''
    %
    \pgf@xa=.5\wd\pgfnodeparttextbox%
    \ifdim\pgf@xa<.5\wd\pgfnodepartlowerbox%
      \pgf@xa=.5\wd\pgfnodepartlowerbox%
    \fi%
    \pgfmathsetlength\pgf@xb{\pgfkeysvalueof{/pgf/inner xsep}}%
    \advance\pgf@xa by\pgf@xb%
    %
    % Calculate length of radius vector:
    %
    \pgf@process{\pgfpointnormalised{\pgfqpoint{\pgf@xa}{\pgf@ya}}}%
    \ifdim\pgf@x>\pgf@y%
        \c@pgf@counta=\pgf@x%
        \ifnum\c@pgf@counta=0\relax%
        \else%
          \divide\c@pgf@counta by 255\relax%
          \pgf@xa=16\pgf@xa\relax%
          \divide\pgf@xa by\c@pgf@counta%
          \pgf@xa=16\pgf@xa\relax%
        \fi%
      \else%
        \c@pgf@counta=\pgf@y%
        \ifnum\c@pgf@counta=0\relax%
        \else%
          \divide\c@pgf@counta by 255\relax%
          \pgf@ya=16\pgf@ya\relax%
          \divide\pgf@ya by\c@pgf@counta%
          \pgf@xa=16\pgf@ya\relax%
        \fi%
    \fi%
    \pgf@x=\pgf@xa%
    %
    % If necessary, adjust radius so that the size requirements are
    % met:
    %
    \pgfmathsetlength{\pgf@xb}{\pgfkeysvalueof{/pgf/minimum width}}%
    \pgfmathsetlength{\pgf@yb}{\pgfkeysvalueof{/pgf/minimum height}}%
    \ifdim\pgf@x<.5\pgf@xb%
        \pgf@x=.5\pgf@xb%
    \fi%
    \ifdim\pgf@x<.5\pgf@yb%
        \pgf@x=.5\pgf@yb%
    \fi%
    %
    % Now, add larger of outer separations.
    %
    \pgfmathsetlength{\pgf@xb}{\pgfkeysvalueof{/pgf/outer xsep}}%
    \pgfmathsetlength{\pgf@yb}{\pgfkeysvalueof{/pgf/outer ysep}}%
    \ifdim\pgf@xb<\pgf@yb%
      \advance\pgf@x by\pgf@yb%
    \else%
      \advance\pgf@x by\pgf@xb%
    \fi%
  }%

  %
  % Anchors
  %
  \inheritanchorborder[from=circle]%
  \inheritanchor[from=circle]{north}%
  \inheritanchor[from=circle]{north west}%
  \inheritanchor[from=circle]{north east}%
  \inheritanchor[from=circle]{center}%
  \inheritanchor[from=circle]{west}%
  \inheritanchor[from=circle]{east}%
  \inheritanchor[from=circle]{mid}%
  \inheritanchor[from=circle]{mid west}%
  \inheritanchor[from=circle]{mid east}%
  \inheritanchor[from=circle]{base}%
  \inheritanchor[from=circle]{base west}%
  \inheritanchor[from=circle]{base east}%
  \inheritanchor[from=circle]{south}%
  \inheritanchor[from=circle]{south west}%
  \inheritanchor[from=circle]{south east}%
  \anchor{lower}{\loweranchor}%

  %
  % Background path
  %
  \inheritbackgroundpath[from=circle]%
  \beforebackgroundpath{
    \pgfutil@tempdima=\radius%
    \pgfmathsetlength{\pgf@xb}{\pgfkeysvalueof{/pgf/outer xsep}}%
    \pgfmathsetlength{\pgf@yb}{\pgfkeysvalueof{/pgf/outer ysep}}%
    \ifdim\pgf@xb<\pgf@yb%
      \advance\pgfutil@tempdima by-\pgf@yb%
    \else%
      \advance\pgfutil@tempdima by-\pgf@xb%
    \fi%
    \advance\pgfutil@tempdima by-.5\pgflinewidth%
    \pgfsetshortenstart{0pt}%
    \pgfsetshortenend{0pt}%
    \pgfsetarrows{-}%
    \pgfpathmoveto{\pgfpointadd{\centerpoint}{\pgfqpoint{-1\pgfutil@tempdima}{0pt}}}%
    \pgfpathlineto{\pgfpointadd{\centerpoint}{\pgfqpoint{\pgfutil@tempdima}{0pt}}}%
    \pgfusepath{stroke}%
  }%
}%


%
% A circle that is split diagonally into an upper and a lower part.
%
% Parts: text, lower

\pgfdeclareshape{circle solidus}{%
  % Node parts
  \nodeparts{text,lower}%
  % Anchors
  % solidus slants at 45 degrees
  % text placement minimizes the required radius,
  % this is achieved placing the "outer" corner
  % of each box in the line orthogonal to the
  % solidus which passes through circle center
  \savedanchor\centerpoint{%
    \pgf@x=0.5\wd\pgfnodeparttextbox%
    \advance\pgf@x by0.5\dp\pgfnodeparttextbox%
    \advance\pgf@x by0.5\ht\pgfnodeparttextbox%
    \pgf@y=-\pgf@x%
    \advance\pgf@y by\ht\pgfnodeparttextbox%
    \advance\pgf@x by0.3536\pgflinewidth%
    \advance\pgf@y by-0.3536\pgflinewidth%
    \pgfmathsetlength{\pgf@xa}{\pgfkeysvalueof{/pgf/inner xsep}}%
    \advance\pgf@x by\pgf@xa%
    \pgfmathsetlength{\pgf@ya}{\pgfkeysvalueof{/pgf/inner ysep}}%
    \advance\pgf@y by-\pgf@ya%
  }%
  \savedanchor\loweranchor{%
    \pgf@x=0.5\wd\pgfnodeparttextbox%
    \advance\pgf@x by0.5\dp\pgfnodeparttextbox%
    \advance\pgf@x by0.5\ht\pgfnodeparttextbox%
    \pgf@y=-\pgf@x%
    \advance\pgf@y by\ht\pgfnodeparttextbox%
    \advance\pgf@x by0.5\ht\pgfnodepartlowerbox%
    \advance\pgf@x by0.5\dp\pgfnodepartlowerbox%
    \advance\pgf@x by-0.5\wd\pgfnodepartlowerbox%
    \advance\pgf@y by-0.5\ht\pgfnodepartlowerbox%
    \advance\pgf@y by0.5\dp\pgfnodepartlowerbox%
    \advance\pgf@y by-0.5\wd\pgfnodepartlowerbox%
    \advance\pgf@x by0.7071\pgflinewidth%
    \advance\pgf@y by-0.7071\pgflinewidth%
    \pgfmathsetlength{\pgf@xa}{\pgfkeysvalueof{/pgf/inner xsep}}%
    \advance\pgf@x by2\pgf@xa%
    \pgfmathsetlength{\pgf@ya}{\pgfkeysvalueof{/pgf/inner ysep}}%
    \advance\pgf@y by-2\pgf@ya%
  }%
  \saveddimen\radius{%
    % "top" radius
    \pgf@x=\ht\pgfnodeparttextbox%
    \advance\pgf@x by\dp\pgfnodeparttextbox%
    \advance\pgf@x by\wd\pgfnodeparttextbox%
    % "bottom" radius
    \pgf@y=\ht\pgfnodepartlowerbox%
    \advance\pgf@y by\dp\pgfnodepartlowerbox%
    \advance\pgf@y by\wd\pgfnodepartlowerbox%
    % use the larger
    \ifdim\pgf@x<\pgf@y%
      \pgf@x=\pgf@y%
    \fi%
    \pgf@x=0.7071\pgf@x%
    % add spacings
    \advance\pgf@x by0.5\pgflinewidth%
    \pgfmathsetlength{\pgf@xa}{\pgfkeysvalueof{/pgf/inner xsep}}%
    \pgfmathsetlength{\pgf@ya}{\pgfkeysvalueof{/pgf/inner ysep}}%
    \pgfmathaddtolength{\pgf@x}{veclen(2\pgf@xa,2\pgf@ya)}%
    % If necessary, adjust radius so that the size requirements are
    % met:
    \pgfmathsetlength{\pgf@xa}{\pgfkeysvalueof{/pgf/minimum width}}%
    \pgfmathsetlength{\pgf@ya}{\pgfkeysvalueof{/pgf/minimum height}}%
    \ifdim\pgf@x<.5\pgf@xa%
      \pgf@x=.5\pgf@xa%
    \fi%
    \ifdim\pgf@x<.5\pgf@ya%
      \pgf@x=.5\pgf@ya%
    \fi%
    % Now, add larger of outer separations.
    \pgfmathsetlength{\pgf@xa}{\pgfkeysvalueof{/pgf/outer xsep}}%
    \pgfmathsetlength{\pgf@ya}{\pgfkeysvalueof{/pgf/outer ysep}}%
    \ifdim\pgf@xa<\pgf@ya%
      \advance\pgf@x by\pgf@ya%
    \else%
      \advance\pgf@x by\pgf@xa%
    \fi%
  }%
  % Anchors
  \inheritanchorborder[from=circle]%
  \inheritanchor[from=circle]{north}%
  \inheritanchor[from=circle]{north west}%
  \inheritanchor[from=circle]{north east}%
  \inheritanchor[from=circle]{center}%
  \inheritanchor[from=circle]{west}%
  \inheritanchor[from=circle]{east}%
  \inheritanchor[from=circle]{mid}%
  \inheritanchor[from=circle]{mid west}%
  \inheritanchor[from=circle]{mid east}%
  \inheritanchor[from=circle]{base}%
  \inheritanchor[from=circle]{base west}%
  \inheritanchor[from=circle]{base east}%
  \inheritanchor[from=circle]{south}%
  \inheritanchor[from=circle]{south west}%
  \inheritanchor[from=circle]{south east}%
  \anchor{lower}{\loweranchor}%
  % Background path
  \inheritbackgroundpath[from=circle]%
  \beforebackgroundpath{%
    \pgfutil@tempdima=\radius%
    \pgfmathsetlength{\pgf@xa}{\pgfkeysvalueof{/pgf/outer xsep}}%
    \pgfmathsetlength{\pgf@ya}{\pgfkeysvalueof{/pgf/outer ysep}}%
    \ifdim\pgf@xa<\pgf@ya%
      \advance\pgfutil@tempdima by-\pgf@ya%
    \else%
      \advance\pgfutil@tempdima by-\pgf@xa%
    \fi%
    \advance\pgfutil@tempdima by-.5\pgflinewidth%
    \pgfsetshortenstart{0pt}%
    \pgfsetshortenend{0pt}%
    \pgfsetarrows{-}%
    % solidus slants at 45 degrees and its length is
    % the golden section of the diameter
    \pgfpathmoveto{\pgfpointadd{\centerpoint}{\pgfqpoint{-0.437\pgfutil@tempdima}{-0.437\pgfutil@tempdima}}}%
    \pgfpathlineto{\pgfpointadd{\centerpoint}{\pgfqpoint{0.437\pgfutil@tempdima}{0.437\pgfutil@tempdima}}}%
    \pgfusepath{stroke}%
  }%
}%


%
% A diamond that is split in the middle into an upper and a lower part.
%
% This node consists of two parts: the upper (text) part is shown in the
% upper half of the diamond. The second part is the (optional) lower part.
%
% Parts: text, lower

\pgfdeclareshape{diamond split}
{%
  %
  % Node parts
  %
  \nodeparts{text,lower}%
  %
  % Anchors
  %
  \savedanchor\outernortheast{%
    %
    % Calculate width and height of the text rectangle
    %
    \pgf@xa=\wd\pgfnodeparttextbox
    \pgfmathsetlength\pgf@xc{\pgfkeysvalueof{/pgf/inner xsep}}%
    \advance\pgf@xa by 0\pgf@xc
    \pgf@ya=\ht\pgfnodeparttextbox
    \advance\pgf@ya by \dp\pgfnodeparttextbox
    \pgfmathsetlength\pgf@yc{\pgfkeysvalueof{/pgf/inner ysep}}%
    \advance\pgf@ya by 0\pgf@yc
    %
    % (xa,ya) is now the size of the *text* part.
    %
    % Calculate width and height of the lower rectangle
    %
    \pgf@xb=\wd\pgfnodepartlowerbox
    \advance\pgf@xb by \pgf@xc
    \pgf@yb=\ht\pgfnodepartlowerbox
    \advance\pgf@yb by \dp\pgfnodepartlowerbox
    \advance\pgf@yb by \pgf@yc
    %
    % (xb,yb) is now the size of the *lower* part.
    % We keep the maximum value of xa vs. xb and ya vs. yb
    %
    \pgfmathmax@{{\pgfmath@tonumber{\pgf@xa}}{\pgfmath@tonumber{\pgf@xb}}}%
    \pgf@xa=\pgfmathresult pt
    \pgfmathmax@{{\pgfmath@tonumber{\pgf@ya}}{\pgfmath@tonumber{\pgf@yb}}}%
    \pgf@ya=\pgfmathresult pt
    %
    % Calculate width and height of diamond
    %
    \pgf@x=\pgf@xa
    \advance\pgf@x by \pgfshapeaspect\pgf@ya
    \pgf@y=\pgfshapeaspectinverse\pgf@xa
    \advance\pgf@y by \pgf@ya
    %
    % Check against minimum height/width
    %
    \pgfmathsetlength\pgf@xb{\pgfkeysvalueof{/pgf/minimum width}}%
    \pgf@xb=.5\pgf@xb
    \ifdim\pgf@x<\pgf@xb
      % yes, too small. Enlarge...
      \pgf@x=\pgf@xb
    \fi
    \pgfmathsetlength\pgf@yb{\pgfkeysvalueof{/pgf/minimum height}}%
    \pgf@yb=.5\pgf@yb
    \ifdim\pgf@y<\pgf@yb
      % yes, too small. Enlarge...
      \pgf@y=\pgf@yb
    \fi
    %
    % Add outer border
    %
    \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/outer xsep}}%
    \advance\pgf@x by\pgf@xa
    \pgfmathsetlength\pgf@ya{\pgfkeysvalueof{/pgf/outer ysep}}%
    \advance\pgf@y by\pgf@ya
  }%
  \savedanchor\text{%
    \pgfmathsetlength{\pgf@yb}{\pgfkeysvalueof{/pgf/outer ysep}}%
    \pgf@x=-0.5\wd\pgfnodeparttextbox
    \pgf@y=0.25\ht\pgfnodeparttextbox
    \advance\pgf@y by 0.25\dp\pgfnodeparttextbox
    \advance\pgf@y by \pgf@yb
  }%
  \savedanchor\loweranchor{%
    \pgfmathsetlength{\pgf@yb}{\pgfkeysvalueof{/pgf/outer ysep}}%
    \pgf@x=-0.5\wd\pgfnodepartlowerbox
    \pgf@y=-1.25\ht\pgfnodepartlowerbox
    \advance\pgf@y by -1.25\dp\pgfnodepartlowerbox
    \advance\pgf@y by -\pgf@yb
  }
  \inheritanchor[from=diamond]{center}
  \inheritanchor[from=diamond]{mid}
  \inheritanchor[from=diamond]{base}
  \inheritanchor[from=diamond]{north}
  \inheritanchor[from=diamond]{south}
  \inheritanchor[from=diamond]{east}
  \inheritanchor[from=diamond]{west}
  \inheritanchor[from=diamond]{north west}
  \inheritanchor[from=diamond]{north east}
  \inheritanchor[from=diamond]{south west}
  \inheritanchor[from=diamond]{south east}
  \inheritanchorborder[from=diamond]
  \inheritbackgroundpath[from=diamond]
  \anchor{text}{\text}%
  \anchor{lower}{\loweranchor}%
  \behindbackgroundpath{%
    \pgfmathsetlength{\pgf@xb}{\pgfkeysvalueof{/pgf/outer xsep}}%
    \pgfpathmoveto{\pgf@process{\outernortheast}\pgf@x=-\pgf@x\pgf@y=0pt\relax
      \advance\pgf@x by \pgf@xb}%
    \pgfpathlineto{\pgf@process{\outernortheast}\pgf@y=0pt\relax
      \advance\pgf@x by -\pgf@xb}%
  }%
}%


\def\pgf@lib@sh@newbox{\csname newbox\endcsname}% Get round outer.

\def\pgf@lib@sh@toalpha#1{%
    \ifcase#1\relax%
        \or one\or two\or three\or four\or five\or six\or seven\or eight\or nine\or ten%
        \or eleven\or twelve\or thirteen\or fourteen\or fifteen%
        \or sixteen\or seventeen\or eighteen\or nineteen\or twenty%
    \else%
        twenty%
    \fi%
}%


\def\pgf@lib@sh@getalpha#1#2{\expandafter\edef\expandafter#1\expandafter{\pgf@lib@sh@toalpha{#2}}}%

\newbox\pgfnodeparttwobox
\newbox\pgfnodepartthreebox
\newbox\pgfnodepartfourbox

\let\pgfnodepartonebox=\pgfnodeparttextbox
\let\pgfnodepartsecondbox=\pgfnodeparttwobox
\let\pgfnodepartthirdbox=\pgfnodepartthreebox
\let\pgfnodepartfourthbox=\pgfnodepartfourbox

\def\pgf@lib@sh@allocateboxes#1{%
    \c@pgf@counta=#1\relax%
    \pgfmathloop%
        \ifnum\c@pgf@counta>4\relax%
        \pgfutil@ifundefined{pgfnodepart\pgf@lib@sh@toalpha{\c@pgf@counta}box}%
        {%
            \expandafter\pgf@lib@sh@newbox\csname pgfnodepart\pgf@lib@sh@toalpha{\c@pgf@counta}box\endcsname%
        }%
        {}%
        \advance\c@pgf@counta by-1\relax%
    \repeatpgfmathloop%
}%

\def\pgf@lib@sh@rs@lefttext{left}%
\def\pgf@lib@sh@rs@righttext{right}%
\def\pgf@lib@sh@rs@centertext{center}%
\def\pgf@lib@sh@rs@bottomtext{bottom}%
\def\pgf@lib@sh@rs@toptext{top}%
\def\pgf@lib@sh@rs@basetext{base}%
\def\pgf@lib@sh@rs@nonetext{none}%


\newif\ifpgfrectanglesplithorizontal
\newif\ifpgfrectanglesplitdrawsplits\pgfrectanglesplitdrawsplitstrue
\newif\ifpgfrectanglesplitignoreemptyparts
\newif\ifpgfrectanglesplitusecustomfill

\let\pgf@lib@sh@rs@every@emptypart=\pgfutil@empty
\let\pgf@lib@sh@rs@every@part=\pgfutil@empty
\def\pgf@lib@sh@rs@list@fill{none}%

\pgfkeys{/pgf/.cd,
    rectangle split parts/.initial=4,
    rectangle split part align/.initial=center,
    rectangle split horizontal/.is if=pgfrectanglesplithorizontal,
    rectangle split ignore empty parts/.is if=pgfrectanglesplitignoreemptyparts,
    rectangle split empty part width/.code={%
        \pgfmathsetlength\pgf@x{#1}
        \edef\pgf@lib@sh@rs@temp{\noexpand\vrule width\the\pgf@x height0ptdepth0pt\relax}%
        \def\pgf@lib@sh@rs@@temp{\def\pgf@lib@sh@rs@every@emptypart}%
        \expandafter\expandafter\expandafter\pgf@lib@sh@rs@@temp\expandafter\expandafter\expandafter{%
            \expandafter\pgf@lib@sh@rs@every@emptypart\pgf@lib@sh@rs@temp}%
    },%
    rectangle split empty part width=1ex,
    rectangle split empty part height/.code={%
        \pgfmathsetlength\pgf@x{#1}
        \edef\pgf@lib@sh@rs@temp{\noexpand\vrule width0ptheight\the\pgf@x depth0pt\relax}%
        \def\pgf@lib@sh@rs@@temp{\def\pgf@lib@sh@rs@every@emptypart}%
        \expandafter\expandafter\expandafter\pgf@lib@sh@rs@@temp\expandafter\expandafter\expandafter{%
            \expandafter\pgf@lib@sh@rs@every@emptypart\pgf@lib@sh@rs@temp}%
    },%
    rectangle split empty part height=1ex,
    rectangle split empty part depth/.code={%
        \pgfmathsetlength\pgf@x{#1}
        \edef\pgf@lib@sh@rs@temp{\noexpand\vrule width0ptheight0ptdepth\the\pgf@x\relax}%
        \def\pgf@lib@sh@rs@@temp{\def\pgf@lib@sh@rs@every@emptypart}%
        \expandafter\expandafter\expandafter\pgf@lib@sh@rs@@temp\expandafter\expandafter\expandafter{%
            \expandafter\pgf@lib@sh@rs@every@emptypart\pgf@lib@sh@rs@temp}%
    },%
    rectangle split empty part depth=0ex,
    rectangle split every empty part/.store in=\pgf@lib@sh@rs@every@emptypart,
    rectangle split part fill/.code=\def\pgf@lib@sh@rs@list@fill{#1}\pgfrectanglesplitusecustomfilltrue,
    rectangle split uses custom fill/.is if=pgfrectanglesplitusecustomfill,
    rectangle split draw splits/.is if=pgfrectanglesplitdrawsplits,
    rectangle split allocate boxes/.code=\pgf@lib@sh@allocateboxes{#1},
}%


\def\pgf@lib@sh@rs@process@list#1#2{%
    \c@pgf@counta=1\relax%
    \c@pgf@countb=#2\relax%
    \edef\pgf@lib@sh@rs@temp{#1}%
    \expandafter\pgf@lib@sh@rs@@process@list\pgf@lib@sh@rs@temp,\pgf@stop,
}%

\def\pgf@lib@sh@rs@@process@list{%
    \pgfutil@ifnextchar x{\pgf@lib@sh@rs@@@process@list}%
        {\pgf@lib@sh@rs@@@process@list}
}%

\def\pgf@lib@sh@rs@@@process@list#1,{%
    \ifx#1\pgf@stop%
        \let\pgf@next\pgf@lib@sh@rs@@@@process@list%
    \else%
        \pgf@lib@sh@getalpha\pgf@lib@sh@rs@number{\c@pgf@counta}%
        \def\pgf@lib@sh@rs@lastalign{#1}%
        \pgfutil@namedef{pgf@lib@sh@rs@\pgf@lib@sh@toalpha{\c@pgf@counta}@item}{#1}%
        \let\pgf@next\pgf@lib@sh@rs@@process@list%
        \advance\c@pgf@counta by1\relax%
    \fi%
    \pgf@next}%

\def\pgf@lib@sh@rs@@@@process@list{%
    \pgfmathloop%
        \ifnum\c@pgf@counta>\c@pgf@countb%
        \else%
            \expandafter\edef\csname pgf@lib@sh@rs@\pgf@lib@sh@toalpha{\c@pgf@counta}@item\endcsname%
                {\pgf@lib@sh@rs@lastalign}%
            \advance\c@pgf@counta by1\relax%
    \repeatpgfmathloop%
}%

\pgf@lib@sh@allocateboxes{20}%

\pgfdeclareshape{rectangle split}{%
    \savedmacro\rectanglesplitparameters{%
        \pgfmathsetcount\c@pgf@counta{\pgfkeysvalueof{/pgf/rectangle split parts}}%
        \edef\parts{\the\c@pgf@counta}%
        \addtosavedmacro\parts%
        %
        \pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/inner xsep}}%
        \edef\innerxsep{\the\pgf@x}%
        \pgfmathsetlength\pgf@y{\pgfkeysvalueof{/pgf/inner ysep}}%
        \edef\innerysep{\the\pgf@y}%
        %
        \pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/outer xsep}}%
        \edef\outerxsep{\the\pgf@x}%
        \pgfmathsetlength\pgf@y{\pgfkeysvalueof{/pgf/outer ysep}}%
        \edef\outerysep{\the\pgf@y}%
        \addtosavedmacro\outerxsep%
        \addtosavedmacro\outerysep%
        %
        \pgf@x=0pt\relax% Widest box.
        \pgf@y=0pt\relax% Tallest box.
        %
        \pgfutil@tempdima=0pt\relax% Maximum box height.
        \pgfutil@tempdimb=0pt\relax% Maximum box depth.
        %
        % Get the dimensions of the boxes...
        %
        \pgfmathloop%
            \ifnum\pgfmathcounter>\parts%
            \else%
                \pgf@lib@sh@getalpha\pgf@lib@sh@rs@number{\pgfmathcounter}%
                %
                \expandafter\let\expandafter\pgf@lib@sh@box\expandafter=%
                    \csname pgfnodepart\pgf@lib@sh@rs@number box\endcsname%
                \pgf@xa=\wd\pgf@lib@sh@box%
                \pgf@ya=\ht\pgf@lib@sh@box%
                \pgf@yb=\dp\pgf@lib@sh@box%
                %
                % Test to see if the box is empty...
                %
                \expandafter\def\csname pgf@lib@sh@rs@empty@\pgf@lib@sh@rs@number\endcsname{\relax}%
                \ifdim\pgf@xa=0pt\relax%
                    \ifdim\pgf@ya=0pt\relax%
                        \ifdim\pgf@yb=0pt\relax%
                            %
                            % ...It is. So...
                            %
                            \ifpgfrectanglesplitignoreemptyparts%
                                %
                                % ...flag this if we are ignoring parts...
                                %
                                \expandafter\let\csname pgf@lib@sh@rs@empty@\pgf@lib@sh@rs@number\endcsname=\pgfutil@empty%
                            \else%
                                %
                                % ...otherwise insert the code for every empty part.
                                %
                                \setbox\pgf@lib@sh@box=\hbox{{\pgf@lib@sh@rs@every@emptypart}}%
                                \pgf@xa=\wd\pgf@lib@sh@box%
                                \pgf@ya=\ht\pgf@lib@sh@box%
                                \pgf@yb=\dp\pgf@lib@sh@box%
                            \fi%
                        \fi%
                    \fi%
                \fi%
                \expandafter\edef\csname pgf@lib@sh@rs@width@\pgf@lib@sh@rs@number\endcsname{\the\pgf@xa}%
                \expandafter\edef\csname pgf@lib@sh@rs@height@\pgf@lib@sh@rs@number\endcsname{\the\pgf@ya}%
                \expandafter\edef\csname pgf@lib@sh@rs@depth@\pgf@lib@sh@rs@number\endcsname{\the\pgf@yb}%
                \expandafter\addtosavedmacro\csname pgf@lib@sh@rs@empty@\pgf@lib@sh@rs@number\endcsname%
                %
                % ...saving the widest box...
                %
                \ifdim\pgf@xa>\pgf@x%
                    \pgf@x=\pgf@xa%
                \fi%
                %
                % ...the maximum height and depth...
                %
                \ifdim\pgf@ya>\pgfutil@tempdima%
                    \pgfutil@tempdima=\pgf@ya%
                \fi%
                \ifdim\pgf@yb>\pgfutil@tempdimb%
                    \pgfutil@tempdimb=\pgf@yb%
                \fi%
                %
                % ...and the tallest box.
                %
                \pgf@yc=\pgfutil@tempdima%
                \advance\pgf@yc by\pgfutil@tempdimb%
                \ifdim\pgf@yc>\pgf@y%
                    \pgf@y=\pgf@yc%
                \fi%
        \repeatpgfmathloop%
        %
        \edef\pgf@lib@sh@rs@max@width{\the\pgf@x}%
        \edef\pgf@lib@sh@rs@max@totalheight{\the\pgf@y}%
        %
        \pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/minimum width}}%
        \advance\pgf@x by-\innerxsep\relax%
        \advance\pgf@x by-\innerxsep\relax%
        \pgf@xa=\pgf@x%
        \advance\pgf@xa by-\pgf@lib@sh@rs@max@width\relax%
        \ifdim\pgf@xa>0pt\relax%
            \edef\pgf@lib@sh@rs@max@width{\the\pgf@x}%
        \fi%
        %
        \pgfmathsetlength\pgf@y{\pgfkeysvalueof{/pgf/minimum height}}%
        \advance\pgf@y by-\innerysep\relax%
        \advance\pgf@y by-\innerysep\relax%
        \pgf@ya=\pgf@y%
        \advance\pgf@ya by-\pgf@lib@sh@rs@max@totalheight\relax%
        \ifdim\pgf@ya>0pt\relax%
            \edef\pgf@lib@sh@rs@max@totalheight{\the\pgf@y}%
        \fi%
        %
        % Get the alignment of each node part box.
        %
        \pgf@lib@sh@rs@process@list{\pgfkeysvalueof{/pgf/rectangle split part align}}{\parts}%
        %
        % Are we splitting horizontally or vertically?
        %
        \ifpgfrectanglesplithorizontal%
            %
            % Calculate the origins of each node part box.
            %
            \pgf@x=0pt\relax%
            \pgfmathloop%
                \ifnum\pgfmathcounter>\parts%
                \else%
                    \pgf@lib@sh@getalpha\pgf@lib@sh@rs@number{\pgfmathcounter}%
                    %
                    \expandafter\let\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number\endcsname=\pgfutil@empty%
                    \expandafter\ifx\csname pgf@lib@sh@rs@empty@\pgf@lib@sh@rs@number\endcsname\pgfutil@empty%
                        \ifpgfrectanglesplitignoreemptyparts%
                            \expandafter\let\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number\endcsname=%
                                \pgf@lib@sh@rs@lastanchor%
                        \fi%
                    \fi%
                    %
                    % Adjust for alignment.
                    %
                    \expandafter\ifx\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number\endcsname\pgfutil@empty%
                        \expandafter\ifx\csname pgf@lib@sh@rs@\pgf@lib@sh@rs@number @item\endcsname%
                                \pgf@lib@sh@rs@bottomtext%
                            \pgf@y=\csname pgf@lib@sh@rs@depth@\pgf@lib@sh@rs@number\endcsname\relax%
                        \else%
                            \expandafter\ifx\csname pgf@lib@sh@rs@\pgf@lib@sh@rs@number @item\endcsname%
                                    \pgf@lib@sh@rs@toptext%
                                \pgf@y=-\csname pgf@lib@sh@rs@height@\pgf@lib@sh@rs@number\endcsname\relax%
                                \advance\pgf@y by\pgf@lib@sh@rs@max@totalheight\relax%
                            \else%
                                \expandafter\ifx\csname pgf@lib@sh@rs@\pgf@lib@sh@rs@number @item\endcsname%
                                        \pgf@lib@sh@rs@basetext%
                                    \pgf@y=\pgf@lib@sh@rs@max@totalheight\relax%
                                    \advance\pgf@y by-\pgfutil@tempdima%
                                    \advance\pgf@y by\pgfutil@tempdimb%
                                    \divide\pgf@y by2\relax%
                                \else%
                                    \pgf@y=\pgf@lib@sh@rs@max@totalheight\relax%
                                    \advance\pgf@y by-\csname pgf@lib@sh@rs@height@\pgf@lib@sh@rs@number\endcsname\relax%
                                    \advance\pgf@y by\csname pgf@lib@sh@rs@depth@\pgf@lib@sh@rs@number\endcsname\relax%
                                    \divide\pgf@y by2\relax%
                                \fi%
                            \fi%
                        \fi%
                        %
                        % Re-adjust as the first box is at the origin.
                        %
                        \ifnum\pgfmathcounter=1\relax%
                            \edef\pgf@lib@sh@rs@yoffset{\the\pgf@y}%
                            \pgf@y=0pt\relax%
                            \pgfextract@process\pgf@lib@sh@rs@anchor@one{}%
                            \addtosavedmacro\pgf@lib@sh@rs@anchor@one%
                            \let\pgf@lib@sh@rs@lastanchor=\pgf@lib@sh@rs@anchor@one%
                            \let\pgf@lib@sh@rs@lastnumber=\pgf@lib@sh@rs@number%
                        \else
                            \advance\pgf@y by-\pgf@lib@sh@rs@yoffset\relax%
                            \advance\pgf@x by\csname pgf@lib@sh@rs@width@\pgf@lib@sh@rs@lastnumber\endcsname\relax%
                            \advance\pgf@x by\innerxsep\relax%
                            \advance\pgf@x by\pgflinewidth%
                            \advance\pgf@x by\innerxsep\relax%
                            \expandafter\pgfextract@process\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number\endcsname{}%
                            \expandafter\let\expandafter\pgf@lib@sh@rs@lastanchor\expandafter=%
                                \csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number\endcsname%
                            \let\pgf@lib@sh@rs@lastnumber=\pgf@lib@sh@rs@number%
                            \expandafter\addtosavedmacro\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number\endcsname%
                        \fi%
                    \fi%
            \repeatpgfmathloop%
            %
            % Calculate some anchors.
            %
            \pgfextract@process\northeast{%
                \pgf@lib@sh@rs@lastanchor%
                \advance\pgf@x by\csname pgf@lib@sh@rs@width@\pgf@lib@sh@rs@lastnumber\endcsname\relax%
                \advance\pgf@x by\innerxsep\relax%
                \advance\pgf@x by\outerxsep\relax%
                \pgf@y=\pgf@lib@sh@rs@max@totalheight\relax%
                \advance\pgf@y by-\pgf@lib@sh@rs@yoffset\relax%
                \advance\pgf@y by\innerysep\relax%
                \advance\pgf@y by\outerysep\relax%
            }%
            \addtosavedmacro\northeast%
            \pgfextract@process\southwest{%
                \pgf@lib@sh@rs@anchor@one%
                \advance\pgf@x by-\innerxsep\relax%
                \advance\pgf@x by-\outerxsep\relax%
                \pgf@y=-\pgf@lib@sh@rs@yoffset\relax%
                \advance\pgf@y by-\innerysep\relax%
                \advance\pgf@y by-\outerysep\relax%
            }%
            \addtosavedmacro\southwest%
            %
            \pgfextract@process\centerpoint{%
                \pgfpointadd{\southwest}{\northeast}%
                \divide\pgf@x by2\relax%
                \divide\pgf@y by2\relax%
            }%
            \addtosavedmacro\centerpoint%
            %
            \pgfmathloop%
                \ifnum\pgfmathcounter>\parts%
                \else%
                    \pgf@lib@sh@getalpha\pgf@lib@sh@rs@number{\pgfmathcounter}%
                    %
                    \expandafter\ifx\csname pgf@lib@sh@rs@empty@\pgf@lib@sh@rs@number\endcsname\pgfutil@empty%
                    \else%
                        \csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number\endcsname%
                        \pgf@xa=\pgf@x%
                        \pgf@xb=\csname pgf@lib@sh@rs@width@\pgf@lib@sh@rs@number\endcsname\relax%
                        \advance\pgf@xa by0.5\pgf@xb%
                        \expandafter\pgfextract@process\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number @south\endcsname{%
                            \southwest%
                            \pgf@x=\pgf@xa%
                        }%
                        \expandafter\pgfextract@process\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number @north\endcsname{%
                            \northeast%
                            \pgf@x=\pgf@xa%
                        }%
                        \expandafter\addtosavedmacro\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number @north\endcsname%
                        \expandafter\addtosavedmacro\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number @south\endcsname%
                        \ifnum\pgfmathcounter=\parts%
                        \else%
                            \advance\pgf@xa by0.5\pgf@xb%
                            \advance\pgf@xa by\innerxsep\relax%
                            \advance\pgf@xa by.5\pgflinewidth%
                            \expandafter\pgfextract@process\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number @split@south\endcsname{%
                                \southwest%
                                \pgf@x=\pgf@xa%
                            }%
                            \expandafter\pgfextract@process\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number @split@north\endcsname{%
                                \northeast%
                                \pgf@x=\pgf@xa%
                            }%
                            \expandafter\pgfextract@process\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number @split\endcsname{%
                                \centerpoint%
                                \pgf@x=\pgf@xa%
                            }%
                            \expandafter\addtosavedmacro\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number @split@north\endcsname%
                            \expandafter\addtosavedmacro\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number @split@south\endcsname%
                            \expandafter\addtosavedmacro\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number @split\endcsname%
                        \fi%
                    \fi%
            \repeatpgfmathloop%
        \else%
            %
            % Calculate the origins of each node part box.
            %
            \pgf@y=0pt\relax%
            \pgfmathloop%
                \ifnum\pgfmathcounter>\parts%
                \else%
                    \pgf@lib@sh@getalpha\pgf@lib@sh@rs@number{\pgfmathcounter}%
                    %
                    \expandafter\let\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number\endcsname=\pgfutil@empty%
                    \expandafter\ifx\csname pgf@lib@sh@rs@empty@\pgf@lib@sh@rs@number\endcsname\pgfutil@empty%
                        \ifpgfrectanglesplitignoreemptyparts%
                            \expandafter\let\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number\endcsname=%
                                \pgf@lib@sh@rs@lastanchor%
                        \fi%
                    \fi%
                    %
                    % Adjust for alignment.
                    %
                    \expandafter\ifx\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number\endcsname\pgfutil@empty%
                        \expandafter\ifx\csname pgf@lib@sh@rs@\pgf@lib@sh@rs@number @item\endcsname%
                                \pgf@lib@sh@rs@lefttext%
                            \pgf@x=0pt\relax%
                        \else%
                            \expandafter\ifx\csname pgf@lib@sh@rs@\pgf@lib@sh@rs@number @item\endcsname%
                                    \pgf@lib@sh@rs@righttext%
                                \pgf@x=-\csname pgf@lib@sh@rs@width@\pgf@lib@sh@rs@number\endcsname\relax%
                                \advance\pgf@x by\pgf@lib@sh@rs@max@width\relax%
                            \else%
                                \pgf@x=-\csname pgf@lib@sh@rs@width@\pgf@lib@sh@rs@number\endcsname\relax%
                                \advance\pgf@x by\pgf@lib@sh@rs@max@width\relax%
                                \divide\pgf@x by2\relax%
                        \fi%
                    \fi%
                    %
                    % Re-adjust as the first box is at the origin.
                    %
                    \ifnum\pgfmathcounter=1\relax%
                        \edef\pgf@lib@sh@rs@xoffset{\the\pgf@x}%
                        \pgf@x=0pt\relax%
                        \pgfextract@process\pgf@lib@sh@rs@anchor@one{}%
                        \addtosavedmacro\pgf@lib@sh@rs@anchor@one%
                        \let\pgf@lib@sh@rs@lastanchor=\pgf@lib@sh@rs@anchor@one%
                        \let\pgf@lib@sh@rs@lastnumber=\pgf@lib@sh@rs@number%
                    \else
                        \advance\pgf@x by-\pgf@lib@sh@rs@xoffset\relax%
                        \advance\pgf@y by-\csname pgf@lib@sh@rs@depth@\pgf@lib@sh@rs@lastnumber\endcsname\relax%
                        \advance\pgf@y by-\innerysep\relax%
                        \advance\pgf@y by-\pgflinewidth%
                        \advance\pgf@y by-\innerysep\relax%
                        \advance\pgf@y by-\csname pgf@lib@sh@rs@height@\pgf@lib@sh@rs@number\endcsname\relax%
                        \expandafter\pgfextract@process\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number\endcsname{}%
                        \expandafter\let\expandafter\pgf@lib@sh@rs@lastanchor\expandafter=%
                            \csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number\endcsname%
                        \let\pgf@lib@sh@rs@lastnumber=\pgf@lib@sh@rs@number%
                        \expandafter\addtosavedmacro\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number\endcsname%
                    \fi%
                \fi%
            \repeatpgfmathloop%
            %
            % Calculate some anchors.
            %
            \pgfextract@process\northeast{%
                \pgf@x=\pgf@lib@sh@rs@max@width\relax%
                \advance\pgf@x by-\pgf@lib@sh@rs@xoffset\relax%
                \advance\pgf@x by\innerxsep\relax%
                \advance\pgf@x by\outerxsep\relax%
                \pgf@y=\pgf@lib@sh@rs@height@one\relax%
                \advance\pgf@y by\innerysep\relax%
                \advance\pgf@y by\outerysep\relax%
                \advance\pgf@y by.5\pgflinewidth%
            }%
            \addtosavedmacro\northeast%
            \pgfextract@process\southwest{%
                \pgf@lib@sh@rs@lastanchor%
                \pgf@x=-\pgf@lib@sh@rs@xoffset\relax%
                \advance\pgf@x by-\innerxsep\relax%
                \advance\pgf@x by-\outerxsep\relax%
                \advance\pgf@y by-\csname pgf@lib@sh@rs@depth@\pgf@lib@sh@rs@lastnumber\endcsname\relax%
                \advance\pgf@y by-\innerysep\relax%
                \advance\pgf@y by-\outerysep\relax%
                \advance\pgf@y by-.5\pgflinewidth%
            }%
            \addtosavedmacro\southwest%
            %
            \pgfextract@process\centerpoint{%
                \pgfpointadd{\southwest}{\northeast}%
                \divide\pgf@x by2\relax%
                \divide\pgf@y by2\relax%
            }%
            \addtosavedmacro\centerpoint%
            %
            \pgfmathloop%
                \ifnum\pgfmathcounter>\parts%
                \else%
                    \pgf@lib@sh@getalpha\pgf@lib@sh@rs@number{\pgfmathcounter}%
                    %
                    \expandafter\ifx\csname pgf@lib@sh@rs@empty@\pgf@lib@sh@rs@number\endcsname\pgfutil@empty%
                    \else%
                        \csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number\endcsname%
                        \pgf@ya=\csname pgf@lib@sh@rs@height@\pgf@lib@sh@rs@number\endcsname\relax%
                        \advance\pgf@y by0.5\pgf@ya%
                        \pgf@ya=\csname pgf@lib@sh@rs@depth@\pgf@lib@sh@rs@number\endcsname\relax%
                        \advance\pgf@y by-0.5\pgf@ya%
                        \pgf@ya=\pgf@y%
                        \expandafter\pgfextract@process\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number @west\endcsname{%
                            \southwest%
                            \pgf@y=\pgf@ya%
                        }%
                        \expandafter\pgfextract@process\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number @east\endcsname{%
                            \northeast%
                            \pgf@y=\pgf@ya%
                        }%
                        \expandafter\addtosavedmacro\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number @east\endcsname%
                        \expandafter\addtosavedmacro\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number @west\endcsname%
                        \ifnum\pgfmathcounter=\parts%
                        \else%
                            \csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number\endcsname%
                            \pgf@ya=\pgf@y%
                            \advance\pgf@ya by-\csname pgf@lib@sh@rs@depth@\pgf@lib@sh@rs@number\endcsname\relax%
                            \advance\pgf@ya by-\innerysep\relax%
                            \advance\pgf@ya by-.5\pgflinewidth%
                            \expandafter\pgfextract@process\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number @split@west\endcsname{%
                                \southwest%
                                \pgf@y=\pgf@ya%
                            }%
                            \expandafter\pgfextract@process\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number @split@east\endcsname{%
                                \northeast%
                                \pgf@y=\pgf@ya%
                            }%
                            \expandafter\pgfextract@process\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number @split\endcsname{%
                                \centerpoint%
                                \pgf@y=\pgf@ya%
                            }%
                            \expandafter\addtosavedmacro\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number @split@east\endcsname%
                            \expandafter\addtosavedmacro\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number @split@west\endcsname%
                            \expandafter\addtosavedmacro\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number @split\endcsname%
                        \fi%
                    \fi%
            \repeatpgfmathloop%
        \fi%
    }%
    \savedanchor\basepoint{%
        \pgf@x=0.5\wd\pgfnodeparttextbox%
        \pgf@y=0pt\relax%
    }%
    \savedanchor\midpoint{%
        \pgf@x=0.5\wd\pgfnodeparttextbox%
        \pgfmathsetlength\pgf@y{+0.5ex}%
    }%
    \anchor{center}{%
        \rectanglesplitparameters%
        \centerpoint%
    }%
    \anchor{base}{\basepoint}%
    \anchor{base east}{%
        \rectanglesplitparameters%
        \northeast%
        \pgf@y=0pt\relax%
    }%
    \anchor{base west}{%
        \rectanglesplitparameters%
        \southwest%
        \pgf@y=0pt\relax%
    }%
    \anchor{mid}{\midpoint}%
    \anchor{mid east}{%
        \rectanglesplitparameters%
        \northeast%
        \pgf@xa=\pgf@x%
        \midpoint%
        \pgf@x=\pgf@xa%
    }%
    \anchor{mid west}{%
        \rectanglesplitparameters%
        \southwest%
        \pgf@xa=\pgf@x%
        \midpoint%
        \pgf@x=\pgf@xa%
    }%
    \anchor{north}{%
        \rectanglesplitparameters%
        \centerpoint%
        \pgf@xa=\pgf@x%
        \northeast%
        \pgf@x=\pgf@xa%
    }%
    \anchor{south}{%
        \rectanglesplitparameters%
        \centerpoint%
        \pgf@xa=\pgf@x%
        \southwest%
        \pgf@x=\pgf@xa%
    }%
    \anchor{east}{%
        \rectanglesplitparameters%
        \centerpoint%
        \pgf@ya=\pgf@y%
        \northeast%
        \pgf@y=\pgf@ya%
    }%
    \anchor{west}{%
        \rectanglesplitparameters%
        \centerpoint%
        \pgf@ya=\pgf@y%
        \southwest%
        \pgf@y=\pgf@ya%
    }%
    \anchor{north east}{%
        \rectanglesplitparameters%
        \northeast%
    }%
    \anchor{north west}{%
        \rectanglesplitparameters%
        \northeast%
        \pgf@ya=\pgf@y%
        \southwest%
        \pgf@y=\pgf@ya%
    }%
    \anchor{south west}{%
        \rectanglesplitparameters%
        \southwest%
    }%
    \anchor{south east}{%
        \rectanglesplitparameters%
        \southwest%
        \pgf@ya=\pgf@y%
        \northeast%
        \pgf@y=\pgf@ya%
    }%
    \behindbackgroundpath{%
        \ifpgfrectanglesplitusecustomfill%
            \pgf@lib@sh@rs@process@list{\pgf@lib@sh@rs@list@fill}{\parts}%
            {%
                \ifpgfrectanglesplithorizontal%
                    \expandafter\let\expandafter\pgf@lib@sh@rs@fill@bottomleft\expandafter=%
                        \csname pgf@anchor@rectangle split@south west\endcsname%
                    \pgfmathloop%
                        \ifnum\pgfmathcounter>\parts%
                        \else%
                            \pgf@lib@sh@getalpha\pgf@lib@sh@rs@number{\pgfmathcounter}%
                            \ifnum\pgfmathcounter=\parts%
                                \expandafter\let\expandafter\pgf@lib@sh@rs@fill@topright\expandafter=%
                                    \csname pgf@anchor@rectangle split@north east\endcsname%
                            \else%
                                \expandafter\let\expandafter\pgf@lib@sh@rs@fill@topright\expandafter=%
                                    \csname pgf@anchor@rectangle split@\pgf@lib@sh@rs@number\space split north\endcsname%
                            \fi%
                            \expandafter\ifx\csname pgf@lib@sh@rs@empty@\pgf@lib@sh@rs@number\endcsname\pgfutil@empty%
                            \else%
                                \expandafter\ifx\csname pgf@lib@sh@rs@\pgf@lib@sh@rs@number @item\endcsname\pgf@lib@sh@rs@nonetext%
                                \else%
                                    \pgfextract@process\pgf@lib@sh@rs@fill@bottomleft{%
                                        \pgf@lib@sh@rs@fill@bottomleft%
                                        \advance\pgf@y by\outerysep\relax%
                                        \ifnum\pgfmathcounter=1\relax%
                                            \advance\pgf@x by\outerxsep\relax%
                                        \fi%
                                    }%
                                    \pgfextract@process\pgf@lib@sh@rs@fill@topright{%
                                        \pgf@lib@sh@rs@fill@topright%
                                        \advance\pgf@y by-\outerysep\relax%
                                        \ifnum\pgfmathcounter=\parts\relax%
                                            \advance\pgf@x by-\outerxsep\relax%
                                        \fi%
                                    }%
                                    \ifnum\pgfmathcounter>1\relax%
                                        \begingroup\pgfsetcornersarced{\pgfpointorigin}%
                                    \fi%
                                    \pgfpathmoveto{%
                                        \pgf@lib@sh@rs@fill@topright%
                                        \pgf@xa=\pgf@x%
                                        \pgf@lib@sh@rs@fill@bottomleft%
                                        \pgf@x=\pgf@xa%
                                    }%
                                    \pgfpathlineto{\pgf@lib@sh@rs@fill@bottomleft}%
                                    \pgfpathlineto{%
                                        \pgf@lib@sh@rs@fill@bottomleft%
                                        \pgf@xa=\pgf@x%
                                        \pgf@lib@sh@rs@fill@topright%
                                        \pgf@x=\pgf@xa%
                                    }%
                                    \ifnum\pgfmathcounter>1\relax%
                                        \endgroup%
                                    \fi%
                                    \ifnum\pgfmathcounter<\parts%
                                        \begingroup\pgfsetcornersarced{\pgfpointorigin}%
                                    \fi%
                                    \pgfpathlineto{\pgf@lib@sh@rs@fill@topright}%
                                    \pgfpathclose%
                                    \ifnum\pgfmathcounter<\parts%
                                        \endgroup%
                                    \fi%
                                    \pgfsetfillcolor{\csname pgf@lib@sh@rs@\pgf@lib@sh@rs@number @item\endcsname}%
                                    \pgfusepath{fill}%
                                \fi%
                            \fi%
                            \pgfextract@process\pgf@lib@sh@rs@fill@bottomleft{%
                                \pgf@lib@sh@rs@fill@bottomleft%
                                \pgf@ya=\pgf@y%
                                \pgf@lib@sh@rs@fill@topright%
                                \pgf@y=\pgf@ya%
                                \advance\pgf@y by-\outerysep%
                            }%
                    \repeatpgfmathloop%
                \else%
                    \expandafter\let\expandafter\pgf@lib@sh@rs@fill@topright\expandafter=%
                        \csname pgf@anchor@rectangle split@north east\endcsname%
                    \pgfmathloop%
                        \ifnum\pgfmathcounter>\parts%
                        \else%
                            \pgf@lib@sh@getalpha\pgf@lib@sh@rs@number{\pgfmathcounter}%
                            \ifnum\pgfmathcounter=\parts%
                                \expandafter\let\expandafter\pgf@lib@sh@rs@fill@bottomleft\expandafter=%
                                    \csname pgf@anchor@rectangle split@south west\endcsname%
                            \else%
                                \expandafter\let\expandafter\pgf@lib@sh@rs@fill@bottomleft\expandafter=%
                                    \csname pgf@anchor@rectangle split@\pgf@lib@sh@rs@number\space split west\endcsname%
                            \fi%
                            \expandafter\ifx\csname pgf@lib@sh@rs@empty@\pgf@lib@sh@rs@number\endcsname\pgfutil@empty%
                            \else%
                                \expandafter\ifx\csname pgf@lib@sh@rs@\pgf@lib@sh@rs@number @item\endcsname\pgf@lib@sh@rs@nonetext%
                                \else%
                                    \pgfextract@process\pgf@lib@sh@rs@fill@bottomleft{%
                                        \pgf@lib@sh@rs@fill@bottomleft%
                                        \advance\pgf@x by\outerxsep\relax%
                                        \ifnum\parts=1\relax%
                                            \advance\pgf@y by\outerysep\relax%
                                        \else%
                                            \ifnum\pgfmathcounter=\parts
                                                \advance\pgf@y by\outerysep\relax%
                                            \fi%
                                        \fi%
                                    }%
                                    \pgfextract@process\pgf@lib@sh@rs@fill@topright{%
                                        \pgf@lib@sh@rs@fill@topright%
                                        \advance\pgf@x by-\outerxsep\relax%
                                        \ifnum\parts=1\relax%
                                            \advance\pgf@y by-\outerysep\relax%
                                        \else%
                                            \ifnum\pgfmathcounter=1\relax%
                                                \advance\pgf@y by-\outerysep\relax%
                                            \fi%
                                        \fi%
                                    }%
                                    \pgfpathmoveto{\pgf@lib@sh@rs@fill@bottomleft}%
                                    \ifnum\pgfmathcounter>1\relax%
                                        \begingroup\pgfsetcornersarced{\pgfpointorigin}%
                                    \fi%
                                    \pgfpathlineto{%
                                        \pgf@lib@sh@rs@fill@bottomleft%
                                        \pgf@xa=\pgf@x%
                                        \pgf@lib@sh@rs@fill@topright%
                                        \pgf@x=\pgf@xa%
                                    }%
                                    \pgfpathlineto{\pgf@lib@sh@rs@fill@topright}%
                                    \ifnum\pgfmathcounter>1\relax%
                                        \endgroup%%
                                    \fi%
                                    \ifnum\pgfmathcounter<\parts%
                                        \begingroup\pgfsetcornersarced{\pgfpointorigin}%
                                    \fi%
                                    \pgfpathlineto{%
                                        \pgf@lib@sh@rs@fill@topright%
                                        \pgf@xa=\pgf@x%
                                        \pgf@lib@sh@rs@fill@bottomleft%
                                        \pgf@x=\pgf@xa%
                                    }%
                                    \pgfpathclose%
                                    \ifnum\pgfmathcounter<\parts%
                                        \endgroup%
                                    \fi%
                                    \pgfsetfillcolor{\csname pgf@lib@sh@rs@\pgf@lib@sh@rs@number @item\endcsname}%
                                    \pgfusepath{fill}%
                                \fi%
                            \fi%
                            \pgfextract@process\pgf@lib@sh@rs@fill@topright{%
                                \pgf@lib@sh@rs@fill@topright%
                                \pgf@xa=\pgf@x%
                                \pgf@lib@sh@rs@fill@bottomleft%
                                \pgf@x=\pgf@xa%
                                \advance\pgf@x by\outerxsep\relax%
                            }%
                    \repeatpgfmathloop%
                \fi%
            }%
        \fi%
    }%
    \backgroundpath{%
        \begingroup%
            \pgfextract@process\southwest{%
                \southwest%
                \advance\pgf@x by\outerxsep\relax%
                \advance\pgf@y by\outerysep\relax%
            }%
            \pgfextract@process\northeast{%
                \northeast%
                \advance\pgf@x by-\outerxsep\relax%
                \advance\pgf@y by-\outerysep\relax%
            }%
            \pgfpathrectangle{\southwest}{\pgfpointdiff{\southwest}{\northeast}}%
        \endgroup%
        \ifpgfrectanglesplitdrawsplits%
            \pgfmathloop%
                \ifnum\pgfmathcounter=\parts%
                \else%
                    \pgf@lib@sh@getalpha\pgf@lib@sh@rs@number{\pgfmathcounter}%
                    %
                    \expandafter\ifx\csname pgf@lib@sh@rs@empty@\pgf@lib@sh@rs@number\endcsname\pgfutil@empty%
                    \else%
                        \pgfpathmoveto{%
                            \ifpgfrectanglesplithorizontal%
                                \csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number @split@north\endcsname%
                                \advance\pgf@y by-\outerysep\relax%
                            \else%
                                \csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number @split@east\endcsname%
                                \advance\pgf@x by-\outerxsep\relax%
                            \fi%
                        }%
                        \pgfpathlineto{%
                            \ifpgfrectanglesplithorizontal%
                                \csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number @split@south\endcsname%
                                \advance\pgf@y by\outerysep\relax%
                            \else%
                                \csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@number @split@west\endcsname%
                                \advance\pgf@x by\outerxsep\relax%
                            \fi%
                        }%
                    \fi%
            \repeatpgfmathloop%
        \fi%
    }%
    \anchorborder{%
        \pgfutil@tempdima\pgf@x%
        \pgfutil@tempdimb\pgf@y%
        \rectanglesplitparameters%
        \pgfpointdiff{\southwest}{\northeast}%
        \pgf@x.5\pgf@x%
        \pgf@y.5\pgf@y%
        \edef\pgf@marshall{%
            \noexpand\pgfpointborderrectangle{%
                    \noexpand\pgfqpoint{\the\pgfutil@tempdima}{\the\pgfutil@tempdimb}%
                }%
                {%
                    \noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}%
                }%
        }%
        \pgf@marshall%
        \pgf@xa\pgf@x%
        \pgf@ya\pgf@y%
        \centerpoint%
        \advance\pgf@x\pgf@xa%
        \advance\pgf@y\pgf@ya%
    }%
    %
    % Hackery to install the correct number of node parts.
    %
    \expandafter\pgfutil@g@addto@macro\csname pgf@sh@s@rectangle split\endcsname{%
        \let\pgf@lib@sh@rs@temp=\pgfutil@empty%
        \pgfmathloop%
            \ifnum\pgfmathcounter=\parts%
                \expandafter\edef\csname pgf@sh@boxes@rectangle split\endcsname%
                    {\pgf@lib@sh@rs@temp\pgf@lib@sh@toalpha{\pgfmathcounter}}%
            \else%
                \edef\pgf@lib@sh@rs@temp{\pgf@lib@sh@rs@temp\pgf@lib@sh@toalpha{\pgfmathcounter},}%
        \repeatpgfmathloop%
    }%
}%

\pgfutil@for\pgf@lib@sh@rs@temp:={one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve,thirteen,fourteen,fifteen,sixteen,seventeen,eighteen,nineteen,twenty}\do{%
    \expandafter\xdef\csname pgf@anchor@rectangle split@\pgf@lib@sh@rs@temp\endcsname{%
        \noexpand\rectanglesplitparameters%
        \noexpand\pgfutil@ifundefined{pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@temp}{\noexpand\pgf@lib@sh@rs@anchor@one}%
            {\noexpand\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@temp\noexpand\endcsname}%
    }%
    \expandafter\xdef\csname pgf@anchor@rectangle split@\pgf@lib@sh@rs@temp\space split\endcsname{%
        \noexpand\rectanglesplitparameters%
        \noexpand\pgfutil@ifundefined{pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@temp @split}%
        {\noexpand\centerpoint}%
        {\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@temp @split\noexpand\endcsname}%
    }%
    \expandafter\xdef\csname pgf@anchor@rectangle split@\pgf@lib@sh@rs@temp\space split north\endcsname{%
        \noexpand\rectanglesplitparameters%
        \noexpand\pgfutil@ifundefined{pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@temp @split@north}%
        {\noexpand\csname pgf@anchor@rectangle split@north\noexpand\endcsname}%
        {\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@temp @split@north\noexpand\endcsname}%
    }%
    \expandafter\xdef\csname pgf@anchor@rectangle split@\pgf@lib@sh@rs@temp\space split south\endcsname{%
        \noexpand\rectanglesplitparameters%
        \noexpand\pgfutil@ifundefined{pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@temp @split@south}%
        {\noexpand\csname pgf@anchor@rectangle split@south\noexpand\endcsname}%
        {\noexpand\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@temp @split@south\noexpand\endcsname}%
    }%
    \expandafter\xdef\csname pgf@anchor@rectangle split@\pgf@lib@sh@rs@temp\space north\endcsname{%
        \noexpand\rectanglesplitparameters%
        \noexpand\pgfutil@ifundefined{pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@temp @north}%
        {\noexpand\csname pgf@anchor@rectangle split@north\noexpand\endcsname}%
        {\noexpand\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@temp @north\noexpand\endcsname}%
    }%
    \expandafter\xdef\csname pgf@anchor@rectangle split@\pgf@lib@sh@rs@temp\space south\endcsname{%
        \noexpand\rectanglesplitparameters%
        \noexpand\pgfutil@ifundefined{pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@temp @south}%
        {\noexpand\csname pgf@anchor@rectangle split@south\noexpand\endcsname}%
        {\noexpand\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@temp @south\noexpand\endcsname}%
    }%
    \expandafter\xdef\csname pgf@anchor@rectangle split@\pgf@lib@sh@rs@temp\space split east\endcsname{%
        \noexpand\rectanglesplitparameters%
        \noexpand\pgfutil@ifundefined{pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@temp @split@east}%
        {\noexpand\csname pgf@anchor@rectangle split@east\noexpand\endcsname}%
        {\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@temp @split@east\noexpand\endcsname}%
    }%
    \expandafter\xdef\csname pgf@anchor@rectangle split@\pgf@lib@sh@rs@temp\space split west\endcsname{%
        \noexpand\rectanglesplitparameters%
        \noexpand\pgfutil@ifundefined{pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@temp @split@west}%
        {\noexpand\csname pgf@anchor@rectangle split@west\noexpand\endcsname}%
        {\noexpand\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@temp @split@west\noexpand\endcsname}%
    }%
    \expandafter\xdef\csname pgf@anchor@rectangle split@\pgf@lib@sh@rs@temp\space east\endcsname{%
        \noexpand\rectanglesplitparameters%
        \noexpand\pgfutil@ifundefined{pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@temp @east}%
        {\noexpand\csname pgf@anchor@rectangle split@east\noexpand\endcsname}%
        {\noexpand\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@temp @east\noexpand\endcsname}%
    }%
    \expandafter\xdef\csname pgf@anchor@rectangle split@\pgf@lib@sh@rs@temp\space west\endcsname{%
        \noexpand\rectanglesplitparameters%
        \noexpand\pgfutil@ifundefined{pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@temp @west}%
        {\noexpand\csname pgf@anchor@rectangle split@west\noexpand\endcsname}%
        {\noexpand\csname pgf@lib@sh@rs@anchor@\pgf@lib@sh@rs@temp @west\noexpand\endcsname}%
    }%
}%


\pgfutil@namelet{pgf@anchor@rectangle split@text east}{pgf@anchor@rectangle split@one east}%
\pgfutil@namelet{pgf@anchor@rectangle split@text west}{pgf@anchor@rectangle split@one west}%
\pgfutil@namelet{pgf@anchor@rectangle split@text split}{pgf@anchor@rectangle split@one split}%
\pgfutil@namelet{pgf@anchor@rectangle split@text split east}{pgf@anchor@rectangle split@one split east}%
\pgfutil@namelet{pgf@anchor@rectangle split@text split west}{pgf@anchor@rectangle split@one split west}%

\pgfutil@namelet{pgf@anchor@rectangle split@second}{pgf@anchor@rectangle split@two}%
\pgfutil@namelet{pgf@anchor@rectangle split@second east}{pgf@anchor@rectangle split@two east}%
\pgfutil@namelet{pgf@anchor@rectangle split@second west}{pgf@anchor@rectangle split@two west}%
\pgfutil@namelet{pgf@anchor@rectangle split@second split}{pgf@anchor@rectangle split@two split}%
\pgfutil@namelet{pgf@anchor@rectangle split@second split east}{pgf@anchor@rectangle split@two split east}%
\pgfutil@namelet{pgf@anchor@rectangle split@second split west}{pgf@anchor@rectangle split@two split west}%

\pgfutil@namelet{pgf@anchor@rectangle split@third}{pgf@anchor@rectangle split@three}%
\pgfutil@namelet{pgf@anchor@rectangle split@third east}{pgf@anchor@rectangle split@three east}%
\pgfutil@namelet{pgf@anchor@rectangle split@third west}{pgf@anchor@rectangle split@three west}%
\pgfutil@namelet{pgf@anchor@rectangle split@third split}{pgf@anchor@rectangle split@three split}%
\pgfutil@namelet{pgf@anchor@rectangle split@third split east}{pgf@anchor@rectangle split@three split east}%
\pgfutil@namelet{pgf@anchor@rectangle split@third split west}{pgf@anchor@rectangle split@three split west}%

\pgfutil@namelet{pgf@anchor@rectangle split@fourth}{pgf@anchor@rectangle split@four}%
\pgfutil@namelet{pgf@anchor@rectangle split@fourth east}{pgf@anchor@rectangle split@four east}%
\pgfutil@namelet{pgf@anchor@rectangle split@fourth west}{pgf@anchor@rectangle split@four west}%
\pgfutil@namelet{pgf@anchor@rectangle split@fourth split}{pgf@anchor@rectangle split@four split}%
\pgfutil@namelet{pgf@anchor@rectangle split@fourth split east}{pgf@anchor@rectangle split@four split east}%
\pgfutil@namelet{pgf@anchor@rectangle split@fourth split west}{pgf@anchor@rectangle split@four split west}%




% Shape: ellipse split.
%
\pgfdeclareshape{ellipse split}{%
    \nodeparts{text,lower}%
    \savedanchor\radii{%
        \pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/inner xsep}}%
        \pgfmathsetlength\pgf@y{\pgfkeysvalueof{/pgf/inner ysep}}%
        \pgf@y2.0\pgf@y%
        \advance\pgf@y.5\pgflinewidth%
        \pgf@xa.5\wd\pgfnodeparttextbox%
        \pgf@xb.5\wd\pgfnodepartlowerbox%
        \advance\pgf@xa\pgf@x%
        \advance\pgf@xb\pgf@x%
        \pgf@ya\ht\pgfnodeparttextbox%
        \advance\pgf@ya\dp\pgfnodeparttextbox%
        \pgf@yb\ht\pgfnodepartlowerbox%
        \advance\pgf@yb\dp\pgfnodepartlowerbox%
        \advance\pgf@ya\pgf@y%
        \advance\pgf@yb\pgf@y%
        \ifdim\pgf@xa>\pgf@xb%
            \pgf@x1.414213\pgf@xa%
        \else%
            \pgf@x1.414213\pgf@xb%
        \fi%
        \ifdim\pgf@ya>\pgf@yb%
            \pgf@y1.414213\pgf@ya%
        \else%
            \pgf@y1.414213\pgf@yb%
        \fi%
        \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/minimum width}}%
        \pgfmathsetlength\pgf@ya{\pgfkeysvalueof{/pgf/minimum height}}%
        \ifdim\pgf@x<.5\pgf@xa%
            \pgf@x.5\pgf@xa%
        \fi%
        \ifdim\pgf@y<.5\pgf@ya%
            \pgf@y.5\pgf@ya%
        \fi%
        \pgfmathaddtolength\pgf@x{\pgfkeysvalueof{/pgf/outer xsep}}%
        \pgfmathaddtolength\pgf@y{\pgfkeysvalueof{/pgf/outer ysep}}%
    }%
    \savedanchor\lower{%
        \pgf@x-.5\wd\pgfnodepartlowerbox%
        \advance\pgf@x.5\wd\pgfnodeparttextbox%
        \pgfmathsetlength\pgf@y{\pgfkeysvalueof{/pgf/inner ysep}}%
        \pgf@y-2.0\pgf@y%
        \advance\pgf@y-\pgflinewidth%
        \advance\pgf@y-\dp\pgfnodeparttextbox%
        \advance\pgf@y-\ht\pgfnodepartlowerbox%
    }%
    \savedanchor\centerpoint{%
        \pgf@x.5\wd\pgfnodeparttextbox%
        \pgfmathsetlength\pgf@y{-\pgfkeysvalueof{/pgf/inner ysep}}%
        \advance\pgf@y-\dp\pgfnodeparttextbox%
        \advance\pgf@y-.5\pgflinewidth%
    }%
    \savedanchor\basepoint{%
        \pgf@x.5\wd\pgfnodeparttextbox%
        \pgf@y0pt\relax%
    }%
    \savedanchor\midpoint{%
        \pgf@x.5\wd\pgfnodeparttextbox%
        \pgfmathsetlength\pgf@y{.5ex}%
    }%
    \anchor{center}{\centerpoint}%
    \anchor{lower}{\lower}%
    \anchor{mid}{\midpoint}%
    \anchor{mid east}{\radii\pgf@xa\pgf@x\midpoint\advance\pgf@x\pgf@xa}%
    \anchor{mid west}{\radii\pgf@xa\pgf@x\midpoint\advance\pgf@x-\pgf@xa}%
    \anchor{base}{\basepoint}%
    \anchor{base east}{\radii\pgf@xa\pgf@x\basepoint\advance\pgf@x\pgf@xa}%
    \anchor{base west}{\radii\pgf@xa\pgf@x\basepoint\advance\pgf@x-\pgf@xa}%
    \anchor{north}{\pgfpointadd{\centerpoint}{\radii\pgf@x0pt}}%
    \anchor{south}{\pgfpointadd{\centerpoint}{\radii\pgf@x0pt\pgf@y-\pgf@y}}%
    \anchor{east}{\pgfpointadd{\centerpoint}{\radii\pgf@y0pt}}%
    \anchor{west}{\pgfpointadd{\centerpoint}{\radii\pgf@x-\pgf@x\pgf@y0pt}}%
    \anchor{north west}{\pgfpointadd{\centerpoint}{\radii\pgf@x-0.707106\pgf@x\pgf@y0.707106\pgf@y}}%
    \anchor{south west}{\pgfpointadd{\centerpoint}{\radii\pgf@x-0.707106\pgf@x\pgf@y-0.707106\pgf@y}}%
    \anchor{north east}{\pgfpointadd{\centerpoint}{\radii\pgf@x0.707106\pgf@x\pgf@y0.707106\pgf@y}}%
    \anchor{south east}{\pgfpointadd{\centerpoint}{\radii\pgf@x0.707106\pgf@x\pgf@y-0.707106\pgf@y}}%
    \backgroundpath{%
        \radii%
        \pgfmathaddtolength\pgf@x{-\pgfkeysvalueof{/pgf/outer xsep}}%
        \pgfmathaddtolength\pgf@y{-\pgfkeysvalueof{/pgf/outer ysep}}%
        \pgfutil@tempdima\pgf@x%
        \pgfutil@tempdimb\pgf@y%
        \pgfpathellipse{\centerpoint}{\pgfqpoint{\the\pgfutil@tempdima}{0pt}}{\pgfqpoint{0pt}{\the\pgfutil@tempdimb}}%
        \pgfpathmoveto{\centerpoint\advance\pgf@x-\pgfutil@tempdima}%
        \pgfpathlineto{\centerpoint\advance\pgf@x\pgfutil@tempdima}%
    }%
    \anchorborder{%
        \pgfextract@process\externalpoint{}%
        \radii%
        \edef\pgf@marshal{%
            \noexpand\pgfpointadd{\noexpand\pgfpointborderellipse{\noexpand\externalpoint}%
                {\noexpand\pgfpoint{\the\pgf@x}{\the\pgf@y}}}{\noexpand\centerpoint}%
        }%
       \pgf@marshal%
    }%
}%

\endinput
