| 1 |
% Copyright 2019 by Till Tantau |
| 2 |
% |
| 3 |
% This file may be distributed and/or modified |
| 4 |
% |
| 5 |
% 1. under the LaTeX Project Public License and/or |
| 6 |
% 2. under the GNU Public License. |
| 7 |
% |
| 8 |
% See the file doc/generic/pgf/licenses/LICENSE for more details. |
| 9 |
|
| 10 |
\ProvidesFileRCS{tikzlibrarytrees.code.tex} |
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
% |
| 15 |
% Three point growth |
| 16 |
% |
| 17 |
|
| 18 |
\tikzoption{grow via three points}{\let\tikz@grow=\tikz@grow@three\tikz@parse@three#1}% |
| 19 |
|
| 20 |
\def\tikz@parse@three one child at#1(#2)#3and two children at#4(#5)#6and#7(#8){% |
| 21 |
\def\tikz@tree@one@child{\tikz@scan@one@point\pgf@process(#2)} |
| 22 |
\def\tikz@tree@left@child{\tikz@scan@one@point\pgf@process(#5)} |
| 23 |
\def\tikz@tree@right@child{\tikz@scan@one@point\pgf@process(#8)} |
| 24 |
}% |
| 25 |
|
| 26 |
\def\tikz@grow@three{% |
| 27 |
\pgf@process{\tikz@tree@one@child}% |
| 28 |
\pgf@xa=\pgf@x% |
| 29 |
\pgf@ya=\pgf@y% |
| 30 |
\pgf@process{\tikz@tree@left@child}% |
| 31 |
\pgf@xb=\pgf@x% |
| 32 |
\pgf@yb=\pgf@y% |
| 33 |
\advance\pgf@xb by-\pgf@xa% |
| 34 |
\advance\pgf@yb by-\pgf@ya% |
| 35 |
\pgf@process{\tikz@tree@right@child}% |
| 36 |
\pgf@xc=\pgf@x% |
| 37 |
\pgf@yc=\pgf@y% |
| 38 |
\advance\pgf@xc by-\pgf@xa% |
| 39 |
\advance\pgf@yc by-\pgf@ya% |
| 40 |
\advance\pgf@xc by-\pgf@xb% |
| 41 |
\advance\pgf@yc by-\pgf@yb% |
| 42 |
\advance\tikznumberofchildren by-1\relax% |
| 43 |
\pgf@xb=\tikznumberofchildren\pgf@xb\relax% |
| 44 |
\pgf@yb=\tikznumberofchildren\pgf@yb\relax% |
| 45 |
\advance\tikznumberofcurrentchild by-1\relax% |
| 46 |
\pgf@xc=\tikznumberofcurrentchild\pgf@xc\relax% |
| 47 |
\pgf@yc=\tikznumberofcurrentchild\pgf@yc\relax% |
| 48 |
\advance\pgf@xa by\pgf@xb% |
| 49 |
\advance\pgf@xa by\pgf@xc% |
| 50 |
\advance\pgf@ya by\pgf@yb% |
| 51 |
\advance\pgf@ya by\pgf@yc% |
| 52 |
\edef\pgf@temp{\noexpand\pgftransformshift{\noexpand\pgfqpoint{\the\pgf@xa}{\the\pgf@ya}}}% |
| 53 |
\pgf@temp% |
| 54 |
}% |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
% |
| 59 |
% Circle grow |
| 60 |
% |
| 61 |
|
| 62 |
\tikzset{ |
| 63 |
grow cyclic/.style={ |
| 64 |
edge from parent/.append style={reset cm}, |
| 65 |
growth function=\tikz@grow@circle, |
| 66 |
} |
| 67 |
}% |
| 68 |
|
| 69 |
\tikzset{sibling angle/.initial=20}% |
| 70 |
|
| 71 |
\def\tikz@grow@circle{% |
| 72 |
\pgftransformrotate{% |
| 73 |
(\pgfkeysvalueof{/tikz/sibling angle})*(-.5-.5*\tikznumberofchildren+\tikznumberofcurrentchild)}% |
| 74 |
\pgftransformxshift{\the\tikzleveldistance}% |
| 75 |
}% |
| 76 |
|
| 77 |
\tikzoption{counterclockwise from}{\let\tikz@grow=\tikz@grow@circle@from\def\tikz@grow@circle@from@start{#1}}% |
| 78 |
|
| 79 |
\def\tikz@grow@circle@from{% |
| 80 |
\pgftransformshift{\pgfpointpolar{\tikz@grow@circle@from@start+(\pgfkeysvalueof{/tikz/sibling angle})*(\tikznumberofcurrentchild-1)}{\the\tikzleveldistance}}% |
| 81 |
}% |
| 82 |
|
| 83 |
\tikzoption{clockwise from}{\let\tikz@grow=\tikz@grow@circle@from@\def\tikz@grow@circle@from@start{#1}}% |
| 84 |
|
| 85 |
\def\tikz@grow@circle@from@{% |
| 86 |
\pgftransformshift{\pgfpointpolar{\tikz@grow@circle@from@start-(\pgfkeysvalueof{/tikz/sibling angle})*(\tikznumberofcurrentchild-1)}{\the\tikzleveldistance}}% |
| 87 |
}% |
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
% |
| 92 |
% Connections |
| 93 |
% |
| 94 |
|
| 95 |
\tikzset{edge from parent fork down/.style= |
| 96 |
{edge from parent path={(\tikzparentnode\tikzparentanchor) -- +(0pt,-.5\tikzleveldistance) -| (\tikzchildnode\tikzchildanchor)}}}% |
| 97 |
|
| 98 |
\tikzset{edge from parent fork up/.style= |
| 99 |
{edge from parent path={(\tikzparentnode\tikzparentanchor) -- +(0pt,.5\tikzleveldistance) -| (\tikzchildnode\tikzchildanchor)}}}% |
| 100 |
|
| 101 |
\tikzset{edge from parent fork left/.style= |
| 102 |
{edge from parent path={(\tikzparentnode\tikzparentanchor) -- +(-.5\tikzleveldistance,0pt) |- (\tikzchildnode\tikzchildanchor)}}}% |
| 103 |
|
| 104 |
\tikzset{edge from parent fork right/.style= |
| 105 |
{edge from parent path={(\tikzparentnode\tikzparentanchor) -- +(.5\tikzleveldistance,0pt) |- (\tikzchildnode\tikzchildanchor)}}}% |
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
\endinput |