summaryrefslogtreecommitdiff
path: root/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries')
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/circuits/tikzlibrarycircuits.code.tex264
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/circuits/tikzlibrarycircuits.ee.IEC.code.tex442
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/circuits/tikzlibrarycircuits.ee.code.tex148
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/circuits/tikzlibrarycircuits.logic.CDH.code.tex28
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/circuits/tikzlibrarycircuits.logic.IEC.code.tex75
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/circuits/tikzlibrarycircuits.logic.US.code.tex64
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/circuits/tikzlibrarycircuits.logic.code.tex45
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/datavisualization/tikzlibrarydatavisualization.3d.code.tex79
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/datavisualization/tikzlibrarydatavisualization.barcharts.code.tex43
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/datavisualization/tikzlibrarydatavisualization.code.tex2733
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/datavisualization/tikzlibrarydatavisualization.formats.functions.code.tex16
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/datavisualization/tikzlibrarydatavisualization.polar.code.tex565
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/datavisualization/tikzlibrarydatavisualization.sparklines.code.tex37
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/graphs/tikzlibrarygraphs.code.tex2674
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/graphs/tikzlibrarygraphs.standard.code.tex109
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzexternalshared.code.tex1714
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrary3d.code.tex108
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryangles.code.tex100
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryanimations.code.tex904
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryarrows.code.tex14
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryautomata.code.tex105
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarybabel.code.tex17
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarybackgrounds.code.tex148
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarybending.code.tex15
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarycalc.code.tex618
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarycalendar.code.tex444
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarychains.code.tex214
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarydecorations.code.tex194
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarydecorations.footprints.code.tex13
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarydecorations.fractals.code.tex13
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarydecorations.markings.code.tex31
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarydecorations.pathmorphing.code.tex13
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarydecorations.pathreplacing.code.tex36
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarydecorations.shapes.code.tex13
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarydecorations.text.code.tex704
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryer.code.tex40
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryfadings.code.tex48
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryfit.code.tex132
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryfixedpointarithmetic.code.tex10
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryfolding.code.tex2444
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryfpu.code.tex10
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryintersections.code.tex148
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarylindenmayersystems.code.tex81
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarymath.code.tex731
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarymatrix.code.tex144
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarymindmap.code.tex417
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarypatterns.code.tex31
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarypatterns.meta.code.tex98
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryperspective.code.tex111
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarypetri.code.tex146
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryplothandlers.code.tex14
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryplotmarks.code.tex14
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarypositioning.code.tex118
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryquotes.code.tex90
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryrdf.code.tex291
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryscopes.code.tex42
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryshadings.code.tex21
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryshadows.code.tex146
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryshapes.arrows.code.tex16
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryshapes.callouts.code.tex35
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryshapes.code.tex19
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryshapes.gates.logic.IEC.code.tex38
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryshapes.gates.logic.US.code.tex40
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryshapes.geometric.code.tex14
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryshapes.misc.code.tex14
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryshapes.multipart.code.tex36
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryshapes.symbols.code.tex17
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarysnakes.code.tex77
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryspy.code.tex134
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarysvg.path.code.tex33
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarythrough.code.tex36
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarytopaths.code.tex381
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarytrees.code.tex109
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryturtle.code.tex84
-rw-r--r--graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryviews.code.tex45
75 files changed, 19195 insertions, 0 deletions
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/circuits/tikzlibrarycircuits.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/circuits/tikzlibrarycircuits.code.tex
new file mode 100644
index 0000000000..1a9173fddc
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/circuits/tikzlibrarycircuits.code.tex
@@ -0,0 +1,264 @@
+% Copyright 2019 by Till Tantau and others 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.
+
+\usetikzlibrary{calc,decorations.markings}%
+
+
+%
+% Indicate that the picture contains a circuit
+%
+\tikzset{
+ circuit/.style={
+ every circuit/.try,
+ /utils/exec=\tikz@lib@circ@on@tofalse,
+ execute at begin to={
+ \tikz@lib@circ@on@totrue
+ \let\tikz@lib@circ@start@node\pgfutil@empty
+ \def\tikz@lib@circ@end{-- (\tikztotarget) \tikztonodes}
+ }
+ }
+}%
+
+\newif\iftikz@lib@circ@on@to
+
+
+%
+% General management
+%
+
+\tikzset{
+ circuit handle symbol/.code={%
+ \global\advance\tikz@lib@circ@count by1\relax%
+ \iftikz@lib@circ@on@to
+ {%
+ % Compute the tikz@time...
+ \pgfkeys{
+ /pgf/key filters/active families or no family/.install key filter={/pgf/key filters/false}{/pgf/key filters/false},
+ /tikz/circuits/pos grabber/.activate family}
+ \pgfqkeysfiltered{/tikz}{pos=.5,#1}%
+ \expandafter%
+ }%
+ \expandafter\def\expandafter\tikz@lib@circ@pos\expandafter{\tikz@time}%
+ \pgfkeysalso{to path={
+ \pgfextra{\tikz@lib@circ@on@tofalse}
+ decorate [decoration={markings,mark connection node=mark node}]
+ {
+ \tikz@lib@circ@start@node
+ \tikz@lib@circ@end
+ }
+ }}
+ \ifdim\tikz@lib@circ@pos pt=0pt\relax%
+ \def\tikz@lib@circ@start@node{%
+ {\pgfextra{\tikz@lib@circ@compute@direction{\tikz@lib@circ@start}}%
+ node[alias=tikz@lib@circ@node@start,at={(0,0)},#1,pos=]{}}(tikz@lib@circ@node@start)}%
+ \else%
+ \ifdim\tikz@lib@circ@pos pt=1pt\relax%
+ \def\tikz@lib@circ@end{
+ {\pgfextra{\tikz@lib@circ@compute@direction{\tikz@lib@circ@target}}%
+ node[alias=tikz@lib@circ@node\the\tikz@lib@circ@count,at={(0,0)},#1,pos=]{}}
+ --(tikz@lib@circ@node\the\tikz@lib@circ@count)\tikztonodes
+ }%
+ \else%
+ \edef\tikz@marshal{mark=at position \tikz@lib@circ@pos\space with}%
+ \def\tikz@marshala{decoration=}%
+ \expandafter\expandafter\expandafter\tikzset%
+ \expandafter\expandafter\expandafter{\expandafter\tikz@marshala\expandafter{\tikz@marshal{\node[alias=mark node,#1,pos=]{};}}}
+ \fi%
+ \fi%
+ \else
+ \pgfkeysalso{#1}
+ \fi
+ }
+}%
+\newcount\tikz@lib@circ@count
+
+\def\tikz@lib@circ@compute@direction#1{%
+ \tikz@scan@one@point\tikz@lib@circ@save@start(\tikztostart)%
+ \tikz@scan@one@point\tikz@lib@circ@save@target(\tikztotarget)%
+ \pgf@process{\pgfpointnormalised{\pgfpointdiff{\tikz@lib@circ@start}{\tikz@lib@circ@target}}}%
+ \pgf@ya=-\pgf@y%
+ \pgftransformcm{\the\pgf@x}{\the\pgf@y}{\the\pgf@ya}{\the\pgf@x}{#1}%
+}%
+\def\tikz@lib@circ@save@start#1{\def\tikz@lib@circ@start{#1}}%
+\def\tikz@lib@circ@save@target#1{\def\tikz@lib@circ@target{#1}}%
+
+\tikzset{
+ circuits/pos grabber/.is family,
+ pos/.belongs to family=/tikz/circuits/pos grabber,
+ at start/.belongs to family=/tikz/circuits/pos grabber,
+ very near start/.belongs to family=/tikz/circuits/pos grabber,
+ near start/.belongs to family=/tikz/circuits/pos grabber,
+ midway/.belongs to family=/tikz/circuits/pos grabber,
+ near end/.belongs to family=/tikz/circuits/pos grabber,
+ very near end/.belongs to family=/tikz/circuits/pos grabber,
+ at end/.belongs to family=/tikz/circuits/pos grabber
+}%
+
+
+%
+% Declaring a new symbol
+%
+\tikzset{
+ circuit declare symbol/.style args={#1}{
+ % Declares a new circuit symbol.
+ %
+ % #1 = name
+ % #2 = factor for default minimum width
+ % #3 = factor for default minimum height
+ %
+ % The following styles are defined:
+ %
+ % #1
+ % Can be given as an option to a "node" command or to a "to"
+ % command. It takes a set of options as parameter that will be
+ % passed to the option.
+ %
+ % set #1 graphic
+ % This keys can be set to the necessary options to make a normal
+ % node look like the symbol. For instance, for a resistor that is
+ % rendered as a rectangle, this keys can be set, basically, to
+ % "rectangle,draw". Set this key to use a different appearance for
+ % symbols of kind #1.
+ %
+ % every #1
+ % This style will be included with every symbols of this kind and
+ % can be used to configure them further.
+ %
+ % every circuit symbol
+ % This style is also included with every symbol.
+ #1/.style={circuit handle symbol={
+ inner sep=0.5pt,
+ every circuit symbol,
+ #1/graphic,
+ every #1/.try,
+ ##1}
+ },
+ #1/graphic/.style={},
+ set #1 graphic/.style={#1/graphic/.style={##1}}
+ },
+ circuit symbol unit/.code=\pgfmathsetlength\tikzcircuitssizeunit{#1},
+ circuit symbol size/.style args={width #1 height #2}{
+ minimum width={(#1)*\tikzcircuitssizeunit},
+ minimum height={(#2)*\tikzcircuitssizeunit}
+ },
+ huge circuit symbols/.style={circuit symbol unit=10pt},
+ large circuit symbols/.style={circuit symbol unit=8pt},
+ medium circuit symbols/.style={circuit symbol unit=7pt},
+ small circuit symbols/.style={circuit symbol unit=6pt},
+ tiny circuit symbols/.style={circuit symbol unit=5pt},
+}%
+
+\newdimen\tikzcircuitssizeunit
+\tikzcircuitssizeunit=7pt
+
+
+%
+% Annotations
+%
+
+\tikzset{
+ circuit declare annotation/.style args={#1#2#3}{%
+ #1/.style={
+ append after command={%
+ \bgroup
+ [current point is local=true]
+ [every circuit annotation/.try]
+ [every #1/.try]
+ [shift={(\tikzlastnode.north)}]
+ [annotation arrow,->]
+ [label distance=#2,##1]
+ #3
+ \tikz@after@path%
+ \egroup%
+ }
+ },
+ #1'/.style={
+ append after command={%
+ \bgroup
+ [current point is local=true]
+ [every circuit annotation/.try]
+ [every #1/.try]
+ [shift={(\tikzlastnode.south)},yscale=-1]
+ [annotation arrow,->]
+ [label distance=#2,##1]
+ #3
+ \tikz@after@path%
+ \egroup%
+ }
+ }
+ },
+ annotation arrow/.style = {
+ /utils/exec={\pgfsetarrowoptions{direction ee}{.4*\the\tikzcircuitssizeunit+.3*\the\pgflinewidth}},
+ >=direction ee
+ }
+}%
+
+
+
+%
+% Rotating symbols
+%
+\tikzset{
+ point up/.style={rotate=90},
+ point down/.style={rotate=-90},
+ point left/.style={rotate=180},
+ point right/.style={}
+}%
+
+
+
+%
+% Basic theming
+%
+
+\tikzset{
+ every circuit symbol/.style={},
+ circuit symbol open/.style={draw},
+ circuit symbol filled/.style={draw,fill=black},
+ circuit symbol lines/.style={draw},
+ circuit symbol wires/.style={draw},
+}%
+
+
+
+
+
+%
+% Labels
+%
+
+\tikzset{
+ info/.code={\pgfutil@ifnextchar[\tikz@lib@circ@lab@plain{\tikz@lib@circ@lab@plain[]}#1\pgf@stop},%}
+ info'/.code={\pgfutil@ifnextchar[\tikz@lib@circ@labp@plain{\tikz@lib@circ@labp@plain[]}#1\pgf@stop},%}
+ info sloped/.code={\pgfutil@ifnextchar[\tikz@lib@circ@lab@sloped@plain{\tikz@lib@circ@lab@sloped@plain[]}#1\pgf@stop},%}
+ info' sloped/.code={\pgfutil@ifnextchar[\tikz@lib@circ@lab@slopedp@plain{\tikz@lib@circ@lab@slopedp@plain[]}#1\pgf@stop},%}
+ circuit declare unit/.style 2 args={
+ %
+ % Defines four styles that can be used to add labels to a node.
+ %
+ #1/.code={\pgfutil@ifnextchar[\tikz@lib@circ@lab{\tikz@lib@circ@lab[]}##1\pgf@stop{#2}{#1}},%}
+ #1 sloped/.code={\pgfutil@ifnextchar[\tikz@lib@circ@lab@sloped{\tikz@lib@circ@lab@sloped[]}##1\pgf@stop{#2}{#1}},%}
+ #1'/.code={\pgfutil@ifnextchar[\tikz@lib@circ@labp{\tikz@lib@circ@labp[]}##1\pgf@stop{#2}{#1}},%}
+ #1' sloped/.code={\pgfutil@ifnextchar[\tikz@lib@circ@lab@slopedp{\tikz@lib@circ@lab@slopedp[]}##1\pgf@stop{#2}{#1}}%}
+ }
+}%
+
+\def\tikz@lib@circ@lab[#1]#2\pgf@stop#3#4{\tikzset{label={[every info/.try,every #4/.try,#1]$\mathrm{#2#3}$}}}%
+\def\tikz@lib@circ@lab@sloped[#1]#2\pgf@stop#3#4{\tikzset{label={[every info/.try,every #4/.try,transform shape,#1]$\mathrm{#2#3}$}}}%
+\def\tikz@lib@circ@labp[#1]#2\pgf@stop#3#4{\tikzset{label={[label position=below,every info/.try,every #4/.try,#1]$\mathrm{#2#3}$}}}%
+\def\tikz@lib@circ@lab@slopedp[#1]#2\pgf@stop#3#4{\tikzset{label={[label position=below,every info/.try,every #4/.try,transform shape,#1]$\mathrm{#2#3}$}}}%
+
+\def\tikz@lib@circ@lab@plain[#1]#2\pgf@stop{\tikzset{label={[every info/.try,#1]#2}}}%
+\def\tikz@lib@circ@lab@sloped@plain[#1]#2\pgf@stop{\tikzset{label={[every info/.try,transform shape,#1]#2}}}%
+\def\tikz@lib@circ@labp@plain[#1]#2\pgf@stop{\tikzset{label={[label position=below,every info/.try,#1]#2}}}%
+\def\tikz@lib@circ@lab@slopedp@plain[#1]#2\pgf@stop{\tikzset{label={[label position=below,every info/.try,transform shape,#1]#2}}}%
+
+
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/circuits/tikzlibrarycircuits.ee.IEC.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/circuits/tikzlibrarycircuits.ee.IEC.code.tex
new file mode 100644
index 0000000000..9d1cfcfcea
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/circuits/tikzlibrarycircuits.ee.IEC.code.tex
@@ -0,0 +1,442 @@
+% Copyright 2019 by Till Tantau and others 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.
+
+\usetikzlibrary{arrows}%
+\usetikzlibrary{circuits.ee}%
+
+\usepgflibrary{shapes.gates.ee.IEC}%
+
+
+%
+% When this lib is loaded, all symbols default to IEC
+%
+
+\tikzset{
+ circuit ee IEC/.style=
+ {
+ circuit ee,
+ set resistor graphic = resistor IEC graphic,
+ set inductor graphic = inductor IEC graphic,
+ set capacitor graphic = capacitor IEC graphic,
+ set contact graphic = contact IEC graphic,
+ set ground graphic = ground IEC graphic,
+ set battery graphic = battery IEC graphic,
+ set diode graphic = diode IEC graphic,
+ set Zener diode graphic = Zener diode IEC graphic,
+ set tunnel diode graphic = tunnel diode IEC graphic,
+ set backward diode graphic = backward diode IEC graphic,
+ set Schottky diode graphic = Schottky diode IEC graphic,
+ set breakdown diode graphic = breakdown diode IEC graphic,
+ set bulb graphic = bulb IEC graphic,
+ set voltage source graphic = voltage source IEC graphic,
+ set current source graphic = current source IEC graphic,
+ set make contact graphic = make contact IEC graphic,
+ set break contact graphic = break contact IEC graphic,
+ set amperemeter graphic = amperemeter graphic,
+ set voltmeter graphic = voltmeter graphic,
+ set ohmmeter graphic = ohmmeter graphic,
+ set ac source graphic = ac source graphic,
+ set dc source graphic = dc source graphic,
+ },
+}%
+
+
+%
+% Resistors
+%
+
+\tikzset{
+ resistor IEC graphic/.style={
+ circuit symbol open,
+ circuit symbol size=width 4 height 1,
+ shape=rectangle ee,
+ transform shape,
+ },
+ var resistor IEC graphic/.style={
+ circuit symbol lines,
+ circuit symbol size=width 4.8 height 0.8,
+ shape=var resistor IEC,
+ transform shape,
+ outer sep=0pt,
+ cap=round,
+ },
+}%
+
+
+
+%
+% Inductors
+%
+
+\tikzset{
+ inductor IEC graphic/.style={
+ circuit symbol lines,
+ circuit symbol size=width 4 height .5,
+ transform shape,
+ shape=inductor IEC,
+ outer sep=0pt,
+ cap=round,
+ },
+ var inductor IEC graphic/.style={
+ circuit symbol filled,
+ circuit symbol size=width 4 height 1,
+ transform shape,
+ shape=rectangle ee,
+ },
+}%
+
+
+
+%
+% Capacitors
+%
+
+\tikzset{
+ capacitor IEC graphic/.style={
+ circuit symbol lines,
+ circuit symbol size=width .5 height 2,
+ transform shape,
+ shape=capacitor IEC,
+ },
+}%
+
+
+
+%
+% Ground
+%
+
+\tikzset{
+ ground IEC graphic/.style={
+ circuit symbol lines,
+ circuit symbol size=width .75 height 2,
+ transform shape,
+ shape=ground IEC,
+ },
+}%
+
+
+
+
+%
+% Battery
+%
+
+\tikzset{
+ battery IEC graphic/.style={
+ circuit symbol lines,
+ circuit symbol size=width .5 height 2.5,
+ transform shape,
+ shape=battery IEC,
+ transform shape,
+ },
+}%
+
+
+
+%
+% Diodes
+%
+
+\tikzset{
+ %
+ % normal diode
+ %
+ diode IEC graphic/.style={
+ circuit symbol open,
+ circuit symbol size=width 1.25 height 1.25,
+ transform shape,
+ shape=generic diode IEC,
+ /pgf/generic diode IEC/before background={
+ \pgfpathmoveto{\pgfqpoint{0pt}{-1pt}}
+ \pgfpathlineto{\pgfqpoint{0pt}{1pt}}
+ \pgfusepathqstroke
+ },
+ },
+ var diode IEC graphic/.style={
+ diode IEC graphic,
+ circuit symbol filled,
+ },
+}%
+
+\tikzset{
+ %
+ % Zener diode
+ %
+ Zener diode IEC graphic/.style={
+ diode IEC graphic,
+ /pgf/generic diode IEC/before background={
+ \pgfpathmoveto{\pgfqpoint{-.5pt}{-1pt}}
+ \pgfpathlineto{\pgfqpoint{0pt}{-1pt}}
+ \pgfpathlineto{\pgfqpoint{0pt}{1pt}}
+ \pgfusepathqstroke
+ },
+ },
+ var Zener diode IEC graphic/.style={
+ Zener diode IEC graphic,
+ circuit symbol filled,
+ },
+}%
+
+\tikzset{
+ %
+ % Schottky diode
+ %
+ Schottky diode IEC graphic/.style={
+ diode IEC graphic,
+ /pgf/generic diode IEC/before background={
+ \pgfpathmoveto{\pgfqpoint{-.4pt}{-.6pt}}
+ \pgfpathlineto{\pgfqpoint{-.4pt}{-1pt}}
+ \pgfpathlineto{\pgfqpoint{0pt}{-1pt}}
+ \pgfpathlineto{\pgfqpoint{0pt}{1pt}}
+ \pgfpathlineto{\pgfqpoint{.4pt}{1pt}}
+ \pgfpathlineto{\pgfqpoint{.4pt}{.6pt}}
+ \pgfusepathqstroke
+ },
+ },
+ var Schottky diode IEC graphic/.style={
+ Schottky diode IEC graphic,
+ circuit symbol filled,
+ },
+}%
+
+\tikzset{
+ %
+ % tunnel diode
+ %
+ tunnel diode IEC graphic/.style={
+ diode IEC graphic,
+ /pgf/generic diode IEC/before background={
+ \pgfpathmoveto{\pgfqpoint{-.5pt}{-1pt}}
+ \pgfpathlineto{\pgfqpoint{0pt}{-1pt}}
+ \pgfpathlineto{\pgfqpoint{0pt}{1pt}}
+ \pgfpathlineto{\pgfqpoint{-.5pt}{1pt}}
+ \pgfusepathqstroke
+ },
+ },
+ var tunnel diode IEC graphic/.style={
+ tunnel diode IEC graphic,
+ circuit symbol filled,
+ },
+}%
+
+\tikzset{
+ %
+ % backward diode
+ %
+ backward diode IEC graphic/.style={
+ diode IEC graphic,
+ /pgf/generic diode IEC/before background={
+ \pgfpathmoveto{\pgfqpoint{-.5pt}{-1pt}}
+ \pgfpathlineto{\pgfqpoint{.5pt}{-1pt}}
+ \pgfpathmoveto{\pgfqpoint{0pt}{-1pt}}
+ \pgfpathlineto{\pgfqpoint{0pt}{1pt}}
+ \pgfpathmoveto{\pgfqpoint{-.5pt}{1pt}}
+ \pgfpathlineto{\pgfqpoint{.5pt}{1pt}}
+ \pgfusepathqstroke
+ },
+ },
+ var backward diode IEC graphic/.style={
+ backward diode IEC graphic,
+ circuit symbol filled,
+ },
+}%
+
+
+\tikzset{
+ %
+ % breakdown diode
+ %
+ breakdown diode IEC graphic/.style={
+ circuit symbol open,
+ circuit symbol size=width 2.5 height 1.25,
+ transform shape,
+ shape=breakdown diode IEC,
+ },
+ var breakdown diode IEC graphic/.style={
+ breakdown diode IEC graphic,
+ circuit symbol filled,
+ },
+}%
+
+
+
+%
+% Contacts
+%
+
+\tikzset{
+ contact IEC graphic/.style={
+ circuit symbol filled,
+ circuit symbol size=width .5 height .5,
+ shape=circle ee,
+ outer sep=.25\pgflinewidth,
+ },
+% connection IEC graphic/.style={
+% circuit symbol open,
+% circuit symbol size=width 1 height 1,
+% shape=circle ee,
+% outer sep=.25\pgflinewidth,
+% },
+}%
+
+
+%
+% Bulbs
+%
+
+\tikzset{
+ bulb IEC graphic/.style={
+ circuit symbol lines,
+ circuit symbol size=width 1.5 height 1.5,
+ shape=generic circle IEC,
+ /pgf/generic circle IEC/before background={
+ \pgfpathmoveto{\pgfpointpolar{-135}{1pt}}
+ \pgfpathlineto{\pgfpointpolar{45}{1pt}}
+ \pgfpathmoveto{\pgfpointpolar{-45}{1pt}}
+ \pgfpathlineto{\pgfpointpolar{135}{1pt}}
+ \pgfusepathqstroke
+ },
+ transform shape,
+ },
+}%
+
+
+%
+% Current and voltage sources
+%
+
+\tikzset{
+ current source IEC graphic/.style={
+ circuit symbol lines,
+ circuit symbol size=width 2 height 2,
+ shape=generic circle IEC,
+ /pgf/generic circle IEC/before background={
+ \pgfpathmoveto{\pgfqpoint{0pt}{-1pt}}
+ \pgfpathlineto{\pgfqpoint{0pt}{1pt}}
+ \pgfusepathqstroke
+ },
+ transform shape,
+ },
+ voltage source IEC graphic/.style={
+ circuit symbol lines,
+ circuit symbol size=width 2 height 2,
+ shape=generic circle IEC,
+ /pgf/generic circle IEC/before background={
+ \pgfpathmoveto{\pgfqpoint{-1pt}{0pt}}
+ \pgfpathlineto{\pgfqpoint{1pt}{0pt}}
+ \pgfusepathqstroke
+ },
+ transform shape,
+ },
+}%
+
+
+
+%
+% Contacts
+%
+
+\tikzset{
+ make contact IEC graphic/.style={
+ circuit symbol wires,
+ circuit symbol size=width 2 height 1,
+ transform shape,
+ shape=make contact IEC,
+ outer sep=0pt,
+ cap=round,
+ },
+ var make contact IEC graphic/.style={
+ circuit symbol wires,
+ circuit symbol size=width 2.4 height 1,
+ transform shape,
+ shape=var make contact IEC,
+ outer sep=0pt,
+ cap=round,
+ },
+}%
+
+
+\tikzset{
+ break contact IEC graphic/.style={
+ circuit symbol wires,
+ circuit symbol size=width 2 height 1,
+ transform shape,
+ shape=break contact IEC,
+ outer sep=0pt,
+ cap=round,
+ },
+}%
+
+
+
+%
+% Measurement devices
+%
+
+\tikzset{
+ amperemeter graphic/.style={
+ circuit symbol open,
+ circuit symbol size=width 2 height 2,
+ transform shape,
+ shape=generic circle IEC,
+ info=center:A,
+ },
+ voltmeter graphic/.style={
+ circuit symbol open,
+ circuit symbol size=width 2 height 2,
+ transform shape,
+ shape=generic circle IEC,
+ info=center:V,
+ },
+ ohmmeter graphic/.style={
+ circuit symbol open,
+ circuit symbol size=width 2 height 2,
+ transform shape,
+ shape=generic circle IEC,
+ info=center:$\Omega$,
+ },
+}%
+
+
+
+%
+% AC/DC
+%
+
+\tikzset{
+ ac source graphic/.style={
+ circuit symbol lines,
+ circuit symbol size=width 2 height 2,
+ shape=generic circle IEC,
+ /pgf/generic circle IEC/before background={
+ \pgfpathmoveto{\pgfqpoint{0.7pt}{0pt}}
+ \pgfpathquadraticcurveto{\pgfqpoint{ 0.35pt}{-0.5pt}}{\pgfqpoint{0pt}{0pt}}
+ \pgfpathquadraticcurveto{\pgfqpoint{-0.35pt}{ 0.5pt}}{\pgfqpoint{-0.7pt}{0pt}}
+ \pgfusepathqstroke
+ },
+ transform shape,
+ },
+ dc source graphic/.style={
+ circuit symbol lines,
+ circuit symbol size=width 2 height 2,
+ shape=generic circle IEC,
+ /pgf/generic circle IEC/before background={
+ \pgfpathmoveto{\pgfqpoint{ 0.7pt}{ 0.2pt}}
+ \pgfpathlineto{\pgfqpoint{-0.7pt}{ 0.2pt}}
+ \pgfusepathqstroke
+ \pgfpathmoveto{\pgfqpoint{ 0.7pt}{-0.2pt}}
+ \pgfpathlineto{\pgfqpoint{-0.7pt}{-0.2pt}}
+ \pgfusepathqstroke
+ },
+ transform shape,
+ },
+}%
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/circuits/tikzlibrarycircuits.ee.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/circuits/tikzlibrarycircuits.ee.code.tex
new file mode 100644
index 0000000000..2e065d7dda
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/circuits/tikzlibrarycircuits.ee.code.tex
@@ -0,0 +1,148 @@
+
+% Copyright 2019 by Till Tantau and others 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.
+
+\usetikzlibrary{circuits}%
+\usepgflibrary{shapes.gates.ee}%
+
+
+%
+% Setting up an ee circuit
+%
+\tikzset{
+ circuit ee/.style={
+ circuit,
+ every circuit ee/.try
+ }
+}%
+
+
+%
+% The default symbols (you need to load a sublib to install the actual rendering).
+%
+
+\tikzset{
+ circuit declare symbol = resistor,
+ circuit declare symbol = inductor,
+ circuit declare symbol = capacitor,
+ circuit declare symbol = contact,
+ circuit declare symbol = ground,
+ circuit declare symbol = battery,
+ circuit declare symbol = diode,
+ circuit declare symbol = Zener diode,
+ circuit declare symbol = Schottky diode,
+ circuit declare symbol = tunnel diode,
+ circuit declare symbol = backward diode,
+ circuit declare symbol = breakdown diode,
+ circuit declare symbol = bulb,
+ circuit declare symbol = current source,
+ circuit declare symbol = voltage source,
+ circuit declare symbol = current direction,
+ circuit declare symbol = current direction',
+ circuit declare symbol = make contact,
+ circuit declare symbol = break contact,
+ circuit declare symbol = amperemeter,
+ circuit declare symbol = voltmeter,
+ circuit declare symbol = ohmmeter,
+ circuit declare symbol = ac source,
+ circuit declare symbol = dc source,
+ %
+ set current direction graphic = current direction ee graphic,
+ set current direction' graphic = current direction' ee graphic,
+}%
+
+
+%
+% The default labels
+%
+
+\tikzset{
+ circuit declare unit={ampere}{A},
+ circuit declare unit={volt}{V},
+ circuit declare unit={ohm}{\Omega},
+ circuit declare unit={siemens}{S},
+ circuit declare unit={henry}{H},
+ circuit declare unit={farad}{F},
+ circuit declare unit={coulomb}{C},
+ circuit declare unit={voltampere}{VA},
+ circuit declare unit={watt}{W},
+ circuit declare unit={hertz}{Hz},
+}%
+
+
+
+%
+% The direction and arrow settings
+%
+
+\tikzset{
+ % These styles should set the end-arrow.
+ %
+ % This arrow will generally be used to indicate current directions in a circuit:
+ current direction arrow/.style = {
+ /utils/exec={\pgfsetarrowoptions{direction ee}{1.3065*.5*\the\tikzcircuitssizeunit+1.3065*.3*\the\pgflinewidth}},
+ >=direction ee,
+ direction ee arrow = direction ee,
+ }
+}%
+
+
+
+
+\tikzset{
+ current direction ee graphic/.style = {
+ shape=direction ee,
+ circuit symbol filled,
+ current direction arrow,
+ minimum width = .5*\the\tikzcircuitssizeunit+.3*\the\pgflinewidth,
+ minimum height = .5*\the\tikzcircuitssizeunit+.3*\the\pgflinewidth,
+ transform shape
+ },
+ current direction' ee graphic/.style = {
+ current direction ee graphic,
+ rotate=180
+ }
+}%
+
+
+
+%
+% Annotations
+%
+
+\tikzset{
+ circuit declare annotation={direction info}{.5\tikzcircuitssizeunit}
+ {
+ (-1.25\tikzcircuitssizeunit,.3333\tikzcircuitssizeunit) edge[line to] (1.25\tikzcircuitssizeunit,.3333\tikzcircuitssizeunit)
+ },
+ circuit declare annotation={light emitting}{1.75\tikzcircuitssizeunit}
+ {
+ (-.2\tikzcircuitssizeunit,.65\tikzcircuitssizeunit) edge[line to] ++(45:1.25\tikzcircuitssizeunit)
+ (.2\tikzcircuitssizeunit,.25\tikzcircuitssizeunit) edge[line to] ++(45:1.25\tikzcircuitssizeunit)
+ },
+ circuit declare annotation={light dependent}{1.75\tikzcircuitssizeunit}
+ {
+ [shift=(135:1.25\tikzcircuitssizeunit)]
+ (.2\tikzcircuitssizeunit,.65\tikzcircuitssizeunit) edge[line to] ++(-45:1.25\tikzcircuitssizeunit)
+ (-.2\tikzcircuitssizeunit,.25\tikzcircuitssizeunit) edge[line to] ++(-45:1.25\tikzcircuitssizeunit)
+ },
+ circuit declare annotation={adjustable}{1.5\tikzcircuitssizeunit}
+ {
+ [shift=(\tikzlastnode.center)]
+ (-1.5\tikzcircuitssizeunit,-1.5\tikzcircuitssizeunit) edge[line to] (1.5\tikzcircuitssizeunit,1.5\tikzcircuitssizeunit)
+ },
+ circuit declare annotation={adjustable'}{1.5\tikzcircuitssizeunit}
+ {
+ [shift=(\tikzlastnode.center)]
+ (-1.5\tikzcircuitssizeunit,1.5\tikzcircuitssizeunit) edge[line to] (1.5\tikzcircuitssizeunit,-1.5\tikzcircuitssizeunit)
+ }
+}%
+
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/circuits/tikzlibrarycircuits.logic.CDH.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/circuits/tikzlibrarycircuits.logic.CDH.code.tex
new file mode 100644
index 0000000000..743bc24be8
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/circuits/tikzlibrarycircuits.logic.CDH.code.tex
@@ -0,0 +1,28 @@
+% Copyright 2018 by Till Tantau and others 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.
+
+\usetikzlibrary{circuits.logic.US}%
+
+\tikzset{
+ circuit logic CDH/.style =
+ {
+ circuit logic US,
+ set and gate graphic = and gate CDH graphic,
+ set nand gate graphic = nand gate CDH graphic,
+ }
+}%
+
+\tikzset{
+ circuit logic US make graphic=and gate CDH,
+ circuit logic US make graphic=nand gate CDH,
+}%
+
+
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/circuits/tikzlibrarycircuits.logic.IEC.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/circuits/tikzlibrarycircuits.logic.IEC.code.tex
new file mode 100644
index 0000000000..3d74ccd197
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/circuits/tikzlibrarycircuits.logic.IEC.code.tex
@@ -0,0 +1,75 @@
+% Copyright 2018 by Till Tantau and others 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.
+
+\usetikzlibrary{circuits.logic}%
+\usepgflibrary{shapes.gates.logic.IEC}%
+
+
+%
+% When this lib is loaded, all symbols default to IEC
+%
+
+\tikzset{
+ circuit logic IEC/.style=
+ {
+ circuit logic,
+ set and gate graphic = and gate IEC graphic,
+ set nand gate graphic = nand gate IEC graphic,
+ set or gate graphic = or gate IEC graphic,
+ set nor gate graphic = nor gate IEC graphic,
+ set xor gate graphic = xor gate IEC graphic,
+ set xnor gate graphic = xnor gate IEC graphic,
+ set not gate graphic = not gate IEC graphic,
+ set buffer gate graphic = buffer gate IEC graphic,
+ %
+ and gate IEC symbol = {$\scriptstyle\char`\&$},
+ nand gate IEC symbol = {$\scriptstyle\char`\&$},
+ or gate IEC symbol = {$\scriptstyle\geq1$},
+ nor gate IEC symbol = {$\scriptstyle\geq1$},
+ xor gate IEC symbol = {$\scriptstyle=1$},
+ xnor gate IEC symbol = {$\scriptstyle=1$},
+ not gate IEC symbol = {$\scriptstyle1$},
+ buffer gate IEC symbol = {$\scriptstyle1$},
+ },
+}%
+
+
+%
+% The logical gate graphics are all nearly identical, so we provide a
+% simple style for creating them:
+%
+\tikzset{
+ circuit logic IEC make graphic/.style=
+ {
+ #1 graphic/.style={
+ circuit symbol open,
+ circuit symbol size=width 2.5 height 4,
+ shape=#1,
+ inner sep=.5ex
+ }
+ }
+}%
+
+
+\tikzset{
+ circuit logic IEC make graphic=and gate IEC,
+ circuit logic IEC make graphic=nand gate IEC,
+ circuit logic IEC make graphic=or gate IEC,
+ circuit logic IEC make graphic=nor gate IEC,
+ circuit logic IEC make graphic=xor gate IEC,
+ circuit logic IEC make graphic=xnor gate IEC,
+ circuit logic IEC make graphic=not gate IEC,
+ circuit logic IEC make graphic=buffer gate IEC,
+ circuit logic IEC make graphic=and gate CDH,
+ circuit logic IEC make graphic=nand gate CDH,
+}%
+
+
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/circuits/tikzlibrarycircuits.logic.US.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/circuits/tikzlibrarycircuits.logic.US.code.tex
new file mode 100644
index 0000000000..b20b4d58ba
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/circuits/tikzlibrarycircuits.logic.US.code.tex
@@ -0,0 +1,64 @@
+% Copyright 2018 by Till Tantau and others 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.
+
+\usetikzlibrary{circuits.logic}%
+\usepgflibrary{shapes.gates.logic.US}%
+
+
+%
+% When this lib is loaded, all symbols default to IEC
+%
+
+\tikzset{
+ circuit logic US/.style=
+ {
+ circuit logic,
+ set and gate graphic = and gate US graphic,
+ set nand gate graphic = nand gate US graphic,
+ set or gate graphic = or gate US graphic,
+ set nor gate graphic = nor gate US graphic,
+ set xor gate graphic = xor gate US graphic,
+ set xnor gate graphic = xnor gate US graphic,
+ set not gate graphic = not gate US graphic,
+ set buffer gate graphic = buffer gate US graphic
+ }
+}%
+
+
+%
+% The logical gate graphics are all nearly identical, so we provide a
+% simple style for creating them:
+%
+\tikzset{
+ circuit logic US make graphic/.style=
+ {
+ #1 graphic/.style={
+ circuit symbol open,
+ circuit symbol size=width 0 height 2.5,
+ shape=#1,
+ transform shape
+ }
+ }
+}%
+
+
+\tikzset{
+ circuit logic US make graphic=and gate US,
+ circuit logic US make graphic=nand gate US,
+ circuit logic US make graphic=or gate US,
+ circuit logic US make graphic=nor gate US,
+ circuit logic US make graphic=xor gate US,
+ circuit logic US make graphic=xnor gate US,
+ circuit logic US make graphic=not gate US,
+ circuit logic US make graphic=buffer gate US,
+}%
+
+
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/circuits/tikzlibrarycircuits.logic.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/circuits/tikzlibrarycircuits.logic.code.tex
new file mode 100644
index 0000000000..390d022a8a
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/circuits/tikzlibrarycircuits.logic.code.tex
@@ -0,0 +1,45 @@
+% 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.
+
+\usetikzlibrary{circuits}%
+
+
+
+%
+% Provides a shortcut to the "logic gates inputs" key.
+%
+
+\tikzset{
+ circuit logic/.style={
+ circuit,
+ inputs/.style={logic gate inputs={##1}},
+ logic gate inverted radius=.25\tikzcircuitssizeunit,
+ every circuit logic/.try,
+ }
+}%
+
+
+
+%
+% The default symbols (you need to load a sublib to install the actual rendering).
+%
+
+\tikzset{
+ circuit declare symbol = and gate,
+ circuit declare symbol = nand gate,
+ circuit declare symbol = or gate,
+ circuit declare symbol = nor gate,
+ circuit declare symbol = xor gate,
+ circuit declare symbol = xnor gate,
+ circuit declare symbol = not gate,
+ circuit declare symbol = buffer gate
+}%
+
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/datavisualization/tikzlibrarydatavisualization.3d.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/datavisualization/tikzlibrarydatavisualization.3d.code.tex
new file mode 100644
index 0000000000..df08b507d5
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/datavisualization/tikzlibrarydatavisualization.3d.code.tex
@@ -0,0 +1,79 @@
+% Copyright 2018 by Till Tantau
+%
+% 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{tikzlibrarydatavisualization.3d.code.tex}
+
+\usetikzlibrary{datavisualization}%
+
+
+
+% The following is not yet really implement. But you might get the idea...
+
+
+
+% A 3d version of the school book plot
+
+\tikzdatavisualizationset{
+ school book 3d plot/.style={
+ xyz Cartesian,
+ x axis={
+ visualize axis={y axis={goto=0},z axis={goto=0},styling/.style=->},
+ visualize ticks={common={y axis={goto=0},z axis={goto=0},direction axis=y axis},only ticks={tick text at min extend}},
+% visualize ticks={common={y axis={goto=0},z axis={goto=0},direction axis=z axis}},
+ },
+ y axis={
+ visualize axis={x axis={goto=0},z axis={goto=0},styling/.style=->},
+ visualize ticks={common={x axis={goto=0},z axis={goto=0},direction axis=x axis},only ticks={tick text at min extend}},
+% visualize ticks={common={x axis={goto=0},z axis={goto=0},direction axis=z axis}},
+ },
+ z axis={
+ visualize axis={x axis={goto=0},y axis={goto=0},styling/.style=->},
+ visualize ticks={common={x axis={goto=0},y axis={goto=0},direction axis=x axis},only ticks={tick text at min extend}},
+% visualize ticks={common={x axis={goto=0},y axis={goto=0},direction axis=y axis}}
+ },
+ new line plot,
+ every school book plot/.try,
+ },
+}%
+
+
+% A 3d version of the scientific plot
+%
+% Here, a "length" is used for the length of the three
+% axes, rather than a predetermined rectangle (this does not really
+% make sense for the z-axis. You overrule these settings easily.
+
+\tikzdatavisualizationset{
+ scientific 3d plot/length/.initial=100pt,
+ scientific 3d plot/.style={
+ xyz Cartesian,
+ x axis={
+ length=\pgfkeysvalueof{/tikz/data visualization/scientific 3d plot/length},
+ visualize axis={y axis={goto=min},z axis={goto=min}},
+ visualize axis={y axis={goto=max},z axis={goto=min}},
+ visualize axis={y axis={goto=min},z axis={goto=max}},
+ visualize axis={y axis={goto=max},z axis={goto=max}},
+ },
+ y axis={
+ length=\pgfkeysvalueof{/tikz/data visualization/scientific 3d plot/length},
+ visualize axis={x axis={goto=min},z axis={goto=min}},
+ visualize axis={x axis={goto=max},z axis={goto=min}},
+ visualize axis={x axis={goto=min},z axis={goto=max}},
+ visualize axis={x axis={goto=max},z axis={goto=max}},
+ },
+ z axis={
+ length=\pgfkeysvalueof{/tikz/data visualization/scientific 3d plot/length},
+ visualize axis={x axis={goto=min},y axis={goto=min}},
+ visualize axis={x axis={goto=max},y axis={goto=min}},
+ visualize axis={x axis={goto=min},y axis={goto=max}},
+ visualize axis={x axis={goto=max},y axis={goto=max}},
+ },
+ new line plot,
+ },
+}%
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/datavisualization/tikzlibrarydatavisualization.barcharts.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/datavisualization/tikzlibrarydatavisualization.barcharts.code.tex
new file mode 100644
index 0000000000..3780a4638a
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/datavisualization/tikzlibrarydatavisualization.barcharts.code.tex
@@ -0,0 +1,43 @@
+% Copyright 2018 by Till Tantau
+%
+% 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{tikzlibrarydatavisualization.barcharts.code.tex}
+
+\usetikzlibrary{datavisualization}%
+\usepgflibrary{datavisualization.barcharts}%
+
+
+\tikzdatavisualizationset{%
+ candle stick plot/.style={
+ new object={
+ store=/tikz/data visualization/count,
+ class=count,
+ arg1=day
+ },
+ new axis=y axis,
+ y axis/source=dax,
+ y axis/source max=100,
+ y axis/vec=\pgfqpoint{0cm}{1cm},
+ new object={
+ store=/tikz/data visualization/x line trans,
+ class=line transformer,
+ arg1=day,
+ arg2=\pgfqpoint{3mm}{0mm}
+ },
+ new object={
+ store=/tikz/data visualization/index,
+ class=candle stick visualizer,
+ arg1 from key=index/source
+ },
+ },
+ index/source/.initial=index,
+}%
+
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/datavisualization/tikzlibrarydatavisualization.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/datavisualization/tikzlibrarydatavisualization.code.tex
new file mode 100644
index 0000000000..04dae1e6b5
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/datavisualization/tikzlibrarydatavisualization.code.tex
@@ -0,0 +1,2733 @@
+% Copyright 2019 by Till Tantau
+%
+% 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{tikzlibrarydatavisualization.code.tex}
+
+\usepgfmodule{datavisualization}%
+\usetikzlibrary{backgrounds}%
+
+
+\tikzset{/tikz/data visualization/.is family,
+ /tikz/data visualization/.unknown/.code={
+ \let\tikz@dv@key\pgfkeyscurrentname%
+ \pgfkeys{/tikz/\tikz@dv@key/.try={#1}}%
+ \ifpgfkeyssuccess%
+ \else%
+ \edef\pgf@temp{/errors/unknown key={/tikz/data visualization/\tikz@dv@key}}%
+ \expandafter\pgfkeys\expandafter{\pgf@temp{#1}}%
+ \fi%
+ },
+ /tikz/data visualization/data/.unknown/.code={%
+ % Redirect to /pgf/data
+ \let\tikz@dv@key\pgfkeyscurrentname%
+ \pgfkeys{/pgf/data/\tikz@dv@key/.try={#1}}%
+ \ifpgfkeyssuccess%
+ \else%
+ \edef\pgf@temp{/errors/unknown key={/pgf/data/\tikz@dv@key}}%
+ \expandafter\pgfkeys\expandafter{\pgf@temp{#1}}%
+ \fi%
+ },
+}%
+
+\def\tikzdatavisualizationset{\pgfqkeys{/tikz/data visualization}}%
+
+
+
+
+% The main \datavisualization command
+%
+% This command must, as always, be given inside a tikz picture. It
+% will add a data visualization to the picture; use "shift" option and
+% friends to place the data visualization somewhere other than at the
+% origin.
+%
+% The \datavisualization is followed by a sequence of blocks and ended
+% with a semicolon. Each block may be one of the following:
+%
+% "data" blocks.
+%
+% Syntax: data [options] % options specify an external source
+% Syntax: data [options] { inline data }
+%
+% The optional arguments may either specify an
+% external data source or the data may follow inline.
+%
+% The options are executed for the path /pgf/data. The style
+% /tikz/every data is executed for each data, which can be useful to
+% generally set, say, a certain data format.
+%
+%
+% "data set" blocks.
+%
+% Syntax: data set [options] {name} = { ... }
+% Syntax: data set [options] {name} += { ... }
+% Syntax: data set [options] {name}
+%
+% The first syntax allows you to define a data set. The data block
+% inside {...} will be stored inside the data set
+% "name". Subsequently, the data set can be referenced by using the
+% third syntax. The second syntax allows you to extend the
+% definition of an already defined data set.
+%
+%
+% "info" and "info'" blocks.
+%
+% Syntax: info [options] {code}
+% Syntax: info' [options] {code}
+%
+% A block starting with "info" or "info'" may contain any code. It
+% will be executed after the visualization (info) or before the
+% visualization (info').
+%
+%
+% Options blocks.
+%
+% Syntax: [options]
+%
+% The options will be executed immediately.
+%
+% Scope blocks.
+%
+% Syntax: scope[options] { blocks }
+%
+% The blocks are executed inside a scope for which the options are
+% set. This can be used to group data blocks.
+%
+% Examples:
+%
+% \datavisualization[schoolbook plot]
+% data [source=my_data_file.csv]
+% ;
+%
+% \datavisualization[schoolbook plot]
+% data [format=key value pairs]
+% {
+% x=0, y=0
+% x=1, y=1
+% x=2, y=4
+% x=3, y=9
+% };
+%
+% \datavisualization[schoolbook plot]
+% data [format=function]
+% {
+% var x: interval [0:3];
+% func y = \value x*\value x;
+% }
+% [at begin visualization={
+% \fill [black!10] (visualization cs:x=0,y=0) -- (visualization cs:x=3,y=9);
+% }]
+% info[red]
+% {
+% \draw (visualization cs:x=0,y=0) -- (visualization cs:x=3,y=9);
+% };
+%
+% \datavisualization[schoolbook plot]
+% data [/data point/label=first experiment,source=file_1]
+% data [/data point/label=second experiment,source=file_2]
+% data [/data point/label=third experiment,source=file_3]
+% data [/data point/label=prediction,format=function]
+% { var x: interval [0,1]; func y = rand(\value x); }
+% ;
+
+\def\tikz@lib@datavisualization{
+ \begingroup%
+ \let\tikz@path@do@at@end=\relax%
+ % Ok, first, start a new data visualization
+ \pgfoonew \tikz@main@dv=new data visualization()%
+ % Next, create a scope for the dv
+ \pgfset{local bounding box=data visualization bounding box}%
+ % Clear the axis list
+ \pgfkeyslet{/tikz/data visualization/axes list}\pgfutil@empty%
+ \pgfkeyslet{/tikz/data visualization/axes actions}\pgfutil@empty%
+ \pgfkeyslet{/tikz/data visualization/label actions}\pgfutil@empty%
+ \pgfkeyslet{/tikz/data visualization/legend actions}\pgfutil@empty%
+ \pgfkeyslet{/tikz/data visualization/grid actions}\pgfutil@empty%
+ \pgfkeyslet{/tikz/data visualization/major grid actions}\pgfutil@empty%
+ \pgfkeyslet{/tikz/data visualization/minor grid actions}\pgfutil@empty%
+ \pgfkeyslet{/tikz/data visualization/subminor grid actions}\pgfutil@empty%
+ \pgfkeyslet{/tikz/data visualization/ticks actions}\pgfutil@empty%
+ \pgfkeyslet{/tikz/data visualization/major ticks actions}\pgfutil@empty%
+ \pgfkeyslet{/tikz/data visualization/minor ticks actions}\pgfutil@empty%
+ \pgfkeyslet{/tikz/data visualization/subminor ticks actions}\pgfutil@empty%
+ \tikz@main@dv.before visualization(%
+ )%
+ \tikz@main@dv.after visualization(%
+ \tikz@lib@dv@alias@dv@bb
+ \pgfkeysvalueof{/tikz/data visualization/grid actions}
+ \pgfkeysvalueof{/tikz/data visualization/subminor grid actions}
+ \pgfkeysvalueof{/tikz/data visualization/minor grid actions}
+ \pgfkeysvalueof{/tikz/data visualization/major grid actions}
+ \pgfkeysvalueof{/tikz/data visualization/ticks actions}
+ \pgfkeysvalueof{/tikz/data visualization/subminor ticks actions}
+ \pgfkeysvalueof{/tikz/data visualization/minor ticks actions}
+ \pgfkeysvalueof{/tikz/data visualization/major ticks actions}
+ \pgfkeysvalueof{/tikz/data visualization/axes actions}
+ \pgfkeysvalueof{/tikz/data visualization/label actions}
+ \pgfkeysvalueof{/tikz/data visualization/legend actions}
+ )%
+ %
+ \pgfset{/pgf/data/continue code=\tikz@lib@dv@parse@loop}%
+ % Now enter parse loop
+ \tikz@lib@dv@parse@loop
+}%
+
+\def\tikz@lib@dv@parse@loop{%
+ \pgfutil@ifnextchar d\tikz@lib@dv@handle@data{%
+ \pgfutil@ifnextchar ;\tikz@lib@dv@parse@end{%
+ \pgfutil@ifnextchar \par\tikz@lib@dv@handle@par{%
+ \pgfutil@ifnextchar s\tikz@lib@dv@handle@beginscope{%
+ \pgfutil@ifnextchar i\tikz@lib@dv@handle@info{%
+ \pgfutil@ifnextchar [\tikz@lib@dv@handle@options{%
+ \pgfutil@ifnextchar \egroup\tikz@lib@dv@handle@endscope{%
+ \tikzerror{Semicolon expected}%
+ \endgroup%
+ }%
+ }%
+ }%
+ }%
+ }%
+ }%
+ }%
+}%
+\def\tikz@lib@dv@parse@end;{%
+ % Go!
+ \tikz@main@dv.survey()%
+ \tikz@main@dv.visualize()%
+ \endgroup%
+ \tikz@path@do@at@end%
+}%
+\def\tikz@lib@dv@handle@par\par{\tikz@lib@dv@parse@loop}%
+
+\def\tikz@lib@dv@handle@options[#1]{%
+ \tikzdatavisualizationset{#1}%
+ \tikz@lib@dv@parse@loop%
+}%
+
+\def\tikz@lib@dv@handle@beginscope scope{%
+ \begingroup%
+ \pgfutil@ifnextchar[\tikz@lib@dv@beg@opt{\tikz@lib@dv@beg@opt[]}%}
+}%
+\def\tikz@lib@dv@beg@opt[#1]{%
+ \pgfkeys{/pgf/data/.cd,/pgf/every data/.try,#1}%
+ \pgf@dv@do@adddata{\pgfkeysvalueof{/pgf/data visualization/obj}.add data({{\begingroup\pgfkeys{/pgf/data/.cd,/pgf/every data/.try,#1}}})}%
+ \pgfutil@ifnextchar\bgroup{
+ \afterassignment\tikz@lib@dv@parse@loop%
+ \let\tikz@dummy=%get rid of \bgroup
+ }{%
+ \tikzerror{Opening brace expected}%
+ \tikz@lib@dv@parse@loop%
+ }%
+}%
+\def\tikz@lib@dv@handle@endscope{%
+ \pgf@dv@do@adddata{\pgfkeysvalueof{/pgf/data visualization/obj}.add data(\endgroup)}%
+ \endgroup%
+ \afterassignment\tikz@lib@dv@parse@loop%
+ \let\tikz@dummy=%get rid of \egroup
+}%
+
+\def\tikz@lib@dv@handle@data data{%
+ \pgfutil@ifnextchar g{\tikz@lib@dv@handle@data@group}{%
+ \pgfutil@ifnextchar p{\tikz@lib@dv@handle@data@point}{%
+ \pgfdata}}}%
+
+\def\tikz@lib@dv@handle@data@group group{\pgfutil@ifnextchar[{\tikz@lib@dv@handle@data@group@opt}{\tikz@lib@dv@handle@data@group@opt[]}}%}%
+
+\def\tikz@lib@dv@handle@data@group@opt[#1]#2{%
+ \pgfutil@ifnextchar={\tikz@lib@dv@handle@data@group@def{#1}{#2}}{%
+ \pgfutil@ifnextchar+{\tikz@lib@dv@handle@data@group@extend{#1}{#2}}{%
+ \tikz@lib@dv@handle@data@group@use{#1}{#2}}}}%
+
+\def\tikz@lib@dv@handle@data@group@def#1#2={%
+ \pgfkeys{/pgf/data/new group={#2}}%
+ \tikz@lib@dv@handle@data@group@extend{#1}{#2}+=%
+}%
+
+\def\tikz@lib@dv@handle@data@group@extend#1#2+={%
+ \pgfutil@ifnextchar\bgroup{
+ \begingroup%
+ \pgfkeys{/pgf/data/store in group={#2}}%
+ \pgf@dv@do@adddata{\pgfkeysvalueof{/pgf/data visualization/obj}.add data({{\begingroup\pgfkeys{/pgf/data/.cd,/pgf/every data/.try,#1}}})}%
+ \afterassignment\tikz@lib@dv@parse@loop%
+ \let\tikz@dummy=%get rid of \bgroup
+ }{%
+ \tikzerror{Opening brace expected}%
+ \tikz@lib@dv@parse@loop%
+ }%
+}%
+
+\def\tikz@lib@dv@handle@data@group@use#1#2{%
+ \pgfdata[#1,use group=#2]%
+}%
+
+\def\tikz@lib@dv@handle@data@point point{\pgfutil@ifnextchar[{\tikz@lib@dv@handle@data@point@opt}{\tikz@lib@dv@handle@data@point@opt[]}}%]%
+\def\tikz@lib@dv@handle@data@point@opt[#1]{%
+ \pgf@dv@do@adddata{\pgfkeysvalueof{/pgf/data visualization/obj}.add data({{\bgroup\pgfkeys{/data point/.cd,#1}\pgfdatapoint\egroup}})}%
+ \tikz@lib@dv@parse@loop%
+}%
+
+\def\tikz@lib@dv@handle@info info{%
+ \pgfutil@ifnextchar'{\tikz@lib@dv@handle@info@prime}{\tikz@lib@dv@handle@info@noprime}}%
+\def\tikz@lib@dv@handle@info@noprime{%
+ \pgfutil@ifnextchar[{\tikz@lib@dv@handle@info@block@opt}{\tikz@lib@dv@handle@info@block@opt[]}}%}%
+\def\tikz@lib@dv@handle@info@block@opt[#1]#2{%
+ \tikz@main@dv.after visualization({\scope[#1]#2\endscope})%
+ \tikz@lib@dv@parse@loop
+}%
+\def\tikz@lib@dv@handle@info@prime'{%
+ \pgfutil@ifnextchar[{\tikz@lib@dv@handle@info@block@opt@prime}{\tikz@lib@dv@handle@info@block@opt@prime[]}}%}%
+\def\tikz@lib@dv@handle@info@block@opt@prime[#1]#2{%
+ \tikz@main@dv.before visualization({\scope[#1]#2\endscope})%
+ \tikz@lib@dv@parse@loop
+}%
+
+
+\pgfset{/pgf/every data/.style={/tikz/every data/.try,/tikz/data visualization/every data/.try}}%
+
+
+%
+% Performing before/after stuff via keys
+%
+
+\tikzdatavisualizationset{
+ before survey/.code=\tikz@main@dv.before survey({#1}),
+ after survey/.code=\tikz@main@dv.after survey({#1}),
+ before visualization/.code=\tikz@main@dv.before visualization({#1}),
+ after visualization/.code=\tikz@main@dv.after visualization({#1}),
+ at start survey/.code=\tikz@main@dv.at start survey({#1}),
+ at end survey/.code=\tikz@main@dv.at end survey({#1}),
+ at start visualization/.code=\tikz@main@dv.at start visualization({#1}),
+ at end visualization/.code=\tikz@main@dv.at end visualization({#1}),
+}%
+
+
+\def\tikz@lib@dv@alias@dv@bb{
+ \pgfnodealias{data bounding box}{data visualization bounding box}%
+ \pgfkeys{/pgf/freeze local bounding box=data bounding box}%
+}%
+
+%
+% The data point key
+%
+\tikzdatavisualizationset{
+ data point/.code={
+ \pgf@dv@do@adddata{\pgfkeysvalueof{/pgf/data visualization/obj}.add data({{\bgroup\pgfkeys{/data point/.cd,#1}\pgfdatapoint\egroup}})}%
+ }
+}%
+
+
+%
+% Object setup
+%
+
+% The following key is used to create objects for the rendering
+% pipeline. They cannot be created "directly" because when it is known
+% that the objects needs to be created, in principle, many keys may
+% not yet be known.
+%
+% The following options are used:
+%
+% store = key that will store the object (handle)
+% class = class of the object
+% arg1 = argument1 of the constructor
+% ...
+% arg8 = argument8 of the constructor
+% when = specifies when the object will be created. Defaults to
+% "before survey", other possible values are "after survey" and
+% "before/after visualization"
+% before creation = code to be executed just before the object is
+% created
+% after creation = code to be executed just after the object has been created
+%
+% The following styles may be useful:
+%
+% arg1 from key = use the contents of the given key as arg1. Similar
+% for other args
+% arg1 handle from key = the contents of the given key should contain
+% an object. Then arg1 will be a handle to this
+% object. Similar for other args
+
+\tikzdatavisualizationset{%
+ new object/.code={%
+ \def\tikz@dv@grabbed@when{before survey}%
+ \let\tikz@dv@grabbed@store\pgfutil@empty
+ \pgfkeys{/tikz/data visualization/new object/grab/.cd,#1}%
+ \ifx\tikz@dv@grabbed@store\pgfutil@empty
+ \else
+ \pgfkeyslet{\tikz@dv@grabbed@store}\pgfutil@empty%
+ \fi
+ \edef\tikz@marshal{\noexpand\tikz@main@dv.\tikz@dv@grabbed@when(\noexpand\tikz@dv@newobject{\tikz@dv@grabbed@store}}%
+ \tikz@marshal{#1})%
+ },
+ new object/grab/store/.store in=\tikz@dv@grabbed@store,
+ new object/grab/when/.store in=\tikz@dv@grabbed@when,
+ new object/grab/.unknown/.code={},%ignore
+}%
+
+\def\tikz@dv@newobject#1#2{%
+ \def\tikz@dv@new@obj@store{#1}%
+ \ifx\tikz@dv@new@obj@store\pgfutil@empty%
+ \let\tikz@dv@new@obj=\pgfutil@empty%
+ \else%
+ \pgfkeysgetvalue\tikz@dv@new@obj@store\tikz@dv@new@obj%
+ \fi%
+ \ifx\tikz@dv@new@obj\pgfutil@empty
+ \let\tikz@dv@arg@a=\tikz@lib@notused%
+ \let\tikz@dv@arg@b=\tikz@lib@notused%
+ \let\tikz@dv@arg@c=\tikz@lib@notused%
+ \let\tikz@dv@arg@d=\tikz@lib@notused%
+ \let\tikz@dv@arg@e=\tikz@lib@notused%
+ \let\tikz@dv@arg@f=\tikz@lib@notused%
+ \let\tikz@dv@arg@g=\tikz@lib@notused%
+ \let\tikz@dv@arg@h=\tikz@lib@notused%
+ \let\tikz@dv@new@after=\relax%
+ \pgfkeys{/tikz/data visualization/new object/parse/.cd,#2}
+ \edef\pgf@marshal{\noexpand\pgfoonew\noexpand\tikzdvobj=new \tikz@dv@new@class(}%
+ \tikz@dv@add@arg{}\tikz@dv@arg@a%
+ \tikz@dv@add@arg{\expandafter,}\tikz@dv@arg@b%
+ \tikz@dv@add@arg{\expandafter,}\tikz@dv@arg@c%
+ \tikz@dv@add@arg{\expandafter,}\tikz@dv@arg@d%
+ \tikz@dv@add@arg{\expandafter,}\tikz@dv@arg@e%
+ \tikz@dv@add@arg{\expandafter,}\tikz@dv@arg@f%
+ \tikz@dv@add@arg{\expandafter,}\tikz@dv@arg@g%
+ \tikz@dv@add@arg{\expandafter,}\tikz@dv@arg@h%
+ \expandafter\def\expandafter\pgf@marshal\expandafter{\pgf@marshal)}%
+ \pgf@marshal%
+ \tikzdvobj.default connects()%
+ \ifx\tikz@dv@new@obj@store\pgfutil@empty%
+ \else%
+ \pgfkeyslet\tikz@dv@new@obj@store\tikzdvobj%
+ \fi%
+ \tikz@dv@new@after%
+ \fi
+}%
+\def\tikz@lib@notused{\tikz@lib@notused}%
+
+\def\tikz@dv@add@arg#1#2{%
+ \ifx#2\tikz@lib@notused%
+ \else%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\pgf@marshal%
+ \expandafter\expandafter\expandafter{\expandafter\pgf@marshal#1#2}%
+ \fi%
+}%
+
+\tikzdatavisualizationset{%
+ new object/parse/.cd,
+ store/.code=,% ignore
+ when/.code=,% ignore
+ class/.store in=\tikz@dv@new@class,
+ before creation/.code={#1},
+ after creation/.store in=\tikz@dv@new@after,
+ arg1/.store in=\tikz@dv@arg@a,
+ arg2/.store in=\tikz@dv@arg@b,
+ arg3/.store in=\tikz@dv@arg@c,
+ arg4/.store in=\tikz@dv@arg@d,
+ arg5/.store in=\tikz@dv@arg@e,
+ arg6/.store in=\tikz@dv@arg@f,
+ arg7/.store in=\tikz@dv@arg@g,
+ arg8/.store in=\tikz@dv@arg@h,
+ arg1 from key/.code=\pgfkeysgetvalue{#1}{\tikz@dv@arg@a},
+ arg2 from key/.code=\pgfkeysgetvalue{#1}{\tikz@dv@arg@b},
+ arg3 from key/.code=\pgfkeysgetvalue{#1}{\tikz@dv@arg@c},
+ arg4 from key/.code=\pgfkeysgetvalue{#1}{\tikz@dv@arg@d},
+ arg5 from key/.code=\pgfkeysgetvalue{#1}{\tikz@dv@arg@e},
+ arg6 from key/.code=\pgfkeysgetvalue{#1}{\tikz@dv@arg@f},
+ arg7 from key/.code=\pgfkeysgetvalue{#1}{\tikz@dv@arg@g},
+ arg8 from key/.code=\pgfkeysgetvalue{#1}{\tikz@dv@arg@h}
+ arg1 handle from key/.code=\tikz@dv@handle@from@key{#1}{\tikz@dv@handle@a}{\tikz@dv@arg@a},
+ arg2 handle from key/.code=\tikz@dv@handle@from@key{#1}{\tikz@dv@handle@b}{\tikz@dv@arg@b},
+ arg3 handle from key/.code=\tikz@dv@handle@from@key{#1}{\tikz@dv@handle@c}{\tikz@dv@arg@c},
+ arg4 handle from key/.code=\tikz@dv@handle@from@key{#1}{\tikz@dv@handle@d}{\tikz@dv@arg@d},
+ arg5 handle from key/.code=\tikz@dv@handle@from@key{#1}{\tikz@dv@handle@e}{\tikz@dv@arg@e},
+ arg6 handle from key/.code=\tikz@dv@handle@from@key{#1}{\tikz@dv@handle@f}{\tikz@dv@arg@f},
+ arg7 handle from key/.code=\tikz@dv@handle@from@key{#1}{\tikz@dv@handle@g}{\tikz@dv@arg@g},
+ arg8 handle from key/.code=\tikz@dv@handle@from@key{#1}{\tikz@dv@handle@h}{\tikz@dv@arg@h}
+}%
+
+\def\tikz@dv@handle@from@key#1#2#3{%
+ \pgfkeysvalueof{#1}.get handle(#2)%
+ \def#3{#2}%
+}%
+
+
+
+
+%
+% Data visualization coordinate system
+%
+%
+% This cs is used to refer to points in a datavisualization. The
+% parameters are keys that are set in the /data point key
+% directory. Then, a (virtual) data point is created and the
+% calculated position is returned
+
+\tikzdeclarecoordinatesystem{visualization}
+{%
+ \tikzset{/data point/.cd,#1}%
+ \pgfpointdvlocaldatapoint%
+}%
+
+
+
+
+%
+%
+% Axes
+%
+%
+
+
+
+%
+% Axis base
+%
+
+\tikzdatavisualizationset{%
+ new axis base/.style={
+ new object={
+ class=scaling mapper,
+ store=/tikz/data visualization/#1/scaling mapper,
+ before creation={
+ \pgfkeysgetvalue{/tikz/data visualization/#1/scaling}\tikz@temp
+ \ifx\tikz@temp\pgfutil@empty%
+ \pgfkeysgetvalue{/tikz/data visualization/#1/scaling/default}\tikz@temp
+ \fi
+ \expandafter\tikz@dv@lib@parse@scaling\tikz@temp\pgf@stop%
+ \pgfkeyslet{/tikz/data visualization/#1/scaling}\tikz@temp
+ },
+ arg1 from key=/tikz/data visualization/#1/attribute,
+ arg2/.expanded=\pgfkeysvalueof{/tikz/data visualization/#1/attribute}/scaled,
+ arg3 from key=/tikz/data visualization/#1/scaling,
+ arg4 from key=/tikz/data visualization/#1/function
+ },
+ #1/attribute/.initial={#1},
+ #1/function/.initial=,
+ #1/scaling/.initial=,
+ #1/scaling/default/.initial=0 at 0 and 1 at 1,
+ #1/ticks at/.initial=,
+ #1/default ticks at/.initial=,
+ #1/major ticks/.initial=,
+ #1/minor ticks/.initial=,
+ #1/subminor ticks/.initial=,
+ #1/grid at/.initial=,
+ #1/default grid at/.initial=,
+ #1/major grid/.initial=,
+ #1/minor grid/.initial=,
+ #1/subminor grid/.initial=,
+ #1/label/.initial=,
+ #1/padding min/.initial=,
+ #1/padding max/.initial=,
+ #1/.code={
+ \let\tikz@temp\tikz@dv@axis%
+ \def\tikz@dv@axis{/tikz/data visualization/#1}%
+ \expandafter\tikz@do@axis@options\expandafter{\tikz@temp}{##1}%
+ },
+ #1/@compute at positions/.initial=\tikz@lib@dv@compute@at@linear,
+ axes list/.append={\tikz@lib@dv@do@axis{#1}}
+ },
+ all axes/.code={
+ \def\tikz@lib@dv@args{#1}%
+ \pgfkeysvalueof{/tikz/data visualization/axes list}%
+ },
+ % General styling
+ styling/.style=,
+ style/.style={styling/.append style={#1}},
+ @node styling/.initial=,
+ node styling/.style={%
+ /utils/exec={\pgfkeysgetvalue{/tikz/data visualization/@node styling}\tikz@temp\expandafter\tikzset\expandafter{\tikz@temp}}},
+ node style/.style={/tikz/data visualization/@node styling/.append={,#1}},
+ % General extends (both axes, grid and ticks)
+ low/.initial=0,
+ high/.initial=0,
+ padded/.style={low=padded min,high=padded max},
+ tick length/.style={low={-#1},high={#1}},
+ % General tick and grid keys:
+ common/.initial=,
+ major/.initial=,
+ minor/.initial=,
+ subminor/.initial=,
+ @setup at setters/.style={
+ common/.code=\tikz@lib@dv@add@{common}{##1},
+ major/.code=\tikz@lib@dv@add@{major}{##1},
+ minor/.code=\tikz@lib@dv@add@{minor}{##1},
+ subminor/.code=\tikz@lib@dv@add@{subminor}{##1}
+ },
+ @setup at setters,
+ % Tick keys
+ direction axis/.initial=,
+ % Tick text modifiers
+ tick text low even padding/.initial=0pt,
+ tick text high even padding/.initial=0pt,
+ tick text low odd padding/.initial=0pt,
+ tick text high odd padding/.initial=0pt,
+ tick text odd padding/.style={tick text low odd padding={-#1},tick text high odd padding={#1}},
+ tick text even padding/.style={tick text low even padding={-#1},tick text high even padding={#1}},
+ tick text padding/.style={tick text odd padding={#1},tick text even padding={#1}},
+ stack/.style={tick text even padding={#1}},
+ stack'/.style={tick text odd padding={#1}},
+ stack/.default=1em,
+ stack'/.default=1em,
+ tick text at low/.is if=tikz@dv@min@tick@node,
+ tick text at high/.is if=tikz@dv@max@tick@node,
+ no tick text/.style={tick text at low=false,tick text at high=false},
+ %
+ every major ticks/.style={style={line cap=round},tick length=2pt},
+ every minor ticks/.style={style={solid, help lines,thin,line cap=round},tick length=1.4pt},
+ every subminor ticks/.style={style={solid, help lines,line cap=round},tick length=0.8pt},
+ clean ticks/.style={node style={fill=white}},
+ % Default grid styles
+ every grid/.style={high=max,low=min},
+ every major grid/.style={style={solid, help lines,thin,black!25}},
+ every minor grid/.style={style={solid, help lines,black!25}},
+ every subminor grid/.style={style={solid, help lines,black!10}},
+ at default ticks/.code={%
+ \expandafter\pgfkeysalso\expandafter{\tikz@lib@dv@ticks@default@at}},
+ at ticks/.code={%
+ \expandafter\pgfkeysalso\expandafter{\tikz@lib@dv@ticks@default@at}%
+ \expandafter\pgfkeysalso\expandafter{\tikz@lib@dv@ticks@at}},
+}%
+
+\def\tikz@lib@dv@add@#1#2{\pgfkeysaddvalue{/tikz/data visualization/#1}{}{,#2}}%
+
+\def\tikz@dv@lib@parse@scaling#1 at#2and #3 at#4\pgf@stop{%
+ \pgfmathsetmacro{\tikz@dv@lib@min@at}{#2}
+ \pgfmathsetmacro{\tikz@dv@lib@max@at}{#4}
+ \edef\tikz@temp{#1 at \tikz@dv@lib@min@at and #3 at \tikz@dv@lib@max@at}%
+}%
+
+
+% Ticks at
+\tikzdatavisualizationset{
+ at/.code={\def\tikz@dv@at@list{#1}},
+ also at/.code={\expandafter\def\expandafter\tikz@dv@at@list\expandafter{\tikz@dv@at@list,#1}},
+ major at/.style={major={at={#1}}},
+ minor at/.style={minor={at={#1}}},
+ subminor at/.style={subminor={at={#1}}},
+ major also at/.style={major={also at={#1}}},
+ minor also at/.style={minor={also at={#1}}},
+ subminor also at/.style={subminor={also at={#1}}},
+ options at/.code={\expandafter\def\expandafter\tikz@dv@style@at@list\expandafter{\tikz@dv@style@at@list,{#1}}},
+ no tick text at/.style={options at={#1 as [no tick text]}}
+}%
+
+
+\def\tikz@lib@dv@do@axis#1{%
+ \def\tikz@marshal{#1=}
+ \expandafter\expandafter\expandafter\tikzdatavisualizationset%
+ \expandafter\expandafter\expandafter{\expandafter\tikz@marshal\expandafter{\tikz@lib@dv@args}}
+}%
+
+\def\tikz@do@axis@options#1#2{
+ \pgfkeys{/tikz/data visualization/axis options/.cd,#2}
+ \def\tikz@dv@axis{#1}
+}%
+\let\tikz@dv@axis\pgfutil@empty
+
+\tikzdatavisualizationset{
+ every ticks/.style={
+ node style={%
+ font=\pgfutil@font@footnotesize,
+ inner sep=1pt,
+ outer sep=.1666em,
+ rounded corners=1.5pt
+ }
+ },
+ every data set label/.style={
+ every ticks,
+ node style={
+ font=\pgfutil@font@small,
+ }
+ },
+ @color of visualizer labels/.style={text=black},
+ every label in legend/.style={
+ node style={
+ fill=none,
+ }
+ },
+ every axis label/.style={
+ node style={%
+ font=\pgfutil@font@small,
+ }
+ }
+}%
+
+
+\tikzset{
+ /tikz/data visualization/axis options/.cd,
+ %
+ % Basic setters
+ %
+ attribute/.style={\tikz@dv@axis/attribute={#1}},
+ function/.style={\tikz@dv@axis/function={#1}},
+ scaling/.style={\tikz@dv@axis/scaling={#1}},
+ padding min/.style={\tikz@dv@axis/padding min={#1}},
+ padding max/.style={\tikz@dv@axis/padding max={#1}},
+ padding/.style={padding min={-#1},padding max={#1}},
+ label/.code={%
+ \def\pgf@temp{#1}%
+ \ifx\pgf@temp\tikz@lib@dv@auto@attribute%
+ \tikzdatavisualizationset{\tikz@dv@axis/label/.expanded=$\noexpand\mathit{\pgfkeysvalueof{\tikz@dv@axis/attribute}}$}%
+ \else
+ \tikzdatavisualizationset{\tikz@dv@axis/label={#1}}%
+ \fi
+ },
+ label/.default=\tikz@lib@dv@auto@attribute,
+ %
+ % Strategies
+ %
+ tick placement strategy/.style={\tikz@dv@axis/@compute at positions={#1}},
+ linear steps/.style={tick placement strategy=\tikz@lib@dv@compute@at@linear},
+ %
+ % Attribute setter
+ %
+ goto/.code={\tikz@dv@goto{\tikz@dv@axis}{#1}},
+ goto pos/.code={\tikz@dv@goto@pos{\tikz@dv@axis}{#1}},
+ anchor at min/.code={\tikz@lib@dv@special@at{\tikz@dv@axis}{\tikz@dv@min@anchor}},
+ anchor at max/.code={\tikz@lib@dv@special@at{\tikz@dv@axis}{\tikz@dv@max@anchor}},
+ %
+ % Visualization setters
+ %
+ visualize axis/.code=\expandafter\tikz@lib@dv@av\expandafter{\tikz@dv@axis}{#1},
+ %
+ % Ticks settings
+ %
+ ticks/.style={\tikz@dv@axis/ticks at/.append={,#1}},
+ ticks/.default=some,
+ visualize ticks/.code=\expandafter\tikz@lib@dv@tv\expandafter{\tikz@dv@axis}{#1},
+ %
+ % Grid settings
+ %
+ grid/.style={\tikz@dv@axis/grid at/.append={,#1}},
+ grid/.default=at default ticks,
+ visualize grid/.code=\expandafter\tikz@lib@dv@gv\expandafter{\tikz@dv@axis}{#1},
+ %
+ ticks and grid/.style={\tikz@dv@axis/ticks at/.append={,#1},\tikz@dv@axis/grid at/.append={,#1}},
+ %
+ % Visualizing axis labels
+ %
+ visualize label/.code=\expandafter\tikz@lib@dv@lv\expandafter{\tikz@dv@axis}{#1},
+}%
+
+\def\tikz@lib@dv@auto@attribute{\tikz@lib@dv@auto@attribute}%
+
+
+% Range options
+\tikzdatavisualizationset{
+ axis options/.cd,
+ %
+ % Including a value in the range
+ %
+ include value/.style={%
+ /tikz/data visualization/before survey/.expanded={%
+ \noexpand\pgfkeysgetvalue{\tikz@dv@axis/scaling mapper}\noexpand\tikz@dv@axis@mapper%
+ \noexpand\foreach \noexpand\tikz@lib@dv@temp in {#1} {%
+ \noexpand\tikz@dv@axis@mapper.include in value(\noexpand\tikz@lib@dv@temp)%
+ }%
+ }%
+ },
+ %
+ % Directly setting the min or max
+ %
+ min value/.style={
+ /tikz/data visualization/at end survey/.expanded={%
+ \noexpand\pgfkeysgetvalue{\tikz@dv@axis/scaling mapper}\noexpand\tikz@dv@axis@mapper%
+ \noexpand\tikz@lib@dv@set\noexpand\tikz@dv@axis@mapper{#1}{min}%
+ }
+ },
+ max value/.style={
+ /tikz/data visualization/at end survey/.expanded={%
+ \noexpand\pgfkeysgetvalue{\tikz@dv@axis/scaling mapper}\noexpand\tikz@dv@axis@mapper%
+ \noexpand\tikz@lib@dv@set\noexpand\tikz@dv@axis@mapper{#1}{max}%
+ }
+ },
+}%
+
+\def\tikz@lib@dv@set#1#2#3{%
+ \pgfdvmathenter{\pgf@dv@value}{#2}%
+ #1.get in range interval()%
+ \pgfdvinrangeinterval.let #3(\pgf@dv@value)%
+}%
+
+% Layer options
+\tikzdatavisualizationset{
+ axis layer/.style=on background layer,
+ ticks layer/.style=on background layer,
+ ticks node layer/.style=,
+ grid layer/.style=on background layer,
+}%
+
+
+% Axis visualization
+%
+% #1 = name of the to-be-visualized axis name
+% #2 = options for the visualization
+
+\def\tikz@lib@dv@av#1#2{
+ \tikzdatavisualizationset{
+ axes actions/.append={\tikz@lib@dv@show@axis{#1}{#2}}
+ }
+}%
+
+\def\tikz@lib@dv@show@axis#1#2{%
+ \scope[data visualization/axis layer,/tikz/data visualization/.cd,low=min,high=max,every axis/.try,#2]
+ \pgfkeysgetvalue{#1/scaling mapper}\tikz@dv@axis@mapper%
+ % Ok, calculate direction vector:
+ \tikzpointandanchordirection{\tikz@dv@axis@mapper.set in to(min)}{\tikz@dv@axis@mapper.set in to(max)}
+ \xdef\tikz@dv@axis@dir{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}
+ \path[draw,/tikz/data visualization/styling]
+ \pgfextra{
+ {
+ \tikz@dv@goto{#1}{\pgfkeysvalueof{/tikz/data visualization/low}}%
+ \pgfpathdvmoveto%
+ }
+ {
+ \tikz@dv@goto{#1}{\pgfkeysvalueof{/tikz/data visualization/high}}%
+ \pgfpathdvlineto%
+ }
+ };
+ \endscope
+}%
+
+\def\tikz@dv@goto#1#2{%
+ \edef\pgf@@temp{#2}%
+ \ifx\pgf@@temp\tikz@lib@dv@padded@min@text%
+ \pgfkeysvalueof{#1/scaling mapper}.set in to(min)%
+ \pgfkeysvalueof{#1/scaling mapper}.get out()%
+ \pgfkeysgetvalue{#1/padding min}\pgf@temp%
+ \pgfmathparse{\pgf@temp}%
+ \pgfkeyslet{/data point/\pgfdvout/offset}\pgfmathresult%
+ \else%
+ \ifx\pgf@@temp\tikz@lib@dv@padded@max@text%
+ \pgfkeysvalueof{#1/scaling mapper}.set in to(max)%
+ \pgfkeysvalueof{#1/scaling mapper}.get out()%
+ \pgfkeysgetvalue{#1/padding max}\pgf@temp%
+ \pgfmathparse{\pgf@temp}%
+ \pgfkeyslet{/data point/\pgfdvout/offset}\pgfmathresult%
+ \else%
+ \pgfkeysvalueof{#1/scaling mapper}.set in to(#2)%
+ \fi%
+ \fi%
+}%
+
+\def\tikz@dv@goto@pos#1#2{%
+ \pgfkeyssetvalue{/data point/\pgfkeysvalueof{#1/attribute}/out pos}{#2}%
+}%
+
+\def\tikz@lib@dv@padded@min@text{padded min}%
+\def\tikz@lib@dv@padded@max@text{padded max}%
+
+\def\tikz@lib@dv@special@at#1#2{%
+ % Ok, calculate direction vector:
+ \tikzpointandanchordirection{\pgfkeysvalueof{#1/scaling mapper}.set in to(min)}{\pgfkeysvalueof{#1/scaling mapper}.set in to(max)}
+ \tikzset{anchor/.expanded={#2}}
+}%
+
+
+% Ticks visualization
+%
+% #1 = name of axis on which ticks should be shown
+% #2 = options for the visualization
+
+\def\tikz@lib@dv@tv#1#2{
+ \tikzdatavisualizationset{
+ ticks actions/.append={\tikz@lib@dv@default@action{ticks}{#1}{#2}},
+ major ticks actions/.append={\tikz@lib@dv@show@ticks{major}{#1}{#2}},
+ minor ticks actions/.append={\tikz@lib@dv@show@ticks{minor}{#1}{#2}},
+ subminor ticks actions/.append={\tikz@lib@dv@show@ticks{subminor}{#1}{#2}}
+ }
+}%
+
+\def\tikz@lib@dv@default@action#1#2#3{%
+ \let\tikz@marshal\pgfutil@empty%
+ {%
+ \let\tikz@lib@dv@ticks@at\pgfutil@empty%
+ \pgfkeysgetvalue{#2/ticks at}\tikz@lib@dv@ticks@default@at%
+ \pgfkeysgetvalue{#2/#1 at}\tikz@lib@dv@settings%
+ \pgfkeysgetvalue{#2/scaling mapper}\tikz@lib@dv@mapper
+ % Normal minor etc. have no effect.
+ \tikzdatavisualizationset{major/.code=,minor/.code=,subminor/.code=,common/.code=}
+ \expandafter\tikzdatavisualizationset\expandafter{\tikz@lib@dv@settings}%
+ \tikzdatavisualizationset{@setup at setters}%
+ \pgfkeysgetvalue{/tikz/data visualization/compute step}\tikz@temp@step%
+ \ifx\tikz@temp@step\pgfutil@empty%
+ % do nothing
+ \else%
+ \pgfkeysvalueof{#2/@compute at positions}%
+ \xdef\tikz@marshal{
+ major={\pgfkeysvalueof{/tikz/data visualization/major}},
+ minor={\pgfkeysvalueof{/tikz/data visualization/minor}},
+ subminor={\pgfkeysvalueof{/tikz/data visualization/subminor}}}
+ \fi
+ }%
+ \pgfkeyslet{#2/default #1 at}\tikz@marshal
+}%
+
+\def\tikz@lib@dv@show@ticks#1#2#3{%
+ % First, check whether there is anything to do at all:
+ \pgfkeysgetvalue{#2/default ticks at}\tikz@lib@dv@default@settings%
+ \ifx\tikz@lib@dv@default@settings\pgfutil@empty%
+ \pgfkeysgetvalue{#2/ticks at}\tikz@lib@dv@settings%
+ \else%
+ \pgfkeysgetvalue{#2/ticks at}\tikz@lib@dv@settings%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\tikz@lib@dv@settings%
+ \expandafter\expandafter\expandafter{\expandafter\tikz@lib@dv@default@settings\expandafter,\tikz@lib@dv@settings}
+ \fi%
+ \ifx\tikz@lib@dv@settings\pgfutil@empty%
+ % Great, nothing to do
+ \else
+ {%
+ \let\tikz@dv@at@list\pgfutil@empty%
+ \let\tikz@dv@style@at@list\pgfutil@empty%
+ \pgfkeysgetvalue{#2/scaling mapper}\tikz@lib@dv@mapper
+ \scope[/tikz/data visualization/.cd,every ticks/.try,every #1 ticks/.try,#3]%
+ % Setup options
+ \expandafter\tikzdatavisualizationset\expandafter{\tikz@lib@dv@settings}%
+ \pgfkeysgetvalue{/tikz/data visualization/common}\tikz@temp
+ \expandafter\tikzdatavisualizationset\expandafter{\tikz@temp}
+ \pgfkeysgetvalue{/tikz/data visualization/#1}\tikz@temp
+ \expandafter\tikzdatavisualizationset\expandafter{\tikz@temp}
+ \pgfkeysgetvalue{/tikz/data visualization/\pgfkeysvalueof{/tikz/data visualization/direction axis}/scaling mapper}\pgf@dv@tick@dir@mapper
+ % Ok, now it's time to draw the ticks!
+ \foreach \tikz@dv@tick@pos[count=\tikz@dv@tick@count] in \tikz@dv@at@list
+ {
+ \ifx\tikz@dv@tick@pos\pgfutil@empty
+ \c@pgf@counta=\tikz@dv@tick@count\relax%
+ \advance\c@pgf@counta by-1\relax%
+ \edef\tikz@dv@tick@count{\the\c@pgf@counta}%
+ \else
+ \expandafter\tikz@lib@dv@parse\tikz@dv@tick@pos\pgf@stop%
+ \expandafter\tikzdatavisualizationset\expandafter{\tikz@lib@dv@tick@opt}%
+ \tikz@lib@dv@mapper.set in to(\tikz@dv@tick@pos)%
+ % First, compute position of tick:
+ \pgf@process{\pgfpointdvlocaldatapoint}
+ \xdef\pgf@dv@tick@origin{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}
+ % Ok, calculate direction vector:
+ \tikzpointandanchordirection{\pgf@dv@tick@dir@mapper.set in to(min)}{\pgf@dv@tick@dir@mapper.set in to(max)}
+ \xdef\pgf@dv@tick@dir{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}
+ % Now, show something:
+ \tikz@lib@handle@at@style%
+ \pgfkeysgetvalue{/tikz/data visualization/high}\tikz@dv@max@val%
+ \pgfkeysgetvalue{/tikz/data visualization/low}\tikz@dv@min@val%
+ \iftikz@dv@max@tick@node\pgfmathsetmacro\tikz@dv@max@val{%
+ \tikz@dv@max@val+(\pgfkeysvalueof{%
+ /tikz/data visualization/tick text high
+ \ifodd\tikz@dv@tick@count odd \else even \fi padding}%
+ )}%
+ \fi%
+ \iftikz@dv@min@tick@node\pgfmathsetmacro\tikz@dv@min@val{%
+ \tikz@dv@min@val+(\pgfkeysvalueof{%
+ /tikz/data visualization/tick text low
+ \ifodd\tikz@dv@tick@count odd \else even \fi padding}%
+ )}%
+ \fi%
+ \pgf@process{\pgfpointadd{\pgf@dv@tick@origin}{\pgfpointscale{\tikz@dv@max@val}{\pgf@dv@tick@dir}}}
+ \xdef\tikz@dv@max@tick{\the\pgf@x,\the\pgf@y}
+ \pgf@process{\pgfpointadd{\pgf@dv@tick@origin}{\pgfpointscale{\tikz@dv@min@val}{\pgf@dv@tick@dir}}}
+ \xdef\tikz@dv@min@tick{\the\pgf@x,\the\pgf@y}
+ \scope[data visualization/ticks layer]
+ \tikzdatavisualizationset{every \ifodd\tikz@dv@tick@count odd \else even \fi tick/.try}
+ \draw [/tikz/data visualization/styling] (\tikz@dv@min@tick) -- (\tikz@dv@max@tick);
+ \endscope
+ \iftikz@dv@min@tick@node
+ \scope[data visualization/ticks node layer]
+ \tikzdatavisualizationset{every \ifodd\tikz@dv@tick@count odd \else even \fi tick/.try}
+ \path [/tikz/data visualization/styling] (\tikz@dv@min@tick) \tikz@dv@handle@tick{\tikz@dv@min@anchor};
+ \endscope
+ \fi
+ \iftikz@dv@max@tick@node
+ \scope[data visualization/ticks node layer]
+ \tikzdatavisualizationset{every \ifodd\tikz@dv@tick@count odd \else even \fi tick/.try}
+ \path [/tikz/data visualization/styling] (\tikz@dv@max@tick) \tikz@dv@handle@tick{\tikz@dv@max@anchor};
+ \endscope
+ \fi
+ \fi
+ }
+ \endscope
+ }
+ \fi
+}%
+
+\def\tikz@lib@dv@parse#1\pgf@stop{%
+ \pgfutil@in@{as}{#1}%
+ \ifpgfutil@in@%
+ \tikz@lib@dv@parse@as#1\pgf@stop%
+ \else%
+ \tikz@lib@dv@parse@as#1as\tikz@lib@dv@typeset\pgf@stop%
+ \fi%
+}%
+\def\tikz@lib@dv@parse@as#1as{%
+ \def\tikz@dv@tick@pos{#1}%
+ \pgfutil@ifnextchar[{\tikz@lib@dv@parse@as@opt}{\tikz@lib@dv@parse@as@opt[]}%]
+}%
+\def\tikz@lib@dv@parse@as@opt[#1]{%
+ \def\tikz@lib@dv@tick@opt{#1}%
+ \pgfutil@ifnextchar\pgf@stop{\tikz@lib@dv@parse@as@text\tikz@lib@dv@typeset}{\tikz@lib@dv@parse@as@text}
+}%
+\def\tikz@lib@dv@parse@as@text#1\pgf@stop{%
+ \def\tikz@lib@dv@tick@text{#1}%
+}%
+
+\def\tikz@lib@dv@typeset{%
+ \pgfdvmathenter{\tikz@lib@dv@typesetnum}{\tikz@dv@tick@pos}%
+ \pgfdvmathexitbyscientificformat{\tikz@lib@dv@typesetnum}{\tikz@lib@dv@typesetnum}% hmm... not sure about this...
+ \pgfkeysvalueof{/tikz/data visualization/tick prefix}%
+ \pgfkeys{/tikz/data visualization/tick typesetter=\tikz@lib@dv@typesetnum}%
+ \pgfkeysvalueof{/tikz/data visualization/tick suffix}%
+}%
+
+\newif\iftikz@dv@min@tick@node
+\newif\iftikz@dv@max@tick@node
+
+\def\tikz@dv@handle@tick#1{%
+ \pgfextra{
+ \ifx\tikz@lib@dv@tick@text\pgfutil@empty%
+ \global\let\tikz@dv@tick@marshal=\pgfutil@empty% Skip!
+ \else
+ \def\tikz@dv@tick@marshal{node[anchor=#1,/tikz/data visualization/node styling]}%
+ \expandafter\pgfutil@g@addto@macro\expandafter\tikz@dv@tick@marshal\expandafter{\expandafter{\tikz@lib@dv@tick@text}}
+ \fi
+ \expandafter}%
+ \tikz@dv@tick@marshal
+}%
+
+
+\def\tikz@lib@handle@at@style{%
+ \ifx\tikz@dv@style@at@list\pgfutil@empty% nothing to do
+ \else%
+ \let\tikz@dv@lib@this@at@style=\pgfutil@empty%
+ \pgfdvmathenter{\tikz@temp}{\tikz@dv@tick@pos}%
+ \pgfdvmathexitbyscientificformat{\tikz@dv@compare@to}{\tikz@temp}%
+ \foreach \tikz@dv@at@style in \tikz@dv@style@at@list {%
+ \ifx\tikz@dv@at@style\pgfutil@empty%
+ \else%
+ \expandafter\tikz@dv@lib@handle@one@at@style\tikz@dv@at@style\tikz@stop%
+ \fi%
+ }
+ \ifx\tikz@dv@lib@this@at@style\pgfutil@empty%
+ \else%
+ \expandafter\tikzdatavisualizationset\expandafter{\tikz@dv@lib@this@at@style}%
+ \fi%
+ \fi%
+}%
+
+\def\tikz@dv@lib@handle@one@at@style#1as#2[#3]#4\tikz@stop{%
+ \pgfdvmathenter{\tikz@lib@dv@at@math@var}{#1}%
+ \pgfdvmathexitbyscientificformat{\tikz@dv@temp}{\tikz@lib@dv@at@math@var}%
+ \ifx\tikz@dv@temp\tikz@dv@compare@to%
+ % Bingo!
+ \expandafter\gdef\expandafter\tikz@dv@lib@this@at@style\expandafter{\tikz@dv@lib@this@at@style,#3}%
+ \fi%
+}%
+
+
+% Help function
+\def\tikzpointandanchordirection#1#2{%
+ % This function works like pgfpointdvdirection, but also computes
+ % appropriate "min" and "max" anchors.
+ \pgf@process{\pgfpointdvdirection{#1}{#2}}
+ {
+ \pgf@ya=\pgf@y
+ \pgf@y=-\pgf@x
+ \pgf@x=\pgf@ya
+ \tikz@auto@anchor
+ \xdef\tikz@dv@max@anchor{\tikz@anchor}
+ \tikz@auto@anchor@prime
+ \xdef\tikz@dv@min@anchor{\tikz@anchor}
+ }
+}%
+
+
+
+
+% Grid visualization
+%
+% #1 = name of axis on which grid lines should be shown
+% #2 = options for the visualization
+
+\def\tikz@lib@dv@gv#1#2{
+ \tikzdatavisualizationset{
+ grid actions/.append={\tikz@lib@dv@default@action{grid}{#1}{#2}},
+ major grid actions/.append={\tikz@lib@dv@show@grid{major}{#1}{#2}},
+ minor grid actions/.append={\tikz@lib@dv@show@grid{minor}{#1}{#2}},
+ subminor grid actions/.append={\tikz@lib@dv@show@grid{subminor}{#1}{#2}},
+ }
+}%
+
+\def\tikz@lib@dv@show@grid#1#2#3{%
+ % First, check whether there is anything to do at all:
+ \pgfkeysgetvalue{#2/default grid at}\tikz@lib@dv@default@settings%
+ \ifx\tikz@lib@dv@default@settings\pgfutil@empty%
+ \pgfkeysgetvalue{#2/grid at}\tikz@lib@dv@settings%
+ \else%
+ \pgfkeysgetvalue{#2/grid at}\tikz@lib@dv@settings%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\tikz@lib@dv@settings%
+ \expandafter\expandafter\expandafter{\expandafter\tikz@lib@dv@default@settings\expandafter,\tikz@lib@dv@settings}
+ \fi%
+ \ifx\tikz@lib@dv@settings\pgfutil@empty%
+ % Great, nothing to do
+ \else
+ {%
+ \let\tikz@dv@at@list\pgfutil@empty
+ \let\tikz@dv@style@at@list\pgfutil@empty
+ \pgfkeysgetvalue{#2/scaling mapper}\tikz@lib@dv@mapper
+ \let\tikz@lib@dv@ticks@default@at\pgfutil@empty%
+ \scope[data visualization/grid layer,/tikz/data visualization/.cd,every #1 grid/.try,every grid,#3]
+ % Setup options
+ \pgfkeysgetvalue{#2/ticks at}\tikz@lib@dv@ticks@at%
+ \expandafter\tikzdatavisualizationset\expandafter{\tikz@lib@dv@settings}%
+ \pgfkeysgetvalue{/tikz/data visualization/common}\tikz@temp
+ \expandafter\tikzdatavisualizationset\expandafter{\tikz@temp}
+ \pgfkeysgetvalue{/tikz/data visualization/#1}\tikz@temp
+ \expandafter\tikzdatavisualizationset\expandafter{\tikz@temp}
+ \edef\tikz@lib@dv@dir@axis{/tikz/data visualization/\pgfkeysvalueof{/tikz/data visualization/direction axis}}%
+ % Ok, now it's time to draw the grid!
+ \foreach \tikz@dv@grid@pos in \tikz@dv@at@list
+ {
+ \ifx\tikz@dv@grid@pos\pgfutil@empty
+ \else
+ \expandafter\tikz@lib@dv@parse\tikz@dv@grid@pos\pgf@stop%
+ \expandafter\tikzdatavisualizationset\expandafter{\tikz@lib@dv@tick@opt}%
+ \tikz@lib@dv@mapper.set in to(\tikz@dv@tick@pos)%
+ \draw[/tikz/data visualization/styling]
+ \pgfextra{
+ % First, compute start of grid:
+ \tikz@dv@goto{\tikz@lib@dv@dir@axis}{\pgfkeysvalueof{/tikz/data visualization/low}}%
+ \pgfpathdvmoveto%
+ \tikz@dv@goto{\tikz@lib@dv@dir@axis}{\pgfkeysvalueof{/tikz/data visualization/high}}%
+ \pgfpathdvlineto%
+ };
+ \fi
+ }
+ \endscope
+ }
+ \fi
+}%
+
+
+
+
+
+
+
+
+
+%
+% Label visualization
+%
+
+\def\tikz@lib@dv@lv#1#2{
+ \tikzdatavisualizationset{
+ label actions/.append={\tikz@lib@dv@show@label{#1}{#2}}
+ }
+}%
+
+\def\tikz@lib@dv@show@label#1#2{%
+ % First, check whether there is anything to do at all:
+ \pgfkeysgetvalue{#1/label}\tikz@dv@lib@label%
+ \ifx\tikz@dv@lib@label\pgfutil@empty%
+ % Great, nothing to do
+ \else
+ \scope[anchor=center,/tikz/data visualization/.cd,every axis label/.try,#2]
+ \expandafter\tikz@lib@dv@parse@node\tikz@dv@lib@label\pgf@stop
+ \endscope
+ \fi
+}%
+
+\def\tikz@lib@dv@parse@node{\pgfutil@ifnextchar[\tikz@lib@dv@parse@node@opt{\tikz@lib@dv@parse@node@opt[]}}%}%
+\def\tikz@lib@dv@parse@node@opt[#1]#2\pgf@stop{
+ \tikzdatavisualizationset{#1}
+ \pgftransformshift{\pgfpointdvlocaldatapoint}%
+ \node [/tikz/data visualization/node styling] {#2};
+}%
+
+
+
+%
+% Tick placement strategies
+%
+
+\tikzdatavisualizationset{
+ compute step/.initial=,
+ step/.style={compute step=\def\tikz@lib@dv@step{#1}},
+ minor steps between steps/.initial=,
+ minor steps between steps/.default=9,
+ phase/.initial=0,
+ tick typesetter/.code=\pgfmathprintnumber{#1},
+ tick prefix/.initial=,
+ tick suffix/.initial=,
+ tick unit/.style={tick suffix={$\,\pgfutil@font@normalfont#1$}},% this is an alias
+}%
+
+\def\tikz@lib@dv@compute@at@linear{%
+ % Setup about:
+ \let\tikz@lib@dv@compute@about=\tikz@lib@dv@about@linear%
+ \let\tikz@lib@dv@step\relax%
+ \pgfkeysvalueof{/tikz/data visualization/compute step}
+ \ifx\tikz@lib@dv@step\relax%
+ \else%
+ % Gather interesting values
+ \tikz@lib@dv@mapper.get in range interval()%
+ \pgfdvinrangeinterval.get min and max()%
+ \pgfkeysgetvalue{/tikz/data visualization/phase}\tikz@temp
+ \pgfdvmathenter{\tikz@dv@lib@phase}{\tikz@temp}
+ \pgfdvmathenter{\tikz@dv@lib@step}{\tikz@lib@dv@step}
+ \pgfdvmathifless{\pgfdvmathalwayszero}{\tikz@dv@lib@step}{%
+ % Compute start:
+ \pgfdvmathsub{\tikz@dv@lib@temp}{\pgfdvmin}{\tikz@dv@lib@phase}% temp = dvmin - phase
+ \pgfdvmathdiv{\tikz@dv@lib@temp}{\tikz@dv@lib@temp}{\tikz@dv@lib@step}% temp = temp/step
+ \pgfdvmathfloor{\tikz@dv@lib@temp}{\tikz@dv@lib@temp}% temp = floor(temp)
+ \pgfdvmathmul{\tikz@lib@dv@current}{\tikz@dv@lib@temp}{\tikz@dv@lib@step}% current = temp*step ...
+ \pgfdvmathadd{\tikz@lib@dv@current}{\tikz@lib@dv@current}{\tikz@dv@lib@phase}% + phase
+ \let\tikz@lib@dv@ats\pgfutil@empty%
+ \let\tikz@lib@dv@minor@ats\pgfutil@empty%
+ \tikz@lib@dv@mapper.get function(\tikz@temp)%
+ \ifx\tikz@temp\pgfutil@empty%
+ \pgfdvmathenter{\tikz@one@hundreth}{0.001}%
+ \pgfdvmathsub{\tikz@lib@temp}{\pgfdvmax}{\pgfdvmin}%
+ \pgfdvmathmul{\tikz@lib@dv@epsilon}{\tikz@lib@temp}{\tikz@one@hundreth}% epsilon = (max - min)/1000
+ \else
+ \let\tikz@lib@dv@epsilon\pgfdvmathalwayszero
+ \fi
+ \pgfdvmathsub{\tikz@lib@dv@min@minus@epsilon}{\pgfdvmin}{\tikz@lib@dv@epsilon}%
+ \pgfdvmathadd{\tikz@lib@dv@max@plus@epsilon}{\pgfdvmax}{\tikz@lib@dv@epsilon}%
+ \pgfkeysgetvalue{/tikz/data visualization/minor steps between steps}\tikz@lib@dv@substeps%
+ \ifx\tikz@lib@dv@substeps\pgfutil@empty
+ \else
+ \pgfmathsetmacro\tikz@temp{\tikz@lib@dv@substeps+1}%
+ \pgfdvmathenter{\tikz@dv@lib@substeps}{\tikz@temp}%
+ \pgfdvmathdiv{\tikz@lib@dv@substep}{\tikz@dv@lib@step}{\tikz@dv@lib@substeps}%
+ \fi
+ \loop%
+ \ifx\tikz@lib@dv@substeps\pgfutil@empty%
+ \else%
+ \let\tikz@lib@dv@subcurrent=\tikz@lib@dv@current%
+ \pgfmathsetcount{\c@pgf@counta}{\tikz@lib@dv@substeps}%
+ \let\tikz@lib@dv@next=\tikz@lib@dv@subloop%
+ \tikz@lib@dv@subloop
+ \fi%
+ \pgfdvmathifless{\tikz@lib@dv@current}{\tikz@lib@dv@min@minus@epsilon}{}{%
+ \pgfdvmathexitbyserializing{\tikz@temp}{\tikz@lib@dv@current}%
+ \edef\tikz@lib@dv@ats{\tikz@lib@dv@ats,\tikz@temp}%
+ }
+ \pgfdvmathadd{\tikz@lib@dv@current}{\tikz@lib@dv@current}{\tikz@dv@lib@step}%
+ \pgfdvmathifless{\tikz@lib@dv@current}{\tikz@lib@dv@max@plus@epsilon}{\tikz@lib@dv@continuetrue}{\tikz@lib@dv@continuefalse}%
+ \iftikz@lib@dv@continue%
+ \repeat%
+ \tikzdatavisualizationset{major/.expanded={at={\tikz@lib@dv@ats}},minor/.expanded={at={\tikz@lib@dv@minor@ats}}}%
+ }{%
+ \pgfdvmathexitbyserializing{\tikz@temp}{\pgfdvmin}%
+ \tikzdatavisualizationset{major/.expanded={at={\tikz@temp}}}%
+ }%
+ \fi%
+}%
+\newif\iftikz@lib@dv@continue
+
+\def\tikz@lib@dv@subloop{
+ \pgfdvmathadd{\tikz@lib@dv@subcurrent}{\tikz@lib@dv@subcurrent}{\tikz@lib@dv@substep}%
+ \pgfdvmathifless{\tikz@lib@dv@subcurrent}{\pgfdvmin}{}{%
+ \pgfdvmathifless{\tikz@lib@dv@subcurrent}{\pgfdvmax}{%
+ \pgfdvmathexitbyserializing{\tikz@temp}{\tikz@lib@dv@subcurrent}%
+ \edef\tikz@lib@dv@minor@ats{\tikz@lib@dv@minor@ats,\tikz@temp}
+ }{}}
+ \advance\c@pgf@counta by-1\relax%
+ \ifnum\c@pgf@counta=0\relax%
+ \let\tikz@lib@dv@next=\relax
+ \fi
+ \tikz@lib@dv@next
+}%
+
+
+
+%
+% Ticks about settings
+%
+
+\tikzdatavisualizationset{
+ about/.style={compute step=\tikz@lib@dv@compute@about{#1}},
+ about strategy/.initial=,
+ standard about strategy/.style={about strategy={1.5/1.0,2.3/2.0,4/2.5,7/5,11/10}},
+ standard about strategy,
+ euro about strategy/.style={about strategy={1.5/1.0,3/2.0,7/5,11/10}},
+ decimal about strategy/.style={about strategy={3/1.0,11/10}},
+ half about strategy/.style={about strategy={2/1.0,7/5,11/10}},
+ quarter about strategy/.style={about strategy={1.8/1.0,4/2.5,7/5,11/10}},
+ int about strategy/.style={about strategy={1.5/1.0,2.5/2.0,3.5/3.0,4.5/4.0,7/5,11/10}},
+ none/.style={compute step=},
+ few/.style={about=3},
+ some/.style={about=5},
+ many/.style={about=10},
+}%
+
+\def\tikz@lib@dv@about@linear#1{%
+ \tikz@lib@dv@mapper.get in range interval()%
+ \pgfdvinrangeinterval.get min and max()%
+ \pgfdvmathsub{\tikz@lib@dv@diff}{\pgfdvmax}{\pgfdvmin}
+ \pgfdvmathenter{\tikz@lib@dv@about@val}{#1}%
+ \pgfdvmathdiv{\tikz@lib@dv@around}{\tikz@lib@dv@diff}{\tikz@lib@dv@about@val}%
+ % Make mantisse sensible
+ \pgfmathfloattomacro{\tikz@lib@dv@around}{\tikz@lib@dv@flags}{\tikz@lib@dv@mant}{\tikz@lib@dv@exp}%
+ \pgf@xc=\tikz@lib@dv@mant pt %
+ \pgfkeysgetvalue{/tikz/data visualization/about strategy}\tikz@lib@dv@strat
+ \foreach \tikz@lib@dv@threshold/\tikz@lib@replace in \tikz@lib@dv@strat
+ {
+ \ifdim\pgf@xc<\tikz@lib@dv@threshold pt%
+ \global\pgf@xc=\tikz@lib@replace pt%
+ \breakforeach
+ \fi
+ }%
+ \ifdim\pgf@xc<10pt%
+ \pgfmathfloatcreate{\tikz@lib@dv@flags}{\pgf@sys@tonumber{\pgf@xc}}{\tikz@lib@dv@exp}%
+ \else
+ \begingroup
+ \c@pgf@countd=\tikz@lib@dv@exp
+ \advance\c@pgf@countd by1
+ \edef\tikz@lib@dv@exp{\the\c@pgf@countd}%
+ \pgfmath@smuggleone\tikz@lib@dv@exp
+ \endgroup
+ \divide\pgf@xc by 10\relax
+ \pgfmathfloatcreate{\tikz@lib@dv@flags}{\pgf@sys@tonumber{\pgf@xc}}{\tikz@lib@dv@exp}%
+ \fi
+ \pgfmathfloattofixed{\pgfmathresult}%
+ \let\tikz@lib@dv@step=\pgfmathresult
+}%
+
+
+
+
+
+%
+% Logarithmic axes
+%
+
+\tikzset{
+ /tikz/data visualization/axis options/.cd,
+ exponential steps/.style={tick placement strategy=\tikz@lib@dv@compute@at@log},
+ %
+ % Basic setters
+ %
+ logarithmic/.style={
+ \tikz@dv@axis/function=\pgfdvmathln{\pgfvalue}{\pgfvalue},
+ \tikz@dv@axis/scaling/default=1 at 0 and 10 at 1,
+ exponential steps
+ }
+}%
+
+\def\tikz@lib@dv@compute@at@log{%
+ % Setup about:
+ \let\tikz@lib@dv@compute@about=\tikz@lib@dv@about@log%
+ \let\tikz@lib@dv@step\relax%
+ \pgfkeysvalueof{/tikz/data visualization/compute step}
+ \ifx\tikz@lib@dv@step\relax%
+ \else%
+ % Gather interesting values
+ \tikz@lib@dv@mapper.get in range interval()%
+ \pgfdvinrangeinterval.get min and max()%
+ \pgfdvmathlog{\pgfdvminlog}{\pgfdvmin}%
+ \pgfdvmathlog{\pgfdvmaxlog}{\pgfdvmax}%
+ \pgfkeysgetvalue{/tikz/data visualization/phase}\tikz@temp
+ \pgfdvmathenter{\tikz@dv@lib@phase}{\tikz@temp}
+ \pgfdvmathenter{\tikz@dv@lib@step}{\tikz@lib@dv@step}
+ % Compute start:
+ \pgfdvmathsub{\tikz@dv@lib@temp}{\pgfdvminlog}{\tikz@dv@lib@phase}% temp = dvmin - phase
+ \pgfdvmathdiv{\tikz@dv@lib@temp}{\tikz@dv@lib@temp}{\tikz@dv@lib@step}% temp = temp/step
+ \pgfdvmathfloor{\tikz@dv@lib@temp}{\tikz@dv@lib@temp}% temp = floor(temp)
+ \pgfdvmathmul{\tikz@lib@dv@current}{\tikz@dv@lib@temp}{\tikz@dv@lib@step}% current = temp*step ...
+ \pgfdvmathadd{\tikz@lib@dv@current}{\tikz@lib@dv@current}{\tikz@dv@lib@phase}% + phase
+ \let\tikz@lib@dv@ats\pgfutil@empty%
+ \let\tikz@lib@dv@minor@ats\pgfutil@empty%
+ \pgfdvmathenter{\tikz@one@hundreth}{0.001}%
+ \pgfdvmathsub{\tikz@lib@temp}{\pgfdvmaxlog}{\pgfdvminlog}%
+ \pgfdvmathmul{\tikz@lib@dv@epsilon}{\tikz@lib@temp}{\tikz@one@hundreth}% epsilon = (max - min)/100
+ \pgfdvmathsub{\tikz@lib@dv@min@minus@epsilon}{\pgfdvminlog}{\tikz@lib@dv@epsilon}%
+ \pgfdvmathadd{\tikz@lib@dv@max@plus@epsilon}{\pgfdvmaxlog}{\tikz@lib@dv@epsilon}%
+ \pgfkeysgetvalue{/tikz/data visualization/minor steps between steps}\tikz@lib@dv@substeps%
+ \ifx\tikz@lib@dv@substeps\pgfutil@empty
+ \else
+ \pgfmathsetmacro\tikz@temp{\tikz@lib@dv@substeps+1}%
+ \pgfdvmathenter{\tikz@dv@lib@substeps}{\tikz@temp}%
+ \fi
+ \loop%
+ \ifx\tikz@lib@dv@substeps\pgfutil@empty%
+ \else%
+ \let\tikz@lib@dv@subcurrent=\tikz@lib@dv@current%
+ \pgfdvmathadd{\tikz@lib@dv@subcurrent@next}{\tikz@lib@dv@subcurrent}{\tikz@dv@lib@step}%
+ \pgfdvmathpowten{\tikz@lib@dv@subcurrent}{\tikz@lib@dv@subcurrent}%
+ \pgfdvmathpowten{\tikz@lib@dv@subcurrent@max}{\tikz@lib@dv@subcurrent@next}%
+ \pgfdvmathsub{\tikz@lib@dv@subcurrent@diff}{\tikz@lib@dv@subcurrent@max}{\tikz@lib@dv@subcurrent}%
+ \pgfdvmathdiv{\tikz@lib@dv@substep}{\tikz@lib@dv@subcurrent@diff}{\tikz@dv@lib@substeps}%
+ \pgfmathsetcount{\c@pgf@counta}{\tikz@lib@dv@substeps}%
+ \let\tikz@lib@dv@next=\tikz@lib@dv@subloop%
+ \tikz@lib@dv@subloop
+ \fi%
+ \pgfdvmathifless{\tikz@lib@dv@current}{\tikz@lib@dv@min@minus@epsilon}{}{%
+ \pgfdvmathpowten{\tikz@lib@dv@current@pow}{\tikz@lib@dv@current}%
+ \pgfdvmathexitbyserializing{\tikz@temp}{\tikz@lib@dv@current@pow}%
+ \edef\tikz@lib@dv@ats{\tikz@lib@dv@ats,\tikz@temp}%
+ }
+ \pgfdvmathadd{\tikz@lib@dv@current}{\tikz@lib@dv@current}{\tikz@dv@lib@step}%
+ \pgfdvmathifless{\tikz@lib@dv@current}{\tikz@lib@dv@max@plus@epsilon}{\tikz@lib@dv@continuetrue}{\tikz@lib@dv@continuefalse}%
+ \iftikz@lib@dv@continue%
+ \repeat%
+ \tikzdatavisualizationset{major/.expanded={at={\tikz@lib@dv@ats}},minor/.expanded={at={\tikz@lib@dv@minor@ats}}}%
+ \fi%
+}%
+
+
+\def\tikz@lib@dv@about@log#1{%
+ \tikz@lib@dv@mapper.get in range interval()%
+ \pgfdvinrangeinterval.get min and max()%
+ \pgfdvmathlog{\pgfdvmin}{\pgfdvmin}%
+ \pgfdvmathlog{\pgfdvmax}{\pgfdvmax}%
+ \pgfdvmathsub{\tikz@lib@dv@diff}{\pgfdvmax}{\pgfdvmin}
+ \pgfdvmathenter{\tikz@lib@dv@about@val}{#1}%
+ \pgfdvmathdiv{\tikz@lib@dv@around}{\tikz@lib@dv@diff}{\tikz@lib@dv@about@val}%
+ % Make mantisse sensible
+ \pgfmathfloattomacro{\tikz@lib@dv@around}{\tikz@lib@dv@flags}{\tikz@lib@dv@mant}{\tikz@lib@dv@exp}
+ \ifdim\tikz@lib@dv@exp pt<0pt%
+ \pgfmathfloatcreate{1}{1.0}{0}%
+ \else
+ \pgf@xc=\tikz@lib@dv@mant pt\relax%
+ \ifdim\pgf@xc<2.5pt
+ \pgfmathfloatcreate{1}{1.0}{\tikz@lib@dv@exp}
+ \else\ifdim\pgf@xc<5.1pt
+ \pgfmathfloatcreate{1}{3.0}{\tikz@lib@dv@exp}
+ \else
+ \pgfmathfloatcreate{1}{6.0}{\tikz@lib@dv@exp}
+ \fi\fi
+ \fi%
+ \pgfmathfloattofixed{\pgfmathresult}
+ \let\tikz@lib@dv@step=\pgfmathresult
+}%
+
+
+
+
+
+
+
+%
+% Cartesian axes
+%
+
+\tikzdatavisualizationset{%
+ new Cartesian axis/.style={
+ new axis base={#1},
+ new object={
+ class=linear transformer,
+ store=/tikz/data visualization/#1/linear transformer,
+ arg1/.expanded=\pgfkeysvalueof{/tikz/data visualization/#1/attribute}/scaled,
+ arg2 from key=/tikz/data visualization/#1/unit vector,
+ },
+ #1/scaling/default/.initial=0 at 0 and 1 at 1cm,
+ #1/unit vector/.initial=\pgfqpoint{1pt}{0pt},
+ }
+}%
+
+\tikzset{
+ /tikz/data visualization/axis options/.cd,
+ unit vector/.code=\tikz@scan@one@point\tikz@lib@dv@uv#1,
+ length/.style={\tikz@dv@axis/scaling=min at 0 and max at {#1}},
+ unit length/.code={\tikz@dv@parse@unit@length{#1}},
+ power unit length/.style={\tikz@dv@axis/scaling=1 at 0 and 10 at {#1}}
+}%
+
+\def\tikz@lib@dv@uv#1{%
+ \pgfkeyssetvalue{\tikz@dv@axis/unit vector}{#1}
+}%
+
+\def\tikz@dv@parse@unit@length#1{
+ \pgfutil@in@{per}{#1}
+ \ifpgfutil@in@%
+ \tikz@dv@parse@unit@length@#1\pgf@stop%
+ \else%
+ \tikz@dv@parse@unit@length@#1per1units\pgf@stop%
+ \fi%
+}%
+\def\tikz@dv@parse@unit@length@#1per#2units\pgf@stop{
+ \pgfkeysalso{\tikz@dv@axis/scaling=0 at 0 and {#2} at {#1}}
+}%
+
+
+%
+% Common visualizer interface
+%
+
+\tikzdatavisualizationset{
+ new visualizer/.style n args={3}{
+ #1/.code={
+ \def\tikz@visualizer{#1}%
+ \pgfkeys{/tikz/data visualization/visualizer options/.cd,##1}
+ \pgf@dv@do@adddata{\pgfkeysvalueof{/pgf/data visualization/obj}.add data(\pgfkeys{/data point/set={#1}})}%
+ },
+ /utils/exec={
+ \advance\tikzdvvisualizercounter by 1\relax
+ \edef\tikz@temp{/data point/set/#1/.initial=\the\tikzdvvisualizercounter}
+ \expandafter\tikzset\expandafter{\tikz@temp}
+ },
+ /data point/#1/execute at begin/.initial={
+ \pgfkeyssetvalue{/data point/set}{#1}
+ \scope[
+ #2,
+ /tikz/data visualization/every visualizer/.try,
+ /tikz/data visualization/visualizers/#1/signal,
+ /tikz/data visualization/visualizers/#1/styling/.try]
+ },
+ /data point/#1/execute at end/.initial={
+ \path; % invokes every path implicitly
+ \endscope
+ },
+ /tikz/data visualization/visualizers/#1/signal/.code=\pgf@signalstyle.emit(),
+ /tikz/data visualization/visualizers/#1/styling/.style=,
+ /tikz/data visualization/visualizers/#1/label in legend options/.style={#3},
+ },
+ style sheet/.style={/data point/set/.style sheet={#1}},
+ /pgf/data/set/.style={/data point/set={#1}},
+}%
+
+\tikzdatavisualizationset{
+ new sub visualizer/.style n args={4}{
+ #4/#1/.code={
+ \def\tikz@visualizer{#4/#1}%
+ \pgfkeys{/tikz/data visualization/visualizer options/.cd,##1}
+ },
+ /data point/#4/#1/execute at begin/.initial={
+ \pgfkeyssetvalue{/data point/set}{#4}
+ \scope[
+ #2,
+ /tikz/data visualization/every visualizer/.try,
+ /tikz/data visualization/visualizers/#4/signal,
+ /tikz/data visualization/visualizers/#4/styling/.try,
+ /tikz/data visualization/visualizers/#4/#1/styling/.try]
+ },
+ /data point/#4/#1/execute at end/.initial={
+ \path; % invokes every path implicitly
+ \endscope
+ },
+ /tikz/data visualization/visualizers/#4/#1/styling/.style=,
+ /tikz/data visualization/visualizers/#4/#1/label in legend options/.style={#3},
+ }
+}%
+
+
+\def\tikz@do@visualizer#1#2{%
+ \tikzdatavisualizationset{
+ #2={#1}
+ }
+}%
+
+\newcount\tikzdvvisualizercounter
+
+\newif\iftikz@dv@visualizer@label@inline
+
+\tikzdatavisualizationset{visualizer options/.cd,
+ @set/.style 2 args={
+ /tikz/data visualization/visualizers/\tikz@visualizer/styling/.append style={/utils/exec={\let\tikz@dv@plot@handler=#1}},
+ /tikz/data visualization/visualizers/\tikz@visualizer/label in legend options/.append style={#2}
+ },
+ no lines/.style={@set={\pgfplothandlerdiscard}{default label in legend mark}},
+ smooth line/.style={@set={\pgfplothandlercurveto}{default label in legend path}},
+ smooth cycle/.style={@set={\pgfplothandlerclosedcurve}{default label in legend closed path}},
+ straight line/.style={@set={\pgfplothandlerlineto}{default label in legend path}},
+ straight cycle/.style={@set={\pgfplothandlerpolygon}{default label in legend closed path}},
+ polygon/.style={straight cycle},% alias
+ gap line/.style={@set={\pgfplothandlergaplineto}{default label in legend path}},
+ gap cycle/.style={@set={\pgfplothandlergapcycle}{gap circular label in legend line}}
+}%
+
+
+
+%
+% Label visualizer
+%
+
+\tikzdatavisualizationset{
+ new label visualizer/.style 2 args={
+ new object={
+ when=before visualization,
+ class=label visualizer,
+ before creation={
+ \begingroup
+ \def\tikz@visualizer{#1}%
+ \pgfkeys{/tikz/data visualization/visualizer label options/.cd,
+ #2}
+ \pgfkeysgetvalue{/tikz/data visualization/visualizer label options/text}\tikz@dv@temp@lab
+ \def\tikz@tempa{
+ \scope[
+ /utils/exec=\def\tikz@visualizer{#1},%
+ /tikz/data visualization/visualizer label options/.cd,
+ #2]
+ \tikzdatavisualizationset{every data set label/.try}
+ \path [
+ /data point/set={#1},/utils/exec=\pgf@signalstyle.emit(),
+ /tikz/data visualization/.cd,every label in data/.try]
+ (label visualizer coordinate') --
+ (label visualizer coordinate)
+ node [
+ auto,
+ at end,
+ /tikz/data visualization/node styling]
+ }
+ \expandafter\def\expandafter\tikz@tempb\expandafter{\expandafter{\tikz@dv@temp@lab};}%
+ \expandafter\expandafter\expandafter\gdef%
+ \expandafter\expandafter\expandafter\tikz@dv@label@code%
+ \expandafter\expandafter\expandafter{\expandafter\expandafter\expandafter\relax%
+ \expandafter\expandafter\expandafter{\expandafter\tikz@tempa\tikz@tempb\endscope}}
+ \global\let\tikz@dv@label@attribute=\tikz@dv@label@attribute
+ \global\let\tikz@dv@label@threshold=\tikz@dv@label@threshold
+ \endgroup
+ },
+ arg1/.expand once=\tikz@dv@label@attribute,
+ arg2=\tikz@dv@label@threshold,
+ arg3/.expand once=\tikz@dv@label@code,
+ arg4=\pgfdvvisualizerfilter{#1}
+ },
+ /utils/exec=\tikz@create@label@count{#1}
+ },
+ % Label style
+ text colored/.style={node style={text=visualizer color}}
+}%
+
+\def\tikz@create@label@count#1{
+ \tikzdatavisualizationset{
+ new object={
+ when=before survey,
+ store=/tikz/data visualization/visualizers/#1/count/obj,
+ class=count,
+ arg1=set/#1/count,
+ after creation={\tikzdvobj.set filter(\pgfdvvisualizerfilter{#1})}
+ }
+ }
+}%
+
+\pgfkeys{
+ /tikz/data visualization/visualizer label options/.cd,
+ when/.code args={#1 is#2}{%
+ \def\tikz@dv@label@attribute{#1}%
+ \def\tikz@dv@label@threshold{#2}%
+ },
+ index/.code={%
+ \edef\tikz@dv@label@attribute{set/\tikz@visualizer/count}%
+ \def\tikz@dv@label@threshold{#1}%
+ },
+ pos/.code={%
+ \edef\tikz@dv@label@attribute{set/\tikz@visualizer/count}%
+ \pgfkeysvalueof{/tikz/data visualization/visualizers/\tikz@visualizer/count/obj}.get max(\tikz@lib@max)
+ \edef\tikz@dv@label@threshold{(#1*\tikz@lib@max)}%
+ },
+ auto/.code={%
+ \edef\tikz@dv@label@attribute{set/\tikz@visualizer/count}%
+ \pgfkeysvalueof{/tikz/data visualization/visualizers/\tikz@visualizer/count/obj}.get max(\tikz@lib@max)
+ \edef\tikz@dv@label@threshold{({(\pgfkeysvalueof{/data point/set/\tikz@visualizer}-0.5)/\the\tikzdvvisualizercounter*\tikz@lib@max})}
+ },
+ text/.initial=,
+ text'/.style={text={#1},node style=swap,/utils/exec=\def\tikz@lib@dv@pin@sign{-}},
+ node style/.style={/tikz/data visualization/node style={#1}},
+ text colored/.style=/tikz/data visualization/text colored,
+ pin angle/.store in=\tikz@lib@dv@pin@dir,
+ pin length/.style={node style={pin distance={#1}}},
+}%
+
+\let\tikz@lib@dv@pin@sign\pgfutil@empty
+
+\let\tikz@dv@label@attribute\pgfutil@empty
+\let\tikz@dv@label@threshold\pgfutil@empty
+\let\tikz@dv@label@code\pgfutil@empty
+
+
+
+
+%
+% Legend handling
+%
+
+\tikzdatavisualizationset{
+ new legend/.code={
+ \pgfkeysifdefined{/tikz/data visualization/#1/at}{}
+ {\tikzdatavisualizationset{
+ new object={
+ class=legend,
+ store=/tikz/data visualization/#1/obj,
+ arg1 from key=/tikz/data visualization/#1/@columns or rows,
+ arg2 from key=/tikz/data visualization/#1/@ideal,
+ arg3 from key=/tikz/data visualization/#1/max entries,
+ arg4 from key=/tikz/data visualization/#1/@strategy,
+ after creation={
+ \tikzdatavisualizationset{
+ legend actions/.append={
+ \pgfkeysgetvalue{/tikz/data visualization/#1/obj}\pgf@dv@legend%
+ {
+ \pgf@dv@legend.get arrangement(\pgf@dv@temp)%
+ \pgfkeysgetvalue{/tikz/data visualization/#1/at}\pgf@dv@at%
+ \pgfkeysgetvalue{/tikz/data visualization/#1/anchor}\pgf@dv@anchor%
+ \let\pgfdvnextcell=\pgfmatrixnextcell%
+ \let\pgfdvendrow=\pgfmatrixendrow%
+ \def\pgf@marshal{
+ \matrix[at/.expand once=\pgf@dv@at,matrix anchor/.expand
+ once=\pgf@dv@anchor,/tikz/data visualization/#1/matrix node styling]
+ }
+ \expandafter\pgf@marshal\expandafter{\pgf@dv@temp};
+ }
+ }
+ }
+ }
+ },
+ #1/@columns or rows/.initial=columns,
+ #1/@ideal/.initial=1,
+ #1/max entries/.initial=100,
+ #1/@strategy/.initial=down then right,
+ #1/anchor/.initial=west,
+ #1/at/.initial=(data visualization bounding box.east),
+ #1/matrix node styling/.style={row sep=0pt,column sep=.8em},
+ %
+ %
+ %
+ #1/.code={
+ \let\tikz@temp\tikz@dv@legend%
+ \def\tikz@dv@legend{/tikz/data visualization/#1}%
+ \expandafter\tikz@do@legend@options\expandafter{\tikz@temp}{##1}%
+ },
+ #1={every new legend}
+ }}},
+ new legend/.default=main legend,
+ legend/.style={
+ new legend,
+ main legend={#1}
+ }
+}%
+
+\def\tikz@do@legend@options#1#2{
+ \pgfkeys{/tikz/data visualization/legend options/.cd,#2}
+ \def\tikz@dv@legend{#1}
+}%
+\let\tikz@dv@legend\pgfutil@empty
+
+
+\tikzset{
+ /tikz/data visualization/legend options/.cd,
+ %
+ % How to arrange the entries in the legend
+ %
+ ideal number of columns/.style={\tikz@dv@legend/@columns or rows=columns,\tikz@dv@legend/@ideal={#1}},
+ ideal number of rows/.style={\tikz@dv@legend/@columns or rows=rows,\tikz@dv@legend/@ideal={#1}},
+ columns/.style={ideal number of columns={#1}},% alias
+ rows/.style={ideal number of rows={#1}},% alias
+ max rows/.style={\tikz@dv@legend/@columns or rows=columns,\tikz@dv@legend/max entries={#1}},
+ max columns/.style={\tikz@dv@legend/@columns or rows=rows,\tikz@dv@legend/max entries={#1}},
+ down then right/.style={\tikz@dv@legend/@strategy=down then right},
+ down then left/.style={\tikz@dv@legend/@strategy=down then left},
+ up then right/.style={\tikz@dv@legend/@strategy=up then right},
+ up then left/.style={\tikz@dv@legend/@strategy=up then left},
+ right then down/.style={\tikz@dv@legend/@strategy=right then down},
+ left then down/.style={\tikz@dv@legend/@strategy=left then down},
+ right then up/.style={\tikz@dv@legend/@strategy=right then up},
+ left then up/.style={\tikz@dv@legend/@strategy=left then up},
+ %
+ % Where to put the legend
+ %
+ anchor/.style={\tikz@dv@legend/anchor={#1}},
+ at/.style={\tikz@dv@legend/at={#1}},
+ % Outer placements
+ right/.style={east outside},
+ left/.style={west outside},
+ above/.style={north outside},
+ below/.style={south outside},
+ east outside/.style={
+ columns=1,
+ at={([xshift=.8em]data visualization bounding box.east)},
+ anchor=west,
+ },
+ north east outside/.style={
+ columns=1,
+ at={([xshift=.8em]data visualization bounding box.north east|-
+ data bounding box.north)},
+ anchor=north west,
+ },
+ south east outside/.style={
+ columns=1,
+ at={([xshift=.8em]data visualization bounding box.south east |-
+ data bounding box.south)},
+ anchor=south west,
+ },
+ west outside/.style={
+ columns=1,
+ label style=text left,
+ at={([xshift=-.8em]data visualization bounding box.west)},
+ anchor=east,
+ },
+ north west outside/.style={
+ columns=1,
+ label style=text left,
+ at={([xshift=-.8em]data visualization bounding box.north west |-
+ data bounding box.north)},
+ anchor=north east,
+ },
+ south west outside/.style={
+ columns=1,
+ label style=text left,
+ at={([xshift=-.8em]data visualization bounding box.south west |-
+ data bounding box.south)},
+ anchor=south east,
+ },
+ south outside/.style={
+ rows=1,
+ at={([yshift=-.5em]data visualization bounding box.south)},
+ anchor=north,
+ },
+ north outside/.style={
+ rows=1,
+ at={([yshift=.5em]data visualization bounding box.north)},
+ anchor=south,
+ },
+ every new legend/.style={east outside,label style=text right},
+ %
+ % Inner placements
+ %
+ % First, styling
+ every legend inside/.style={
+ opaque=white,
+ label style={node style={font=\pgfutil@font@footnotesize}}
+ },
+ opaque/.style={
+ matrix node style={
+ inner sep=.333ex,
+ outer sep=.5ex,
+ rounded corners=3pt,
+ execute at begin cell={\tikzset{sharp corners}}, % get rid of
+ % rounded corners in cells of the
+ % legend matrix
+ fill=#1
+ },
+ },
+ opaque/.default=white,
+ transparent/.style={matrix node style={fill=none}},
+ % Second, the placements
+ north east inside/.style={
+ columns=1,
+ at={([xshift=-.3em]data bounding box.north east)},
+ anchor=north east,
+ every legend inside
+ },
+ south west inside/.style={
+ columns=1,
+ at={([xshift=.3em]data bounding box.south west)},
+ anchor=south west,
+ every legend inside
+ },
+ north west inside/.style={
+ columns=1,
+ at={([xshift=.3em]data bounding box.north west)},
+ anchor=north west,
+ every legend inside
+ },
+ south east inside/.style={
+ columns=1,
+ at={([xshift=-.3em]data bounding box.south east)},
+ anchor=south east,
+ every legend inside
+ },
+ west inside/.style={
+ columns=1,
+ at={([xshift=.3em]data bounding box.west)},
+ anchor=west,
+ every legend inside
+ },
+ east inside/.style={
+ columns=1,
+ at={([xshift=.3em]data bounding box.east)},
+ anchor=east,
+ every legend inside
+ },
+ north inside/.style={
+ rows=1,
+ at={(data bounding box.north)},
+ anchor=north,
+ every legend inside
+ },
+ south inside/.style={
+ rows=1,
+ at={(data bounding box.south)},
+ anchor=south,
+ every legend inside
+ },
+ % Additional inner placements
+ at values/.style={
+ at={(visualization cs:#1)},
+ anchor=center,
+ every legend inside
+ },
+ right of/.style={
+ at={(visualization cs:#1)},
+ anchor=west,
+ every legend inside
+ },
+ left of/.style={
+ at={(visualization cs:#1)},
+ anchor=east,
+ every legend inside
+ },
+ above of/.style={
+ at={(visualization cs:#1)},
+ anchor=south,
+ every legend inside
+ },
+ below of/.style={
+ at={(visualization cs:#1)},
+ anchor=north,
+ every legend inside
+ },
+ above right of/.style={
+ at={(visualization cs:#1)},
+ anchor=south west,
+ every legend inside
+ },
+ above left of/.style={
+ at={(visualization cs:#1)},
+ anchor=south east,
+ every legend inside
+ },
+ below right of/.style={
+ at={(visualization cs:#1)},
+ anchor=north west,
+ every legend inside
+ },
+ below left of/.style={
+ at={(visualization cs:#1)},
+ anchor=north east,
+ every legend inside
+ },
+ %
+ %
+ %
+ % Label text styling
+ %
+ label style/.style={
+ matrix node style={/tikz/data visualization/every label in legend/.append style={#1}}
+ },
+ %
+ % Styling
+ %
+ matrix node style/.style={\tikz@dv@legend/matrix node styling/.append style={#1}},
+}%
+
+
+\tikzdatavisualizationset{
+ new legend entry/.code={
+ \begingroup
+ \pgfkeys{/tikz/data visualization/legend entry options/.cd,#1}
+ \pgfkeysgetvalue{/tikz/data visualization/legend entry options/legend}\tikz@dv@temp@legend
+ \global\let\tikz@dv@temp@legend\tikz@dv@temp@legend
+ \endgroup
+ \tikzdatavisualizationset{new legend/.expanded=\tikz@dv@temp@legend}%
+ \expandafter\tikz@dv@add@legend@entry\expandafter{\tikz@dv@temp@legend}{#1}
+ }
+}%
+
+\def\tikz@dv@add@legend@entry#1#2{
+ \tikz@main@dv.at start survey({
+ \pgfkeysgetvalue{/tikz/data visualization/#1/obj}\pgf@temp
+ \pgf@temp.add entry(\tikz@dv@render@legend@entry{legend=#1,#2})
+ })
+}%
+
+\def\tikz@dv@render@legend@entry#1{
+ \pgfkeys{/tikz/data visualization/.cd,every data set label}
+ \pgfkeys{/tikz/data visualization/legend entry options/.cd,
+ /tikz/data visualization/every label in legend,#1}%
+ \pgfkeysgetvalue{/tikz/data visualization/legend entry options/text}\tikz@dv@temp@lab
+ \pgfkeysgetvalue{/tikz/data visualization/@node styling}\tikz@dv@temp@style
+ \pgfkeysgetvalue{/tikz/data visualization/legend entry options/setup}\tikz@dv@temp@setup
+ \pgfkeysgetvalue{/tikz/data visualization/legend entry options/visualizer in legend styling}\tikz@dv@temp@visual@styling
+ \scope[/utils/exec=\expandafter\pgfkeysalso\expandafter{\tikz@dv@temp@setup},
+ /utils/exec=\pgf@signalstyle.emit()]
+ \node[/tikz/data visualization/node styling,
+ /utils/exec=\expandafter\pgfkeysalso\expandafter{\tikz@dv@temp@style}]
+ {\tikz@dv@pre@height\tikz@dv@temp@lab\tikz@dv@post@height};
+ \scope[/utils/exec=\expandafter\pgfkeysalso\expandafter{\tikz@dv@temp@visual@styling}]
+ \iftikz@lib@dv@text@only
+ \else
+ \pgfkeysvalueof{/tikz/data visualization/legend entry options/visualizer in legend}
+ \fi
+ \endscope
+ \endscope
+}%
+
+\def\tikz@dv@pre@height{\hbox{\vrule height .75em width0pt}}%
+\def\tikz@dv@post@height{\hbox{\vrule depth .25em width0pt}}%
+
+
+
+\pgfkeys{
+ /tikz/data visualization/legend entry options/.cd,
+ %
+ % General options
+ %
+ text/.initial=,
+ node style/.style={/tikz/data visualization/node style={#1}},
+ legend/.initial=main legend,
+ setup/.initial=,
+ visualizer in legend/.initial=,
+ visualizer in legend styling/.initial=,
+ visualizer in legend style/.style={visualizer in legend styling/.append={,#1}},
+ %
+ % Legend visualizers for plots
+ %
+ text right/.style={
+ node style={anchor=mid west,inner ysep=1pt,inner xsep=0pt,reset cm,xshift=.333em},
+ visualizer in legend style={reset cm},
+ },
+ text left/.style={
+ node style={anchor=mid east,inner ysep=1pt,inner xsep=0pt,reset
+ cm,xshift=-.333em,align=right},
+ visualizer in legend style={reset cm,xscale=-1},
+ },
+ text only/.style={
+ node style={anchor=mid west,inner ysep=1pt,inner xsep=0pt,reset cm,text=visualizer color},
+ /utils/exec=\tikz@lib@dv@text@onlytrue
+ },
+ text colored/.style=/tikz/data visualization/text colored,
+}%
+\let\tikz@lib@dv@pin@dir\pgfutil@empty
+\newif\iftikz@lib@dv@text@only
+
+\pgfkeys{
+ /tikz/data visualization/visualizer options/.cd,
+ label in legend/.code={\expandafter\tikz@dv@new@label@in@legend@for@visualizer\expandafter{\tikz@visualizer}{#1}},
+ label in data/.code=\tikzdatavisualizationset{new label visualizer/.expand once=\expandafter{\tikz@visualizer}{auto,#1}},
+ pin in data/.style={label in data={%
+ node style={%
+ /utils/exec={
+ \ifx\tikz@lib@dv@pin@dir\pgfutil@empty
+ \pgf@process{\pgfpointnormalised{%
+ \pgfpointdiff%
+ {\pgfpointanchor{label visualizer coordinate}{center}}%
+ {\pgfpointanchor{label visualizer coordinate'}{center}}}}%
+ \pgf@x=-\pgf@x\relax%
+ \edef\tikz@lib@dv@temp@rot{\noexpand\pgfqpoint{\the\pgf@y}{\the\pgf@x}}%
+ \tikz@addtransform{\pgftransformshift{\pgfpointscale{\tikz@lib@dv@pin@sign\tikz@pin@distance}{\tikz@lib@dv@temp@rot}}}
+ \else%
+ \tikz@addtransform{\pgftransformshift{\pgfpointpolar{\tikz@lib@dv@pin@dir}{\tikz@lib@dv@pin@sign\tikz@pin@distance}}}
+ \fi%
+ },
+ append after command={
+ \bgroup
+ [current point is local=true]
+ (\tikzlastnode) edge [solid, every pin edge] (label visualizer coordinate)
+ \egroup%
+ }},
+ ,#1}},
+ style/.style={/tikz/data visualization/visualizers/\tikz@visualizer/styling/.append style={,#1}},
+ label in legend options/.style={/tikz/data visualization/visualizers/\tikz@visualizer/label in legend options/.append style={,#1}},
+ ignore style sheets/.style={/tikz/data visualization/visualizers/\tikz@visualizer/signal/.code=,/utils/exec=\advance\tikzdvvisualizercounter by -1\relax},
+}%
+
+\def\tikz@dv@new@label@in@legend@for@visualizer#1#2{
+ \tikzdatavisualizationset{
+ new legend entry={
+ visualizer in legend style={/tikz/data visualization/visualizers/#1/styling/.try},
+ /tikz/data visualization/every label in legend/.try,
+ /tikz/.cd,
+ every label/.try,
+ /tikz/data visualization/legend entry options/.cd,
+ setup={/data point/set={#1}},
+ /tikz/data visualization/visualizers/#1/label in legend options/.try,
+ #2,
+ }
+ }
+}%
+
+\def\tikz@dv@legend@entry@as@example{
+ \pgfkeysgetvalue{/data point/set}{\tikz@visualizer}
+ \pgfkeysvalueof{/data point/\tikz@visualizer/execute at begin}
+ \tikz@dv@plot@handler
+ \pgfplotstreamstart
+ \pgfkeysgetvalue{/tikz/data visualization/legend entry options/label in legend line coordinates}{\tikz@dv@temp}
+ \foreach \coordinate in \tikz@dv@temp
+ { \pgfplotstreampoint{\expandafter\tikz@scan@one@point\expandafter\pgfutil@firstofone\coordinate} }
+ \pgfplotstreamend
+ \pgfkeysvalueof{/data point/\tikz@visualizer/execute at end}
+ \pgfkeysvalueof{/data point/\tikz@visualizer/execute at begin}
+ \tikz@dv@plot@mark@maker
+ \pgfplotstreamstart
+ \pgfkeysgetvalue{/tikz/data visualization/legend entry options/label in legend mark coordinates}{\tikz@dv@temp}
+ \foreach \coordinate in \tikz@dv@temp
+ { \pgfplotstreampoint{\expandafter\tikz@scan@one@point\expandafter\pgfutil@firstofone\coordinate} }
+ \pgfplotstreamend
+ \pgfkeysvalueof{/data point/\tikz@visualizer/execute at end}
+}%
+
+
+\tikzdatavisualizationset{
+ legend entry options/.cd,
+ label in legend line coordinates/.initial=,
+ label in legend rectangle coordinates/.initial={(-1ex,-.5ex),(-1ex,0.968ex),(0ex,0.968ex),(0ex,-.5ex)},
+ label in legend mark coordinates/.initial=,
+ label in legend one mark/.style={
+ label in legend line coordinates={},
+ label in legend mark coordinates={(0,0)},
+ },
+ label in legend three marks/.style={
+ label in legend line coordinates={},
+ label in legend mark coordinates={(-3ex,-.3ex),(-1.5ex,.3ex),(0,0)},
+ },
+ straight label in legend line/.style={
+ label in legend line coordinates={(-2em,0),(-1.5em,0),(-.5em,0),(0,0)},
+ label in legend mark coordinates={(-1.5em,0),(-.5em,0)},
+ },
+ zig zag label in legend line/.style={
+ label in legend line coordinates={(-2em,0),(-1.5em,.3ex),(-.5em,-.3ex),(0,0)},
+ label in legend mark coordinates={(-1.5em,.3ex),(-.5em,-.3ex)},
+ },
+ circular label in legend line/.style={
+ label in legend line coordinates={%
+ ([xshift=-1em]0:.9em and .35ex),%
+ ([xshift=-1em]45:.9em and .35ex),%
+ ([xshift=-1em]90:.9em and .35ex),%
+ ([xshift=-1em]135:.9em and .35ex),%
+ ([xshift=-1em]180:.9em and .35ex),%
+ ([xshift=-1em]225:.9em and .35ex),%
+ ([xshift=-1em]270:.9em and .35ex),%
+ ([xshift=-1em]315:.9em and .35ex)},%
+ label in legend mark coordinates={([xshift=-1em]120:.9em and .35ex),([xshift=-1em]-60:.9em and .35ex)},
+ },
+ gap circular label in legend line/.style={
+ label in legend line coordinates={%
+ ([xshift=-1em,yshift=.2ex]90:1.4ex and 0.9ex),%
+ ([xshift=-1em,yshift=.2ex]162:1.4ex and 0.9ex),%
+ ([xshift=-1em,yshift=.2ex]234:1.4ex and 0.9ex),%
+ ([xshift=-1em,yshift=.2ex]306:1.4ex and 0.9ex),%
+ ([xshift=-1em,yshift=.2ex]18:1.4ex and 0.9ex)},
+ label in legend mark coordinates={
+ ([xshift=-1em,yshift=.2ex]90:1.4ex and 0.9ex),%
+ ([xshift=-1em,yshift=.2ex]162:1.4ex and 0.9ex),%
+ ([xshift=-1em,yshift=.2ex]234:1.4ex and 0.9ex),%
+ ([xshift=-1em,yshift=.2ex]306:1.4ex and 0.9ex),%
+ ([xshift=-1em,yshift=.2ex]18:1.4ex and 0.9ex)}
+ },
+ default label in legend path/.style={zig zag label in legend line},
+ default label in legend closed path/.style={circular label in legend line},
+ default label in legend mark/.style={label in legend one mark},
+}%
+
+
+\def\tikz@dv@legend@entry@visualizer@visualizer{
+}%
+
+
+
+%
+% Basic visualizers
+%
+
+\tikzdatavisualizationset{
+ visualize as line/.style={
+ new object={
+ when=after survey,
+ store=/tikz/data visualization/visualizers/#1,
+ class=plot handler visualizer,
+ arg1=#1,
+ arg2={\tikz@dv@plot@handler,\tikz@dv@plot@mark@maker}
+ },
+ new visualizer={#1}{%
+ every path/.style={draw},
+ style={every mark/.append style={color=visualizer color}},
+ mark size=2pt,
+ semithick,
+ color=visualizer color,
+ mark=none,
+ /tikz/data visualization/every visualize as line/.try,
+ }{visualizer in legend=\tikz@dv@legend@entry@as@example},
+ #1={straight line}
+ },
+ visualize as line/.default=line,
+ visualize as smooth line/.style={
+ visualize as line={#1},
+ #1={smooth line}
+ },
+ visualize as smooth line/.default=line,
+ visualize as smooth cycle/.style={
+ visualize as smooth line={#1},
+ #1={smooth cycle}
+ },
+ visualize as smooth cycle/.default=line,
+ visualize as scatter/.style={
+ new object={
+ when=after survey,
+ store=/tikz/data visualization/visualizers/#1,
+ class=plot handler visualizer,
+ arg1=#1,
+ arg2={\tikz@dv@plot@mark@maker}
+ },
+ new visualizer={#1}{%
+ mark=x,
+ mark size=2pt,
+ style={every mark/.append style={color=visualizer color}},
+ /tikz/data visualization/every visualize as scatter/.try,
+ }{visualizer in legend=\tikz@dv@legend@entry@as@example},
+ #1={no lines}
+ },
+ visualize as scatter/.default=scatter
+}%
+
+\def\tikz@dv@plot@mark@maker{
+ \let\tikz@options=\pgfutil@empty%
+ \let\tikz@transform=\pgfutil@empty%
+ \tikzset{solid,shift only,every mark}%
+ \tikz@options%
+ \ifx\tikz@plot@mark\pgfutil@empty%
+ \pgfplothandlerdiscard
+ \else
+ \pgfplothandlermark{\tikz@transform\pgfuseplotmark{\tikz@plot@mark}}
+ \fi
+}%
+
+
+
+%
+% Rectangle visualizers
+%
+
+
+\tikzdatavisualizationset{
+ visualize as rectangles/.style={
+ new object={
+ when=before survey,
+ store=/tikz/data visualization/visualizers/#1,
+ class=rectangle visualizer,
+ arg1=#1
+ },
+ /data point/#1/attribute 1/.initial=x,
+ /data point/#1/attribute 2/.initial=y,
+ new visualizer={#1}{%
+ every path/.style={draw},
+ semithick,
+ color=visualizer color,
+ /tikz/data visualization/every visualize as rectangles/.try,
+ }{visualizer in legend=\tikz@dv@legend@entry@as@rectangle},
+ #1={}
+ },
+ visualize as rectangles/.default=rectangles,
+ %
+ %
+ %
+ visualizer options/.cd,
+ attribute 1/.style={/data point/\tikz@visualizer/attribute 1={#1}},
+ attribute 2/.style={/data point/\tikz@visualizer/attribute 2={#1}},
+}%
+
+
+
+\def\tikz@dv@legend@entry@as@rectangle{
+ \pgfkeysgetvalue{/data point/set}{\tikz@visualizer}
+ \pgfkeysvalueof{/data point/\tikz@visualizer/execute at begin}
+ \pgfplothandlerpolygon
+ \pgfplotstreamstart
+ \pgfkeysgetvalue{/tikz/data visualization/legend entry options/label in legend rectangle coordinates}{\tikz@dv@temp}
+ \foreach \coordinate in \tikz@dv@temp
+ { \pgfplotstreampoint{\expandafter\tikz@scan@one@point\expandafter\pgfutil@firstofone\coordinate} }
+ \pgfplotstreamend
+ \pgfkeysvalueof{/data point/\tikz@visualizer/execute at end}
+}%
+
+
+
+
+%
+% Style sheets
+%
+
+% Style sheet handler
+
+\pgfkeysdef{/handlers/.style sheet}{%
+ \edef\pgf@marshal{
+ \noexpand \pgfoonew \noexpand\tikz@dv@temp=new style attribute(\pgfkeyscurrentpath,#1)
+ \noexpand \tikz@dv@temp.default connects()
+ }
+ \pgf@marshal
+}%
+
+\tikzset{
+ visualizer color/.code=\colorlet{visualizer color}{#1},
+ visualizer color=black
+}%
+
+% Default style sheets
+
+\pgfdvdeclarestylesheet{vary thickness}
+{
+ default style/.style={line width={0.3pt+(#1)*0.2pt}}
+}%
+
+\pgfdvdeclarestylesheet{vary dashing}
+{
+ default style/.style=solid,
+ 1/.style=solid,
+ 2/.style={dash pattern=on 5\pgflinewidth off 2\pgflinewidth},
+ 3/.style={dash pattern=on 1.5\pgflinewidth off 1.5\pgflinewidth},
+ 4/.style={dash pattern=on 5\pgflinewidth off 1.5\pgflinewidth on 1.5\pgflinewidth off 1.5\pgflinewidth},
+ 5/.style={dash pattern=on 10\pgflinewidth off 3\pgflinewidth},
+ 6/.style={dash pattern=on 10\pgflinewidth off 2\pgflinewidth on 2\pgflinewidth off 2\pgflinewidth},
+ 7/.style={dash pattern=on 8\pgflinewidth off 2\pgflinewidth on
+ 1.5\pgflinewidth off 1.5\pgflinewidth on 1.5\pgflinewidth off
+ 1.5\pgflinewidth on 1.5\pgflinewidth off 1.5\pgflinewidth}
+}%
+
+\pgfdvdeclarestylesheet{vary thickness and dashing}
+{
+ default style/.style=thin,
+ 1/.style=thin,
+ 2/.style=thick,
+ 3/.style={
+ dash pattern=on 5\pgflinewidth off 2\pgflinewidth,
+ thin
+ },
+ 4/.style={
+ dash pattern=on 5\pgflinewidth off 2\pgflinewidth,
+ thick,
+ },
+ 5/.style={
+ dash pattern=on 1.5\pgflinewidth off 1.5\pgflinewidth,
+ thin
+ },
+ 6/.style={
+ dash pattern=on 1.5\pgflinewidth off 1.5\pgflinewidth,
+ thick
+ },
+ 7/.style={
+ dash pattern=on 5\pgflinewidth off 1.5\pgflinewidth on
+ 1.5\pgflinewidth off 1.5\pgflinewidth,
+ thin
+ },
+ 8/.style={
+ dash pattern=on 5\pgflinewidth off 1.5\pgflinewidth on
+ 1.5\pgflinewidth off 1.5\pgflinewidth,
+ thick
+ },
+ 9/.style={
+ dash pattern=on 10\pgflinewidth off 3\pgflinewidth,
+ thin
+ },
+ 10/.style={
+ dash pattern=on 10\pgflinewidth off 3\pgflinewidth,
+ thick
+ },
+ 11/.style={
+ dash pattern=on 10\pgflinewidth off 2\pgflinewidth on
+ 2\pgflinewidth off 2\pgflinewidth,
+ thin
+ },
+ 12/.style={
+ dash pattern=on 10\pgflinewidth off 2\pgflinewidth on
+ 2\pgflinewidth off 2\pgflinewidth,
+ thick
+ },
+ 13/.style={
+ dash pattern=on 8\pgflinewidth off 2\pgflinewidth on
+ 1.5\pgflinewidth off 1.5\pgflinewidth on 1.5\pgflinewidth off
+ 1.5\pgflinewidth on 1.5\pgflinewidth off 1.5\pgflinewidth,
+ thin
+ },
+ 14/.style={
+ dash pattern=on 8\pgflinewidth off 2\pgflinewidth on
+ 1.5\pgflinewidth off 1.5\pgflinewidth on 1.5\pgflinewidth off
+ 1.5\pgflinewidth on 1.5\pgflinewidth off 1.5\pgflinewidth,
+ thick
+ }
+}%
+
+
+\pgfdvdeclarestylesheet{strong colors}
+{
+ default style/.style={visualizer color=black},
+ 1/.style={visualizer color=black},
+ 2/.style={visualizer color=red!80!black},
+ 3/.style={visualizer color=blue!80!black},
+ 4/.style={visualizer color=green!60!black},
+ 5/.style={visualizer color=orange!80!black},
+ 6/.style={visualizer color=black!60}
+}%
+
+
+\pgfdvdeclarestylesheet{cross marks}
+{
+ default style/.style={mark=x,every mark/.append style=thin,mark size=2pt},
+ 1/.style={mark=x,every mark/.append style=thin,mark size=2pt},
+ 2/.style={mark=+,every mark/.append style=thin,mark size=2pt},
+ 3/.style={mark=Mercedes star,every mark/.append style=thin,mark size=2pt},
+ 4/.style={mark=Mercedes star flipped,every mark/.append style=thin,mark size=2pt},
+ 5/.style={mark=star,every mark/.append style=thin,mark size=2pt},
+ 6/.style={mark=10-pointed star,every mark/.append style={line width=.3pt,mark size=1.8pt}}
+}%
+
+
+\pgfdvdeclarestylesheet{* mark}
+{
+ default style/.style={mark=*,every mark/.append style=thin,mark size=1.4pt},
+}%
+
+\pgfdvdeclarestylesheet{dot mark}
+{
+ default style/.style={mark=*,every mark/.append style=thin,mark size=0.6pt},
+}%
+
+
+\pgfdvdeclarestylesheet{o mark}
+{
+ default style/.style={mark=o,every mark/.append style=thin,mark size=1.4pt},
+}%
+
+
+
+% Declare a color series style sheet
+%
+% #1 = name of the style sheet
+% #2 = color model
+% #3 = initial color
+% #4 = step
+%
+% Description:
+%
+% This function declares a style sheet that changes colors according
+% to the value of the attribute. No test is made that the attribute is
+% a number.
+
+\def\tikzdvdeclarestylesheetcolorseries#1#2#3#4{%
+ \definecolorseries{tikzdvcolorseries#1}{#2}{step}[#2]{#3}{#4}%
+ \resetcolorseries{tikzdvcolorseries#1}%
+ \pgfdvdeclarestylesheet{#1}
+ {
+ default style/.style={
+ /utils/exec=\colorlet{tikz@dv@temp}[rgb]{tikzdvcolorseries#1!![##1]},
+ visualizer color=tikz@dv@temp
+ }
+ }%
+}%
+
+\tikzdvdeclarestylesheetcolorseries{vary hue}{hsb}{.4,0.9,0.8}{.213,0,0}%
+\tikzdvdeclarestylesheetcolorseries{shades of blue}{hsb}{.65,1.4,1}{0,-.4,-.0}%
+\tikzdvdeclarestylesheetcolorseries{shades of red}{hsb}{0,1.4,1}{0,-.4,-.0}%
+\tikzdvdeclarestylesheetcolorseries{gray scale}{hsb}{0,0,-.34}{0,0,.34}%
+
+
+
+
+
+%
+% Basic Axes & Coordinate Systems
+%
+
+
+%
+%
+% Basic axis systems
+%
+%
+
+\tikzdatavisualizationset{
+ xy Cartesian/.style={
+ new Cartesian axis=x axis,
+ x axis={attribute=x,unit vector={(1pt,0cm)}},
+ new Cartesian axis=y axis,
+ y axis={attribute=y,unit vector={(0cm,1pt)}}
+ },
+ Xy axes/.style={x axis={#1},y axis={#1}},
+ uv Cartesian/.style={
+ new Cartesian axis=u axis,
+ u axis={attribute=u,unit vector={(1pt,0cm)}},
+ new Cartesian axis=v axis,
+ v axis={attribute=v,unit vector={(0cm,1pt)}}
+ },
+ uv axes/.style={u axis={#1},v axis={#1}},
+}%
+
+\tikzdatavisualizationset{
+ xyz Cartesian cabinet/.style={
+ xy Cartesian,
+ new Cartesian axis=z axis,
+ z axis={attribute=z,unit vector={(-0.353553pt,-0.353553pt)}}
+ },
+ xyz axes/.style={x axis={#1},y axis={#1},z axis={#1}},
+ uvw Cartesian cabinet/.style={
+ uv Cartesian,
+ new Cartesian axis=w axis,
+ w axis={attribute=w,unit vector={(-0.353553pt,-0.353553pt)}}
+ }
+ uvw axes/.style={u axis={#1},v axis={#1},w axis={#1}},
+}%
+
+
+
+%
+% Create a new axis system
+%
+
+\tikzdatavisualizationset{
+ new axis system/.style n args={4}{
+ #1/.style={
+ #2,
+ #1/.cd,
+ #3,
+ /tikz/data visualization/every #1/.try,
+ ##1,
+ /tikz/data visualization/.cd,
+ #4,
+ }
+ }
+}%
+
+
+% The school book axes
+%
+% This coordinate system can be used to create plots that look like
+% plots in a typical school book: There are two axes called "x axis"
+% and "y axis" that meet at the origin, there are arrows at the ends
+% of the axes, pointing in the directions of the positive axes. No
+% scaling is done by default, rather one unit equals one 1cm. This
+% ensures that the even when multiple plots are created, the same
+% scaling will be used each time.
+%
+% To change the scaling, say "all axes={unit length=1mm}" for
+% instance.
+
+\tikzdatavisualizationset{
+ new axis system={school book axes}{%
+ xy Cartesian,
+ x axis={
+ include value=0,
+ scaling=0 at 0 and \pgfkeysvalueof{/tikz/data visualization/school book axes/unit} at 1cm,
+ visualize axis={y axis={goto=0},style=->,padded},
+ visualize ticks={common={y axis={goto=0},direction axis=y axis},
+ major={tick text at low,
+ options at=0 as [{style={draw=none},no tick text}]
+ }},
+ visualize grid={common={direction axis=y axis,padded}},
+ ticks={step=\pgfkeysvalueof{/tikz/data visualization/school book axes/unit}},
+ padding=0.75em
+ },
+ y axis={
+ include value=0,
+ scaling=0 at 0 and \pgfkeysvalueof{/tikz/data visualization/school book axes/unit} at 1cm,
+ visualize axis={x axis={goto=0},style=->,padded},
+ visualize ticks={
+ common={x axis={goto=0},direction axis=x axis},
+ major={tick text at low,options at=0 as [{high=0,low=0,style={draw=none},node style={anchor=north east}}]}
+ },
+ visualize grid={common={direction axis=x axis,padded}},
+ ticks={step=\pgfkeysvalueof{/tikz/data visualization/school book axes/unit}},
+ padding=0.75em
+ }
+ }{%
+ standard labels
+ }{%
+ @make labels
+ },
+ school book axes/.cd,
+ % Possible axis positionings:
+ %
+ % Place labels at the ends of the axes
+ %
+ standard labels/.style={
+ /tikz/data visualization/@make labels/.style={
+ x axis={
+ visualize label={
+ x axis={goto=padded max, anchor at max},
+ y axis={goto=0}
+ }
+ },
+ y axis={
+ visualize label={
+ y axis={goto=padded max, anchor at max},
+ x axis={goto=0}
+ }
+ }
+ }
+ },
+ %
+ % Basic unit
+ %
+ unit/.initial=1,
+}%
+
+
+
+
+% The scientific axes
+%
+% The scientific axes is a 2d plot that has a predetermined width and
+% height. The data is then scaled in such a way that it fits inside
+% this given rectangle.
+
+\tikzdatavisualizationset{
+ new axis system={scientific axes}{%
+ xy Cartesian,
+ every axis/.append style={style={draw=black!50}},
+ every ticks/.append style={style={draw=black!50}},
+ x axis={
+ length=\pgfkeysvalueof{/tikz/data visualization/scientific axes/width},
+ ticks
+ },
+ y axis={
+ length=\pgfkeysvalueof{/tikz/data visualization/scientific axes/height},
+ ticks
+ }
+ }{%
+ standard labels,
+ outer ticks,
+ }{%
+ @make axes,
+ @make labels
+ },
+ scientific axes/.cd,
+ width/.initial=5cm,
+ height/.initial=0.618*\pgfkeysvalueof{/tikz/data visualization/scientific axes/width},% golden ratio...
+ outer ticks/.style={
+ /tikz/data visualization/@make axes/.style={
+ x axis={
+ visualize ticks={common={y axis={goto=padded min},direction axis=y axis,high=0pt},major={tick text at low}},
+ visualize ticks={common={y axis={goto=padded max},direction axis=y axis,low=0pt}},
+ visualize axis={y axis={goto=padded min},padded},
+ visualize axis={y axis={goto=padded max},padded},
+ visualize grid={common={direction axis=y axis,padded}},
+ },
+ y axis={
+ visualize ticks={common={x axis={goto=padded min},direction axis=x axis,high=0pt},major={tick text at low}},
+ visualize ticks={common={x axis={goto=padded max},direction axis=x axis,low=0pt}},
+ visualize axis={x axis={goto=padded min},padded},
+ visualize axis={x axis={goto=padded max},padded},
+ visualize grid={common={direction axis=x axis,padded}},
+ }
+ }
+ },
+ inner ticks/.style={
+ /tikz/data visualization/@make axes/.style={
+ x axis={
+ visualize ticks={common={y axis={goto=padded min},direction axis=y axis,low=0pt},major={tick text at low}},
+ visualize ticks={common={y axis={goto=padded max},direction axis=y axis,high=0pt}},
+ visualize axis={y axis={goto=padded min},padded},
+ visualize axis={y axis={goto=padded max},padded},
+ visualize grid={common={direction axis=y axis,padded}},
+ },
+ y axis={
+ visualize ticks={common={x axis={goto=padded min},direction axis=x axis,low=0pt},major={tick text at low}},
+ visualize ticks={common={x axis={goto=padded max},direction axis=x axis,high=0pt}},
+ visualize axis={x axis={goto=padded min},padded},
+ visualize axis={x axis={goto=padded max},padded},
+ visualize grid={common={direction axis=x axis,padded}},
+ }
+ }
+ },
+ clean/.style={
+ /tikz/data visualization/@make axes/.style={
+ x axis={
+ visualize ticks={common={y axis={goto=padded min},direction axis=y axis,high=0pt},major={tick text at low}},
+ visualize axis={y axis={goto=padded min}},
+ visualize axis={y axis={goto=min}, style={black!25, line cap=rect}},
+ visualize axis={y axis={goto=max}, style={black!25, line cap=rect}},
+ visualize grid={common={direction axis=y axis}},
+ padding=.5em,
+ },
+ y axis={
+ visualize ticks={common={x axis={goto=padded min},direction axis=x axis,high=0pt},major={tick text at low}},
+ visualize axis={x axis={goto=padded min}},
+ visualize axis={x axis={goto=min}, style={black!25, line cap=rect}},
+ visualize axis={x axis={goto=max}, style={black!25, line cap=rect}},
+ visualize grid={common={direction axis=x axis}},
+ padding=.5em
+ },
+ }
+ },
+ % Possible axis positionings:
+ %
+ % Place axes labels below and left, where left label is rotated
+ %
+ standard labels/.style={
+ /tikz/data visualization/@make labels/.style={
+ x axis={
+ visualize label={
+ x axis={goto pos=.5},
+ % Vertical position comes from bounding box:
+ node style={
+ at={(0,0 |- data visualization bounding box.south)},
+ below
+ }
+ }
+ },
+ y axis={
+ visualize label={
+ y axis={goto pos=.5},
+ % Horizontal position comes from bounding box:
+ node style={
+ at={(0,0 -| data visualization bounding box.west)},
+ rotate=90,
+ above}
+ }
+ }
+ }
+ },
+ %
+ % Place axes labels below and left, no rotation
+ %
+ upright labels/.style={
+ /tikz/data visualization/@make labels/.style={
+ x axis={
+ visualize label={
+ x axis={goto pos=.5},
+ % Vertical position comes from bounding box:
+ node style={
+ at={(0,0 |- data visualization bounding box.south)},
+ below
+ }
+ }
+ },
+ y axis={
+ visualize label={
+ y axis={goto pos=.5},
+ % Horizontal position comes from bounding box:
+ node style={
+ at={(0,0 -| data visualization bounding box.west)},
+ left
+ }
+ }
+ }
+ }
+ },
+ %
+ % Place axes at the ends of the axes
+ %
+ end labels/.style={
+ /tikz/data visualization/@make labels/.style={
+ x axis={
+ visualize label={
+ y axis={goto=padded min},
+ % Vertical position comes from bounding box:
+ node style={
+ at={(0,0 -| data visualization bounding box.east)},
+ right
+ }
+ }
+ },
+ y axis={
+ visualize label={
+ x axis={goto=padded min},
+ % Horizontal position comes from bounding box:
+ node style={
+ at={(0,0 |- data visualization bounding box.north)},
+ above
+ }
+ }
+ }
+ }
+ }
+}%
+
+
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/datavisualization/tikzlibrarydatavisualization.formats.functions.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/datavisualization/tikzlibrarydatavisualization.formats.functions.code.tex
new file mode 100644
index 0000000000..5a04c51646
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/datavisualization/tikzlibrarydatavisualization.formats.functions.code.tex
@@ -0,0 +1,16 @@
+% Copyright 2018 by Till Tantau
+%
+% 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{tikzlibrarydatavisualization.formats.functions.code.tex}
+
+\usetikzlibrary{datavisualization}%
+\usepgflibrary{datavisualization.formats.functions}%
+
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/datavisualization/tikzlibrarydatavisualization.polar.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/datavisualization/tikzlibrarydatavisualization.polar.code.tex
new file mode 100644
index 0000000000..5a37b82854
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/datavisualization/tikzlibrarydatavisualization.polar.code.tex
@@ -0,0 +1,565 @@
+% Copyright 2018 by Till Tantau
+%
+% 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{tikzlibrarydatavisualization.polar.code.tex}
+
+\usetikzlibrary{datavisualization}%
+\usepgflibrary{datavisualization.polar}%
+
+
+\tikzdatavisualizationset{%
+ new polar axes/.style 2 args={
+ new axis base=#1,
+ #1={attribute=angle},
+ new axis base=#2,
+ #2={attribute=radius},
+ #2/scaling/default=0 at 0 and 1 at 1cm,
+ new object={
+ store=/tikz/data visualization/#1/polar transformer,
+ class=polar transformer,
+ arg1/.expanded=\pgfkeysvalueof{/tikz/data visualization/angle axis/attribute}/scaled,
+ arg2/.expanded=\pgfkeysvalueof{/tikz/data visualization/radius axis/attribute}/scaled,
+ arg3 from key=/tikz/data visualization/#1/unit vector 0 degrees,
+ arg4 from key=/tikz/data visualization/#1/unit vector 90 degrees
+ },
+ /tikz/data visualization/#1/unit vector 0 degrees/.initial=\pgfqpoint{1pt}{0pt},
+ /tikz/data visualization/#1/unit vector 90 degrees/.initial=\pgfqpoint{0pt}{1pt},
+ },
+ new polar axes/.default={angle axis}{radius axis}
+}%
+\def\tikz@lib@dv@polar@a#1{
+ \pgfkeyssetvalue{\tikz@dv@axis/unit vector 0 degrees}{#1}
+}%
+\def\tikz@lib@dv@polar@b#1{
+ \pgfkeyssetvalue{\tikz@dv@axis/unit vector 90 degrees}{#1}
+}%
+
+
+
+%
+% Scientific polar axes
+%
+
+\tikzset{
+ /tikz/data visualization/axis options/.cd,
+ unit vectors/.code 2 args={
+ \tikz@scan@one@point\tikz@lib@dv@polar@a#1
+ \tikz@scan@one@point\tikz@lib@dv@polar@b#2
+ },
+ degrees/.style={\tikz@dv@axis/scaling=0 at 0 and 1 at 1},
+ radians/.style={\tikz@dv@axis/scaling=0 at 0 and 0.03141592653589793 at 1.8},
+}%
+
+
+
+\tikzdatavisualizationset{
+ new axis system={scientific polar axes}{%
+ new polar axes,
+ angle axis={attribute=angle},
+ radius axis={attribute=radius},
+ every axis/.append style={style={draw=black!50}},
+ every ticks/.append style={style={draw=black!50}},
+ }{%
+ 0 to 360,%
+ outer ticks,
+ }{%
+ @make axes,
+ scientific polar axes/@setup axes,
+ /utils/exec={
+ \edef\pgf@marshal{\noexpand\tikzdatavisualizationset{\pgfkeysvalueof{/tikz/data visualization/@which visualize radius axis}/.list={\pgfkeysvalueof{/tikz/data visualization/\pgfkeysvalueof{/tikz/data visualization/@which radius axes at}}}}}
+ \pgf@marshal
+ },
+ @make labels
+ },
+ @which radius axes at/.initial=@inner radius axes at,
+ @which visualize radius axis/.initial=@visualize radius axis,
+ @inner radius axes at/.initial=,
+ @clean radius axes at/.initial=,
+ @visualize radius axis/.style 2 args={
+ radius axis={
+ visualize axis={angle axis={goto=#1},high=padded max,low=0},
+ visualize ticks={
+ common={angle axis={goto=#1}, direction axis=angle axis},
+ major={tick text at #2,
+ options at=0 as [{style={draw=none},no tick text}]
+ }
+ }
+ }
+ },
+ @visualize clean radius axis/.style n args={5}{
+ radius axis={
+ visualize axis={angle
+ axis={goto=#1},high=max,low=0,style={black!25,line cap=rect}},
+ visualize axis={angle
+ axis={goto=#1},high=max,low=0,style={line cap=rect,#4}},
+ visualize ticks={
+ style={#4},
+ common={angle axis={goto=#1}, direction axis=angle axis, #3=0},
+ major={tick text at #2,#5}
+ }
+ }
+ },
+ @visualize zero/.style={@inner visualize zero={#1}},
+ @clean visualize zero/.style={},
+ @inner visualize zero/.style={
+ radius axis={
+ visualize ticks={
+ common={angle axis={goto=0}, direction axis=angle axis},
+ major={tick text at low,low=0,high=0,at=0 as
+ [{style={draw=none},node style={anchor=#1}}]
+ }
+ }
+ }
+ },
+ @degrees/.style={
+ angle axis={degrees, ticks={step=15, tick suffix=$^\circ$, major={
+ options at=360 as [{style={draw=none},no tick text}],
+ options at=-180 as [{style={draw=none},no tick text}]}}}
+ },
+ @rad/.style={
+ angle axis={radians, ticks={
+ step=(pi/12),
+ node style={
+ /pgf/number format/frac,
+ /pgf/number format/frac shift={1}
+ },
+ tick typesetter/.code={%
+ \pgfmathsetmacro{\tikz@lib@dv@pol}{round(####1*3.819718634205488)/12}%
+ \pgfmathapproxequalto{\tikz@lib@dv@pol}{0}%
+ \ifdim\pgfmathresult pt=1.0pt%
+ $0$%
+ \else%
+ \pgfmathapproxequalto{\tikz@lib@dv@pol}{1}%
+ \ifdim\pgfmathresult pt=1.0pt%
+ $\pi$%
+ \else
+ \pgfmathapproxequalto{\tikz@lib@dv@pol}{-1}%
+ \ifdim\pgfmathresult pt=1.0pt%
+ $-\pi$%
+ \else%
+ \pgfmathprintnumber{\tikz@lib@dv@pol}$\pi$%
+ \fi%
+ \fi%
+ \fi%
+ },
+ major={
+ options at=6.2831985e0 as [{style={draw=none},no tick text}],
+ options at=6.2831192e0 as [{style={draw=none},no tick text}],
+ options at=6.2830794e0 as [{style={draw=none},no tick text}],
+ options at=6.2828787e0 as [{style={draw=none},no tick text}],
+ options at=6.2831598e0 as [{style={draw=none},no tick text}],
+ options at=-3.1415991e0 as [{style={draw=none},no tick text}],
+ options at=-3.1415802e0 as [{style={draw=none},no tick text}],
+ options at=-3.1415602e0 as [{style={draw=none},no tick text}],
+ options at=-3.14153961e0 as [{style={draw=none},no tick text}],
+ options at=-3.1414406e0 as [{style={draw=none},no tick text}],
+ }
+ }
+ }
+ },
+ @make labels/.style={},
+}%
+
+\tikzdatavisualizationset{
+ scientific polar axes/.cd,
+ %
+ %
+ %
+ outer ticks/.style={
+ /tikz/data visualization/@make axes/.style={
+ radius axis={
+ min value=0,
+ length=\pgfkeysvalueof{/tikz/data visualization/scientific polar axes/radius},
+ padding=0em,
+ ticks={few},
+ visualize grid={common={direction axis=angle axis,low=min,high=max}},
+ },
+ angle axis={
+ visualize axis={radius axis={goto=padded max},low=min,high=max},
+ visualize ticks={common={radius axis={goto=padded max},direction
+ axis=radius axis},common={low=0},major={tick text at high}},
+ visualize grid={common={direction axis=radius axis},low=0,high=padded max},
+ }
+ },
+ /tikz/data visualization/@which radius axes at=@inner radius axes at,
+ /tikz/data visualization/@which visualize radius axis=@visualize radius axis,
+ /tikz/data visualization/@visualize zero/.style={@inner visualize zero={##1}},
+ },
+ inner ticks/.style={
+ /tikz/data visualization/@make axes/.style={
+ radius axis={
+ min value=0,
+ length=\pgfkeysvalueof{/tikz/data visualization/scientific polar axes/radius},
+ padding=0em,
+ ticks={few},
+ visualize grid={common={direction axis=angle axis,low=min,high=max}},
+ },
+ angle axis={
+ visualize axis={radius axis={goto=padded max},low=min,high=max},
+ visualize ticks={common={radius axis={goto=padded max},direction
+ axis=radius axis},common={high=0},major={tick text at high}},
+ visualize grid={common={direction axis=radius axis},low=0,high=padded max},
+ }
+ },
+ /tikz/data visualization/@which radius axes at=@inner radius axes at,
+ /tikz/data visualization/@which visualize radius axis=@visualize radius axis,
+ /tikz/data visualization/@visualize zero/.style={@inner visualize zero={##1}},
+ },
+ clean/.style={
+ /tikz/data visualization/@make axes/.style={
+ radius axis={
+ min value=0,
+ length=\pgfkeysvalueof{/tikz/data visualization/scientific polar axes/radius},
+ padding=.5em,
+ ticks={few},
+ visualize grid={common={direction axis=angle axis,low=min,high=max}},
+ },
+ angle axis={
+ padding=.5em,
+ visualize axis={radius axis={goto=max}, style={black!25, line cap=rect},low=min,high=max},
+ visualize axis={radius axis={goto=padded max}, style={line cap=rect}, low=min,high=max},
+ visualize ticks={common={radius axis={goto=padded max}, direction axis=radius axis},common={low=0},major={tick text at high}},
+ visualize grid={common={direction axis=radius axis},low=0,high=max},
+ }
+ },
+ /tikz/data visualization/@which radius axes at=@clean radius axes at,
+ /tikz/data visualization/@which visualize radius axis=@visualize clean radius axis,
+ /tikz/data visualization/@visualize zero/.style={@clean visualize zero={##1}},
+ },
+ radius/.initial=3.25cm,
+ %
+ % First quadrant
+ %
+ 0 to pi half/.style={
+ @setup axes/.style={
+ angle axis={min value=0, max value=1.570796326794897},
+ @rad,
+ @visualize zero=north east,
+ @inner radius axes at={{0}{low},{1.570796326794897}{high}},
+ @clean radius axes at={%
+ {0}{low}{high}{yshift=\pgfkeysvalueof{/tikz/data visualization/angle axis/padding min}}{},%
+ {1.570796326794897}{high}{low}{xshift=-\pgfkeysvalueof{/tikz/data visualization/angle axis/padding max}}{}
+ }
+ }
+ },
+ 0 to 90/.style={
+ @setup axes/.style={
+ angle axis={min value=0, max value=90},
+ @degrees,
+ @visualize zero=north east,
+ @inner radius axes at={{0}{low},{90}{high}},
+ @clean radius axes at={%
+ {0}{low}{high}{yshift=\pgfkeysvalueof{/tikz/data visualization/angle axis/padding min}}{},%
+ {90}{high}{low}{xshift=-\pgfkeysvalueof{/tikz/data visualization/angle axis/padding max}}{}
+ }
+ }
+ },
+ quadrant/.style={
+ @setup axes/.style={
+ angle axis={scaling=min at 0 and max at 90, ticks},
+ @visualize zero=north east,
+ @inner radius axes at={{min}{low},{max}{high}},
+ @clean radius axes at={%
+ {min}{low}{high}{yshift=\pgfkeysvalueof{/tikz/data visualization/angle axis/padding min}}{},%
+ {max}{high}{low}{xshift=-\pgfkeysvalueof{/tikz/data visualization/angle axis/padding max}}{}
+ }
+ }
+ },
+ quadrant clockwise/.style={
+ @setup axes/.style={
+ angle axis={scaling=min at 90 and max at 0, ticks},
+ @visualize zero=north east,
+ @inner radius axes at={{min}{low},{max}{high}},
+ @clean radius axes at={%
+ {max}{high}{low}{yshift=\pgfkeysvalueof{/tikz/data visualization/angle axis/padding min}}{},%
+ {min}{low}{high}{xshift=-\pgfkeysvalueof{/tikz/data visualization/angle axis/padding max}}{}
+ }
+ }
+ },
+ %
+ % Fourth quadrant
+ %
+ -pi half to 0/.style={
+ @setup axes/.style={
+ angle axis={min value=-1.570796326794897, max value=0},
+ @rad,
+ @visualize zero=south east,
+ @inner radius axes at={{-1.570796326794897}{low},{0}{high}},
+ @clean radius axes at={%
+ {-1.570796326794897}{low}{high}{xshift=\pgfkeysvalueof{/tikz/data visualization/angle axis/padding min}}{},%
+ {0}{high}{low}{yshift=\pgfkeysvalueof{/tikz/data visualization/angle axis/padding max}}{}
+ }
+ }
+ },
+ -90 to 0/.style={
+ @setup axes/.style={
+ angle axis={min value=-90, max value=0},
+ @degrees,
+ @visualize zero=south east,
+ @inner radius axes at={{-90}{low},{0}{high}},
+ @clean radius axes at={%
+ {-90}{low}{high}{xshift=\pgfkeysvalueof{/tikz/data visualization/angle axis/padding min}}{},%
+ {0}{high}{low}{yshift=\pgfkeysvalueof{/tikz/data visualization/angle axis/padding max}}{}
+ }
+ }
+ },
+ fourth quadrant/.style={
+ @setup axes/.style={
+ angle axis={scaling=min at -90 and max at 0, ticks},
+ @visualize zero=south east,
+ @inner radius axes at={{min}{low},{max}{high}},
+ @clean radius axes at={%
+ {min}{low}{high}{xshift=\pgfkeysvalueof{/tikz/data visualization/angle axis/padding min}}{},%
+ {max}{high}{low}{yshift=\pgfkeysvalueof{/tikz/data visualization/angle axis/padding max}}{}
+ }
+ }
+ },
+ fourth quadrant clockwise/.style={
+ @setup axes/.style={
+ angle axis={scaling=min at 0 and max at -90, ticks},
+ @visualize zero=south east,
+ @inner radius axes at={{min}{low},{max}{high}},
+ @clean radius axes at={%
+ {max}{high}{low}{xshift=\pgfkeysvalueof{/tikz/data visualization/angle axis/padding min}}{},%
+ {min}{low}{high}{yshift=\pgfkeysvalueof{/tikz/data visualization/angle axis/padding max}}{}
+ }
+ }
+ },
+ %
+ % Upper half
+ %
+ 0 to pi/.style={
+ @setup axes/.style={
+ angle axis={min value=0, max value=3.141592653589793},
+ @rad,
+ @visualize zero=north,
+ @inner radius axes at={{0}{low},{1.570796326794897}{high},{3.141592653589793}{high}},
+ @clean radius axes at={%
+ {0}{low}{high}{yshift=\pgfkeysvalueof{/tikz/data visualization/angle axis/padding min}}{},%
+ {3.141592653589793}{high}{low}{yshift=-\pgfkeysvalueof{/tikz/data
+ visualization/angle axis/padding max}}{options at=0 as
+ [{style={draw=none}, no tick text}]}
+ }
+ }
+ },
+ 0 to 180/.style={
+ @setup axes/.style={
+ angle axis={min value=0, max value=180},
+ @degrees,
+ @visualize zero=north,
+ @inner radius axes at={{0}{low},{90}{high},{180}{high}},
+ @clean radius axes at={%
+ {0}{low}{high}{yshift=\pgfkeysvalueof{/tikz/data visualization/angle axis/padding min}}{},%
+ {180}{high}{low}{yshift=-\pgfkeysvalueof{/tikz/data
+ visualization/angle axis/padding max}}{options at=0 as
+ [{style={draw=none}, no tick text}]}
+ }
+ }
+ },
+ upper half/.style={
+ @setup axes/.style={
+ angle axis={scaling=min at 0 and max at 180, ticks},
+ @visualize zero=north,
+ @inner radius axes at={{min}{low},{max}{high}},
+ @clean radius axes at={%
+ {min}{low}{high}{yshift=\pgfkeysvalueof{/tikz/data visualization/angle axis/padding min}}{},%
+ {max}{high}{low}{yshift=-\pgfkeysvalueof{/tikz/data
+ visualization/angle axis/padding max}}{options at=0 as
+ [{style={draw=none}, no tick text}]}
+ }
+ }
+ },
+ upper half clockwise/.style={
+ @setup axes/.style={
+ angle axis={scaling=min at 180 and max at 0, ticks},
+ @visualize zero=north,
+ @inner radius axes at={{min}{low},{max}{high}},
+ @clean radius axes at={%
+ {min}{low}{high}{yshift=\pgfkeysvalueof{/tikz/data visualization/angle axis/padding min}}{},%
+ {max}{high}{low}{yshift=-\pgfkeysvalueof{/tikz/data
+ visualization/angle axis/padding max}}{options at=0 as
+ [{style={draw=none}, no tick text}]}
+ }
+ }
+ },
+ %
+ % Lower half
+ %
+ lower half/.style={
+ @setup axes/.style={
+ angle axis={scaling=min at -180 and max at 0, ticks},
+ @visualize zero=south,
+ @inner radius axes at={{min}{low},{max}{high}},
+ @clean radius axes at={%
+ {min}{low}{high}{yshift=-\pgfkeysvalueof{/tikz/data visualization/angle axis/padding min}}{},%
+ {max}{high}{low}{yshift=\pgfkeysvalueof{/tikz/data
+ visualization/angle axis/padding max}}{options at=0 as
+ [{style={draw=none}, no tick text}]}
+ }
+ }
+ },
+ lower half clockwise/.style={
+ @setup axes/.style={
+ angle axis={scaling=min at 0 and max at -180, ticks},
+ @visualize zero=south,
+ @inner radius axes at={{min}{low},{max}{high}},
+ @clean radius axes at={%
+ {min}{low}{high}{yshift=-\pgfkeysvalueof{/tikz/data visualization/angle axis/padding min}}{},%
+ {max}{high}{low}{yshift=\pgfkeysvalueof{/tikz/data
+ visualization/angle axis/padding max}}{options at=0 as
+ [{style={draw=none}, no tick text}]}
+ }
+ }
+ },
+ %
+ % Right half
+ %
+ -pi half to pi half/.style={
+ @setup axes/.style={
+ @rad,
+ angle axis={min value=-1.570796326794897, max value=1.570796326794897},
+ @visualize zero=east,
+ @inner radius axes at={{0}{low},{1.570796326794897}{low},{-1.570796326794897}{high}},
+ @clean radius axes at={%
+ {-1.570796326794897}{low}{high}{xshift=\pgfkeysvalueof{/tikz/data visualization/angle axis/padding min}}{},%
+ {1.570796326794897}{high}{low}{xshift=-\pgfkeysvalueof{/tikz/data
+ visualization/angle axis/padding max}}{options at=0 as
+ [{style={draw=none}, no tick text}]}
+ }
+ }
+ },
+ -90 to 90/.style={
+ @setup axes/.style={
+ angle axis={min value=-90, max value=90},
+ @degrees,
+ @visualize zero=east,
+ @inner radius axes at={{-90}{low},{0}{low},{90}{high}},
+ @clean radius axes at={%
+ {-90}{low}{high}{xshift=\pgfkeysvalueof{/tikz/data visualization/angle axis/padding min}}{},%
+ {90}{high}{low}{xshift=-\pgfkeysvalueof{/tikz/data
+ visualization/angle axis/padding max}}{options at=0 as
+ [{style={draw=none}, no tick text}]}
+ }
+ }
+ },
+ right half/.style={
+ @setup axes/.style={
+ angle axis={scaling=min at -90 and max at 90, ticks},
+ @visualize zero=east,
+ @inner radius axes at={{min}{low},{max}{high}},
+ @clean radius axes at={%
+ {min}{low}{high}{xshift=\pgfkeysvalueof{/tikz/data visualization/angle axis/padding min}}{},%
+ {max}{high}{low}{xshift=-\pgfkeysvalueof{/tikz/data
+ visualization/angle axis/padding max}}{options at=0 as
+ [{style={draw=none}, no tick text}]}
+ }
+ }
+ },
+ right half clockwise/.style={
+ @setup axes/.style={
+ angle axis={scaling=min at 90 and max at -90, ticks},
+ @visualize zero=east,
+ @inner radius axes at={{min}{low},{max}{high}},
+ @clean radius axes at={%
+ {min}{low}{high}{xshift=\pgfkeysvalueof{/tikz/data visualization/angle axis/padding min}}{},%
+ {max}{high}{low}{xshift=-\pgfkeysvalueof{/tikz/data
+ visualization/angle axis/padding max}}{options at=0 as
+ [{style={draw=none}, no tick text}]}
+ }
+ }
+ },
+ %
+ % Left half
+ %
+ left half/.style={
+ @setup axes/.style={
+ angle axis={scaling=min at 90 and max at 270, ticks},
+ @visualize zero=west,
+ @inner radius axes at={{min}{low},{max}{high}},
+ @clean radius axes at={%
+ {min}{low}{high}{xshift=-\pgfkeysvalueof{/tikz/data visualization/angle axis/padding min}}{},%
+ {max}{high}{low}{xshift=\pgfkeysvalueof{/tikz/data
+ visualization/angle axis/padding max}}{options at=0 as
+ [{style={draw=none}, no tick text}]}
+ }
+ }
+ },
+ left half clockwise/.style={
+ @setup axes/.style={
+ angle axis={scaling=min at 270 and max at 90, ticks},
+ @visualize zero=west,
+ @inner radius axes at={{min}{low},{max}{high}},
+ @clean radius axes at={%
+ {min}{low}{high}{xshift=-\pgfkeysvalueof{/tikz/data visualization/angle axis/padding min}}{},%
+ {max}{high}{low}{xshift=\pgfkeysvalueof{/tikz/data
+ visualization/angle axis/padding max}}{options at=0 as
+ [{style={draw=none}, no tick text}]}
+ }
+ }
+ },
+ %
+ % Full circle
+ %
+ 0 to 2pi/.style={
+ @setup axes/.style={
+ angle axis={min value=0, max value=6.283185307179586},
+ @rad,
+ @visualize zero=north east,
+ @inner radius axes at={{0}{low},{1.570796326794897}{high},{3.141592653589793}{high},{4.71238898038469}{low}},
+ @clean radius axes at={{0}{low}{high}{}{}}
+ }
+ },
+ -pi to pi/.style={
+ @setup axes/.style={
+ angle axis={min value=-3.141592653589793, max value=3.141592653589793},
+ @rad,
+ @visualize zero=north east,
+ @inner radius axes at={{0}{low},{1.570796326794897}{high},{3.141592653589793}{high},{-1.57079632679489}{low}},
+ @clean radius axes at={{0}{low}{high}{}{}}
+ }
+ },
+ 0 to 360/.style={
+ @setup axes/.style={
+ angle axis={min value=0, max value=360},
+ @degrees,
+ @visualize zero=north east,
+ @inner radius axes at={{0}{low},{90}{high},{180}{high},{270}{low}},
+ @clean radius axes at={{0}{low}{high}{}{}}
+ }
+ },
+ -180 to 180/.style={
+ @setup axes/.style={
+ angle axis={min value=-180, max value=180},
+ @degrees,
+ @visualize zero=north east,
+ @inner radius axes at={{0}{low},{90}{high},{180}{high},{-90}{low}},
+ @clean radius axes at={{0}{low}{high}{}{}}
+ }
+ },
+}%
+
+
+
+
+%
+% Pie-charts -- still under construction...
+%
+
+\tikzset{
+ /tikz/data visualization/axis options/.cd,
+ percent/.style={\tikz@dv@axis/scaling=0 at 0 and 1 at 3.6},
+ full circle/.style={\tikz@dv@axis/scaling=min at 0 and max at 360},
+ half circle/.style={\tikz@dv@axis/scaling=min at 0 and max at 180},
+ quarter circle/.style={\tikz@dv@axis/scaling=min at 0 and max at 90}
+}%
+
+
+
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/datavisualization/tikzlibrarydatavisualization.sparklines.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/datavisualization/tikzlibrarydatavisualization.sparklines.code.tex
new file mode 100644
index 0000000000..2e2e77ae0b
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/datavisualization/tikzlibrarydatavisualization.sparklines.code.tex
@@ -0,0 +1,37 @@
+% Copyright 2018 by Till Tantau
+%
+% 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{tikzlibrarydatavisualization.sparklines.code.tex}
+
+\usetikzlibrary{datavisualization}%
+
+
+
+
+%
+% Sparklines (not yet usable...)
+%
+
+\tikzdatavisualizationset{
+ spark line/.style={
+ xy Cartesian,
+ x axis={
+ unit length={1pt}
+ },
+ y axis={
+ scaling={min at -0.2em and max at 0.8em}
+ },
+ new line plot,
+ every spark line plot/.try
+ }
+}%
+
+
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/graphs/tikzlibrarygraphs.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/graphs/tikzlibrarygraphs.code.tex
new file mode 100644
index 0000000000..20a1735807
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/graphs/tikzlibrarygraphs.code.tex
@@ -0,0 +1,2674 @@
+% Copyright 2019 by Till Tantau
+% Copyright 2019 by Jannis Pohlmann
+%
+% 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{tikzlibrarygraphs.code.tex}
+
+
+%
+% Interface keys
+%
+
+\def\tikzgraphsset{\pgfqkeys{/tikz/graphs}}%
+
+\tikzgraphsset{
+ new ->/.code n args={4}{%
+ \path [->,every new ->/.try]
+ (#1\tikzgraphleftanchor)
+ edge[#3] #4
+ (#2\tikzgraphrightanchor);},
+ new --/.code n args={4}{
+ \path [-,every new --/.try]
+ (#1\tikzgraphleftanchor)
+ edge[#3] #4
+ (#2\tikzgraphrightanchor);},
+ new <->/.code n args={4}{
+ \path [<->,every new <->/.try]
+ (#1\tikzgraphleftanchor)
+ edge[#3] #4
+ (#2\tikzgraphrightanchor);},
+ new -!-/.code n args={4}{},
+ new <-/.code n args={4}{%
+ \path [<-,every new <-/.try]
+ (#1\tikzgraphleftanchor)
+ edge[#3] #4
+ (#2\tikzgraphrightanchor);
+ }
+}%
+
+
+\def\tikz@lib@graph@store@anchor#1#2{%
+ \def\tikz@temp{#1}%
+ \ifx\tikz@temp\pgfutil@empty%
+ \let#2\tikz@temp%
+ \else%
+ \def\tikz@temp{.#1}%
+ \let#2\tikz@temp%
+ \fi%
+}%
+
+\tikzgraphsset{
+ default edge kind/.initial=--,
+ --/.style={default edge kind=--},
+ ->/.style={default edge kind=->},
+ <-/.style={default edge kind=<-},
+ <->/.style={default edge kind=<->},
+ -!-/.style={default edge kind=-!-},
+ default edge operator/.initial=matching and star,
+ left anchor/.code=\tikz@lib@graph@store@anchor{#1}{\tikzgraphleftanchor},
+ right anchor/.code=\tikz@lib@graph@store@anchor{#1}{\tikzgraphrightanchor},
+ left anchor=,
+ right anchor=
+}%
+
+
+%
+% Keys for using nodes declared outside a graph inside a graph as if
+% it were declared there
+%
+
+\tikzgraphsset{
+ use existing nodes/.is if=tikz@lib@graph@all
+}%
+
+\tikzset{
+ new set/.code={
+ \expandafter\global\expandafter\let\csname tikz@lg@node@set #1\endcsname\pgfutil@empty%
+ },
+ set/.code={
+ \tikz@fig@mustbenamed%
+ \ifcsname tikz@lg@node@set #1\endcsname\else
+ \tikzerror{Undefined set `#1'}%
+ \fi
+ \expandafter\def\expandafter\tikz@alias\expandafter{\tikz@alias%
+ \expandafter\def\expandafter\pgf@temp\expandafter{\csname tikz@lg@node@set #1\endcsname}%
+ \expandafter\expandafter\expandafter\pgfutil@g@addto@macro\expandafter\pgf@temp\expandafter{\expandafter\tikz@lg@do\expandafter{\tikz@fig@name}}%
+ }%
+ },%
+}%
+
+\newif\iftikz@lib@graph@all
+
+
+%
+% Simple versus multi graphs
+%
+\tikzgraphsset{
+ simple/.code={
+ \iftikz@lib@graph@simple%
+ % is already simple, ignore
+ \else
+ \tikz@lib@graph@simpletrue%
+ \pgfkeysalso{operator=\tikz@lib@graph@simple@done}%
+ \fi%
+ },
+ multi/.code={
+ \tikz@lib@graph@simplefalse%
+ }
+}%
+
+\newif\iftikz@lib@graph@simple
+
+\def\tikz@lib@graph@set@simple@edge#1#2#3#4#5{%
+ % #1 = kind (<-, ->, ...)
+ % #2 = from
+ % #3 = to
+ % #4 = options
+ % #5 = edge nodes
+ %
+ % Ok, first, test, whether edge exists:
+ \ifcsname tikz@lg@e@#3@#2\endcsname%
+ \expandafter\global\expandafter\let\csname tikz@lg@e@#3@#2\endcsname\relax% reset
+ \fi%
+ \expandafter\gdef\csname tikz@lg@e@#2@#3\endcsname{\tikz@lib@graph@make@simple@edge{#1}{#2}{#3}{#4}{#5}}%
+}%
+
+\def\tikz@lib@graph@make@simple@edge#1#2#3#4#5{%
+ \pgfqkeys{/tikz/graphs}{new #1={#2}{#3}{#4}{#5}}%
+}%
+
+
+\def\tikz@lib@graph@simple@done{%
+ \tikz@lib@graph@pack@node@list%
+ {%
+ \let\tikz@lg@do\tikz@lib@graph@simple@node%
+ \tikz@lib@graph@node@list
+ }%
+}%
+
+\def\tikz@lib@graph@simple@node#1{%
+ {%
+ \def\tikz@lib@graph@simple@from@node{#1}%
+ \let\tikz@lg@do\tikz@lib@graph@simple@other@node%
+ \tikz@lib@graph@node@list%
+ }%
+}%
+
+\def\tikz@lib@graph@simple@other@node#1{%
+ \ifcsname tikz@lg@e@\tikz@lib@graph@simple@from@node @#1\endcsname%
+ \csname tikz@lg@e@\tikz@lib@graph@simple@from@node @#1\endcsname%
+ \expandafter\global\expandafter\let\csname tikz@lg@e@\tikz@lib@graph@simple@from@node @#1\endcsname\relax%
+ \fi%
+}%
+
+
+%
+% Basic options
+%
+
+\tikzgraphsset{
+ @nodes styling/.style=,
+ nodes/.style={/tikz/graphs/@nodes styling/.append style={,#1}},
+ @edges styling/.initial=,
+ edges/.style={/tikz/graphs/@edges styling/.append={,#1}},
+ edge/.style={edges={#1}},
+ @edges node/.initial=,
+ edge node/.style={/tikz/graphs/@edges node/.append={#1}},
+ edge label/.style={/tikz/graphs/@edges node/.append={node[auto]{#1}}},
+ edge label'/.style={/tikz/graphs/@edges node/.append={node[auto,swap]{#1}}},
+ @operators/.initial=,
+ operator/.style={/tikz/graphs/@operators/.append={#1}},
+ @extra group options/.style=,
+}%
+
+
+\def\tikzgraphinvokeoperator#1{%
+ {%
+ \pgfkeyslet{/tikz/graphs/@operators}\pgfutil@empty%
+ \pgfkeys{/tikz/graphs/.cd,#1}%
+ \pgfkeysgetvalue{/tikz/graphs/@operators}\tikz@lib@graph@temp%
+ \global\let\tikz@lib@graph@temp\tikz@lib@graph@temp%
+ }%
+ \tikz@lib@graph@temp%
+ \global\let\tikz@lib@graph@temp\relax%
+}%
+
+
+%
+% The parser
+%
+
+\def\tikz@lib@graph@parser{%
+ \pgfutil@ifnextchar[{\tikz@lib@graph@parser@}{\tikz@lib@graph@parser@[]}%]
+}%
+
+\def\tikz@lib@graph@parser@[#1]{%
+ \setbox\tikz@whichbox=\hbox\bgroup%
+ \unhbox\tikz@whichbox%
+ \hbox\bgroup
+ \bgroup%
+ \pgfinterruptpath%
+ \scope[graphs/.cd,@graph drawing setup/.try,@operators=,every graph/.try,#1]%
+ \begingroup%
+ \iftikz@graph@quick%
+ \expandafter\tikz@lib@graphs@parse@quick@graph%
+ \else%
+ \expandafter\tikz@lib@graphs@normal@main%
+ \fi%
+}%
+
+\long\def\tikz@lib@graphs@normal@main#1{%
+ \pgfkeysgetvalue{/tikz/graphs/@operators}\tikz@lib@graph@outer@operators%
+ \let\tikz@lib@graph@options\pgfutil@empty%
+ \let\tikz@lib@graph@node@list\pgfutil@empty%
+ \pgfkeyssetvalue{/tikz/graphs/placement/depth}{0}%
+ \pgfkeyssetvalue{/tikz/graphs/placement/width}{0}%
+ \pgfkeyssetvalue{/tikz/graphs/placement/level}{0}%
+ \tikz@lib@graph@start@hint@group%
+ \tikz@lib@graph@parse@group{#1}%
+ \tikz@lib@graph@end@hint@group
+ \tikz@lib@graph@outer@operators%
+ \let\tikz@lg@do=\tikz@lib@graph@cleanup%
+ \tikz@lib@graph@node@list%
+ \tikz@lib@graph@main@done%
+}%
+
+\def\tikz@lib@graph@main@done{%
+ \endgroup%
+ \endscope%
+ \endpgfinterruptpath%
+ \egroup
+ \egroup%
+ \egroup%
+ \tikz@lib@graph@parser@done%
+}%
+
+
+
+
+
+\def\tikz@lib@graph@start@hint@group{%
+ \pgfkeyssetvalue{/tikz/graphs/placement/local depth}{0}%
+ \pgfkeyssetvalue{/tikz/graphs/placement/local width}{0}%
+ \pgfkeyssetvalue{/tikz/graphs/placement/chain count}{0}%
+ \pgfkeyssetvalue{/tikz/graphs/placement/element count}{0}%
+}%
+
+\def\tikz@lib@graph@end@hint@group{%
+ % Get local depth and width outside
+ \xdef\tikz@lib@graph@group@depth{\pgfkeysvalueof{/tikz/graphs/placement/local depth}}
+ \xdef\tikz@lib@graph@group@width{\pgfkeysvalueof{/tikz/graphs/placement/local width}}
+}%
+
+\def\tikz@lib@graph@hint@aftergroup{%
+ \pgfkeysgetvalue{/tikz/graphs/placement/width}\tikz@temp@h%
+ \pgfkeysgetvalue{/tikz/graphs/placement/local width}\tikz@temp@lh%
+ \pgfkeysgetvalue{/tikz/graphs/placement/local depth}\tikz@temp@lw%
+ \pgfmathsetmacro\tikz@temp@h{\tikz@lib@graph@group@width+\tikz@temp@h}
+ \pgfmathsetmacro\tikz@temp@lh{\tikz@lib@graph@group@width+\tikz@temp@lh}
+ \pgfmathsetmacro\tikz@temp@lw{max(\tikz@lib@graph@group@depth,\tikz@temp@lw)}
+ \pgfkeyslet{/tikz/graphs/placement/width}\tikz@temp@h%
+ \pgfkeyslet{/tikz/graphs/placement/local width}\tikz@temp@lh%
+ \pgfkeyslet{/tikz/graphs/placement/local depth}\tikz@temp@lw%
+ %
+ \pgfkeysgetvalue{/tikz/graphs/placement/element count}\tikz@temp%
+ \c@pgf@counta=\tikz@temp\relax%
+ \advance\c@pgf@counta by1\relax%
+ \edef\tikz@temp{\the\c@pgf@counta}%
+ \pgfkeyslet{/tikz/graphs/placement/element count}\tikz@temp%
+}%
+
+\def\tikz@lib@graph@placement@update{%
+ \pgfkeys{/tikz/graphs/placement/logical node depth/.expand once=\tikz@lib@graph@name}
+ \let\tikz@lib@graph@node@depth\pgfmathresult
+ \pgfkeys{/tikz/graphs/placement/logical node width/.expand once=\tikz@lib@graph@name}
+ \let\tikz@lib@graph@node@width\pgfmathresult
+ % This is a single node, so update the lengths accordingly
+ \pgfkeysgetvalue{/tikz/graphs/placement/width}\tikz@temp@h%
+ \pgfkeysgetvalue{/tikz/graphs/placement/local width}\tikz@temp@lh%
+ \pgfkeysgetvalue{/tikz/graphs/placement/local depth}\tikz@temp@lw%
+ \pgfmathsetmacro\tikz@temp@h{\tikz@lib@graph@node@width+\tikz@temp@h}
+ \pgfmathsetmacro\tikz@temp@lh{\tikz@lib@graph@node@width+\tikz@temp@lh}
+ \pgfmathsetmacro\tikz@temp@lw{max(\tikz@lib@graph@node@depth,\tikz@temp@lw)}
+ \pgfkeyslet{/tikz/graphs/placement/width}\tikz@temp@h%
+ \pgfkeyslet{/tikz/graphs/placement/local width}\tikz@temp@lh%
+ \pgfkeyslet{/tikz/graphs/placement/local depth}\tikz@temp@lw%
+ %
+ \pgfkeysgetvalue{/tikz/graphs/placement/element count}\tikz@temp%
+ \c@pgf@counta=\tikz@temp\relax%
+ \advance\c@pgf@counta by1\relax%
+ \edef\tikz@temp{\the\c@pgf@counta}%
+ \pgfkeyslet{/tikz/graphs/placement/element count}\tikz@temp%
+}%
+
+\def\tikz@lib@graph@placement@after@chain@update{%
+ \pgfkeysgetvalue{/tikz/graphs/placement/depth}\tikz@temp@w%
+ \pgfkeysgetvalue{/tikz/graphs/placement/local width}\tikz@temp@lh%
+ \pgfkeysgetvalue{/tikz/graphs/placement/local depth}\tikz@temp@lw%
+ \pgfmathsetmacro\tikz@temp@w{\tikz@lib@graph@chain@depth+\tikz@temp@w}%
+ \pgfmathsetmacro\tikz@temp@lw{\tikz@lib@graph@chain@depth+\tikz@temp@lw}%
+ \pgfmathsetmacro\tikz@temp@lh{max(\tikz@lib@graph@chain@width,\tikz@temp@lh)}%
+ \pgfkeyslet{/tikz/graphs/placement/depth}\tikz@temp@w%
+ \pgfkeyslet{/tikz/graphs/placement/local width}\tikz@temp@lh%
+ \pgfkeyslet{/tikz/graphs/placement/local depth}\tikz@temp@lw%
+ %
+ \pgfkeysgetvalue{/tikz/graphs/placement/chain count}\tikz@temp%
+ \c@pgf@counta=\tikz@temp\relax%
+ \advance\c@pgf@counta by1\relax%
+ \edef\tikz@temp{\the\c@pgf@counta}%
+ \pgfkeyslet{/tikz/graphs/placement/chain count}\tikz@temp%
+}%
+
+
+%
+% Parse a group
+%
+
+\long\def\tikz@lib@graph@parse@group#1{
+ \let\tikz@lib@graph@group@qa\pgfutil@empty%
+ \let\tikz@lib@graph@group@q\pgfutil@empty%
+ \let\tikz@lib@graph@group@c\pgfutil@empty%
+ \let\tikz@lib@graph@group@cont\pgfutil@empty%
+ \let\tikz@lib@graph@group@conta\pgfutil@empty%
+ \tikz@lib@graph@group@check#1\par\pgf@stop@eogroup%
+}%
+
+
+
+%
+% Start of a group
+%
+\def\tikz@lib@graph@group@check{%
+ \pgfutil@ifnextchar[\tikz@lib@graph@group@opt{\tikz@lib@graph@group@opt[]}%]
+}%
+
+\def\tikz@lib@graph@group@opt[#1]{%
+ \let\tikz@lib@graph@parse@extras\pgfutil@empty%
+ \tikzgraphsset{
+ @operators=,
+ every group/.try,
+ @extra group options,
+ @extra group options/.style=,%
+ #1}%
+ \expandafter\tikz@lib@graph@par\tikz@lib@graph@parse@extras%
+}%
+
+\tikzgraphsset{
+ parse/.code={\expandafter\def\expandafter\tikz@lib@graph@parse@extras\expandafter{\tikz@lib@graph@parse@extras#1}},
+}%
+
+
+
+%
+% Remove \par
+%
+
+\def\tikz@lib@graph@par{%
+ \pgfutil@ifnextchar\bgroup{\tikz@lib@graph@par@@}{\tikz@lib@graph@par@}%
+}%
+\long\def\tikz@lib@graph@par@#1\par{%
+ \pgfutil@ifnextchar\pgf@stop@eogroup{%
+ \expandafter\tikz@lib@graph@quotes\tikz@lib@graph@group@c#1"}{%
+ \expandafter\def\expandafter\tikz@lib@graph@group@c\expandafter{\tikz@lib@graph@group@c#1}%
+ \tikz@lib@graph@par%
+ }%
+}%
+\long\def\tikz@lib@graph@par@@#1{%
+ \expandafter\def\expandafter\tikz@lib@graph@group@c\expandafter{\tikz@lib@graph@group@c{#1}}%
+ \tikz@lib@graph@par
+}%
+
+
+
+%
+% Replace ..."..."... by ..."{...}"...
+%
+\def\tikz@lib@graph@quotes{%
+ \pgfutil@ifnextchar\bgroup{\tikz@lib@graph@quotes@@}{\tikz@lib@graph@quotes@}%
+}%
+\def\tikz@lib@graph@quotes@#1"{%
+ \pgfutil@ifnextchar\pgf@stop@eogroup{%
+ \tikz@lib@graph@passon{#1}%
+ }{%
+ \expandafter\def\expandafter\tikz@lib@graph@group@q\expandafter{\tikz@lib@graph@group@q#1"}%
+ \tikz@lib@graph@quotes@cont%
+ }%
+}%
+
+\def\tikz@lib@graph@quotes@cont#1"#2"{%
+ \pgfutil@ifnextchar\pgf@stop@eogroup{%
+ \tikz@lib@graph@passon{{#1}"#2}}{%
+ \expandafter\def\expandafter\tikz@lib@graph@group@q\expandafter{\tikz@lib@graph@group@q{#1}"#2"}%
+ \tikz@lib@graph@quotes@cont}%
+}%
+
+\def\tikz@lib@graph@quotes@@#1{%
+ \expandafter\def\expandafter\tikz@lib@graph@group@q\expandafter{\tikz@lib@graph@group@q{#1}}%
+ \tikz@lib@graph@quotes%
+}%
+
+
+
+%
+% Replace ..."..."... by ..."{...}"... (active version)
+%
+{%
+ \catcode`\"=13\relax
+
+ \gdef\tikz@lib@graph@passon#1{\expandafter\tikz@lib@graph@quotesactive\tikz@lib@graph@group@q#1"}%
+
+ \gdef\tikz@lib@graph@quotesactive{%
+ \pgfutil@ifnextchar\bgroup{\tikz@lib@graph@quotesactive@@}{\tikz@lib@graph@quotesactive@}%
+ }%
+ \gdef\tikz@lib@graph@quotesactive@#1"{%
+ \pgfutil@ifnextchar\pgf@stop@eogroup{%
+ \expandafter\tikz@lib@graph@encloser\tikz@lib@graph@group@qa#1[%
+ }{%
+ \expandafter\def\expandafter\tikz@lib@graph@group@qa\expandafter{\tikz@lib@graph@group@qa#1"}%
+ \tikz@lib@graph@quotesactive@cont%
+ }%
+ }%
+
+ \gdef\tikz@lib@graph@quotesactive@cont#1"#2"{%
+ \pgfutil@ifnextchar\pgf@stop@eogroup{%
+ \expandafter\tikz@lib@graph@encloser\tikz@lib@graph@group@qa{#1}"#2[}{%
+ \expandafter\def\expandafter\tikz@lib@graph@group@qa\expandafter{\tikz@lib@graph@group@qa{#1}"#2"}%
+ \tikz@lib@graph@quotesactive@cont}%
+ }%
+
+ \gdef\tikz@lib@graph@quotesactive@@#1{%
+ \expandafter\def\expandafter\tikz@lib@graph@group@qa\expandafter{\tikz@lib@graph@group@qa{#1}}%
+ \tikz@lib@graph@quotesactive%
+ }%
+}%
+
+
+
+
+%
+% Replace ...[...]... by ...[{...}]...
+%
+\def\tikz@lib@graph@encloser{%
+ \pgfutil@ifnextchar\bgroup{\tikz@lib@graph@encloser@@}{\tikz@lib@graph@encloser@}%
+}%
+\def\tikz@lib@graph@encloser@#1[{%
+ \pgfutil@ifnextchar\pgf@stop@eogroup{%
+ \expandafter\tikz@lib@graph@semi\tikz@lib@graph@group@cont#1;%
+ }{%
+ \expandafter\def\expandafter\tikz@lib@graph@group@cont\expandafter{\tikz@lib@graph@group@cont#1[}%]
+ \tikz@lib@graph@encloser@cont%
+ }%
+}%
+
+\def\tikz@lib@graph@encloser@cont#1]#2[{%
+ \pgfutil@ifnextchar\pgf@stop@eogroup{%
+ \expandafter\tikz@lib@graph@semi\tikz@lib@graph@group@cont{#1}]#2;}{%
+ \expandafter\def\expandafter\tikz@lib@graph@group@cont\expandafter{\tikz@lib@graph@group@cont{#1}]#2[}%
+ \tikz@lib@graph@encloser@cont}%
+}%
+
+\def\tikz@lib@graph@encloser@@#1{%
+ \expandafter\def\expandafter\tikz@lib@graph@group@cont\expandafter{\tikz@lib@graph@group@cont{#1}}%
+ \tikz@lib@graph@encloser%
+}%
+
+
+
+
+%
+% Replace ; by ,
+%
+
+\def\tikz@lib@graph@semi{%
+ \pgfutil@ifnextchar\bgroup{\tikz@lib@graph@semi@@}{\tikz@lib@graph@semi@}%
+}%
+\def\tikz@lib@graph@semi@#1;{%
+ \pgfutil@ifnextchar\pgf@stop@eogroup{%
+ \expandafter\tikz@lib@graph@main@parser\tikz@lib@graph@group@conta#1,}{%
+ \expandafter\def\expandafter\tikz@lib@graph@group@conta\expandafter{\tikz@lib@graph@group@conta#1,}%
+ \tikz@lib@graph@semi%
+ }%
+}%
+\def\tikz@lib@graph@semi@@#1{%
+ \expandafter\def\expandafter\tikz@lib@graph@group@conta\expandafter{\tikz@lib@graph@group@conta{#1}}%
+ \tikz@lib@graph@semi%
+}%
+
+
+%
+% Main parse
+%
+
+\def\tikz@lib@graph@main@parser{%
+ \begingroup%
+ \pgfkeyssetvalue{/tikz/graphs/placement/local depth}{0}%
+ \pgfkeyssetvalue{/tikz/graphs/placement/local width}{0}%
+ \let\tikz@lib@graph@stored@actions\pgfutil@empty%
+ \let\tikz@lib@graph@node@list\pgfutil@empty% reset
+ \tikz@lib@graph@main@parser@start%
+}%
+\def\tikz@lib@graph@main@parser@start{%
+ \pgfutil@ifnextchar\bgroup{\tikz@lib@graph@protect@group}{\tikz@lib@graph@main@parser@cont}%
+}%
+
+\def\tikz@lib@graph@protect@group#1{% skip space
+ \pgfutil@ifnextchar\relax{\tikz@lib@graph@main@parser@cont{{#1}}}{\tikz@lib@graph@main@parser@cont{{#1}}}%
+}%
+
+\def\tikz@lib@graph@main@parser@cont{\tikz@lib@graph@check@quotes\tikz@lib@graph@main@parser@cont@normal}%
+\def\tikz@lib@graph@main@parser@cont@normal#1,{%
+ \tikz@lib@graph@parse@one#1-\pgf@stop@eodashes%
+}%
+
+\def\tikz@lib@graph@parse@one{%
+ \pgfutil@ifnextchar\bgroup\tikz@lib@graph@scope\tikz@lib@graph@node%
+}%
+
+
+
+% Special quoted nodes
+
+\def\tikz@lib@graph@check@quotes#1{%
+ \let\tikz@lib@graph@cont@quote#1%
+ \pgfutil@ifnextchar"{\begingroup\pgfkeys@temptoks{}\pgfutil@empty\tikz@lib@graph@quote@parser}{\tikz@lib@graph@check@quotes@active}%
+}%
+{%
+ \catcode`\"=13\relax
+ \gdef\tikz@lib@graph@check@quotes@active{%
+ \pgfutil@ifnextchar"{\begingroup\pgfkeys@temptoks{}\pgfutil@empty\tikz@lib@graph@quote@parser@active}{\tikz@lib@graph@cont@quote}%
+ }%
+ \gdef\tikz@lib@graph@quote@parser@active"#1"{%
+ \pgfkeys@temptoks\expandafter{\the\pgfkeys@temptoks #1}%
+ \pgfutil@ifnextchar"{\pgfkeys@temptoks\expandafter{\the\pgfkeys@temptoks "}\tikz@lib@graph@quote@parser@active}{\tikz@lib@graph@quote@parser@done}%
+ }%
+}%
+
+\def\tikz@lib@graph@quote@parser"#1"{%
+ \pgfkeys@temptoks\expandafter{\the\pgfkeys@temptoks #1}%
+ \pgfutil@ifnextchar"{\pgfkeys@temptoks\expandafter{\the\pgfkeys@temptoks "}\tikz@lib@graph@quote@parser}{\tikz@lib@graph@quote@parser@done}%
+}%
+
+\def\tikz@lib@graph@quote@parser@done{%
+ {\expandafter\scantokens\expandafter{%
+ \expandafter\expandafter\expandafter\tikzlibgraphactivations\expandafter\expandafter\expandafter\tikzlibgraphdoedef\expandafter{\the\pgfkeys@temptoks}%
+ }}%
+ {\expandafter\scantokens\expandafter{\expandafter\tikzlibgraphactivationsbrace\expandafter\xdef\expandafter\tikzlibgraphreplaced\expandafter<\tikzlibgraphreplaced>\catcode`\}=2\relax}}%
+ \edef\tikzlibgraphreplaced{\expandafter\detokenize\expandafter{\tikzlibgraphreplaced}}
+ \pgfutil@ifnextchar/\tikz@lib@graph@quotes@slash\tikz@lib@graph@quotes@no@slash%
+}%
+\def\tikz@lib@graph@quotes@no@slash{%
+ \expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter%
+ \tikz@smuggle\expandafter\expandafter\expandafter{\expandafter\tikzlibgraphreplaced\expandafter/\expandafter{\the\pgfkeys@temptoks}}%
+ \expandafter\endgroup\expandafter\tikz@lib@graph@cont@quote\tikz@smuggle%
+}%
+\def\tikz@lib@graph@quotes@slash/{%
+ \pgfutil@ifnextchar/% Ah, double slash...
+ {\tikz@lib@graph@quotes@no@slash/}{\expandafter\endgroup\expandafter\tikz@lib@graph@cont@quote\tikzlibgraphreplaced/}%
+}%
+\def\tikzlibgraphdoedef{\xdef\tikzlibgraphreplaced}%
+
+\def\tikz@lib@prepare@active#1#2#3{%
+ {%
+ \catcode`#1=13\relax%
+ \scantokens{\gdef\tikzlibgraphactivator{\def#2{@#3@}}}%
+ }%
+ \pgfutil@g@addto@macro\tikzlibgraphactivations{\catcode`#1=13\relax}%
+ \expandafter\pgfutil@g@addto@macro\expandafter\tikzlibgraphactivations\expandafter{\tikzlibgraphactivator}%
+}%
+
+\let\tikzlibgraphactivations\pgfutil@empty
+
+%
+% Remove \outer from \+ for plain TeX
+%
+
+\outer\def\tikz@lib@outer@test{\tabalign}%
+\ifx\+\tikz@lib@outer@test
+ \def\+{\tabalign}
+\fi
+
+\tikz@lib@prepare@active{\$}{$}{DOLLAR SIGN}% $
+\tikz@lib@prepare@active{\&}{&}{AMPERSAND}%
+\tikz@lib@prepare@active{\^}{^}{CIRCUMFLEX ACCENT}%
+\tikz@lib@prepare@active{\~}{~}{TILDE}%
+\tikz@lib@prepare@active{\_}{_}{LOW LINE}%
+\tikz@lib@prepare@active{\|}{|}{VERTICAL LINE}%
+\tikz@lib@prepare@active{\[}{[}{LEFT SQUARE BRACKET}%
+\tikz@lib@prepare@active{\]}{]}{RIGHT SQUARE BRACKET}%
+\tikz@lib@prepare@active{\(}{(}{LEFT PARENTHESIS}%
+\tikz@lib@prepare@active{\)}{)}{RIGHT PARENTHESIS}%
+\tikz@lib@prepare@active{\/}{/}{SOLIDUS}%
+\tikz@lib@prepare@active{\.}{.}{FULL STOP}%
+\tikz@lib@prepare@active{\-}{-}{HYPHEN MINUS}%
+\tikz@lib@prepare@active{\,}{,}{COMMA}%
+\tikz@lib@prepare@active{\+}{+}{PLUS SIGN}%
+\tikz@lib@prepare@active{\*}{*}{ASTERISK}%
+\tikz@lib@prepare@active{\'}{'}{APOSTROPHE}%
+\tikz@lib@prepare@active{\!}{!}{EXCLAMATION MARK}%
+\tikz@lib@prepare@active{\"}{"}{QUOTATION MARK}%
+\tikz@lib@prepare@active{\:}{:}{COLON}%
+\tikz@lib@prepare@active{\;}{;}{SEMINCOLON}%
+\tikz@lib@prepare@active{\<}{<}{LESS THAN SIGN}%
+\tikz@lib@prepare@active{\=}{=}{EQUALS SIGN}%
+\tikz@lib@prepare@active{\>}{>}{GREATER THAN SIGN}%
+\tikz@lib@prepare@active{\?}{?}{QUESTION MARK}%
+%\tikz@lib@prepare@active{\@}{@}{COMMERCIAL AT}%
+\tikz@lib@prepare@active{\`}{`}{GRAVE ACCENT}%
+{\catcode`\%=11\catcode`\#=11
+\tikz@lib@prepare@active{\%}{%}{PERCENT SIGN}
+\tikz@lib@prepare@active{\#}{#}{NUMBER SIGN}
+}
+
+\pgfutil@g@addto@macro\tikzlibgraphactivations{\catcode`\\=13\relax}%
+{%
+ \catcode`\|=0\relax
+ \catcode`\\=13\relax
+ |pgfutil@g@addto@macro|tikzlibgraphactivations{|def\{@REVERSE SOLIDUS@}}%
+}%
+{%
+ \gdef\tikzlibgraphscommercialat{@COMMERCIAL AT@}%
+ \let\g=\pgfutil@g@addto@macro
+ \catcode`\@=13\relax
+ \g\tikzlibgraphactivations{\catcode`\@=13\relax\let@=\tikzlibgraphscommercialat}%
+}%
+
+\def\tikzlibgraphactivationsbrace{%
+ \catcode`\{=13\relax%
+ \catcode`\}=13\relax%
+ \catcode`\<=1\relax%
+ \catcode`\>=2\relax%
+}%
+{%
+ \catcode`\{=13\relax%
+ \catcode`\}=13\relax%
+ \catcode`\<=1\relax%
+ \catcode`\>=2\relax%
+ \pgfutil@g@addto@macro\tikzlibgraphactivationsbrace<\def{<@LEFT CURLY BRACE@>> %}
+ \pgfutil@g@addto@macro\tikzlibgraphactivationsbrace<\def}<@RIGHT CURLY BRACE@>> %{
+>%
+
+% A normal node
+
+% First, check for special quote syntax:
+
+\def\tikz@lib@graph@node{\tikz@lib@graph@check@quotes\tikz@lib@graph@node@normal}%
+
+\def\tikz@lib@graph@node@normal{%
+ \pgfutil@ifnextchar({\tikz@lib@graph@node@dressed}{\tikz@lib@graph@node@naked}%
+}%
+
+\def\tikz@lib@graph@node@dressed(#1){%
+ % Add extra braces around nodes to protect dashes
+ \tikz@lib@graph@node@naked{(#1)}%
+}%
+
+\def\tikz@lib@graph@node@naked#1-{%
+ % Detect trailing <
+ \tikz@lib@graph@@node#1<\pgf@stop%
+}%
+
+\def\tikz@lib@graph@@node#1<#2\pgf@stop%
+{
+ %
+ % #1 will be a node (not a group)
+ %
+ % Syntax: node name [options]
+ %
+ % Grab node name
+ \tikz@lib@graph@grab@name#1\pgf@stop%
+ \tikz@lib@graph@stored@actions%
+ \pgfutil@ifnextchar\pgf@stop@eodashes{%
+ \tikz@lib@graph@graph@done%
+ }{%
+ %
+ % Now, get arrow kind
+ %
+ \def\pgf@test{#2}%
+ \ifx\pgf@test\pgfutil@empty%
+ \expandafter\tikz@lib@graph@no@back@arrow%
+ \else%
+ \expandafter\tikz@lib@graph@back@arrow%
+ \fi%
+ }%
+}%
+
+\def\tikz@lib@graph@no@back@arrow{%
+ \pgfutil@ifnextchar>\tikz@lib@graph@forward@arrow{%
+ \pgfutil@ifnextchar-\tikz@lib@graph@undirected@arrow{%
+ \pgfutil@ifnextchar!\tikz@lib@graph@no@arrow{%
+ \tikzerror{One of the arrow types <-, --, ->, -!- or <-> expected}%
+ \tikz@lib@graph@undirected@arrow%
+ }%
+ }%
+ }%
+}%
+
+\def\tikz@lib@graph@undirected@arrow-{%
+ \def\tikz@lib@graph@arrow@type{--}%
+ \tikz@lib@graph@after@arrow%
+}%
+
+\def\tikz@lib@graph@forward@arrow>{%
+ \def\tikz@lib@graph@arrow@type{->}%
+ \tikz@lib@graph@after@arrow%
+}%
+
+\def\tikz@lib@graph@bi@arrow>{%
+ \def\tikz@lib@graph@arrow@type{<->}%
+ \tikz@lib@graph@after@arrow%
+}%
+
+\def\tikz@lib@graph@no@arrow!-{%
+ \def\tikz@lib@graph@arrow@type{-!-}%
+ \tikz@lib@graph@after@arrow%
+}%
+
+\def\tikz@lib@graph@back@arrow{%
+ \pgfutil@ifnextchar>{\tikz@lib@graph@bi@arrow}{%
+ \def\tikz@lib@graph@arrow@type{<-}%
+ \tikz@lib@graph@after@arrow%
+ }%
+}%
+
+\def\tikz@lib@graph@after@arrow{%
+ \pgfutil@ifnextchar[{\tikz@lib@graph@after@arrow@opt}{\tikz@lib@graph@after@arrow@opt[]}%]
+}%
+
+\def\tikz@lib@graph@after@arrow@opt[#1]{%
+ %
+ % Ok, first recolor
+ %
+ \tikzgraphinvokeoperator{recolor source by=source''}
+ \tikzgraphinvokeoperator{recolor target by=target'}
+ % Save action for next node
+ \expandafter\def\expandafter\tikz@lib@graph@stored@actions\expandafter{%
+ \expandafter\tikz@lib@graph@joiner\expandafter{\tikz@lib@graph@arrow@type}{#1}}%
+ %
+ \tikzgdeventgroupcallback{descendants}%
+ \tikz@lib@graph@parse@one%
+}%
+
+\def\tikz@lib@graph@joiner#1#2{%
+ \tikzgraphinvokeoperator{recolor source by=source'}
+ \tikzgraphinvokeoperator{recolor source'' by=source}
+ {%
+ \tikz@enable@edge@quotes%
+ \pgfkeyssetvalue{/tikz/graphs/default edge kind}{#1}%
+ \pgfkeys{/tikz/graphs/.cd,@operators=,%
+ /tikz/graphs/.unknown/.code=\tikz@lib@graph@unknown@edge@option{##1},#2}%
+ \pgfkeysgetvalue{/tikz/graphs/@operators}\pgf@temp%
+ \ifx\pgf@temp\pgfutil@empty%
+ \edef\pgf@temp{\noexpand\pgfkeys{/tikz/graphs/.cd,\pgfkeysvalueof{/tikz/graphs/default edge operator}}}%
+ \pgf@temp%
+ \pgfkeysgetvalue{/tikz/graphs/@operators}\pgf@temp%
+ \fi%
+ \pgf@temp%
+ }%
+ \tikzgraphinvokeoperator{not source',not target'}
+}%
+
+\def\tikz@lib@graph@unknown@edge@option#1{%
+ \def\tikz@temp{/tikz/graphs/@edges styling/.append=}
+ \expandafter\expandafter\expandafter\pgfkeys%
+ \expandafter\expandafter\expandafter{\expandafter\tikz@temp\expandafter{\expandafter,\pgfkeyscurrentname={#1}}}
+}%
+
+\def\tikz@lib@graph@graph@done\pgf@stop@eodashes{%
+ % Get local depth and width outside
+ \xdef\tikz@lib@graph@chain@depth{\pgfkeysvalueof{/tikz/graphs/placement/local depth}}
+ \xdef\tikz@lib@graph@chain@width{\pgfkeysvalueof{/tikz/graphs/placement/local width}}
+ % Get node list outside...
+ \expandafter%
+ \endgroup%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\tikz@lib@graph@node@list%
+ \expandafter\expandafter\expandafter{\expandafter\tikz@lib@graph@node@list\tikz@lib@graph@node@list}%
+ % Compute new local depth and width of group...
+ \tikz@lib@graph@placement@after@chain@update
+ %
+ \pgfutil@ifnextchar\pgf@stop@eogroup%
+ \tikz@lib@graph@graph@group@done%
+ \tikz@lib@graph@main@parser%
+}%
+
+\def\tikz@lib@graph@graph@group@done\pgf@stop@eogroup{%
+ \pgfkeysvalueof{/tikz/graphs/@operators}%
+}%
+
+
+
+%
+% Handle node
+%
+\def\tikz@lib@graph@grab@name{%
+ \pgfutil@ifnextchar\foreach\tikz@lib@graph@do@foreach\tikz@lib@graph@parse@node@text%
+}%
+
+\def\tikz@lib@graph@do@foreach\foreach#1in{%
+ \pgfutil@ifnextchar\bgroup{\tikz@lib@graph@do@foreach@normal{#1}}{\def\tikz@temp{#1}\tikz@lib@graph@do@foreach@macro}%
+}%
+\def\tikz@lib@graph@do@foreach@macro#1{%
+ \expandafter\expandafter\expandafter\tikz@lib@graph@do@foreach@normal\expandafter\tikz@temp\expandafter{#1}%
+}%
+
+\def\tikz@lib@graph@do@foreach@normal#1#2#3\pgf@stop{%
+ % Ok, we do a parse on a foreach loop.
+ \begingroup
+ \let\tikz@lib@graph@node@list@saved\pgfutil@empty%
+ \xdef\tikz@lib@graph@saved@placement{%
+ {\pgfkeysvalueof{/tikz/graphs/placement/local depth}}%
+ {\pgfkeysvalueof{/tikz/graphs/placement/local width}}%
+ {\pgfkeysvalueof{/tikz/graphs/placement/chain count}}%
+ {\pgfkeysvalueof{/tikz/graphs/placement/element count}}%
+ {\pgfkeysvalueof{/tikz/graphs/placement/width}}%
+ {\pgfkeysvalueof{/tikz/graphs/placement/depth}}%
+ }%
+ \foreach #1 in {#2}%
+ {%
+ \let\tikz@lib@graph@node@list\tikz@lib@graph@node@list@saved%
+ \expandafter\tikz@lib@graph@setup@placement\tikz@lib@graph@saved@placement%
+ \tikz@lib@graph@parse@group{#3}%
+ \xdef\tikz@lib@graph@saved@placement{%
+ {\pgfkeysvalueof{/tikz/graphs/placement/local depth}}%
+ {\pgfkeysvalueof{/tikz/graphs/placement/local width}}%
+ {\pgfkeysvalueof{/tikz/graphs/placement/chain count}}%
+ {\pgfkeysvalueof{/tikz/graphs/placement/element count}}%
+ {\pgfkeysvalueof{/tikz/graphs/placement/width}}%
+ {\pgfkeysvalueof{/tikz/graphs/placement/depth}}%
+ }%
+ % TODO: Need to also save hints!
+ \global\let\tikz@lib@graph@node@list@saved\tikz@lib@graph@node@list%
+ }%
+ \expandafter%
+ \endgroup%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\tikz@lib@graph@node@list%
+ \expandafter\expandafter\expandafter{\expandafter\tikz@lib@graph@node@list\tikz@lib@graph@node@list@saved}%
+ \expandafter\tikz@lib@graph@setup@placement\tikz@lib@graph@saved@placement%
+}%
+
+\def\tikz@lib@graph@setup@placement#1#2#3#4#5#6{%
+ \pgfkeyssetvalue{/tikz/graphs/placement/local depth}{#1}%
+ \pgfkeyssetvalue{/tikz/graphs/placement/local width}{#2}%
+ \pgfkeyssetvalue{/tikz/graphs/placement/chain count}{#3}%
+ \pgfkeyssetvalue{/tikz/graphs/placement/element count}{#4}%
+ \pgfkeyssetvalue{/tikz/graphs/placement/width}{#5}%
+ \pgfkeyssetvalue{/tikz/graphs/placement/depth}{#6}%
+}%
+
+\def\tikz@lib@graph@parse@node@text#1\pgf@stop{%
+ %
+ % Ok, first test whether #1 contains "//"
+ %
+ \pgfutil@in@{//}{#1 }
+ \ifpgfutil@in@%
+ % Ok, a layout node:
+ \tikz@lib@parse@layout@node#1\pgf@stop%
+ \else%
+ \tikz@lib@graph@fake@nodefalse
+ \let\tikz@lib@graph@node@parsed\tikz@lib@graph@node@opt@normal%
+ \def\tikz@lib@graph@empty@node@parsed{\tikzgdeventcallback{node}{}}%
+ \tikz@lib@parse@normal@node#1[\pgf@stop%
+ \fi%
+}%
+
+\newif\iftikzgraphsautonumbernodes
+\newcount\tikz@lib@auto@number
+
+\def\tikz@lib@do@autonumber{%
+ \ifx\tikz@lib@graph@name@only\pgfutil@empty%
+ \else%
+ \edef\tikz@lib@graph@name@only{\tikz@lib@graph@name@only\tikz@lib@auto@sep\the\tikz@lib@auto@number}%
+ \global\advance\tikz@lib@auto@number by1\relax%
+ \fi%
+}%
+
+%
+% Parse the normal part of a node (name and, possibly, text after slash)
+%
+
+\def\tikz@lib@parse@normal@node#1[{
+ %
+ % Test whether #1 contains "/" or "__"
+ %
+ \pgfutil@in@{/}{#1}%
+ \ifpgfutil@in@%
+ \tikz@lib@parse@node@with@slash#1\pgf@stop%
+ \else
+ \pgfutil@in@{__}{#1}%
+ \ifpgfutil@in@%
+ \tikz@lib@parse@node@with@doubleunder#1\pgf@stop%
+ \else
+ \edef\pgf@marshal{\noexpand\pgfkeys@spdef\noexpand\tikz@lib@graph@name@only{#1}}%
+ \pgf@marshal%
+ \let\tikz@lib@graph@node@text\tikz@lib@graph@name@only%
+ \edef\tikz@lib@graph@name{\tikz@lib@graph@path\tikz@lib@graph@name@only}%
+ \fi%
+ \fi%
+ \tikz@lib@graph@handle@node@cont%
+}%
+
+\def\tikz@lib@parse@node@with@slash#1/{
+ \pgfkeys@spdef\tikz@lib@graph@name@only{#1}%
+ \ifx\tikz@lib@graph@name@only\pgfutil@empty%
+ \global\advance\tikz@fig@count by1\relax
+ \edef\tikz@lib@graph@name@only{tikz@f@\the\tikz@fig@count}%
+ \fi%
+ \edef\tikz@lib@graph@name{\tikz@lib@graph@path\tikz@lib@graph@name@only}%
+ \pgfutil@ifnextchar"\tikz@lg@slash@quote{\pgfutil@ifnextchar\tikz@active@quotes@token\tikz@lg@slash@quote@active\tikz@lg@slash@cont}
+}%
+\def\tikz@lg@slash@quote"#1"#2\pgf@stop{%
+ \iftikz@handle@active@nodes%
+ \def\tikz@lib@graph@node@text{\scantokens{#1}}%
+ \else
+ \def\tikz@lib@graph@node@text{#1}%
+ \fi%
+}%
+{\catcode`\"=13\relax
+ \gdef\tikz@lg@slash@quote@active"#1"#2\pgf@stop{%
+ \iftikz@handle@active@nodes%
+ \def\tikz@lib@graph@node@text{\scantokens{#1}}%
+ \else
+ \def\tikz@lib@graph@node@text{#1}%
+ \fi%
+ }%
+}%
+\def\tikz@lg@slash@cont#1\pgf@stop{%
+ \iftikz@handle@active@nodes%
+ \def\tikz@lib@graph@node@text{\scantokens{#1}}%
+ \else
+ \def\tikz@lib@graph@node@text{#1}%
+ \fi%
+}%
+
+\def\tikz@lib@parse@node@with@doubleunder#1__{\tikz@lib@parse@node@with@slash{#1}/}%
+
+\def\tikz@lg@find@fresh@name{%
+ \edef\tikz@lib@graph@name@only{\tikz@lib@graph@name@only'}%
+ \edef\tikz@lib@graph@name{\tikz@lib@graph@path\tikz@lib@graph@name@only}%
+ \tikz@lg@if@local@node{\tikz@lib@graph@name}{\tikz@lg@find@fresh@name}{}%
+}%
+
+
+%
+% We have now parsed everything up to the opening "[". We continue
+%
+
+\def\tikz@lib@graph@handle@node@cont{%
+ \iftikzgraphsautonumbernodes%
+ \tikz@lib@do@autonumber%
+ \fi%
+ \iftikz@lib@graph@fresh@node%
+ \tikz@lg@if@local@node{\tikz@lib@graph@name}{\tikz@lg@find@fresh@name}{}%
+ \fi%
+ \let\tikzgraphnodeas\tikzgraphnodeas@default%
+ \pgfutil@ifnextchar\pgf@stop{%
+ \ifx\tikz@lib@graph@name@only\pgfutil@empty%
+ \expandafter\tikz@lib@graph@node@empty@done%
+ \else
+ \expandafter\tikz@lib@graph@node@opt\expandafter[\expandafter]\expandafter[%
+ \fi%
+ }{\tikz@lib@graph@node@opt[}%
+}%
+
+\def\tikzgraphnodeas@default{%
+ \tikz@lib@graph@typesetter%
+}%
+
+\let\tikz@lib@graph@empty@node@parsed\relax%
+
+\def\tikz@lib@graph@node@opt[#1]#2[\pgf@stop{%
+ \tikz@lib@graph@node@parsed{#1}%
+}%
+
+\def\tikz@lib@graph@node@empty@done\pgf@stop{\tikz@lib@graph@empty@node@parsed}%
+
+%
+% Parse a layout node
+%
+
+\def\tikz@lib@parse@layout@node#1//{%
+ \pgf@lib@graph@empty@layout@nodefalse%
+ \let\tikz@lib@graph@node@parsed\tikz@lib@layout@node@parsed%
+ \let\tikz@lib@graph@empty@node@parsed\tikz@lib@graph@empty@layout@node@parsed
+ \tikz@lib@parse@normal@node#1[\pgf@stop%
+}%
+
+\newif\ifpgf@lib@graph@empty@layout@node
+
+\def\tikz@lib@layout@node@parsed{%
+ \tikz@lib@layout@parse@rest%
+}%
+
+\def\tikz@lib@graph@empty@layout@node@parsed{%
+ \pgf@lib@graph@empty@layout@nodetrue
+ \tikz@lib@layout@parse@rest{}%
+}%
+
+\def\tikz@lib@layout@parse@rest#1{%
+ \def\tikz@lib@layout@node@options{#1}%
+ \pgfutil@ifnextchar[{\tikz@lib@layout@node@opt}{\tikz@lib@layout@node@opt[]}%}
+}%
+
+\def\tikz@lib@layout@node@parsed#1{%
+ \def\tikz@lib@layout@node@options{#1}%
+ \pgfutil@ifnextchar[{\tikz@lib@layout@node@opt}{\tikz@lib@layout@node@opt[]}%}
+}%
+
+\def\tikz@lib@layout@node@opt[#1]{%
+ \def\tikz@lib@layout@options{#1}%
+ \pgfutil@ifnextchar\bgroup{\tikz@lib@layout@start}{\tikzerror{Opening brace at beginning of sublayout expected}}%
+}%
+
+
+%
+% Typeset a normal node
+%
+
+\def\tikz@lib@graph@node@opt@normal#1{%
+ \expandafter\tikz@lib@graph@test@use@list\tikz@lib@graph@name@only\pgf@stop
+ \iftikz@lib@graph@use@list%
+ % Ok, make a list of the nodes stored in #1:
+ \let\tikz@lg@temp\pgfutil@empty%
+ \foreach \tikz@lg@node@name in \tikz@lib@graph@use@list {\expandafter\tikz@lib@graph@handle@use\expandafter{\tikz@lg@node@name}}
+ % Ok, now add the nodes to the node list
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\tikz@lib@graph@node@list%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\tikz@lib@graph@node@list\tikz@lg@temp}%
+ % Then color and initialize them:
+ \let\tikz@lg@do\tikz@lib@graph@do@use%
+ \tikz@lg@temp%
+ \else%
+ \edef\tikz@lib@graph@name{\tikz@lib@graph@path\tikz@lib@graph@name@only}%
+ \expandafter\ifx\csname tikz@lib@graph@def@\tikz@lib@graph@name@only\endcsname\relax%
+ \pgfkeysgetvalue{/tikz/graphs/placement/level}\tikz@temp%
+ \c@pgf@counta=\tikz@temp\relax%
+ \advance\c@pgf@counta by1\relax%
+ \edef\tikz@temp{\the\c@pgf@counta}%
+ \pgfkeyslet{/tikz/graphs/placement/level}\tikz@temp%
+ \tikzgraphsset{
+ level/.try=\pgfkeysvalueof{/tikz/graphs/placement/level},
+ level \pgfkeysvalueof{/tikz/graphs/placement/level}/.try
+ }
+ {%
+ \edef\tikz@lib@graph@node@list{\noexpand\tikz@lg@do{\tikz@lib@graph@name}}%
+ \global\tikz@lib@graph@node@createdfalse%
+ \pgfkeyslet{/tikz/graphs/@operators}\pgfutil@empty%
+ \tikz@lib@activate@source@target@edge@syntax%
+ \tikz@lg@if@local@node{\tikz@lib@graph@name}%
+ {\tikz@lg@local@node@handle{#1}}%
+ {%
+ \tikz@lg@init@color{\tikz@lib@graph@name}{\tikz@lgc@all@true\tikz@lgc@source@true\tikz@lgc@target@true}%
+ \iftikz@lib@graph@all%
+ \tikzgraphsset{#1}\pgfkeysvalueof{/tikz/graphs/@operators}%
+ \else%
+ \pgfkeys{/tikz/graphs/placement/place}%
+ \let\tikzgraphnodetext\tikz@lib@graph@node@text%
+ \let\tikzgraphnodename\tikz@lib@graph@name@only%
+ \let\tikzgraphnodepath\tikz@lib@graph@path%
+ \let\tikzgraphnodefullname\tikz@lib@graph@name%
+ \iftikz@lib@graph@fake@node%
+ {% run options in protected mode...
+ \pgfkeys{
+ /tikz/graphs/.cd,%
+ .unknown/.code=,
+ /tikz/graphs/@nodes styling,%
+ #1}%
+ \pgfkeysgetvalue{/tikz/graphs/@operators}\tikz@lib@graph@op@save%
+ \global\let\tikz@lib@graph@op@save\tikz@lib@graph@op@save%
+ }%
+ \else%
+ \node [%
+ name=\tikz@lib@graph@name,%
+ execute at end node={%
+ \pgfkeysgetvalue{/tikz/graphs/@operators}\tikz@lib@graph@op@save%
+ \global\let\tikz@lib@graph@op@save\tikz@lib@graph@op@save%
+ },%
+ graphs/redirect unknown to tikz,
+ /tikz/graphs/.cd,%
+ /tikz/graphs/@nodes styling,%
+ #1]%
+ {%
+ \tikzgraphnodeas%
+ };%
+ \fi%
+ \tikz@lib@graph@op@save\global\let\tikz@lib@graph@op@save\relax%%
+ \global\tikz@lib@graph@node@createdtrue%
+ \fi
+ }%
+ }%
+ \iftikz@lib@graph@node@created\tikz@lib@graph@placement@update\fi%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\tikz@lib@graph@node@list%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\tikz@lib@graph@node@list\expandafter\tikz@lg@do\expandafter{\tikz@lib@graph@name}}%
+ \iftikz@lib@graph@trie\tikzgraphsset{name=\tikz@lib@graph@name@only}\fi%
+ \else
+ % The name of the node is a graph name
+ \tikz@lib@graph@handle@graph{#1}%
+ \fi
+ \fi%
+}%
+
+\newif\iftikz@lib@graph@fake@node
+
+\newif\iftikz@lib@graph@use@list
+\def\tikz@lib@graph@test@use@list{%
+ \pgfutil@ifnextchar({\tikz@lib@graph@use@list@grap}{\tikz@lib@graph@test@use@list@done}%)
+}%
+
+\def\tikz@lib@graph@test@use@list@done#1\pgf@stop{\tikz@lib@graph@use@listfalse}%
+\def\tikz@lib@graph@use@list@grap(#1)\pgf@stop{\def\tikz@lib@graph@use@list{#1}\tikz@lib@graph@use@listtrue}%
+
+
+%
+% Typeset a layout node
+%
+
+\def\tikz@lib@layout@start#1#2\pgf@stop{%
+ \tikz@lib@ensure@gd@loaded%
+ % Parameters are:
+ %
+ % Node name is \tikz@lib@graph@name@only
+ % Node text is \tikz@lib@graph@node@text
+ % Node options are \tikz@lib@layout@node@options
+ % Layout options are \tikz@lib@layout@options
+ % Layout is #1
+ % Rest is #2 (should be empty or just whitespace)
+ \tikz@lib@graph@fake@nodefalse%
+ \ifpgf@lib@graph@empty@layout@node%
+ \else%
+ \ifx\tikz@lib@graph@name\pgfutil@empty%
+ \tikzerror{Internal error: Node has no name, but it should!}%
+ \else
+ \tikz@lib@graph@fake@nodetrue%
+ \expandafter\tikz@lib@graph@node@opt@normal\expandafter{\tikz@lib@layout@node@options}%
+ \fi%
+ \fi%
+ \edef\tikz@lib@graph@name{\tikz@lib@graph@path\tikz@lib@graph@name@only}%
+ %
+ % Prepare tikz node options
+ %
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\tikz@lib@layout@node@options\expandafter\expandafter\expandafter{\expandafter\tikz@lib@layout@startup@node@options\tikz@lib@layout@node@options,}%
+ \begingroup
+ % Create a subgraph node, if name is given.
+ \iftikz@lib@graph@fake@node%
+ \expandafter\expandafter\expandafter%
+ \expandafter\expandafter\expandafter\expandafter\tikz@lib@make@subgraph@node%
+ \expandafter\expandafter\expandafter%
+ \expandafter\expandafter\expandafter\expandafter{%
+ \expandafter\expandafter\expandafter\tikz@lib@graph@name%
+ \expandafter\expandafter\expandafter}%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\tikz@lib@graph@node@text\expandafter}\expandafter{\tikz@lib@layout@node@options}
+ \fi%
+ %
+ % Here comes the scope:
+ %
+ \expandafter\expandafter\expandafter\scope\expandafter\expandafter\expandafter[\expandafter\tikz@lib@layout@node@options@prefix\tikz@lib@layout@options]
+ \tikzgdeventgroupcallback{array}%
+ \let\tikz@lib@graph@node@list\pgfutil@empty%
+ \tikz@lib@graph@start@hint@group%
+ \tikz@lib@graph@parse@group{#1}%
+ \tikz@lib@graph@end@hint@group%
+ \def\tikz@lg@old@col{\tikz@lgc@source@true}%
+ \let\tikz@lg@new@col\pgfutil@empty%
+ \let\tikz@lg@do\tikz@lg@change@color%
+ \tikz@lib@graph@node@list%
+ \def\tikz@lg@old@col{\tikz@lgc@target@true}%
+ \tikz@lib@graph@node@list%
+ \expandafter%
+ \endscope\expandafter%
+ \endgroup%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\tikz@lib@graph@node@list%
+ \expandafter\expandafter\expandafter{\expandafter\tikz@lib@graph@node@list\tikz@lib@graph@node@list}%
+ \tikz@lib@graph@hint@aftergroup%
+}%
+\def\tikz@lib@make@subgraph@node#1#2#3{%
+ \pgfgdsubgraphnode{#1}{#3}{\pgfgdsubgraphnodecontents{#2}}%
+}%
+\def\tikz@lib@layout@startup@node@options{%
+ /utils/exec=\tikzlibignorecomparisonsINTERNAL,
+ /tikz/graphs/.cd,%
+ redirect unknown to tikz,%
+ anchor=base,%
+ /tikz/every subgraph node/.try,%
+}%
+\def\tikzlibignorecomparisonsINTERNAL{%
+ \pgfkeys{/handlers/first char syntax=true}
+ \pgfkeyssetvalue{/handlers/first char syntax/\expandafter\meaning\string>}{\pgfutil@gobble}%
+ \pgfkeyssetvalue{/handlers/first char syntax/\expandafter\meaning\string<}{\pgfutil@gobble}%
+}%
+\def\tikz@lib@layout@node@options@prefix{graphs/.cd,}%
+
+\ifx\tikz@lib@ensure@gd@loaded\pgfutil@undefined%
+\def\tikz@lib@ensure@gd@loaded{\tikzerror{You must say \string\usetikzlibrary{graphdrawing} to use the (sub)layout syntax}}%
+\fi
+
+\def\tikz@lg@local@node@handle#1{%
+ %
+ % Handle late options and operators
+ \tikzgraphsset{source,target,.unknown/.code=,#1}%
+ \tikzgdlatenodeoptionacallback{\tikz@pp@name\tikz@lib@graph@name}%
+ \node also[graphs/redirect unknown to tikz,/tikz/graphs/.cd,#1](\tikz@lib@graph@name);%
+ \pgfkeysvalueof{/tikz/graphs/@operators}%
+}%
+
+\tikzgraphsset{redirect unknown to tikz/.style={
+ /tikz/graphs/.unknown/.code={%
+ \let\tikz@key\pgfkeyscurrentname%
+ \pgfkeys{tikz/.cd,\tikz@key={##1},/tikz/graphs/.cd}%
+ }}
+}%
+
+\def\tikz@lib@activate@source@target@edge@syntax{%
+ \pgfkeys{/handlers/first char syntax=true}
+ \pgfkeyssetvalue{/handlers/first char syntax/\expandafter\meaning\string>}{\tikz@lg@parse@more}%
+ \pgfkeyssetvalue{/handlers/first char syntax/\expandafter\meaning\string<}{\tikz@lg@parse@less}%
+}%
+
+\def\tikz@lg@parse@less#1{\tikz@lg@parse@less@#1\pgf@stop}%
+\def\tikz@lg@parse@less@<{\pgfutil@ifnextchar"{\tikz@lg@parse@quote{source}}{\tikz@lg@parse@noquote{source}}}%
+\def\tikz@lg@parse@more#1{\tikz@lg@parse@more@#1\pgf@stop}%
+\def\tikz@lg@parse@more@>{\pgfutil@ifnextchar"{\tikz@lg@parse@quote{target}}{\tikz@lg@parse@noquote{target}}}%
+
+\def\tikz@lg@parse@noquote#1#2\pgf@stop{{\tikzgraphsset{#1 edge style={#2}}}}%
+\def\tikz@lg@parse@quote#1#2\pgf@stop{%
+ {\tikzgraphsset{/tikz/node quotes mean={#1 edge node={node [every edge quotes,##2]{##1}}},/utils/exec=\tikz@enable@node@quotes,#2}}%
+}%
+
+\tikzgraphsset{
+ clear >/.style=target edge clear,
+ clear </.style=source edge clear
+}%
+
+
+% Positioning
+
+\def\tikz@lib@graph@x{0}%
+\def\tikz@lib@graph@y{0}%
+
+\tikzgraphsset{
+ x/.code=\def\tikz@lib@graph@x{#1}\tikz@lib@graphs@check@at,
+ y/.code=\def\tikz@lib@graph@y{#1}\tikz@lib@graphs@check@at
+}%
+\def\tikz@lib@graphs@check@at{%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\tikz@temp%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\expandafter\expandafter(%
+ \expandafter\expandafter\expandafter{\expandafter\tikz@lib@graph@x\expandafter}%
+ \expandafter,\expandafter{\tikz@lib@graph@y})}%
+ \pgfqkeys{/tikz}{at/.expand once=\tikz@temp}%
+}%
+
+
+\newif\iftikz@lib@graph@trie
+\tikzgraphsset{
+ trie/.is if=tikz@lib@graph@trie,
+ put node text on incoming
+ edges/.style={nodes={/utils/exec=\tikz@lg@make@edge@node{target}{#1}}},
+ put node text on outgoing
+ edges/.style={nodes={/utils/exec=\tikz@lg@make@edge@node{source}{#1}}},
+ edge quotes/.style={/tikz/every edge quotes/.style={#1}},
+ edge quotes center/.style={edge quotes={anchor=center}},
+ edge quotes mid/.style={edge quotes={anchor=mid}}
+}%
+
+\def\tikz@lg@make@edge@node#1#2{%
+ \def\pgf@marshal{node[#2]}%
+ \expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter\pgf@marshal\expandafter\expandafter\expandafter{\expandafter\pgf@marshal\expandafter{\tikzgraphnodetext}}%
+ \pgfkeysalso{#1 edge node/.expand once=\pgf@marshal,as=}%
+}%
+
+\newif\iftikz@lib@graph@fresh@node
+\tikzgraphsset{fresh nodes/.is if=tikz@lib@graph@fresh@node}%
+
+\tikzgraphsset{number nodes/.code=%
+ \pgfmathsetcount\tikz@lib@auto@number{#1}%
+ \tikzgraphsautonumbernodestrue,%
+ number nodes/.default=1,%
+ number nodes sep/.code=\def\tikz@lib@auto@sep{#1}
+}%
+\def\tikz@lib@auto@sep{\space}%
+
+\newif\iftikz@lib@graph@node@created
+
+\def\tikz@lib@graph@handle@use#1{%
+ % Is #1 the name of a node set?
+ \expandafter\let\expandafter\pgf@temp\csname tikz@lg@node@set #1\endcsname
+ \ifx\pgf@temp\relax
+ \pgfutil@g@addto@macro\tikz@lg@temp{\tikz@lg@do{#1}}
+ \else%
+ \expandafter\pgfutil@g@addto@macro\expandafter\tikz@lg@temp\expandafter{\pgf@temp}
+ \fi
+}%
+
+\def\tikz@lib@graph@do@use#1{%
+ \tikz@lg@init@color{#1}{\tikz@lgc@all@true\tikz@lgc@source@true\tikz@lgc@target@true}%
+}%
+
+\tikzgraphsset{
+ typeset/.store in=\tikz@lib@graph@typesetter,
+ math nodes/.style={/tikz/graphs/typeset=$\tikzgraphnodetext$},
+ empty nodes/.style={/tikz/graphs/typeset=},
+ typeset=\tikzgraphnodetext
+}%
+
+
+%
+% Handle scope
+%
+\def\tikz@lib@graph@scope#1{
+ \begingroup%
+ \tikzgdeventgroupcallback{array}%
+ \let\tikz@lib@graph@node@list\pgfutil@empty%
+ \tikz@lib@graph@start@hint@group%
+ \tikz@lib@graph@parse@group{#1}%
+ \tikz@lib@graph@end@hint@group%
+ \expandafter%
+ \endgroup%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\tikz@lib@graph@node@list%
+ \expandafter\expandafter\expandafter{\expandafter\tikz@lib@graph@node@list\tikz@lib@graph@node@list}%
+ \tikz@lib@graph@hint@aftergroup%
+ \tikz@lib@graph@stored@actions%
+ \pgfutil@ifnextchar-{\tikz@lib@graph@scope@minus}{%
+ \pgfutil@ifnextchar<{\tikz@lib@graph@scope@less}{%
+ \tikzerror{One of the arrow types <-, --, ->, -!-, or <-> expected}%
+ }%
+ }%
+}%
+
+\def\tikz@lib@graph@scope@minus-{
+ \pgfutil@ifnextchar>\tikz@lib@graph@forward@arrow{%
+ \pgfutil@ifnextchar-\tikz@lib@graph@undirected@arrow{%
+ \pgfutil@ifnextchar!\tikz@lib@graph@no@arrow{%
+ \pgfutil@ifnextchar\pgf@stop@eodashes\tikz@lib@graph@graph@done{%
+ \tikzerror{One of the arrow types <-, --, ->, -!-, or <-> expected}%
+ \tikz@lib@graph@undirected@arrow%
+ }%
+ }%
+ }%
+ }%
+}%
+
+\def\tikz@lib@graph@scope@less<-{\tikz@lib@graph@back@arrow}%
+
+
+
+
+%
+% Predefining graphs
+%
+
+\tikzgraphsset{
+ declare/.code 2 args={\expandafter\def\csname tikz@lib@graph@def@#1\endcsname{\tikz@lib@graph@do@graph{#2}}}%
+}%
+
+\def\tikz@lib@graph@handle@graph#1{%
+ \begingroup%
+ \let\tikz@lib@graph@node@list\pgfutil@empty%
+ \tikzgraphsset{@extra group options/.style={#1}}%
+ \tikz@lib@graph@start@hint@group%
+ \csname tikz@lib@graph@def@\tikz@lib@graph@name@only\endcsname%
+ \tikz@lib@graph@end@hint@group%
+ \expandafter%
+ \endgroup%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\tikz@lib@graph@node@list%
+ \expandafter\expandafter\expandafter{\expandafter\tikz@lib@graph@node@list\tikz@lib@graph@node@list}%
+ \tikz@lib@graph@hint@aftergroup%
+}%
+
+\def\tikz@lib@graph@do@graph#1{%
+ \tikz@lib@graph@parse@group{#1}%
+}%
+
+\let\tikz@lib@graph@path\pgfutil@empty
+
+\tikzgraphsset{
+ name separator/.store in=\tikz@lib@graph@name@separator,
+ name separator=\space,
+ name/.code={%
+ \edef\tikz@lib@graph@path{\tikz@lib@graph@path#1\tikz@lib@graph@name@separator}%
+ }%
+}%
+
+
+%
+% Colors
+%
+\def\tikz@lg@newif{\csname newif\endcsname}%
+\tikzgraphsset{
+ as/.code=\def\tikzgraphnodeas{#1},%
+ color class/.style={%
+ /utils/exec=\expandafter\tikz@lg@newif\csname iftikz@lgc@#1@\endcsname,
+ #1/.style={operator={%
+ \edef\tikz@lg@col{\expandafter\noexpand\csname tikz@lgc@#1@true\endcsname}%
+ \let\tikz@lg@do\tikz@lg@colorize%
+ \tikz@lib@graph@node@list%
+ }},
+ not #1/.style={operator={%
+ \edef\tikz@lg@old@col{\expandafter\noexpand\csname tikz@lgc@#1@true\endcsname}%
+ \let\tikz@lg@new@col\pgfutil@empty%
+ \let\tikz@lg@do\tikz@lg@change@color%
+ \tikz@lib@graph@node@list%
+ }},
+ recolor #1 by/.style={operator={%
+ \edef\tikz@lg@old@col{\expandafter\noexpand\csname tikz@lgc@#1@true\endcsname}%
+ \edef\tikz@lg@new@col{\expandafter\noexpand\csname tikz@lgc@##1@true\endcsname}%
+ \let\tikz@lg@do\tikz@lg@change@color%
+ \tikz@lib@graph@node@list%
+ }},
+ !#1/.style=not #1,
+ },
+ color class=source,
+ color class=source',
+ color class=source'',
+ color class=target,
+ color class=target',
+ color class=all
+}%
+
+\def\tikz@lg@init@color#1#2{%
+ \expandafter\gdef\csname tikz@lgc@#1\endcsname{#2}%
+}%
+
+\def\tikz@lib@graph@cleanup#1{%
+ \expandafter\global\expandafter\let\csname tikz@lgc@#1\endcsname\relax%
+ \ifcsname tikz@lgca@@#1\endcsname\expandafter\global\expandafter\let\csname tikz@lgca@@#1\endcsname\relax\fi%
+ \ifcsname tikz@lgcb@@#1\endcsname\expandafter\global\expandafter\let\csname tikz@lgcb@@#1\endcsname\relax\fi%
+}%
+
+\def\tikz@lg@colorize#1{%
+ \expandafter\let\expandafter\pgf@temp\csname tikz@lgc@#1\endcsname%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\pgf@temp%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\tikz@lg@col\pgf@temp}%
+ \expandafter\global\expandafter\let\csname tikz@lgc@#1\endcsname\pgf@temp%
+}%
+
+\def\tikz@lg@change@color#1{%
+ \def\tikz@lg@temp@save{#1}%
+ \let\tikz@lg@collect\pgfutil@empty%
+ \expandafter\let\expandafter\pgf@temp\csname tikz@lgc@#1\endcsname%
+ \expandafter\tikz@lg@change@check\pgf@temp\pgf@stop%
+}%
+\def\tikz@lg@change@check#1{%
+ \ifx#1\pgf@stop%
+ \tikz@lg@change@write@back%
+ \else%
+ \def\pgf@temp{#1}%
+ \ifx\pgf@temp\tikz@lg@old@col%
+ \expandafter\tikz@lg@change@add\expandafter{\tikz@lg@new@col}% Found!
+ \else%
+ \tikz@lg@change@add{#1}%
+ \fi%
+ \expandafter\tikz@lg@change@check
+ \fi%
+}%
+\def\tikz@lg@change@add#1{%
+ \expandafter\def\expandafter\tikz@lg@collect\expandafter{\tikz@lg@collect#1}%
+}%
+
+\def\tikz@lg@change@write@back{%
+ \expandafter\global\expandafter\let\csname tikz@lgc@\tikz@lg@temp@save\endcsname\tikz@lg@collect%
+}%
+
+
+
+\def\tikz@lg@if@has@color#1#2#3#4{%
+ {%
+ \csname tikz@lgc@#1\endcsname%
+ \expandafter\let\expandafter\pgf@temp\csname iftikz@lgc@#2@\endcsname%
+ \ifx\pgf@temp\relax%
+ \tikz@lib@reset@temp%
+ \fi%
+ \pgf@temp%
+ \global\tikz@color@testtrue%
+ \else%
+ \global\tikz@color@testfalse%
+ \fi%
+ }%
+ \iftikz@color@test#3\else#4\fi%
+}%
+\newif\iftikz@color@test
+
+\def\tikz@lg@if@local@node#1#2#3{\expandafter\ifx\csname tikz@lgc@#1\endcsname\relax#3\else#2\fi}%
+
+\def\tikz@lib@reset@temp{\let\pgf@temp\iffalse}%
+
+%
+% Handle connection annotations
+%
+\def\tikz@lib@annotate@#1#2#3#4{%
+ \expandafter\ifx\csname tikz@lgc#1@@#2\endcsname\relax%
+ \expandafter\gdef\csname tikz@lgc#1@@#2\endcsname{{#3}{#4}}%
+ \else%
+ \expandafter\expandafter\expandafter\tikz@lib@annotate@read\csname tikz@lgc#1@@#2\endcsname{#3}{#4}%
+ \expandafter\global\expandafter\let\csname tikz@lgc#1@@#2\endcsname\pgf@temp%
+ \fi%
+}%
+\def\tikz@lib@annotate@read#1#2#3#4{\def\pgf@temp{{#1,#3}{#2#4}}}%
+
+\tikzgraphsset{
+ source edge style/.code=\tikz@lib@annotate@{a}{\tikz@lib@graph@name}{#1}{},
+ source edge node/.code=\tikz@lib@annotate@{a}{\tikz@lib@graph@name}{}{#1},
+ source edge clear/.code={
+ \expandafter\global\expandafter\let\csname tikz@lgca@@\tikz@lib@graph@name\endcsname\relax%
+ },
+ target edge style/.code=\tikz@lib@annotate@{b}{\tikz@lib@graph@name}{#1}{},
+ target edge node/.code=\tikz@lib@annotate@{b}{\tikz@lib@graph@name}{}{#1},
+ target edge clear/.code={%
+ \expandafter\global\expandafter\let\csname tikz@lgcb@@\tikz@lib@graph@name\endcsname\relax%
+ }
+}%
+
+
+
+% Packing a node list: Replace the node list by a new node list where
+% each node is mentioned at most once.
+
+\def\tikz@lib@graph@pack@node@list{%
+ {%
+ \let\tikz@lg@packed\pgfutil@empty%
+ \let\tikz@lg@do\tikz@lg@packer%
+ \tikz@lib@graph@node@list%
+ \expandafter
+ }\expandafter%
+ \def\expandafter\tikz@lib@graph@node@list\expandafter{\tikz@lg@packed}%
+}%
+
+\def\tikz@lg@packer#1{%
+ \expandafter\ifx\csname tikz@lg@p@#1\endcsname\pgf@stop%
+ \else%
+ \expandafter\let\csname tikz@lg@p@#1\endcsname\pgf@stop%
+ \expandafter\def\expandafter\tikz@lg@packed\expandafter{\tikz@lg@packed\tikz@lg@do{#1}}
+ \fi
+}%
+
+%
+% Color functions
+%
+
+% Do something for all nodes having a certain color
+%
+% #1 = the color name
+% #2 = a macro
+%
+% Description:
+%
+% For each node having color #1, the macro #2 will be called. This
+% macro should take a single parameter, which will be set
+% to the node's name.
+
+\def\tikzgraphforeachcolorednode#1#2{%
+ \tikz@lib@graph@pack@node@list%
+ \expandafter\def\expandafter\iftikz@lib@graph@color@picker\expandafter{\csname iftikz@lgc@#1@\endcsname}%
+ \let\tikz@lib@graph@action#2%
+ \let\tikz@lg@do\tikz@lg@pick%
+ \tikz@lib@graph@node@list%
+}%
+\def\tikz@lg@pick#1{
+ {%
+ \csname tikz@lgc@#1\endcsname%
+ \iftikz@lib@graph@color@picker
+ \global\tikz@color@testtrue%
+ \else%
+ \global\tikz@color@testfalse%
+ \fi%
+ }%
+ \iftikz@color@test\tikz@lib@graph@action{#1}\fi%
+}%
+
+
+
+% Prepare a color
+%
+% #1 is the color name
+% #2 is a counter
+% #3 is a prefix
+%
+% Description:
+%
+% You can call this function inside a connector. It will do the
+% following: First, its counts how many nodes exist that have color
+% #1. This number is stored in the counter passed as #2. Furthermore,
+% let <name> be the name of the <i>-th vertex that has color #1. Then, a
+% macro called \#3<i> will store <name>. For instance, if #1 is "red"
+% and the third red node is called foo and if #3 is "bar", then a
+% macro called "\bar3" is set to "foo" as if you had said
+% "\expandafter\def\csname bar3\endcsname{foo}".
+%
+% The bottom line of all this is that after a preparation you can
+% easily iterate over nodes having a certain color. If you wish to
+% iterate over a single color, it will be quicker and easier to call
+% \tikzgraphforeachcolorednode, but if you need to iterate over two
+% colors simultaneously, it will be better to first prepare the color.
+
+\def\tikzgraphpreparecolor#1#2#3{%
+ \let\tikz@lib@graph@count#2%
+ \tikz@lib@graph@count0\relax
+ \def\tikz@lib@graph@prefix{#3}%
+ \tikzgraphforeachcolorednode{#1}\tikz@lib@graph@prepare%
+}%
+
+\def\tikz@lib@graph@prepare#1{%
+ \advance\tikz@lib@graph@count by1\relax%
+ \expandafter\def\csname\tikz@lib@graph@prefix\the\tikz@lib@graph@count\endcsname{#1}%
+}%
+
+
+
+
+%
+% The bipartite connector
+%
+
+\tikzgraphsset{
+ complete bipartite/.style 2 args={operator={
+ \def\tikz@lg@shoreb{#2}%
+ \tikzgraphforeachcolorednode{#1}\tikz@lib@graph@bipartite@outer
+ }},
+ complete bipartite/.default={target'}{source'},
+ induced complete bipartite/.style 2 args={
+ induced independent set={#1},
+ induced independent set={#2},
+ complete bipartite={#1}{#2}
+ },
+ induced complete bipartite/.default={target'}{source'},
+}%
+
+\def\tikz@lib@graph@bipartite@outer#1{%
+ \def\tikz@lib@graph@from{#1}%
+ {%
+ \tikzgraphforeachcolorednode{\tikz@lg@shoreb}\tikz@lib@graph@bipartite@inner%
+ }%
+}%
+
+\def\tikz@lib@graph@bipartite@inner#1{%
+ \def\pgf@temp{#1}%
+ \ifx\pgf@temp\tikz@lib@graph@from\else%
+ \tikz@lib@graph@default@new@edge{\tikz@lib@graph@from}{#1}%
+ \fi%
+}%
+
+\def\tikz@lib@graph@default@new@edge#1#2{%
+ \pgfkeysgetvalue{/tikz/graphs/@edges styling}\pgf@temp
+ \pgfkeysgetvalue{/tikz/graphs/@edges node}\pgf@temp@b
+ \let\tikz@lib@add@temp\pgfutil@empty%
+ \tikz@lib@graph@add@edge@annotations{a}{#1}
+ \tikz@lib@graph@add@edge@annotations{b}{#2}
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\pgf@temp%
+ \expandafter\expandafter\expandafter{\expandafter\pgf@temp\tikz@lib@add@temp}%
+ \expandafter\expandafter\expandafter\tikz@lib@graph@default@new@edge@%
+ \expandafter\expandafter\expandafter{\expandafter\pgf@temp\expandafter}\expandafter{\pgf@temp@b}{#1}{#2}%
+}%
+\def\tikz@lib@graph@default@new@edge@#1#2#3#4{%
+ \iftikz@lib@graph@simple%
+ \edef\tikz@temp{{\pgfkeysvalueof{/tikz/graphs/default edge kind}}{#3}{#4}}
+ \expandafter\tikz@lib@graph@set@simple@edge\tikz@temp{#1}{#2}%
+ \else%
+ \pgfkeys{/tikz/graphs/.cd,new \pgfkeysvalueof{/tikz/graphs/default edge kind}={#3}{#4}{#1}{#2}}%
+ \fi%
+}%
+\def\tikz@lib@graph@add@edge@annotations#1#2{%
+ \ifcsname tikz@lgc#1@@#2\endcsname%
+ \expandafter\let\expandafter\tikz@lg@temp@\csname tikz@lgc#1@@#2\endcsname%
+ \ifx\tikz@lg@temp@\relax\else
+ \expandafter\tikz@lib@graph@add@edge@annotations@\tikz@lg@temp@%
+ \let\tikz@lib@add@temp\tikz@lib@final@edge@style
+ \fi%
+ \fi%
+}%
+\def\tikz@lib@graph@add@edge@annotations@#1#2{
+ \expandafter\def\expandafter\pgf@temp\expandafter{\pgf@temp,#1}%
+ \expandafter\def\expandafter\pgf@temp@b\expandafter{\pgf@temp@b#2}%
+}%
+\def\tikz@lib@final@edge@style{,after source and target edge/.try}%
+
+%
+% The clique connector
+%
+
+\tikzgraphsset{
+ clique/.style={operator={
+ \tikzgraphpreparecolor{#1}\c@pgf@counta{tikz@lg}%
+ \tikz@lg@clique@loop%
+ }},
+ clique/.default=all
+}%
+
+\def\tikz@lg@clique@loop{%
+ \ifnum\c@pgf@counta=0\relax%
+ \else
+ \c@pgf@countb=\c@pgf@counta\relax%
+ \tikz@lg@clique@loop@inner%
+ \advance\c@pgf@counta by-1\relax%
+ \expandafter\tikz@lg@clique@loop%
+ \fi%
+}%
+
+\def\tikz@lg@clique@loop@inner{%
+ \advance\c@pgf@countb by-1\relax%
+ \ifnum\c@pgf@countb>0\relax%
+ \tikz@lib@graph@default@new@edge{\csname tikz@lg\the\c@pgf@countb\endcsname}{\csname tikz@lg\the\c@pgf@counta\endcsname}%
+ \expandafter\tikz@lg@clique@loop@inner%
+ \fi%
+}%
+
+
+%
+% The independent set connector
+%
+
+\tikzgraphsset{
+ induced independent set/.style={operator={
+ \pgfkeysgetvalue{/tikz/graphs/default edge kind}\tikz@lg@default%
+ \pgfkeyssetvalue{/tikz/graphs/default edge kind}{-!-}%
+ \tikzgraphpreparecolor{#1}\c@pgf@counta{tikz@lg}%
+ \tikz@lg@indep@loop%
+ \pgfkeyslet{/tikz/graphs/default edge kind}\tikz@lg@default%
+ }},
+ induced independent set/.default=all
+}%
+
+\def\tikz@lg@indep@loop{%
+ \ifnum\c@pgf@counta=0\relax%
+ \else
+ \c@pgf@countb=\c@pgf@counta\relax%
+ \tikz@lg@indep@loop@inner%
+ \advance\c@pgf@counta by-1\relax%
+ \expandafter\tikz@lg@indep@loop%
+ \fi%
+}%
+
+\def\tikz@lg@indep@loop@inner{%
+ \advance\c@pgf@countb by-1\relax%
+ \ifnum\c@pgf@countb>0\relax%
+ \tikz@lib@graph@default@new@edge{\csname tikz@lg\the\c@pgf@counta\endcsname}{\csname tikz@lg\the\c@pgf@countb\endcsname}%
+ \expandafter\tikz@lg@indep@loop@inner%
+ \fi%
+}%
+
+
+%
+% The path connector
+%
+
+\tikzgraphsset{
+ path/.style={operator={%
+ \let\tikz@lg@prev\relax%
+ \tikzgraphforeachcolorednode{#1}\tikz@lib@graph@path@do%
+ }},
+ path/.default=all,
+ induced path/.style={induced independent set={#1},path={#1}},
+ induced path/.default=all,
+}%
+
+\def\tikz@lib@graph@path@do#1{%
+ \ifx\tikz@lg@prev\relax%
+ \else%
+ \tikz@lib@graph@default@new@edge{\tikz@lg@prev}{#1}%
+ \fi
+ \def\tikz@lg@prev{#1}%
+}%
+
+
+%
+% The cycle connector
+%
+
+\tikzgraphsset{
+ cycle/.style={operator={%
+ \let\tikz@lg@prev\relax%
+ \let\tikz@lg@first\relax%
+ \tikzgraphforeachcolorednode{#1}\tikz@lib@graph@cycle@do%
+ \ifx\tikz@lg@first\relax%
+ \else%
+ \tikz@lib@graph@default@new@edge{\tikz@lg@prev}{\tikz@lg@first}%
+ \fi%
+ }},
+ cycle/.default=all,
+ induced cycle/.style={induced independent set={#1},cycle={#1}},
+ induced cycle/.default=all,
+}%
+
+\def\tikz@lib@graph@cycle@do#1{%
+ \ifx\tikz@lg@prev\relax%
+ \def\tikz@lg@prev{#1}%
+ \let\tikz@lg@first\tikz@lg@prev%
+ \else%
+ \tikz@lib@graph@default@new@edge{\tikz@lg@prev}{#1}%
+ \def\tikz@lg@prev{#1}%
+ \fi%
+}%
+
+
+
+
+%
+% The matching and star connector
+%
+
+\tikzgraphsset{
+ matching and star/.style 2 args={operator=%
+ {%
+ \tikzgraphpreparecolor{#1}\c@pgf@counta{tikz@lg}
+ \c@pgf@countb=0\relax%
+ \let\tikz@lg@prev\relax
+ \tikzgraphforeachcolorednode{#2}\tikz@lib@graph@flow@do%
+ \tikz@lib@graph@flow@rest%
+ }%
+ },
+ matching and star/.default={target'}{source'}
+}%
+
+\def\tikz@lib@graph@flow@do#1{%
+ \advance\c@pgf@countb by1\relax%
+ \ifnum\c@pgf@countb>\c@pgf@counta\relax%
+ \c@pgf@countb=\c@pgf@counta\relax%
+ \fi%
+ \ifnum\c@pgf@countb>0\relax%
+ \tikz@lib@graph@default@new@edge{\csname tikz@lg\the\c@pgf@countb\endcsname}{#1}%
+ \fi%
+ \def\tikz@lg@prev{#1}%
+}%
+
+\def\tikz@lib@graph@flow@rest{%
+ \ifnum\c@pgf@countb<\c@pgf@counta\relax%
+ \ifnum\c@pgf@countb>0\relax%
+ \advance\c@pgf@countb by1\relax%
+ \tikz@lib@graph@default@new@edge{\csname tikz@lg\the\c@pgf@countb\endcsname}{\tikz@lg@prev}%
+ \expandafter\tikz@lib@graph@flow@rest%
+ \fi%
+ \fi%
+}%
+
+
+
+%
+% The matching connector
+%
+
+\tikzgraphsset{
+ matching/.style 2 args={operator=
+ {%
+ \tikzgraphpreparecolor{#1}\c@pgf@counta{tikz@lg}
+ \c@pgf@countb=0\relax%
+ \tikzgraphforeachcolorednode{#2}\tikz@lib@graph@matching@do%
+ }%
+ },
+ matching/.default={target'}{source'}
+}%
+
+\def\tikz@lib@graph@matching@do#1{%
+ \advance\c@pgf@countb by1\relax%
+ \ifnum\c@pgf@countb>\c@pgf@counta\relax%
+ \else%
+ \tikz@lib@graph@default@new@edge{\csname tikz@lg\the\c@pgf@countb\endcsname}{#1}%
+ \fi%
+}%
+
+
+
+
+
+%
+% The butterfly connector
+%
+
+\tikzgraphsset{
+ butterfly/.style={operator=
+ {}{%
+ \pgfkeys{/tikz/graphs/butterfly/.cd,#1}%
+ \ifnum\pgfkeysvalueof{/tikz/graphs/butterfly/level}=0\relax%
+ \tikzgraphinvokeoperator{matching and star={\pgfkeysvalueof{/tikz/graphs/butterfly/from}}{\pgfkeysvalueof{/tikz/graphs/butterfly/to}}}%
+ \else%
+ {%
+ \tikzgraphpreparecolor{\pgfkeysvalueof{/tikz/graphs/butterfly/from}}\c@pgf@counta{tikz@lg}
+ \c@pgf@countb=0\relax%
+ \tikzgraphforeachcolorednode{\pgfkeysvalueof{/tikz/graphs/butterfly/to}}\tikz@lib@graph@butterfly@do%
+ }%
+ \iftikz@butterfly@prime\else\tikzgraphinvokeoperator{matching and star={\pgfkeysvalueof{/tikz/graphs/butterfly/from}}{\pgfkeysvalueof{/tikz/graphs/butterfly/to}}}\fi%
+ \fi%
+ }%
+ },
+ butterfly/.default=,
+ butterfly/level/.initial=1,
+ butterfly/from/.initial=target',
+ butterfly/to/.initial=source',
+ butterfly'/.style={operator={}{\tikz@butterfly@primetrue\pgfkeysalso{butterfly={#1}}}},
+ butterfly'/.default=,
+}%
+
+\newif\iftikz@butterfly@prime
+
+\def\tikz@lib@graph@butterfly@do#1{%
+ \advance\c@pgf@countb by1\relax%
+ % Compute other side...
+ \c@pgf@countc=\pgfkeysvalueof{/tikz/graphs/butterfly/level}\relax%
+ {%
+ % Computer countb mod (2level)
+ \count0=\c@pgf@countc\relax%
+ \multiply\count0 by2\relax%
+ \count1=\c@pgf@countb\relax%
+ \advance\count1 by-1\relax%
+ \count2=\count1\relax%
+ \count3=\count1\relax%
+ \divide\count1 by\count0\relax%
+ \multiply\count1 by\count0\relax%
+ \advance\count2 by-\count1\relax%
+ % count0 = 2*level
+ % count2 = countb mod (2level) (starting with 0)
+ % count1 = countb - count2 (starting with 0)
+ \ifnum\count2<\c@pgf@countc\relax%
+ \advance\count3 by \c@pgf@countc\relax%
+ \else%
+ \advance\count3 by -\c@pgf@countc\relax%
+ \fi%
+ \expandafter%
+ }%
+ \expandafter\c@pgf@countc\the\count3\relax%
+ \advance\c@pgf@countc by1\relax%
+ \ifnum\c@pgf@countc>\c@pgf@counta\relax%
+ \c@pgf@countc=\c@pgf@counta\relax%
+ \fi%
+ \tikz@lib@graph@default@new@edge{\csname tikz@lg\the\c@pgf@countc\endcsname}{#1}%
+}%
+
+
+
+
+%
+% The no edges connector
+%
+\tikzgraphsset{no edges/.style={operator=\relax}}%
+
+
+
+
+%
+% The grid connector
+%
+\tikzgraphsset{
+ grid/.style={operator={
+ \tikzgraphpreparecolor{#1}\c@pgf@counta{tikz@lg}%
+ \c@pgf@countb=0\relax%
+ \tikzgraphpreparewrapafter%
+ \tikz@lg@grid@loop%
+ }%
+ },
+ grid/.default=all
+}%
+
+\def\tikzgraphpreparewrapafter{%
+ \pgfkeysgetvalue{/tikz/graphs/wrap after}\tikz@temp%
+ \ifnum\tikz@temp=0\relax%
+ \pgfmathparse{sqrt(\tikzgraphVnum)}%
+ \pgfmathint{\pgfmathresult}%
+ \edef\tikzgraphwrapafter{\pgfmathresult}%
+ \else%
+ \edef\tikzgraphwrapafter{\tikz@temp}
+ \fi%
+}%
+
+\def\tikz@lg@grid@loop{%
+ \ifnum\c@pgf@counta=0\relax%
+ \else%
+ \advance\c@pgf@countb by 1\relax%
+ \pgfmathmod{\c@pgf@countb-1}{\tikzgraphwrapafter}%
+ \pgfmathint{\pgfmathresult}%
+ \ifnum\pgfmathresult>0%
+ \pgfmathsubtract{\c@pgf@countb}{1}%
+ \pgfmathint{\pgfmathresult}%
+ \tikz@lib@graph@default@new@edge{\csname tikz@lg\the\c@pgf@countb\endcsname}{\csname tikz@lg\pgfmathresult\endcsname}%
+ \fi%
+ \pgfmathparse{\c@pgf@countb <= \tikzgraphwrapafter}%
+ \ifnum\pgfmathresult=0%
+ \pgfmathsubtract{\c@pgf@countb}{\tikzgraphwrapafter}%
+ \pgfmathint{\pgfmathresult}%
+ \tikz@lib@graph@default@new@edge{\csname tikz@lg\pgfmathresult\endcsname}{\csname tikz@lg\the\c@pgf@countb\endcsname}%
+ \fi%
+ \advance\c@pgf@counta by-1\relax%
+ \expandafter\tikz@lg@grid@loop%
+ \fi%
+}%
+
+
+
+
+% Positioning
+%
+% It is not the job of the graph library to compute good positions for
+% nodes in a graph. However, some basic support is provided for simple
+% cases.
+%
+% The idea is at follows: Graphs are specified hierarchically. For
+% instance, consider the following graph specification:
+%
+% graph { a, b, c -> d -> {e -> f -> g, h} -> i, j -> k }
+%
+% Here, we have the *group* {e->f->g,h} inside the larger graph
+% specification. Each group consists of sequence of *chains* like
+% e->f->g or j->k.
+%
+% In order to facilitate the automatic positioning of nodes, the graph
+% library will provide you with information about the position of
+% nodes inside their groups and chains.
+%
+% As a chain is being parsed, a counter stored in
+% /tikz/graphs/placement/element count is available that is advanced for
+% each element in the chain.
+%
+% Additionally, a counter stored in placement/width is
+% available. This "logical" width is defined recursively as follows: The
+% width of a single node is computed by calling the key
+% placement/logical node width, which should return a real or logical
+% width of the node passed as a parameter in the macro \pgfmathresult. The
+% width of a chain is the sum of the widths of its elements. The
+% width of a group is the maximum of the widths of its elements.
+%
+%
+% Symmetrically, as a group is being constructed, a counter stored in
+% placement/chain count is available that is advanced for each chain
+% in the group. The number placement/depth is the defined
+% recursively as follows: For a single node, the depth is
+% computed by the key placement/logical node depth. The depth
+% of a group is the sum of the depths of its elements. The depth of a
+% chain is the maximum of the depth of its elements.
+%
+%
+% The above keys get updated automatically. You should setup the key
+% placement/compute position such that it uses the above keys to
+% compute a good position for a new node based on the above
+% keys. Typically, this key should execute node={shift=(...)} to setup
+% the necessary shift for a new node.
+%
+% The key placement/compute position should not be called
+% directly. Instead, the key placement/place should be used. This key
+% has two effects: First, it calls placement/compute position. Second,
+% it resets the length and normal counters. It will setup a completely
+% new counting of lengths and counters inside the current scope.
+%
+% The placmenet/place key is executed automatically whenever a new
+% node is automatically created. Furthermore, placement strategies
+% will call this key.
+
+\tikzgraphsset{
+ placement/.cd,
+ compute position/.code=\tikz@lib@graph@linear@pos,
+ place/.code={%
+ \pgfkeys{/tikz/graphs/placement/compute position}%
+ \aftergroup\tikz@lib@graph@reset@locals%
+ \pgfkeyssetvalue{/tikz/graphs/placement/element count}{0}%
+ \pgfkeyssetvalue{/tikz/graphs/placement/chain count}{0}%
+ \pgfkeyssetvalue{/tikz/graphs/placement/depth}{0}%
+ \pgfkeyssetvalue{/tikz/graphs/placement/width}{0}%
+ \pgfkeyssetvalue{/tikz/graphs/placement/local depth}{0}%
+ \pgfkeyssetvalue{/tikz/graphs/placement/local width}{0}%
+ },
+ element count/.initial=0,
+ chain count/.initial=0,
+ depth/.initial=0,
+ width/.initial=0,
+ level/.initial=0,
+ logical node depth/.code=\def\pgfmathresult{1},
+ logical node width/.code=\def\pgfmathresult{1},
+}%
+
+\def\tikz@lib@graph@reset@locals{%
+ \gdef\tikz@lib@graph@group@depth{0}%
+ \gdef\tikz@lib@graph@group@width{0}%
+}%
+
+
+% Arrange nodes evenly
+%
+% This strategy works as follows: You specify a "chain shift vector"
+% and a "group shift vector". Then each new element on a chain is
+% shifted by the chain shift vector relative to the previous element
+% on the chain. Similarly for each new element of a group.
+
+\tikzgraphsset{
+ Cartesian placement/.style={
+ placement/place,
+ placement/compute position/.code=\tikz@lib@graph@linear@pos%
+ },
+ chain shift/.initial={(1,0)},
+ group shift/.initial={(0,-1)},
+ grow right/.style={
+ placement/place,
+ chain shift={(#1,0)},
+ @auto anchor horizontal=center,
+ placement/logical node width/.code=\def\pgfmathresult{1}
+ },
+ grow right/.default=1,
+ grow left/.style={
+ placement/place,
+ chain shift={(-#1,0)},
+ @auto anchor horizontal=center,
+ placement/logical node width/.code=\def\pgfmathresult{1}
+ },
+ grow left/.default=1,
+ grow up/.style={
+ placement/place,
+ chain shift={(0,#1)},
+ @auto anchor horizontal=center,
+ placement/logical node width/.code=\def\pgfmathresult{1}
+ },
+ grow up/.default=1,
+ grow down/.style={
+ placement/place,
+ chain shift={(0,-#1)},
+ @auto anchor vertical=center,
+ placement/logical node width/.code=\def\pgfmathresult{1}
+ },
+ grow down/.default=1,
+ branch right/.style={
+ placement/place,
+ group shift={(#1,0)},
+ @auto anchor horizontal=center,
+ placement/logical node depth/.code=\def\pgfmathresult{1}
+ },
+ branch right/.default=1,
+ branch left/.style={
+ placement/place,
+ group shift={(-#1,0)},
+ @auto anchor horizontal=center,
+ placement/logical node depth/.code=\def\pgfmathresult{1}
+ },
+ branch left/.default=1,
+ branch up/.style={
+ placement/place,
+ group shift={(0,#1)},
+ @auto anchor vertical=center,
+ placement/logical node depth/.code=\def\pgfmathresult{1}
+ },
+ branch up/.default=1,
+ branch down/.style={
+ placement/place,
+ group shift={(0,-#1)},
+ @auto anchor vertical=center,
+ placement/logical node depth/.code=\def\pgfmathresult{1}
+ },
+ branch down/.default=1,
+ %
+ % Sep shifts
+ %
+ grow right sep/.style={
+ Cartesian placement,
+ chain shift={(1pt,0)},
+ @auto anchor horizontal=west,
+ placement/logical node width/.code=\tikz@lib@graph@width@sep{##1}{#1}
+ },
+ grow right sep/.default=1em,
+ grow left sep/.style={
+ Cartesian placement,
+ chain shift={(-1pt,0)},
+ @auto anchor horizontal=east,
+ placement/logical node width/.code=\tikz@lib@graph@width@sep{##1}{#1}
+ },
+ grow left sep/.default=1em,
+ grow up sep/.style={
+ Cartesian placement,
+ chain shift={(0,1pt)},
+ @auto anchor vertical=south,
+ placement/logical node width/.code=\tikz@lib@graph@depth@sep{##1}{#1}
+ },
+ grow up sep/.default=1em,
+ grow down sep/.style={
+ Cartesian placement,
+ chain shift={(0,-1pt)},
+ @auto anchor vertical=north,
+ placement/logical node width/.code=\tikz@lib@graph@depth@sep{##1}{#1}
+ },
+ grow down sep/.default=1em,
+ grow right sep/.style={
+ Cartesian placement,
+ chain shift={(1pt,0)},
+ @auto anchor horizontal=west,
+ placement/logical node width/.code=\tikz@lib@graph@width@sep{##1}{#1}
+ },
+ %
+ branch right sep/.style={
+ Cartesian placement,
+ group shift={(1pt,0)},
+ @auto anchor horizontal=west,
+ placement/logical node depth/.code=\tikz@lib@graph@width@sep{##1}{#1}
+ },
+ branch right sep/.default=1em,
+ branch left sep/.style={
+ Cartesian placement,
+ group shift={(-1pt,0)},
+ @auto anchor horizontal=east,
+ placement/logical node depth/.code=\tikz@lib@graph@width@sep{##1}{#1}
+ },
+ branch left sep/.default=1em,
+ branch up sep/.style={
+ Cartesian placement,
+ group shift={(0,1pt)},
+ @auto anchor vertical=south,
+ placement/logical node depth/.code=\tikz@lib@graph@depth@sep{##1}{#1}
+ },
+ branch up sep/.default=1em,
+ branch down sep/.style={
+ Cartesian placement,
+ group shift={(0,-1pt)},
+ @auto anchor vertical=north,
+ placement/logical node depth/.code=\tikz@lib@graph@depth@sep{##1}{#1}
+ },
+ branch down sep/.default=1em,
+ %
+ @auto anchor horizontal/.style={
+ nodes={anchor=\csname tikz@lib@graph@auto@\tikz@lib@graph@auto@h @\tikz@lib@graph@auto@v\endcsname},
+ /utils/exec=\def\tikz@lib@graph@auto@h{#1}
+ },
+ @auto anchor vertical/.style={
+ nodes={anchor=\csname tikz@lib@graph@auto@\tikz@lib@graph@auto@h @\tikz@lib@graph@auto@v\endcsname},
+ /utils/exec=\def\tikz@lib@graph@auto@v{#1}
+ },
+ %
+ %
+ no placement/.style={
+ placement/place,
+ placement/compute position/.code=%
+ }
+}%
+
+\def\tikz@lib@graph@auto@h{center}%
+\def\tikz@lib@graph@auto@v{center}%
+
+\def\tikz@lib@graph@auto@center@center{center}%
+\def\tikz@lib@graph@auto@west@center{west}%
+\def\tikz@lib@graph@auto@east@center{east}%
+\def\tikz@lib@graph@auto@center@north{north}%
+\def\tikz@lib@graph@auto@west@north{north west}%
+\def\tikz@lib@graph@auto@east@north{north east}%
+\def\tikz@lib@graph@auto@center@south{south}%
+\def\tikz@lib@graph@auto@west@south{south west}%
+\def\tikz@lib@graph@auto@east@south{south east}%
+
+\def\tikz@lib@graph@linear@pos{%
+ \pgfkeysgetvalue{/tikz/graphs/chain shift}\tikz@temp
+ \expandafter\tikz@scan@one@point\expandafter\pgf@process\tikz@temp
+ \pgf@process{\pgfpointscale{\pgfkeysvalueof{/tikz/graphs/placement/width}}{}}%
+ \pgf@xa=\pgf@x%
+ \pgf@ya=\pgf@y%
+ \pgfkeysgetvalue{/tikz/graphs/group shift}\tikz@temp
+ \expandafter\tikz@scan@one@point\expandafter\pgf@process\tikz@temp
+ \pgf@process{\pgfpointscale{\pgfkeysvalueof{/tikz/graphs/placement/depth}}{}}%
+ \advance\pgf@xa by\pgf@x%
+ \advance\pgf@ya by\pgf@y%
+ \edef\tikz@lib@graph@shift{(\the\pgf@xa,\the\pgf@ya)}
+ \pgfkeys{/tikz/graphs/nodes/.expanded={shift={\tikz@lib@graph@shift}}}
+}%
+
+
+\def\tikz@lib@graph@width@sep#1#2{%
+ \pgf@process{\pgfpointdiff{\pgfpointanchor{#1}{west}}{\pgfpointanchor{#1}{east}}}%
+ \pgfmathparse{#2+\the\pgf@x}%
+}%
+
+\def\tikz@lib@graph@depth@sep#1#2{%
+ \pgf@process{\pgfpointdiff{\pgfpointanchor{#1}{south}}{\pgfpointanchor{#1}{north}}}%
+ \pgfmathparse{#2+\the\pgf@y}%
+}%
+
+
+% Circular arrangements
+%
+% This strategy works a bit like the arrange evenly strategy, but in
+% polar coordinates. Both for the chains and the groups you specify a
+% polar shift, which must be in the form "(delta degree:delta
+% distance)". For each element in a chain, the delta degree is added
+% to the chain degree, likewise for each element the delta distance is
+% added. Similarly for groups.
+%
+% There is an initial degree and radius, stored in the key "phase" and
+% "radius".
+
+\tikzgraphsset{,
+ circular placement/.style={
+ placement/place,
+ placement/compute position/.code=\tikz@lib@graph@circular@pos,%
+ placement/logical node depth/.code=\def\pgfmathresult{1},
+ placement/logical node width/.code=\def\pgfmathresult{1},
+ },
+ clockwise/.style={
+ circular placement,
+ group polar shift={(-360/#1:0)}
+ },
+ clockwise/.default=\tikzgraphVnum,
+ counterclockwise/.style={
+ circular placement,
+ group polar shift={(360/#1:0)}
+ },
+ counterclockwise/.default=\tikzgraphVnum,
+ chain polar shift/.initial={(0:1cm)},
+ group polar shift/.initial={(60:0)},
+ radius/.initial=1cm,
+ phase/.initial=90,
+}%
+
+\def\tikz@lib@graph@circular@pos{%
+ \pgfkeysgetvalue{/tikz/graphs/chain polar shift}\tikz@temp
+ \expandafter\tikz@lib@graph@decompose@polar\tikz@temp%
+ \pgf@process{\pgfpointscale{\pgfkeysvalueof{/tikz/graphs/placement/width}}{}}%
+ \pgf@xa=\pgf@x%
+ \pgf@ya=\pgf@y%
+ \pgfkeysgetvalue{/tikz/graphs/group polar shift}\tikz@temp
+ \expandafter\tikz@lib@graph@decompose@polar\tikz@temp%
+ \pgf@process{\pgfpointscale{\pgfkeysvalueof{/tikz/graphs/placement/depth}}{}}%
+ \advance\pgf@xa by\pgf@x%
+ \advance\pgf@ya by\pgf@y%
+ \pgfmathparse{\pgfkeysvalueof{/tikz/graphs/radius}}%
+ \advance\pgf@ya by\pgfmathresult pt%
+ \pgfmathsetmacro\tikz@temp{\the\pgf@xa+\pgfkeysvalueof{/tikz/graphs/phase}}%
+ \edef\tikz@lib@graph@shift{(\tikz@temp:\the\pgf@ya)}
+ \pgfkeys{/tikz/graphs/nodes/.expanded={shift={\tikz@lib@graph@shift}}}
+}%
+
+
+\def\tikz@lib@graph@decompose@polar(#1:#2){%
+ \pgfmathsetlength\pgf@x{#1}%
+ \pgfmathsetlength\pgf@y{#2}%
+}%
+
+
+% Grid arrangements
+%
+\tikzgraphsset{
+ grid placement/.style={
+ placement/place,
+ placement/compute position/.code=\tikz@lib@graph@grid@pos,%
+ },
+}%
+
+
+\def\tikz@lib@graph@grid@pos{%
+ %
+ % Make sure to set \tikzgraphwrapafter before we compute
+ % the positions of nodes in the grid
+ %
+ \tikzgraphpreparewrapafter%
+ %
+ % find out the coordinate in the grid
+ %
+ \pgfkeysgetvalue{/tikz/graphs/placement/depth}\tikz@temp@depth%
+ \pgfkeysgetvalue{/tikz/graphs/placement/width}\tikz@temp@width%
+ \pgfmathsetmacro{\tikz@temp}{max(\tikz@temp@depth, \tikz@temp@width)}%
+ \pgfmathsetmacro{\tikz@temp@col}{mod(\tikz@temp,\tikzgraphwrapafter)}%
+ \pgfmathsetmacro{\tikz@temp@row}{div(\tikz@temp,\tikzgraphwrapafter)}%
+ %
+ % multiply row by the group shift and col by the chain shift
+ %
+ \pgfkeysgetvalue{/tikz/graphs/group shift}\tikz@temp%
+ \expandafter\tikz@scan@one@point\expandafter\tikz@lib@graph@grid@pos@a\tikz@temp%
+ \pgfkeysgetvalue{/tikz/graphs/chain shift}\tikz@temp%
+ \expandafter\tikz@scan@one@point\expandafter\tikz@lib@graph@grid@pos@b\tikz@temp%
+ %
+ % apply the shift
+ %
+ \edef\tikz@lib@graph@shift{(\the\pgf@xa,\the\pgf@ya)}
+ \pgfkeys{/tikz/graphs/nodes/.expanded={shift={\tikz@lib@graph@shift}}}
+}%
+
+\def\tikz@lib@graph@grid@pos@a#1{\pgf@process{\pgfpointscale{\tikz@temp@row}{#1}}\pgf@xa=\pgf@x\relax\pgf@ya=\pgf@y\relax}%
+\def\tikz@lib@graph@grid@pos@b#1{\pgf@process{\pgfpointscale{\tikz@temp@col}{#1}}%
+ \advance\pgf@xa by\pgf@x\relax
+ \advance\pgf@ya by\pgf@y\relax}%
+
+\tikzgraphsset{
+ % Grids:
+ wrap after/.initial=0,
+ % Node sets:
+ V/.code={%
+ \def\tikzgraphV{#1}%
+ \c@pgf@counta=0\foreach \tikz@dummy in {#1} {\global\advance\c@pgf@counta by1\relax}%
+ \edef\tikzgraphVnum{\the\c@pgf@counta}
+ },
+ V={1},
+ n/.style={V={1,...,#1},name shore V/.style={name=V}},
+ W/.code={%
+ \def\tikzgraphW{#1}%
+ \c@pgf@counta=0\foreach \tikz@dummy in {#1} {\global\advance\c@pgf@counta by1\relax}%
+ \edef\tikzgraphWnum{\the\c@pgf@counta}
+ },
+ W={1},
+ m/.style={W={1,...,#1},name shore W/.style={name=W}},
+ % Shores:
+ name shore V/.style=,
+ name shore W/.style=,
+}%
+
+
+
+%
+% Quick graphs
+%
+% Parsing the graph syntax can take a lot of time for large
+% graphs. This is mainly due to the transformation of commas and
+% semicolons and all the internal bookkeeping.
+%
+% For large graphs, the quick graph syntax offers a greatly reduced
+% syntax that will be processed much more quickly. This syntax is
+% compatible with the normal graph syntax in the sense that all
+% specifications written in the reduced syntax are also legal in the
+% normal syntax, but not the other way round.
+%
+% The following rules apply:
+%
+% 1) A quick graph consists of a sequence of either nodes, edges sequences, or
+% groups. These are separated by commas or semicolons.
+%
+% 2) Every node is of the form
+%
+% "node name"/"node text"[options]
+%
+% Here, the quotation marks are mandatory. The part '/"node text"' may
+% be missing, in which case the node name is used as the node
+% text. The options may also be missing. The node name may not contain
+% any "funny" characters (unlike in the normal graph command).
+%
+% 3) Every edge is of the form
+%
+% <node spec> <connector> <node spec> <connector> <node spec> ... <connector> <node spec>;
+%
+% Here, the <node spec> are node specifications as described above,
+% the <connector> is one of the four connectors "->", "<-", "--", and
+% "<->", followed by optional options in square
+% brackets. The semicolon may be replaced by a comma.
+%
+% 4) Every group is of the form
+%
+% { [options] lines };
+%
+% The options are compulsory, the lines must be a sequence of nodes,
+% edges, and groups as described above. The semicolon can, again, be
+% replaced by a comma.
+%
+%
+% Things that are allowed in the normal syntax, but not in the quick
+% syntax, include:
+%
+% - Connecting a node and a group as in a->{b,c}.
+% - Node names without quotation marks.
+% - Using subgraphs (graph macros).
+% - Using graph sets.
+% - Using graph color classes.
+% - Using anonymous nodes.
+% - Using the "fresh nodes" option.
+% - Using sublayouts.
+% - Using the -!- edge connector.
+% - Using the "simple" option.
+% - Using edge annotations.
+%
+% Example:
+%
+% \graph [quick] {
+% "a"/"$a$"[red] -> "b"[blue] -> "c";
+% "b" -> "d";
+% "c" ->[thick] "e";
+% { [same layer] "c", "d" };
+% };
+%
+%
+
+\tikzgraphsset{quick/.is if=tikz@graph@quick}%
+\newif\iftikz@graph@quick
+
+\def\tikz@lib@graphs@parse@quick@graph{
+ % Ok, we are before the initial brace. We open a group and start
+ % setting up some bookkeeping
+ \begingroup%
+ \global\tikz@qnode@count0\relax%
+ \let\tikzgraphnodepath\pgfutil@empty%
+ \tikz@q@outertrue%
+ \afterassignment\tikz@lib@graphs@quick@main\let\pgf@temp=%
+}%
+
+\newcount\tikz@qnode@count
+\newif\iftikz@q@outer
+
+\def\tikz@lib@graphs@quick@main{%
+ \afterassignment\tikz@lib@graphs@quick@handle\let\pgf@let@token=%
+}%
+\def\tikz@lib@graphs@quick@handle{%
+ \ifx\pgf@let@token"%
+ \expandafter\tikz@lib@graphs@quick@first@node%
+ \else%
+ \expandafter\tikz@lib@graphs@quick@other%
+ \fi%
+}%
+\def\tikz@lib@graphs@quick@other{%
+ \let\tikz@next\tikz@lib@graphs@quick@error%
+ \ifx\pgf@let@token\egroup%
+ \let\tikz@next\tikz@lib@graphs@quick@end@group%
+ \else%
+ \ifx\pgf@let@token\bgroup%
+ \let\tikz@next\tikz@lib@graphs@quick@start@group%
+ \else%
+ \ifx\pgf@let@token\par%
+ \let\tikz@next\tikz@lib@graphs@quick@main%
+ \fi%
+ \fi
+ \fi%
+ \tikz@next%
+}%
+
+\def\tikz@lib@graphs@quick@error#1{\tikzerror{Unexpected token '\string#1' in quick graph syntax}\tikz@lib@graphs@quick@main}%
+\def\tikz@lib@graphs@quick@start@group{%
+ \pgfutil@ifnextchar[\tikz@lib@graphs@quick@start@group@{\tikzerror{Group
+ in quick graph syntax must start with options.}}
+}%
+
+\def\tikz@lib@graphs@quick@start@group@[#1]{%
+ \begingroup%
+ \tikz@q@outerfalse%
+ \tikzgraphsset{#1}%
+ \tikz@lib@graphs@quick@main%
+}%
+\def\tikz@lib@graphs@quick@end@group{%
+ \iftikz@q@outer%
+ \endgroup%
+ % Ok, cleanup!
+ \pgfutil@loop%
+ \ifnum\tikz@qnode@count>0\relax%
+ \expandafter\global\expandafter\let\csname tikz@gr@q@@\csname tikz@gr@qn@@\the\tikz@qnode@count\endcsname\endcsname\relax%
+ \expandafter\global\expandafter\let\csname tikz@gr@qn@@\the\tikz@qnode@count\endcsname\relax%
+ \global\advance\tikz@qnode@count by-1\relax%
+ \pgfutil@repeat%
+ \expandafter\tikz@lib@graph@main@done%
+ \else%
+ \endgroup%
+ \expandafter\tikz@lib@graphs@end@group@%
+ \fi%
+}%
+\def\tikz@lib@graphs@end@group@{%
+ \pgfutil@ifnextchar;{\expandafter\tikz@lib@graphs@quick@main\pgfutil@gobble}{%
+ \pgfutil@ifnextchar,{\expandafter\tikz@lib@graphs@quick@main\pgfutil@gobble}{%
+ \tikzerror{Graph groups in quick syntax must be followed by a semicolon or a comma.}%
+ }%
+ }%
+}%
+
+
+\def\tikz@lib@graphs@quick@first@node{%
+ \let\tikz@quick@prev@node\relax%
+ \tikz@lib@graphs@quick@node%
+}%
+
+\def\tikz@lib@graphs@quick@node#1"{%
+ \def\tikzgraphnodename{#1}%
+ \let\tikzgraphnodetext\tikzgraphnodename%
+ \iftikzgraphsautonumbernodes
+ \edef\tikzgraphnodename{\tikzgraphnodename\tikz@lib@auto@sep\the\tikz@lib@auto@number}%
+ \global\advance\tikz@lib@auto@number by1\relax%
+ \fi
+ \pgfutil@ifnextchar/\tikz@lib@graphs@quick@text\tikz@lib@graphs@quick@opt%
+}%
+\def\tikz@lib@graphs@quick@text/"#1"{%
+ \def\tikzgraphnodetext{#1}%
+ \tikz@lib@graphs@quick@opt%
+}%
+\def\tikz@lib@graphs@quick@opt{%
+ \pgfutil@ifnextchar[\tikz@lib@graphs@quick@withopt{\tikz@lib@graphs@quick@withopt[]}%]
+}%
+\def\tikz@lib@graphs@quick@withopt[#1]{%
+ % Test, whether node already exists
+ \expandafter\ifx\csname tikz@gr@q@@\tikzgraphnodename\endcsname\relax%
+ % New node
+ \global\advance\tikz@qnode@count by1\relax%
+ \expandafter\global\expandafter\let\csname tikz@gr@q@@\tikzgraphnodename\endcsname\pgfutil@empty% not relax
+ \expandafter\global\expandafter\let\csname tikz@gr@qn@@\the\tikz@qnode@count\endcsname\tikzgraphnodename% back pointer
+ \let\tikzgraphnodefullname\tikzgraphnodename%
+ \let\tikzgraphnodeas\tikzgraphnodeas@default%
+ \node [%
+ name=\tikzgraphnodename,%
+ graphs/redirect unknown to tikz,
+ /tikz/graphs/.cd,%
+ /tikz/graphs/@nodes styling,%
+ #1]%
+ {%
+ \tikzgraphnodeas%
+ };%
+ \else%
+ %
+ % Handle late options and operators
+ \tikzgdlatenodeoptionacallback{\tikzgraphnodename}%
+ \node also[graphs/redirect unknown to tikz,/tikz/graphs/.cd,#1](\tikzgraphnodename);%
+ \fi%
+ % Connect, if necessary
+ \tikz@lig@graph@quikc@make@edge@if@necessary%
+ \tikz@lib@graphs@quick@scan@after@node%
+}%
+
+\def\tikz@lig@graph@quikc@make@edge@if@necessary{%
+ \ifx\tikz@quick@prev@node\relax%
+ \else%
+ \tikz@lib@graphs@quick@make@edge%
+ \fi%
+}%
+
+\def\tikz@lib@graphs@quick@scan@after@node{%
+ \pgfutil@ifnextchar,\tikz@lib@graphs@quick@comma{%
+ \pgfutil@ifnextchar;\tikz@lib@graphs@quick@semi{%
+ \pgfutil@ifnextchar\egroup{\tikz@lib@graphs@quick@semi;}{%
+ \pgfutil@ifnextchar\par{\expandafter\tikz@lib@graphs@quick@scan@after@node\tikz@lib@graphs@quick@gobble@par}%
+ \tikz@lib@graphs@quick@connector}}}%
+}%
+\long\def\tikz@lib@graphs@quick@gobble@par#1{}%
+
+\def\tikz@lib@graphs@quick@comma,{\tikz@lib@graphs@quick@main}%
+\def\tikz@lib@graphs@quick@semi;{\tikz@lib@graphs@quick@main}%
+\def\tikz@lib@graphs@quick@connector#1#2{%
+ \def\tikz@lib@graphs@quick@edge@kind{#1#2}%
+ \pgfutil@ifnextchar>\tikz@lib@graphs@back@edge{%
+ \pgfutil@ifnextchar[\tikz@lib@graphs@quick@connector@handle@opt{\tikz@lib@graphs@quick@connector@handle@opt[]}%]
+ }%
+}%
+\def\tikz@lib@graphs@back@edge#1{%
+ \expandafter\def\expandafter\tikz@lib@graphs@quick@edge@kind\expandafter{\tikz@lib@graphs@quick@edge@kind#1}%
+ \pgfutil@ifnextchar[\tikz@lib@graphs@quick@connector@handle@opt{\tikz@lib@graphs@quick@connector@handle@opt[]}%]
+}%
+\def\tikz@lib@graphs@quick@connector@handle@opt[#1]{%
+ \def\tikz@lib@graphs@quick@edge@options{#1}%
+ \let\tikz@quick@prev@node\tikzgraphnodename%
+ \tikz@lib@graphs@quick@scan@after@connector%
+}%
+\def\tikz@lib@graphs@quick@scan@after@connector{%
+ \pgfutil@ifnextchar\par{\expandafter\tikz@lib@graphs@quick@scan@after@connector\tikz@lib@graphs@quick@gobble@par}{%
+ \pgfutil@ifnextchar"{\expandafter\tikz@lib@graphs@quick@node\pgfutil@gobble}{%
+ \tikzerror{Quotation marks expected after edge connector}%
+ }%
+ }%
+}%
+
+\def\tikz@lib@graphs@quick@make@edge{%
+ {
+ \expandafter\tikz@lib@graphs@quick@make@edge@styling\expandafter{\tikz@lib@graphs@quick@edge@options}%
+ \expandafter\expandafter\expandafter\tikz@lib@graphs@quick@make@edge@for%
+ \expandafter\expandafter\expandafter{\expandafter\tikz@quick@prev@node\expandafter}\expandafter{\tikzgraphnodename}%
+ }
+}%
+
+\def\tikz@lib@graphs@quick@make@edge@styling#1{%
+ \tikz@enable@edge@quotes%
+ \tikzgraphsset{.unknown/.code=\tikz@lib@graph@unknown@edge@option{##1},#1}%
+}%
+
+\def\tikz@lib@graphs@quick@make@edge@for#1#2{%
+ \pgfkeysgetvalue{/tikz/graphs/@edges styling}\pgf@tempa
+ \pgfkeysgetvalue{/tikz/graphs/@edges node}\pgf@temp@b
+ \expandafter\expandafter\expandafter\tikz@lib@graphs@quick@make@edge@for@with%
+ \expandafter\expandafter\expandafter{\expandafter\pgf@tempa\expandafter}\expandafter{\pgf@temp@b}{#1}{#2}%
+}%
+
+\def\tikz@lib@graphs@quick@make@edge@for@with#1#2#3#4{%
+ \tikzgraphsset{new \tikz@lib@graphs@quick@edge@kind={#3}{#4}{#1}{#2}}%
+}%
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/graphs/tikzlibrarygraphs.standard.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/graphs/tikzlibrarygraphs.standard.code.tex
new file mode 100644
index 0000000000..4cac3e51eb
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/graphs/tikzlibrarygraphs.standard.code.tex
@@ -0,0 +1,109 @@
+% Copyright 2019 by Till Tantau
+% Copyright 2019 by Jannis Pohlmann
+%
+% 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{tikzlibrarygraphs.standard.code.tex}
+
+\usetikzlibrary{graphs}%
+
+%
+% Basic graphs
+%
+
+
+\tikzgraphsset{
+ %
+ % An independent set $V$ of nodes.
+ %
+ declare={subgraph I_n}%
+ {
+ \foreach \tikz@lib@graph@node@num in \tikzgraphV
+ { \tikz@lib@graph@node@num }
+ },
+ %
+ % An two-shore independent set $V$ with shores V and W.
+ %
+ declare={subgraph I_nm}%
+ {
+ subgraph I_n [name shore V] -- [no edges]
+ subgraph I_n [name shore W, V/.expand once=\tikzgraphW]
+ },
+ %
+ % The complete clique on $V$.
+ %
+ declare={subgraph K_n}%
+ {
+ [clique]
+ subgraph I_n
+ },
+ %
+ % A complete bipartite graph with shores V and W.
+ %
+ declare={subgraph K_nm}%
+ {
+ [color class=shore V,
+ color class=shore W,
+ complete bipartite={shore V}{shore W}]
+ subgraph I_n [name shore V, shore V] -- [no edges]
+ subgraph I_n [name shore W, V/.expand once=\tikzgraphW, shore W]
+ },
+ %
+ % A cycle with n nodes.
+ %
+ declare={subgraph C_n}%
+ {
+ [cycle]
+ subgraph I_n
+ },
+ %
+ % A path with n nodes.
+ %
+ declare={subgraph P_n}%
+ {
+ [path]
+ subgraph I_n
+ },
+ %
+ % A grid with n nodes.
+ %
+ declare={subgraph Grid_n}%
+ {
+ [grid]
+ subgraph I_n
+ },
+ %
+ % A random graph according to the G_{n,p} model: For each pair of
+ % vertices there is an edge between them with probability p.
+ %
+ p/.initial=0.5,
+ declare={subgraph G_np}%
+ {
+ [/utils/exec={
+ \pgfmathsetmacro\tikz@lib@lg@p{\pgfkeysvalueof{/tikz/graphs/p}}
+ \let\tikz@lib@gnp@edges\pgfutil@empty%
+ \foreach \tikz@lib@graph@node@a [count=\tikz@lib@g@count@a] in \tikzgraphV
+ \foreach \tikz@lib@graph@node@b [count=\tikz@lib@g@count@b] in \tikzgraphV
+ {
+ \ifnum\tikz@lib@g@count@a<\tikz@lib@g@count@b\relax
+ \pgfmathparse{rnd}
+ \ifdim\pgfmathresult pt<\tikz@lib@lg@p pt%
+ \ifx\tikz@lib@gnp@edges\pgfutil@empty
+ \xdef\tikz@lib@gnp@edges{\tikz@lib@graph@node@a--\tikz@lib@graph@node@b}%
+ \else
+ \xdef\tikz@lib@gnp@edges{\tikz@lib@gnp@edges,\tikz@lib@graph@node@a--\tikz@lib@graph@node@b}%
+ \fi
+ \fi
+ \fi
+ }
+ }]
+ \foreach \tikz@lg@temp in \tikz@lib@gnp@edges {
+ [parse/.expand once=\tikz@lg@temp]
+ }
+ },
+}%
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzexternalshared.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzexternalshared.code.tex
new file mode 100644
index 0000000000..2ff5aa2d38
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzexternalshared.code.tex
@@ -0,0 +1,1714 @@
+% Copyright 2008-2020 by Christian Feuersaenger
+%
+% 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.
+%
+% ******************************
+% This here is the shared implementation of TeX-dialect specific files
+% tikzlibraryexternal.code.tex
+% ******************************
+%
+%
+% This file provides a high-level automatic export feature for tikz pictures.
+% It allows to export EACH SINGLE FIGURE into a separate PDF.
+%
+% The simplest way is to use the 'convert with system call' option; it simply converts every figure using the write18 method. If that is not possible, a list of figure file names is generated and you need to generate these figures manually (or with a script).
+%
+%
+% It replaces \tikzpicture/ \endtikzpicture and \tikz and invokes \beginpgfgraphicnamed ... \endpgfgraphicnamed
+% commands if necessary.
+
+% handle with extreme care and only in small, local groups:
+\toksdef\t@tikzexternal@tmpa=0
+\toksdef\t@tikzexternal@tmpb=1
+
+\newif\iftikzexternal@nestedflag
+\newif\iftikzexternal@verboseuptodate
+\newif\iftikzexternal@verboseio
+\newif\iftikzexternal@genfigurelist
+\newif\iftikzexternal@onlynamed
+\newif\iftikzexternal@file@isuptodate
+\newif\iftikzexternal@force@remake
+\newif\iftikzexternal@optimize
+\newif\iftikzexternal@export@enabled
+\tikzexternal@export@enabledtrue
+
+% must be numeric!
+\gdef\c@tikzexternal@version{2}
+
+% This 'if' can be used as part of the public user interface.
+%
+% It is set by the 'remake next' key.
+%
+% It disables any up-to-date checks for the *next* picture, forcing a
+% remake of it.
+%
+% It applies only to *one* picture.
+\newif\iftikzexternalremakenext
+\newif\iftikzexternal@verbose@optimize
+\tikzexternal@verbose@optimizetrue
+
+% A global boolean which can be used to skip single figures.
+\newif\iftikzexternalexportnext
+\tikzexternalexportnexttrue
+
+% Invokes '#1' if the external lib is currently externalizing
+% something and '#2' if not.
+%
+% This command must be called *after* \tikzexternalize.
+\def\tikzifexternalizing#1#2{%
+ \ifpgf@external@grabshipout #1\else #2\fi
+}%
+% Invokes '#1' if the external lib is currently externalizing the NEXT FOLLOWING
+% tikzpicture. It invokes '#2' if that is not the case.
+\def\tikzifexternalizingnext#1#2{%
+ \ifpgf@external@grabshipout
+ \tikzexternalgetnextfilename\tikzexternal@temp
+ \tikzifexternaljobnamematches\tikzexternal@temp{#1}{#2}%
+ \else
+ #2%
+ \fi
+}%
+% Invokes '#1' if the external lib is currently externalizing the
+% current picture. It invokes '#2' if that is not the case.
+%
+% If the command is invoked outside of a picture, '#2' will be
+% invoked.
+\def\tikzifexternalizingcurrent#1#2{%
+ \ifpgf@external@grabshipout
+ \tikzexternalgetcurrentfilename\tikzexternal@temp
+ \ifx\tikzexternal@temp\pgfutil@empty
+ #2%
+ \else
+ \tikzifexternaljobnamematches\tikzexternal@temp{#1}{#2}%
+ \fi
+ \else
+ #2%
+ \fi
+}%
+
+% Invokes '#2' if \jobname equals '#1' and '#3' if not.
+% I suppose that '#1' is a macro containing the file name.
+%
+\def\tikzifexternaljobnamematches#1#2#3{%
+ \edef\pgf@tempa{\expandafter\string\csname#1\endcsname}%
+ \edef\pgf@tempb{\expandafter\string\csname\pgfactualjobname\endcsname}%
+ \ifx\pgf@tempa\pgf@tempb #2\else#3 \fi%
+}%
+
+
+\pgfutil@IfUndefined{pdfshellescape}{%
+ % let's hope that \usepackage{pdftexcmds} has been used...
+ \pgfutil@IfUndefined{pdf@shellescape}{%
+ \def\tikzexternalcheckshellescape{0}%
+ }{%
+ \let\tikzexternalcheckshellescape=\pdf@shellescape
+ }%
+}{%
+ \let\tikzexternalcheckshellescape=\pdfshellescape
+}%
+\ifnum\tikzexternalcheckshellescape=1
+ \def\tikzexternalcheckshellescape{\pgfkeysvalueof{/tikz/external/shell escape}\space}%
+\else
+ \def\tikzexternalcheckshellescape{}%
+\fi
+
+\newif\iftikzexternal@auto@detect@jobname
+
+\pgfqkeys{/tikz/external}{
+ figure list/.is if=tikzexternal@genfigurelist,
+ aux in dpth/.style={/pgf/images/aux in dpth={#1}},%
+ disable dependency files/.code={%
+ \let\tikzexternalfiledependsonfile@ACTIVE=\tikzexternalfiledependsonfile
+ },
+ % 'mode' applies only if \jobname==real job name.
+ mode/.is choice,
+ mode/only graphics/.code = {%
+ \def\tikzexternal@opmode{0}%
+ \pgfkeysalso{/pgf/images/aux in dpth=true}%
+ },
+ mode/no graphics/.code = {\def\tikzexternal@opmode{1}},
+ % an alias for 'no graphics:'
+ mode/only pictures/.code = {\def\tikzexternal@opmode{1}},
+ mode/graphics if exists/.code= {%
+ \def\tikzexternal@opmode{2}%
+ \pgfkeysalso{/pgf/images/aux in dpth=true}%
+ },
+ mode/list only/.code = {\def\tikzexternal@opmode{3}\tikzexternal@genfigurelisttrue},
+ mode/convert with system call/.code={%
+ \def\tikzexternal@opmode{4}%
+ \pgfkeysalso{/tikz/external/figure list=false,/pgf/images/aux in dpth=true}%
+ },
+ mode/list and make/.code = {%
+ \def\tikzexternal@opmode{5}%
+ \pgfkeysalso{/tikz/external/figure list=true,/pgf/images/aux in dpth=true}%
+ },
+ mode=convert with system call,
+ force remake/.is if=tikzexternal@force@remake,
+ force remake/.default=true,
+ %
+ % DEPRECATED: this here will work out-of-the box (provided that
+ % 'aux in dpth' is active):
+ failed ref warnings for/.initial={\ref,\cite,\pageref},
+ export next/.is if=tikzexternalexportnext,
+ export/.is if=tikzexternal@export@enabled,
+ remake next/.is if=tikzexternalremakenext,
+ remake next/.default=true,
+ verbose IO/.is if=tikzexternal@verboseio,
+ verbose IO/.default=true,
+ verbose IO=true,
+ verbose optimize/.is if=tikzexternal@verbose@optimize,
+ verbose up to date/.is if=tikzexternal@verboseuptodate,
+ verbose/.style={
+ verbose IO=#1,
+ verbose optimize=#1,
+ verbose up to date=#1,
+ },
+ shell escape/.initial=-shell-escape,
+ read main aux/.is if=pgfexternalreadmainaux,
+ image discarded text/.initial={%
+ [[ \textsc{Image Discarded Due To} \texttt{`/tikz/external/%
+ \ifcase\tikzexternal@opmode\relax
+ mode=only graphics%
+ \or
+ mode=no graphics%
+ \or
+ mode=graphics if exists%
+ \or
+ mode=list only%
+ \or
+ mode=convert with system call%
+ \or
+ mode=list and make%
+ \fi
+ '}~]]%
+ \pgfutil@ifundefined{tikzexternal@warning@at@end}{%
+ \pgfutil@ifundefined{AtEndDocument}{}{%
+ \AtEndDocument{%
+ \message{! Package tikz Warning: Some images are not up-to-date and need to be generated. }%
+ }%
+ }%
+ \gdef\tikzexternal@warning@at@end{1}%
+ }{}%
+ },
+ optimize/.is choice,
+ optimize/true/.code={%
+ \tikzexternal@optimizetrue
+ \iftikzexternal@optimize
+ \ifpgf@external@grabshipout
+ % we have already started the externalization! Install
+ % optimization commands to activate the new one:
+ \tikzexternal@optimize@REPLACE
+ \fi
+ \fi
+ },
+ optimize/false/.code={%
+ \tikzexternal@optimizefalse%
+ \tikzexternal@optimize@RESTORE
+ },%
+ optimize=true,
+ optimize away text/.code={[ \textsc{\string#1\ optimized away because it does not contribute to exported PDF}]},
+ optimize/install/.code={},%
+ optimize/restore/.code={},%
+ % Expects two arguments, the command name and (optionally) a count
+ % of expected arguments.
+ % Example:
+ % 'optimize command away=\includegraphics'
+ % 'optimize command away={\mycommand}{3}'
+ %
+ % It accepts commands which have '[]' arguments and whose first
+ % argument always begins with '{'.
+ %
+ % #1: the command name
+ % #2: either empty or a number of EXPECTED arguments. It will be checked
+ % for one optional argument in square brackets as well.
+ optimize command away/.code 2 args={%
+ \expandafter\global\expandafter\let\csname\string#1@ORIG\endcsname=#1%
+ \pgfkeysalso{%
+ /tikz/external/optimize/install/.append code={%
+ \def#1{\tikzexternal@optimize@away@cmd{#1}{#2}}%
+ },
+ /tikz/external/optimize/restore/.append code={%
+ \expandafter\let\expandafter#1\csname\string#1@ORIG\endcsname
+ }
+ }%
+ \iftikzexternal@optimize
+ \ifpgf@external@grabshipout
+ % we have already started the externalization! Install
+ % optimization commands to activate the new one:
+ \tikzexternal@optimize@REPLACE
+ \fi
+ \fi
+ },
+ optimize command away=\includegraphics,
+ optimize command away=\pgfincludeexternalgraphics,
+ % EXPERIMENTAL (UNTESTED):
+ optimize latex env away/.code={%
+ \expandafter\let\expandafter\pgf@tempa\csname #1\endcsname
+ \expandafter\global\expandafter\let\csname #1@ORIG\endcsname=\pgf@tempa%
+ \pgfkeysalso{%
+ /tikz/external/optimize/install/.append code={%
+ \pgfutil@namedef{#1}{\tikzexternal@optimize@away@latex@env{#1}}%
+ },
+ /tikz/external/optimize/restore/.append code={%
+ \pgfutil@namelet{#1}{#1@ORIG}%
+ }%
+ }%
+ },
+ only named/.is if=tikzexternal@onlynamed,
+ only named/.default=true,
+ figure name/.initial=\tikzexternal@realjob-figure,
+ reset counter/.code={%
+ \expandafter\gdef\csname c@tikzext@no@#1\endcsname{0}%
+ },%
+ prefix/.code={\tikzsetexternalprefix{#1}},
+ up to date check/.is choice,
+ up to date check/simple/.code={\def\tikzexternal@uptodate@mode{0}},
+ % md5 relies on \pdfmdfivesum of pdftex. It uses 'diff' as fallback if we do not have that command.
+ up to date check/md5/.code={\def\tikzexternal@uptodate@mode{1}},
+ up to date check/diff/.code={\def\tikzexternal@uptodate@mode{2}},
+ up to date check=md5,
+}
+
+\expandafter\def\csname tikzexternal@driver@pgfsys-luatex.def\endcsname{%
+ \pgfkeyssetvalue{/tikz/external/system call}{%
+ lualatex \tikzexternalcheckshellescape -halt-on-error -interaction=batchmode -jobname "\image" "\texsource"%
+ }%
+}%
+\expandafter\def\csname tikzexternal@driver@pgfsys-pdftex.def\endcsname{%
+ \pgfutil@IfUndefined{directlua}{%
+ \pgfkeyssetvalue{/tikz/external/system call}{%
+ pdflatex \tikzexternalcheckshellescape -halt-on-error -interaction=batchmode -jobname "\image" "\texsource"%
+ }%
+ }{%
+ \pgfkeyssetvalue{/tikz/external/system call}{%
+ lualatex \tikzexternalcheckshellescape -halt-on-error -interaction=batchmode -jobname "\image" "\texsource"%
+ }%
+ }%
+}%
+%--------------------------------------------------
+% \expandafter\def\csname tikzexternal@driver@pgfsys-dvipdfm.def\endcsname{%
+% \pgfkeyssetvalue{/tikz/external/system call}{%
+% latex \tikzexternalcheckshellescape -halt-on-error -interaction=batchmode -jobname "\image" "\texsource"%
+% && dvipdfm "\image".dvi %
+% }%
+% }%
+%--------------------------------------------------
+\expandafter\def\csname tikzexternal@driver@pgfsys-xetex.def\endcsname{%
+ \pgfkeyssetvalue{/tikz/external/system call}{%
+ xelatex \tikzexternalcheckshellescape -halt-on-error -interaction=batchmode -jobname "\image" "\texsource"%
+ }%
+}%
+\expandafter\def\csname tikzexternal@driver@pgfsys-dvips.def\endcsname{%
+ \pgfkeyssetvalue{/tikz/external/system call}{%
+ latex \tikzexternalcheckshellescape -halt-on-error -interaction=batchmode -jobname "\image" "\texsource" %
+ && dvips -o "\image".ps "\image".dvi %
+ }%
+}%
+
+% Auto-select a suitable default value fo 'system call':
+\pgfutil@ifundefined{tikzexternal@driver@\pgfsysdriver}{%
+ % fallback. We do not know the driver here.
+ \csname tikzexternal@driver@pgfsys-pdftex.def\endcsname
+}{%
+ \csname tikzexternal@driver@\pgfsysdriver\endcsname
+}%
+
+
+\def\tikzsetfigurename#1{\pgfkeyssetvalue{/tikz/external/figure name}{#1}}%
+\def\tikzappendtofigurename#1{\pgfkeys{/tikz/external/figure name/.add={}{#1}}}
+
+% This method sets the file name prefix used for every import/export.
+%
+% It is invoked by the '/tikz/external/prefix' key.
+\def\tikzsetexternalprefix#1{\def\tikzexternal@filenameprefix{#1}}
+\tikzsetexternalprefix{}
+
+% This method initialises automatic externalization.
+%
+% The command does need any argument, but it has two optional ones:
+%
+% 1. \tikzexternalize[<options>]
+%
+% 2. \tikzexternalize{<real job's name>}
+%
+% 3. \tikzexternalize[<options>]{<real job's name>}
+%
+% The <real job's name> is the job's file name, without the suffix
+% .tex .
+% If the <real job's name> is omitted, it will be deduced
+% automatically.
+%
+% The effect is:
+% 1. automatically surround EVERY tikzpicture by \beginpgfgraphicnamed % sections.
+% 2. in case that the job's real name and the current \jobname differ,
+% it will process ONLY the matching tikzpicture.
+\def\tikzexternalize{%
+ \pgfutil@ifnextchar[{%
+ \tikzexternalize@opt
+ }{%
+ \tikzexternalize@opt[]%
+ }%
+}%
+\def\tikzexternalize@opt[#1]{%
+ \pgfutil@ifnextchar\bgroup{%
+ \tikzexternal@auto@detect@jobnamefalse
+ \tikzexternalize@opt@withname[#1]%
+ }{%
+ \tikzexternal@auto@detect@jobnametrue
+ \pgfutil@ifundefined{tikzexternalrealjob}{%
+ % ok, \tikzexternalrealjob is not known.
+ % Assume we are currently *not* externalizing.
+ \let\tikzexternalrealjob=\jobname
+ }{}%
+ \def\pgf@tempa{\tikzexternalize@opt@withname[#1]}%
+ \expandafter\pgf@tempa\expandafter{\tikzexternalrealjob}%
+ }%
+}%
+\def\tikzexternalize@opt@withname[#1]#2{%
+ \gdef\tikzexternalrealjob{#2}%
+ \if1\tikzexternalize@hasbeencalled
+ \else
+ \pgfqkeys{/tikz/external}{#1}%
+ \def\tikzexternal@realjob{#2}%
+ \tikzexternalauxlock@init
+ \pgfrealjobname{#2}%
+ \def\tikzexternalize@hasbeencalled{1}%
+ \tikzexternalenable
+ \def\tikzexternal@determineimgextension##1:##2\relax{\gdef\tikzexternalimgextension{##1}}%
+ \xdef\pgf@tempa{\pgfsys@imagesuffixlist}%
+ \expandafter\tikzexternal@determineimgextension\pgf@tempa:\relax
+ \pgfutil@ifundefined{includegraphics}{%
+ \let\tikzexternal@orig@includegraphics=\relax
+ }{%
+ \let\tikzexternal@orig@includegraphics=\includegraphics
+ }%
+ \let\tikzexternalfiledependsonfile=\tikzexternalfiledependsonfile@ACTIVE
+ \let\tikzpicturedependsonfile=\tikzpicturedependsonfile@ACTIVE
+ \fi
+}
+\def\tikzexternalize@hasbeencalled{0}%
+
+\def\tikzifexternalizehasbeencalled#1#2{%
+ \if1\tikzexternalize@hasbeencalled
+ #1%
+ \else
+ #2%
+ \fi
+}%
+
+% If mode=`convert with system call', the boolean \ifpgfexternalreadmainaux
+% will be set depending on the current lock file.
+%
+% The idea is as follows: Suppose
+% pdflatex -shell-escape mainjob.tex
+% is running.
+%
+% While it runs,
+% a) it modifies its mainjob.aux file,
+% b) it issues pdflatex -jobname mainjob-figure0 mainjob.tex .
+%
+% The call (b) will try to read mainjob.aux in order to resolve \ref
+% commands. This may fail since the aux
+% file is not complete; it may be subject to output buffering. To
+% avoid such failure, a locking mechanism is established.
+%
+% The locking mechanisms causes (a) to write a lock command into
+% mainjob.auxlock
+% just before (b) is called. Then, (b) will check it. After (b) has
+% completed, the lock will be reset.
+%
+% Thus: mode=convert with system call does NOT support \ref commands
+% inside of images. You will need to call the externalization command
+% manually. In this case, it should work.
+%
+% The lock file allows to detect automatically whether an image is created by
+% 'convert with system call' or if the user issued the required command manually.
+%
+% @PRECONDITION : this command must be invoked AFTER
+% \tikzexternal@realjob has been defined but BEFORE \pgfrealjobname is
+% called.
+%
+% @POSTCONDITION : If \ifpgfexternalreadmainaux=\iffalse, we won't do
+% anything. Otherwise, it will be changed depending for 'mode=convert
+% with system call' if necessary.
+\def\tikzexternalauxlock@init{%
+ \if4\tikzexternal@opmode
+ % mode=convert with system call
+ \ifpgfexternalreadmainaux
+ % ohoh. This case needs care because the main.aux might
+ % not be ready at this time!
+ % check.
+ %
+ \edef\pgf@tempa{\expandafter\string\csname\tikzexternal@realjob\endcsname}%
+ \edef\pgf@tempb{\expandafter\string\csname\jobname\endcsname}%
+ \ifx\pgf@tempa\pgf@tempb
+ % we are *not* externalizing. Set lock into its
+ % initial "unlocked" state.
+ \tikzexternalauxlock@setlock{0}%
+ \else
+ % we are externalizing. Query the lock's value:
+ \tikzexternalauxlock@getlockvalue
+ \if1\tikzexternallocked
+ \pgfexternalreadmainauxfalse
+ % the main .aux file won't be read right now.
+ \else
+ \pgfexternalreadmainauxtrue
+ \fi
+ \fi
+ \else
+ % NO-OP. We won't read the main aux file anyway.
+ \def\tikzexternalauxlock@setlock##1{}%
+ \fi
+ \fi
+}
+% defines \tikzexternallocked to be either 0 or 1, depending on the
+% lock file.
+\def\tikzexternalauxlock@getlockvalue{%
+ \openin\r@pgf@reada=\tikzexternal@realjob.auxlock
+ \ifeof\r@pgf@reada
+ % no lock file. Unlock.
+ \def\tikzexternallocked{0}%
+ \else
+ % read first line...
+ \read\r@pgf@reada to\pgf@tempa
+ % ... and execute it.
+ \pgf@tempa
+ % it should contain a definition of \tikzexternallocked. If
+ % not, lock it anyway.
+ \pgfutil@ifundefined
+ {tikzexternallocked}
+ {\def\tikzexternallocked{1}}%
+ {}%
+ \fi
+ \closein\r@pgf@reada
+}%
+\def\tikzexternalauxlock@setlock#1{%
+ \immediate\openout\w@pgf@writea=\tikzexternal@realjob.auxlock
+ \immediate\write\w@pgf@writea{\noexpand\def\noexpand\tikzexternallocked{#1}}%
+ \immediate\closeout\w@pgf@writea
+}
+
+
+% this is a hook into pgfcoreexternal.code.tex:
+\def\pgf@external@grab@refundefinedtrue@code{%
+ \gdef\noexpand\tikzexternal@systemcall@reschedule@to@end@document{1}%
+}%
+
+% Expands to the default image extension (it is set by
+% \tikzexternalize).
+%
+% This image extension may not resemble the correct one; you may need
+% to overwrite this macro *after* \tikzexternalize in this case.
+%
+% The default setting uses the first registered image extension.
+\def\tikzexternalimgextension{}%
+
+% can be used to (temporarily) disable the externalization.
+\def\tikzexternaldisable{%
+ \tikzexternaldisable@nofading
+ \pgfutil@ifundefined{tikzexternal@orig@tikzfadingfrompicture}
+ {}% NOP
+ {%
+ \let\tikzfadingfrompicture=\tikzexternal@orig@tikzfadingfrompicture
+ \let\endtikzfadingfrompicture=\tikzexternal@orig@endtikzfadingfrompicture
+ \let\tikzfading=\tikzexternal@orig@tikzfading
+ }%
+}%
+\def\tikzexternaldisable@nofading{%
+ \let\tikz=\tikzexternal@origtikz
+ \tikzexternal@TEXDIALECT@restore@picture
+ \iftikzexternal@optimize
+ \ifpgf@external@grabshipout
+ \tikzexternal@optimize@RESTORE
+ \fi
+ \fi
+}
+% re-enables externalization after a \tikzexternalizedisable.
+\def\tikzexternalenable{%
+ \if\tikzexternalize@hasbeencalled1%
+ \let\tikz=\tikzexternal@tikz@replacement
+ \tikzexternal@TEXDIALECT@installreplacement@picture
+ \pgfutil@ifundefined{tikzfadingfrompicture}%
+ {}% no special handling for 'fading lib'
+ {%
+ % oh, ok -- patch fading lib!
+ \pgfutil@ifundefined{tikzexternal@orig@tikzfadingfrompicture}{%
+ \let\tikzexternal@orig@tikzfadingfrompicture=\tikzfadingfrompicture
+ \let\tikzexternal@orig@endtikzfadingfrompicture=\endtikzfadingfrompicture
+ \let\tikzexternal@orig@tikzfading=\tikzfading
+ }{}%
+ \def\tikzfadingfrompicture{%
+ \begingroup
+ \tikzexternaldisable@nofading
+ \tikzexternal@orig@tikzfadingfrompicture}%
+ \def\endtikzfadingfrompicture{%
+ \tikzexternal@orig@endtikzfadingfrompicture
+ \endgroup}%
+ \def\tikzfading[##1]{%
+ \begingroup
+ \tikzexternaldisable@nofading
+ \tikzexternal@orig@tikzfading[##1]%
+ \endgroup}%
+ }%
+ \iftikzexternal@optimize
+ \ifpgf@external@grabshipout
+ \tikzexternal@optimize@REPLACE
+ \fi
+ \fi
+ \fi
+}%
+
+% Sets the filename for the next tikzpicture or \tikz shortcommand.
+%
+% It will *only* be used for the next picture.
+%
+% If you don't call \tikzsetnextfilename for a picture, a file name
+% will be assembled automatically.
+%
+% Please note that the global file prefix will be prepended anyway.
+\def\tikzsetnextfilename#1{\gdef\tikzexternal@nextfile{#1}}
+\tikzsetnextfilename{}
+
+
+% These are few TeX dialect-specific commands which need to be overridden when used with
+% something different than plain TeX:
+%
+% 1. this command collects a complete image into a macro, up to (but not including) the
+% final TeX-dialect specific end-image command.
+% This is really difficult for LaTeX because \end{tikzpicture} either involves dirty
+% catcode-hacks to parse the braces or an ugly loop which loops until it
+% finds \end followed by {tikzpicture}.
+%
+% #1: a macro which will be called with the collected environment contents.
+% all following tokens: the environment contents.
+\long\gdef\tikzexternal@TEXDIALECT@collectpicture#1#2\endtikzpicture{#1{#2}}
+%
+% 2. the following commands should expand to the TeX-dialect specific begin and end image command, i.e.
+% \tikzpicture / \endtikzpicture
+% or
+% \begin{tikzpicture} / \end{tikzpicture}
+% or
+% \starttikzpicture / \stoptikzpicture
+\def\tikzexternal@TEXDIALECT@begpicture{\tikzpicture}
+\def\tikzexternal@TEXDIALECT@endpicture{\endtikzpicture}%
+%
+% 3. This installs the replacement macros:
+\def\tikzexternal@TEXDIALECT@installreplacement@picture{%
+ \let\tikzpicture=\tikzexternal@tikzpicture@replacement
+}%
+\def\tikzexternal@TEXDIALECT@restore@picture{%
+ \let\tikzpicture=\tikzexternal@origpicture
+}%
+
+
+
+
+\let\tikzexternal@origtikz=\tikz
+\let\tikzexternal@origpicture=\tikzpicture
+\let\tikzexternal@origendpicture=\endtikzpicture
+\let\tikzexternal@curfilename=\relax
+
+% Replacement for '\tikzpicture'.
+%
+% There are two different states in which this method is applied:
+% - normal typesetting. Then, the 'mode' key controls its behavior.
+% - externalize mode (i.e. jobname != real job name). Then, it will
+% externalize the picture selected by 'jobname' (and only this picture).
+\def\tikzexternal@tikzpicture@replacement{%
+ \leavevmode
+ \global\tikzexternal@file@isuptodatetrue% may be set to false during checks.
+ \tikzexternal@getnextfilename\tikzexternal@curfilename
+ \ifx\tikzexternal@curfilename\pgfutil@empty
+ \ifpgf@external@grabshipout
+ % This picture won't be externalized.
+ % But maybe we can optimize it away:
+ \iftikzexternal@optimize
+ % -> it won't be shipped out anyway, so save typesetting time!
+ \let\tikzexternal@next=\tikzexternal@skipfigure
+ \else
+ % include this graphics into the output (even if
+ % it will be discarded anyway).
+ \let\tikzexternal@next=\tikzexternal@normalpicture@nographics
+ \fi
+ \else
+ \let\tikzexternal@next=\tikzexternal@normalpicture@nographics
+ \fi
+ \else
+ \ifpgf@external@grabshipout
+ \tikzifexternaljobnamematches\tikzexternal@curfilename{%
+ % ok, this here IS the picture for which
+ % pdflatex --jobname <my name>
+ % has been invoked.
+ \let\tikzexternal@next=\tikzexternal@externalizefig
+ }{%
+ \iftikzexternal@optimize
+ % No, another picture should be exported. Simply skip this one
+ % -> it won't be shipped out anyway, so save typesetting time!
+ \let\tikzexternal@next=\tikzexternal@skipfigure
+ \else
+ % include this graphics into the output (even it
+ % it will be discarded anyway).
+ \let\tikzexternal@next=\tikzexternal@normalpicture@nographics
+ \fi
+ }%
+ \else
+ \ifcase\tikzexternal@opmode\relax
+ % 'mode=only graphics'
+ \let\tikzexternal@next=\tikzexternal@forcegraphics
+ \or
+ % 'mode=no graphics'
+ \let\tikzexternal@next=\tikzexternal@normalpicture@nographics
+ \or
+ % 'mode=graphics if exists'
+ \let\tikzexternal@next=\tikzexternal@externalizefig
+ \or
+ % 'mode=list only'
+ \let\tikzexternal@next=\tikzexternal@listmodepicture
+ \or
+ % 'mode=convert with system call'
+ \let\tikzexternal@next=\tikzexternal@externalizefig@systemcall
+ \or
+ % 'mode=list and make'
+ \let\tikzexternal@next=\tikzexternal@list@and@makefile@mode@picture
+ \fi
+ \fi
+ \fi
+ \tikzexternal@next
+}%
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Replacement for \tikz short command:
+\def\tikzexternal@tikz@replacement{%
+ \pgfutil@ifnextchar[{\tikzexternal@tikz@replacement@opt}{\tikzexternal@tikz@replacement@opt[]}%
+}%
+\def\tikzexternal@tikz@replacement@opt[#1]{%
+ \pgfutil@ifnextchar\bgroup{\tikzexternal@tikz@replacement@opt@{#1}}{\tikzexternal@tikz@replacement@opt@@{#1}}%
+}
+\long\def\tikzexternal@tikz@replacement@opt@#1#2{%
+ \tikzexternal@tikz@replacement@opt@process{#1}{#2}%
+}%
+\def\tikzexternal@tikz@replacement@opt@@#1{%
+ \def\tikz@next{\tikzexternal@tikz@replacement@collectnormalsemicolon{#1}}%
+ \ifnum\the\catcode`\;=\active\relax%
+ \def\tikz@next{\tikzexternal@tikz@replacement@collectactivesemicolon{#1}}%
+ \fi%
+ \tikz@next}
+\long\def\tikzexternal@tikz@replacement@collectnormalsemicolon#1#2;{%
+ \tikzexternal@tikz@replacement@opt@process{#1}{#2;}%
+}%
+{
+ \catcode`\;=\active
+ \long\gdef\tikzexternal@tikz@replacement@collectactivesemicolon#1#2;{%
+ \tikzexternal@tikz@replacement@opt@process{#1}{#2;}%
+ }
+}
+\long\def\tikzexternal@tikz@replacement@opt@process#1#2{%
+ \begingroup
+ \t@tikzexternal@tmpa=\expandafter{\tikzexternal@TEXDIALECT@begpicture[#1]#2}%
+ \t@tikzexternal@tmpb=\expandafter{\tikzexternal@TEXDIALECT@endpicture}%
+ \xdef\pgf@tempa{\the\t@tikzexternal@tmpa\the\t@tikzexternal@tmpb}%
+ \endgroup
+ \pgf@tempa
+}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\def\tikzexternal@getnextfilename@advancecount{%
+ \begingroup
+ \c@pgf@counta=\csname c@tikzext@no@\tikzexternal@figurename\endcsname\relax
+ \advance\c@pgf@counta by1
+ \expandafter\xdef\csname c@tikzext@no@\tikzexternal@figurename\endcsname{\the\c@pgf@counta}%
+ \endgroup
+}%
+
+% Returns the file name which will be used for the next tikzpicture (based on the currently available information only, of course).
+\def\tikzexternalgetnextfilename#1{%
+ \begingroup
+ \let\tikzexternal@getnextfilename@advancecount\relax% NOP
+ \let\tikzexternal@getnextfilename@resetglobals=\relax% NOP
+ \def\tikzexternal@protocol@to@file##1{}% NOP
+ \tikzexternal@getnextfilename#1%
+ \pgfmath@smuggleone#1%
+ \endgroup
+}%
+
+% Returns the file name of the current picture.
+%
+% It returns the empty string in case the command is invoked outside
+% of a picture.
+% #1 the macro which will contain the file name.
+% @see \tikzexternalgetnextfilename
+\def\tikzexternalgetcurrentfilename#1{%
+ \ifx\tikzexternal@curfilename\relax
+ % we are outside of a picture.
+ \let#1=\pgfutil@empty
+ \else
+ % we are inside of a picture.
+ \let#1=\tikzexternal@curfilename
+ \fi
+}
+
+% Fills #1 with a filename for the current picture.
+%
+% The filename will be generated automatically by appending '-figure<number>' to the real jobname.
+%
+% This method deals with
+% - \tikzsetnextfilename
+% - \tikzexternalexportnextfalse
+%
+% It returns #1={} if the current figure shall NOT be exported.
+%
+% Please note that both, \tikzsetnextfilename and \tikzexternalexportnextfalse
+% affect only ONE picture. They will be reset afterwards.
+\def\tikzexternal@getnextfilename#1{%
+ \let#1=\pgfutil@empty
+ % determine next file name:
+ \iftikzexternal@export@enabled
+ \iftikzexternalexportnext
+ \begingroup
+ \t@tikzexternal@tmpa=\expandafter{\tikzexternal@filenameprefix}%
+ \ifx\tikzexternal@nextfile\pgfutil@empty
+ \iftikzexternal@onlynamed
+ \xdef\pgf@tempa{}%
+ \else
+ \pgfkeysgetvalue{/tikz/external/figure name}\tikzexternal@figurename
+ \pgfutil@ifundefined{c@tikzext@no@\tikzexternal@figurename}{%
+ % initialise on first usage:
+ \expandafter\gdef\csname c@tikzext@no@\tikzexternal@figurename\endcsname{0}%
+ }{}%
+ \t@tikzexternal@tmpb=\expandafter{\tikzexternal@figurename}%
+ \xdef\pgf@tempa{\the\t@tikzexternal@tmpa\the\t@tikzexternal@tmpb\csname c@tikzext@no@\tikzexternal@figurename\endcsname}%
+ % advance the counter for 'figure name':
+ \tikzexternal@getnextfilename@advancecount
+ \fi
+ \else
+ \t@tikzexternal@tmpb=\expandafter{\tikzexternal@nextfile}%
+ \xdef\pgf@tempa{\the\t@tikzexternal@tmpa\the\t@tikzexternal@tmpb}%
+ \fi
+ \endgroup
+ \let#1=\pgf@tempa
+ \fi
+ \fi
+ %
+ \tikzexternal@getnextfilename@resetglobals%
+ %
+ \tikzexternal@protocol@to@file#1%
+}%
+
+\def\tikzexternal@getnextfilename@resetglobals{%
+ % Reset global flags:
+ \global\let\tikzexternal@nextfile=\pgfutil@empty
+ \global\tikzexternalexportnexttrue
+}%
+
+% #1: the image file name which should be protocolled. (can be a
+% macro)
+\def\tikzexternal@protocol@to@file#1{%
+ \ifpgf@external@grabshipout%
+ \else
+ \iftikzexternal@genfigurelist
+ \edef\tikzexternal@temp{#1}%
+ \ifx\tikzexternal@temp\pgfutil@empty
+ \else
+ \pgfutil@ifundefined{tikzexternal@listmode@openedfile}{%
+ \message{Opening '\tikzexternal@realjob.figlist' for writing.}%
+ \begingroup
+ \globaldefs=1
+ % this gets round '\outer\newwrite' in plain TeX:
+ \csname newwrite\endcsname\tikzexternal@outfile
+ \endgroup
+ \immediate\openout\tikzexternal@outfile=\tikzexternal@realjob.figlist\relax
+ \gdef\tikzexternal@listmode@openedfile{1}%
+ \if\tikzexternal@opmode5% mode='list and make'
+ \tikzexternal@list@and@make@prepare
+ \fi
+ }{}%
+ \iftikzexternal@verboseio
+ \pgf@typeout{Writing '#1' to '\tikzexternal@realjob.figlist'.}%
+ \fi
+ \immediate\write\tikzexternal@outfile{#1}%
+ \if\tikzexternal@opmode5% mode='list and make'
+ \tikzexternal@list@and@make@gentarget{#1}%
+ \fi
+ \fi
+ \fi
+ \fi
+}%
+
+\def\tikzexternal@list@and@make@gentarget#1{%
+ \tikzexternal@assemble@systemcall{#1}{\pgf@tempa}%
+ \def\tikzexternal@tempb{\pgfutilstrreplace{^^J}{^^J\tikzexternal@TABchar}}%
+ \expandafter\tikzexternal@tempb\expandafter{\pgf@tempa}%
+ \let\pgf@tempa=\pgfretval
+ \iftikzexternal@verboseio
+ \pgf@typeout{Writing '#1' to '\tikzexternal@realjob.makefile'.}%
+ \fi
+ \global\tikzexternal@file@isuptodatetrue% only check for force remake:
+ \tikzexternal@checkforceremake%
+ \immediate\write\tikzexternal@outmakefile{#1\tikzexternalimgextension: \iftikzexternal@file@isuptodate\else FORCEREMAKE\fi}%
+ \immediate\write\tikzexternal@outmakefile{\tikzexternal@TABchar\pgf@tempa}%
+ \immediate\write\tikzexternal@outmakefile{}%
+}
+
+\def\tikzexternal@list@and@make@prepare{%
+ \iftikzexternal@verboseio
+ \pgf@typeout{Opening '\tikzexternal@realjob.makefile' for writing.}%
+ \fi
+ \begingroup
+ % this makes \tikzexternal@outmakefile global:
+ \globaldefs=1
+ % this gets round '\outer\newwrite' in plain TeX:
+ \csname newwrite\endcsname\tikzexternal@outmakefile
+ \endgroup
+ \immediate\openout\tikzexternal@outmakefile=\tikzexternal@realjob.makefile\relax
+ \immediate\write\tikzexternal@outmakefile{ALL_FIGURE_NAMES=\tikzexternal@DOLLARchar(shell cat \tikzexternal@realjob.figlist)}%
+ \immediate\write\tikzexternal@outmakefile{ALL_FIGURES=\tikzexternal@DOLLARchar(ALL_FIGURE_NAMES:\tikzexternal@PERCENTchar=\tikzexternal@PERCENTchar\tikzexternalimgextension)}%
+ \immediate\write\tikzexternal@outmakefile{}%
+ \immediate\write\tikzexternal@outmakefile{allimages: \tikzexternal@DOLLARchar(ALL_FIGURES)}%
+ \immediate\write\tikzexternal@outmakefile{\tikzexternal@TABchar @echo All images exist now. Use make -B to re-generate them.}%
+ \immediate\write\tikzexternal@outmakefile{}%
+ \immediate\write\tikzexternal@outmakefile{FORCEREMAKE:}%
+ \immediate\write\tikzexternal@outmakefile{}%
+ %
+ % support for .dep files and auto-dependencies:
+ \immediate\write\tikzexternal@outmakefile{-include $(ALL_FIGURE_NAMES:\tikzexternal@PERCENTchar=\tikzexternal@PERCENTchar.\tikzexternaldepext)}%
+ \immediate\write\tikzexternal@outmakefile{}%
+ \tikzexternalmakefiledefaultdeprule
+ \immediate\write\tikzexternal@outmakefile{}%
+ \tikzexternal@outmakefile@pendingcommands
+ \pgfutil@ifundefined{AtEndDocument}{}{%
+ \AtEndDocument{\pgf@typeout{===== mode=`list and make': Use 'make -f \tikzexternal@realjob.makefile' to generate all images. Then, re-run (pdf)latex \tikzexternal@realjob. =====}}%
+ }%
+}%
+\def\tikzexternaldepext{dep}
+
+\def\tikzexternalmakefiledefaultdeprule{%
+ \immediate\write\tikzexternal@outmakefile{\tikzexternal@PERCENTchar.\tikzexternaldepext:}%
+ \immediate\write\tikzexternal@outmakefile{\tikzexternal@TABchar mkdir -p \tikzexternal@normal@dq $(dir $@)\tikzexternal@normal@dq}%
+ \immediate\write\tikzexternal@outmakefile{\tikzexternal@TABchar touch \tikzexternal@normal@dq $@\tikzexternal@normal@dq\space \tikzexternal@HASHchar\space will be filled later.}%
+}%
+
+% Invokes '#1' if a makefile is to be written and '#2' if not.
+\def\tikzexternalifwritesmakefile#1#2{%
+ \if5\tikzexternal@opmode #1\else #2\fi
+}%
+\def\tikzexternal@outmakefile@pendingcommands{}%
+
+% Will write something to the make file. If the makefile is not yet
+% opened, #1 will be written as soon as it *is* opened.
+\def\tikzexternalwritetomakefile#1{%
+ \if\tikzexternal@opmode5% mode='list and make'
+ \pgfutil@ifundefined{tikzexternal@outmakefile}{%
+ \expandafter\gdef\expandafter\tikzexternal@outmakefile@pendingcommands\expandafter{%
+ \tikzexternal@outmakefile@pendingcommands
+ \immediate\write\tikzexternal@outmakefile{#1}%
+ }%
+ }{%
+ \immediate\write\tikzexternal@outmakefile{#1}%
+ }%
+ \fi
+}%
+
+\def\tikzexternal@dep@file@name{}
+
+% Adds a dependency for the externalized picture file name `#1',
+% namely another file `#2'.
+%
+% #1: the fully qualified path name (without image extension) of the
+% external graphics for which we are adding a dependency.
+% #2: a file name. If this file gets changed, #1 shall be remade.
+%
+% This command will be activated as soon as \tikzexternalize has been
+% called.
+\def\tikzexternalfiledependsonfile@ACTIVE#1#2{%
+ \begingroup
+ \def\tikzpicturedependsonfile@name{#1}%
+ \ifx\tikzpicturedependsonfile@name\pgfutil@empty
+ % could be auto-generated: empty file name means "picture
+ % won't be externalized". Skip it.
+ \else
+ % if we encounter any dependencies while we externalize a
+ % picture, we have to write these things into the image's .dep
+ % file.
+ \tikzifexternalizingcurrent
+ {\tikzexternalfiledependsonfile@append@to@dep@file{#1}{#2}}%
+ {\tikzexternalfiledependsonfile@append@to@makefile{#1}{#2}}%
+ \fi
+ \endgroup
+}%
+\def\tikzexternalfiledependsonfile#1#2{}% NO-OP until \tikzexternalize has been called.
+
+% sub-routine of \tikzexternalfiledependsonfile which appends stuff to
+% the pictures .dep file.
+%
+% The file #1.dep is generated during the externalization of #1. If
+% you change and/or overwrite it in any other context, its information
+% might get lost (because #1 won't be regenerated).
+%
+% Consequently, this here has to be called if and only if #1 is about
+% to be externalized.
+\def\tikzexternalfiledependsonfile@append@to@dep@file#1#2{%
+ % write every dependency which is defined *INSIDE* of the current
+ % picture into the .dep file of the current picture:
+ \tikzexternalgetcurrentfilename\tikzpicturedependsonfile@name
+ \edef\tikzpicturedependsonfile@name{\tikzpicturedependsonfile@name.\tikzexternaldepext}%
+ %\edef\tikzpicturedependsonfile@name{#1.\tikzexternaldepext}%
+ \ifx\tikzexternal@dep@file@name\tikzpicturedependsonfile@name
+ % file is open and ready.
+ \else
+ % create new output file.
+ \pgfutil@ifundefined{tikzexternal@dep@file}{%
+ \begingroup
+ % this makes \tikzexternal@dep@file global:
+ \globaldefs=1
+ % this gets round '\outer\newwrite' in plain TeX:
+ \csname newwrite\endcsname\tikzexternal@dep@file
+ \endgroup
+ }{}%
+ \ifx\tikzexternal@dep@file@name\pgfutil@empty
+ \else
+ % it is already open. Close it.
+ \immediate\closeout\tikzexternal@dep@file
+ \fi
+ \global\let\tikzexternal@dep@file@name=\tikzpicturedependsonfile@name
+ \immediate\openout\tikzexternal@dep@file=\tikzexternal@dep@file@name\relax
+ \fi
+ \immediate\write\tikzexternal@dep@file{#1\tikzexternalimgextension: #2}%
+}
+
+% sub-routine of \tikzexternalfiledependsonfile which appends stuff to
+% the makefile of the current \jobname .
+%
+% This is used for dependencies which are recomputed by every run of
+% tex; we must not write them into #1.dep (for reasons explained in
+% the documentation of
+% \tikzexternalfiledependsonfile@append@to@dep@file)
+\def\tikzexternalfiledependsonfile@append@to@makefile#1#2{%
+ \edef\tikzexternal@temp{#1\tikzexternalimgextension: #2}%
+ \expandafter\tikzexternalwritetomakefile\expandafter{\tikzexternal@temp}%
+}
+
+% Adds a dependency for the NEXT picture which is about to be
+% externalized. If we are currently inside of a picture, the
+% dependency is added for this current picture.
+%
+% #1: a file name. If this file gets changed, the tikzpicture's
+% externalized graphics shall be remade.
+%
+% This command will be activated as soon as \tikzexternalize has been
+% called.
+\def\tikzpicturedependsonfile@ACTIVE#1{%
+ \begingroup
+ \tikzexternalgetcurrentfilename\tikzpicturedependsonfile@name
+ \ifx\tikzpicturedependsonfile@name\pgfutil@empty
+ \tikzexternalgetnextfilename\tikzpicturedependsonfile@name
+ \fi
+ \expandafter\tikzexternalfiledependsonfile\expandafter{\tikzpicturedependsonfile@name}{#1}%
+ \endgroup
+}%
+\def\tikzpicturedependsonfile#1{}% NO-OP until \tikzexternalize has been called.
+
+
+% This command is invoked
+% if and only if ( (grab mode && --jobname matches) || 'mode=graphics if exists' )
+%
+% It converts the current tikzpicture into an image in grab mode
+% or processes the 'graphics if exist' mode.
+\def\tikzexternal@externalizefig{%
+ \ifpgf@external@grabshipout%
+ % In this case, we already KNOW that the filename matches.
+ \expandafter\tikzexternal@externalizefig@GRAB%
+ \else
+ \expandafter\tikzexternal@externalizefig@mode@graphics@if@exists
+ \fi%
+}
+\def\tikzexternal@externalizefig@mode@graphics@if@exists{%
+ % check if there is already a file.
+ % In that case, use it. If not, typeset the picture normally.
+ \gdef\pgf@filename{}%
+ \xdef\pgf@tempa{\noexpand\pgf@findfile\pgfsys@imagesuffixlist:+{\tikzexternal@curfilename}}%
+ \pgf@tempa
+ \ifx\pgf@filename\pgfutil@empty%
+ % Note: since we have no 'GRAB' mode, we do not have to deal with optimization.
+ % there is no graphics.
+ \expandafter\tikzexternal@normalpicture@nographics
+ \else
+ \expandafter\tikzexternal@forcegraphics
+ \fi
+}%
+
+
+% Used by the optimization code.
+% It will be called if GRAB mode is on.
+% See the 'optimize command away' key.
+\def\tikzexternal@optimize@away@cmd#1#2{%
+ \pgfutil@ifnextchar[{%
+ \tikzexternal@optimize@away@cmd@{#1}{#2}%
+ }{%
+ \tikzexternal@optimize@away@cmd@{#1}{#2}[]%
+ }%
+}%
+\def\tikzexternal@optimize@away@cmd@#1#2[#3]{%
+ \def\tikz@temp{#2}%
+ \ifx\tikz@temp\pgfutil@empty
+ \def\tikz@temp{\tikzexternal@optimize@away@cmd@auto{#1}{#3}}%
+ \else
+ \ifcase#2\relax
+ \def\tikzexternal@optimize@away@cmd@manual{%
+ \tikzexternal@optimize@away@cmd@@@{#1}{#3}{}%
+ }%
+ \or
+ \def\tikzexternal@optimize@away@cmd@manual##1{%
+ \tikzexternal@optimize@away@cmd@@@{#1}{#3}{{##1}}%
+ }%
+ \or
+ \def\tikzexternal@optimize@away@cmd@manual##1##2{%
+ \tikzexternal@optimize@away@cmd@@@{#1}{#3}{{##1}{##2}}%
+ }%
+ \or
+ \def\tikzexternal@optimize@away@cmd@manual##1##2##3{%
+ \tikzexternal@optimize@away@cmd@@@{#1}{#3}{{##1}{##2}{##3}}%
+ }%
+ \or
+ \def\tikzexternal@optimize@away@cmd@manual##1##2##3##4{%
+ \tikzexternal@optimize@away@cmd@@@{#1}{#3}{{##1}{##2}{##3}{##4}}%
+ }%
+ \or
+ \def\tikzexternal@optimize@away@cmd@manual##1##2##3##4##5{%
+ \tikzexternal@optimize@away@cmd@@@{#1}{#3}{{##1}{##2}{##3}{##4}{##5}}%
+ }%
+ \or
+ \def\tikzexternal@optimize@away@cmd@manual##1##2##3##4##5##6{%
+ \tikzexternal@optimize@away@cmd@@@{#1}{#3}{{##1}{##2}{##3}{##4}{##5}{##6}}%
+ }%
+ \or
+ \def\tikzexternal@optimize@away@cmd@manual##1##2##3##4##5##6##7{%
+ \tikzexternal@optimize@away@cmd@@@{#1}{#3}{{##1}{##2}{##3}{##4}{##5}{##6}{##7}}%
+ }%
+ \or
+ \def\tikzexternal@optimize@away@cmd@manual##1##2##3##4##5##6##7##8{%
+ \tikzexternal@optimize@away@cmd@@@{#1}{#3}{{##1}{##2}{##3}{##4}{##5}{##6}{##7}{##8}}%
+ }%
+ \or
+ \def\tikzexternal@optimize@away@cmd@manual##1##2##3##4##5##6##7##8##9{%
+ \tikzexternal@optimize@away@cmd@@@{#1}{#3}{{##1}{##2}{##3}{##4}{##5}{##6}{##7}{##8}{##9}}%
+ }%
+ \fi
+ \def\tikz@temp{\tikzexternal@optimize@away@cmd@manual}%
+ \fi
+ \tikz@temp
+}%
+\def\tikzexternal@optimize@away@cmd@auto#1#2{%
+ \pgfutil@ifnextchar\bgroup{%
+ \tikzexternal@optimize@away@cmd@auto@{#1}{#2}%
+ }{%
+ \tikzexternal@optimize@away@cmd@auto@{#1}{#2}{<no argument in curly braces>}% give empty argument.
+ }
+}%
+
+\def\tikzexternal@optimize@away@cmd@auto@#1#2#3{%
+ \tikzexternal@optimize@away@cmd@@@{#1}{#2}{{#3}}% <-- provide braces
+}%
+\def\tikzexternal@optimize@away@cmd@@@#1#2#3{%
+ \begingroup
+ \toks0={#1[#2]#3}%
+ \iftikzexternal@verbose@optimize
+ \pgf@typeout{The command '\the\toks0' has been optimized away. Use '/tikz/external/optimize=false' to disable this.}%
+ \fi
+ \endgroup
+ \begingroup
+ \pgfkeysvalueof{/tikz/external/optimize away text/.@cmd}#1\pgfeov%
+ \endgroup
+}%
+
+\def\tikzexternal@optimize@away@latex@env#1{%
+ \def\tikzexternal@optimize@away@latex@env@{#1}%
+ \begingroup
+ \def\tikzexternal@laTeX@collect@until@end@tikzpicturetikzpicturestring{#1}%
+ \tikzexternal@TEXDIALECT@collectpicture\tikzexternal@optimize@away@latex@env@close
+}%
+\long\def\tikzexternal@optimize@away@latex@env@close#1{%
+ \iftikzexternal@verbose@optimize
+ \pgf@typeout{The complete contents of \string\begin{tikzexternal@optimize@away@latex@env@} up to the next \end{tikzexternal@optimize@away@latex@env@} has been optimized away because it does not contribute to the exported PDF. Use '/tikz/external/optimize=false' to disable this.}%
+ \fi
+ \endgroup
+ % we still need to invoke \end{<name>} in latex because \begin{<name>}
+ % starts a local group - that must be closed properly. Make sure then \end<name> does nothing:
+ \expandafter\let\csname end\tikzexternal@optimize@away@latex@env@\endcsname=\relax
+ \expandafter\end\expandafter{\tikzexternal@optimize@away@latex@env@}%
+}%
+
+\def\tikzexternal@optimize@REPLACE{%
+ \pgfkeysvalueof{/tikz/external/optimize/install/.@cmd}\pgfeov
+}%
+
+\def\tikzexternal@optimize@RESTORE{%
+ \pgfkeysvalueof{/tikz/external/optimize/restore/.@cmd}\pgfeov
+}%
+
+% Closes one 'tikzpicture' environment. This is only used for LaTeX,
+% because the '\end{tikzpicture}' command would raise an exception otherwise.
+% It does *not* call \endtikzpicture.
+\def\tikzexternal@closeenvironments{%
+ \let\endtikzpicture=\relax
+ \tikzexternal@TEXDIALECT@endpicture
+ \let\endtikzpicture=\tikzexternal@origendpicture
+ \let\tikzexternal@curfilename=\relax
+}
+
+% Throws a tikzpicture away - without further notice.
+% Used if we are currently converting *another* picture. No need to waste time
+% with expensive pictures if they are not shipped out anyway.
+%
+% See the 'optimize' key to disable this.
+\def\tikzexternal@skipfigure{%
+ \tikzexternal@TEXDIALECT@collectpicture\tikzexternal@skipfigure@@
+}
+\long\def\tikzexternal@skipfigure@@#1{%
+ \iftikzexternal@verbose@optimize
+ \pgf@typeout{A tikzpicture has been optimized away. Use '/tikz/external/optimize=false' to disable this.}%
+ \fi
+ \tikzexternal@closeenvironments
+ \pgfkeysvalueof{/tikz/external/optimize away text/.@cmd}tikzpicture\pgfeov%
+}
+
+% Processes tikzpicture normally; without any externalization.
+%
+% We need to do further work here to deal with NESTED tikzpicture environments
+% because all of them shall also be typeset normally.
+%
+% Idea:
+% 1. restore the original \tikzpicture macro
+% 2. install the replacement \tikzpicture in \end{tikzpicture}.
+% and keep track of nesting.
+%
+% FIXME: could it be possible that nested tikzpictures use other code anyway?
+\def\tikzexternal@normalpicture@nographics{%
+ \tikzexternal@nestedflagfalse
+ \let\tikzpicture=\tikzexternal@normalpicture@begreplace
+ \let\endtikzpicture=\tikzexternal@normalpicture@endreplace
+ \tikzpicture
+}
+\def\tikzexternal@normalpicture@begreplace{%
+ \begingroup
+ \tikzexternal@nestedflagtrue
+ \tikzexternal@origpicture
+}
+\def\tikzexternal@normalpicture@endreplace{%
+ \tikzexternal@origendpicture
+ \endgroup
+ \iftikzexternal@nestedflag
+ \else
+ \let\tikzpicture=\tikzexternal@tikzpicture@replacement
+ \let\endtikzpicture=\tikzexternal@origendpicture
+ \fi
+}%
+
+% Assumes there is an image on disk and reads it. The tikzpicture is thrown away.
+\def\tikzexternal@forcegraphics{%
+ \tikzexternal@TEXDIALECT@collectpicture\tikzexternal@forcegraphics@@
+}
+\long\def\tikzexternal@forcegraphics@@#1{\tikzexternal@forcegraphics@@@}%
+\def\tikzexternal@forcegraphics@@@{%
+ \if5\tikzexternal@opmode
+ \let\tikz@refundefinedtrue@@=\G@refundefinedtrue
+ \gdef\G@refundefinedtrue{%
+ \tikz@refundefinedtrue@@
+ \tikzexternal@forceremake@undefined@reference@handler
+ }%
+ \fi
+ \expandafter\pgfincludeexternalgraphics\expandafter{\tikzexternal@curfilename}%
+ \if5\tikzexternal@opmode
+ \global\let\G@refundefinedtrue=\tikz@refundefinedtrue@@
+ \fi
+ \tikzexternal@closeenvironments
+}
+
+\def\tikzexternal@forceremake@undefined@reference@handler{%
+ \pgf@typeout{===== 'mode=list and make': encountered undefined reference in current picture. Adding dependency to FORCEREMAKE. Rerun make to update the picture.' ========^^J}%
+ \tikzpicturedependsonfile{FORCEREMAKE}%
+}%
+
+% Simply replaces the complete picture by some placeholder text.
+% It is used by 'mode=list only' to reduce runtime.
+\def\tikzexternal@listmodepicture{%
+ \tikzexternal@TEXDIALECT@collectpicture\tikzexternal@listmodepicture@@
+}
+\long\def\tikzexternal@listmodepicture@@#1{\tikzexternal@listmodepicture@@@}
+\def\tikzexternal@listmodepicture@@@{%
+ \pgfkeysvalueof{/tikz/external/image discarded text}%
+ \tikzexternal@closeenvironments
+}
+
+% check if there is already a file.
+% In that case, use it. If not, skip it.
+\def\tikzexternal@list@and@makefile@mode@picture{%
+ \tikzexternal@TEXDIALECT@collectpicture\tikzexternal@list@and@makefile@mode@picture@
+}%
+\long\def\tikzexternal@list@and@makefile@mode@picture@#1{%
+ %
+ \tikzexternal@check@uptodate@mode{#1}%
+ %
+ \gdef\pgf@filename{}%
+ \xdef\pgf@tempa{\noexpand\pgf@findfile\pgfsys@imagesuffixlist:+{\tikzexternal@curfilename}}%
+ \pgf@tempa
+ \ifx\pgf@filename\pgfutil@empty%
+ % Note: since we have no 'GRAB' mode, we do not have to deal with optimization.
+ % there is no graphics.
+ \expandafter\tikzexternal@listmodepicture@@@
+ \else
+ \expandafter\tikzexternal@forcegraphics@@@
+ \fi
+}%
+
+\def\tikzexternal@externalizefig@before@grab{%
+ \pgfutil@IfUndefined{TP@holdbox}{%
+ }{%
+ % \usepackage[absolute]{textpos}
+ % populates this box -- and would inject unwanted material into our images. Reset it:
+ \global\setbox\TP@holdbox\vbox{}%
+ }%
+}%
+
+\def\tikzexternal@externalizefig@GRAB{%
+ \ifpgf@external@grabshipout
+ \iftikzexternal@optimize
+ \tikzexternal@optimize@RESTORE
+ \fi
+ \tikzexternal@externalizefig@before@grab
+ \fi
+ \def\tikzpicture{%
+ \def\tikzpicture{% make sure that nested \tikzpicture are processed normally.
+ \begingroup
+ \def\endtikzpicture{%
+ \tikzexternal@origendpicture
+ \endgroup
+ }%
+ \tikzexternal@origpicture
+ }%
+ \pgf@external@grab{\tikzexternal@curfilename}%
+ \tikzexternal@origpicture
+ }%
+ \def\endtikzpicture{%
+ \tikzexternal@origendpicture
+ \pgf@externalend
+ %
+ \tikzexternal@ensure@nonempty@floats
+ %
+ \let\tikzpicture=\tikzexternal@tikzpicture@replacement
+ \let\endtikzpicture=\tikzexternal@origendpicture
+ \iftikzexternal@optimize
+ \ifpgf@external@grabshipout
+ \tikzexternal@optimize@REPLACE
+ \fi
+ \fi
+ }%
+ \tikzpicture
+}%
+
+% If a sequence of floats containing JUST tikzpictures is
+% externalized, this results in EMPTY floats. Empty floats, in turn,
+% can confuse latex; it thinks it did something wrong.
+%
+% Solution: Avoid empty floats by writing junk into it.
+%
+% Note that this method is only invoked if \ifpgf@external@grabshipout
+% is true and if the text is OUTSIDE of the original shipout routine.
+% In other words: this text is being thrown away.
+%
+% see
+% http://tex.stackexchange.com/questions/54625/why-is-fixltx2e-incompatible-with-tikzexternalize
+\def\tikzexternal@ensure@nonempty@floats{%
+ tikzexternal: picture has been externalized. This text is required to avoid empty floats.
+}%
+
+% 1. Discards the current picture in this document.
+% 2. Checks whether an image exists already. If that is the case: acquire it.
+% 3. If no image exists: call '/tikz/external/system call'. This will
+% process \tikzexternal@externalizefig.
+% 4. Assert that finally an image exists and use it.
+\def\tikzexternal@externalizefig@systemcall{%
+ \tikzexternal@TEXDIALECT@collectpicture\tikzexternal@externalizefig@systemcall@@
+}
+
+{
+\catcode`\"=12
+\catcode`\'=12
+\catcode`\;=12
+\catcode`\&=12
+\catcode`\-=12
+\xdef\tikzexternal@normal@dq{"}
+\xdef\tikzexternal@normal@sq{'}
+\xdef\tikzexternal@normal@semic{;}
+\xdef\tikzexternal@normal@and{&}
+\xdef\tikzexternal@normal@dash{-}
+\catcode`\"=13
+\catcode`\'=13
+\catcode`\;=13
+\catcode`\&=13
+\catcode`\-=13
+\gdef\tikzexternal@activate@normal@dq{\let"=\tikzexternal@normal@dq}
+\gdef\tikzexternal@activate@normal@sq{\let'=\tikzexternal@normal@sq}
+\gdef\tikzexternal@activate@normal@semic{\let;=\tikzexternal@normal@semic}
+\gdef\tikzexternal@activate@normal@and{\let&=\tikzexternal@normal@and}
+\gdef\tikzexternal@activate@normal@dash{\let-=\tikzexternal@normal@dash}
+\catcode`\|=0
+\catcode`\\=12
+|xdef|tikzexternal@normal@backslash{\}%
+}
+{
+\catcode`\^^I=12
+\catcode`\$=12
+\catcode`\%=12
+\catcode`\#=12
+\gdef\tikzexternal@HASHchar{#}
+\gdef\tikzexternal@TABchar{^^I}\gdef\tikzexternal@PERCENTchar{%}\xdef\tikzexternal@DOLLARchar{$}}
+
+% Creates the '/tikz/external/system call' command as string and
+% returns it into the (global!) macro #2.
+% #1: the image file name (as returned by
+% \tikzexternalgetnextfilename)
+% #2: the global return value macro
+%
+\def\tikzexternal@assemble@systemcall#1#2{%
+ \begingroup
+ \def\image{#1}%
+ \iftikzexternal@auto@detect@jobname
+ \edef\texsource{\string\def\string\tikzexternalrealjob{\tikzexternal@realjob}\string\input{\tikzexternal@realjob}}%
+ \else
+ \let\texsource=\tikzexternal@realjob
+ \fi
+ \ifnum\the\catcode`\"=13 \tikzexternal@activate@normal@dq\fi
+ \ifnum\the\catcode`\'=13 \tikzexternal@activate@normal@sq\fi
+ \ifnum\the\catcode`\;=13 \tikzexternal@activate@normal@semic\fi
+ \ifnum\the\catcode`\-=13 \tikzexternal@activate@normal@dash\fi
+ \let\\=\tikzexternal@normal@backslash
+ \xdef#2{\pgfkeysvalueof{/tikz/external/system call}}%
+ \endgroup
+}%
+\long\def\tikzexternal@externalizefig@systemcall@@#1{%
+ \tikzexternal@externalizefig@systemcall@uptodatecheck{#1}%
+ \tikzexternal@assemble@systemcall{\tikzexternal@curfilename}{\pgf@tempa}%
+ \global\let\tikzexternal@cursyscall=\pgf@tempa
+ \gdef\tikzexternal@typeset@picture@on@failure{1}%
+ \iftikzexternal@file@isuptodate
+ \iftikzexternal@verboseio
+ \pgf@typeout{===== Image '\tikzexternal@curfilename' is up-to-date. ======}%
+ \fi
+ \let\pgf@filename=\tikzexternal@curfilename
+ \else
+ \begingroup
+ % no such image. Generate it!
+ %
+ \tikzexternalauxlock@setlock1%
+ \tikzexternal@externalizefig@systemcall@call{\tikzexternal@cursyscall}%
+ \tikzexternalauxlock@setlock0%
+ \expandafter\tikzexternal@externalizefig@systemcall@assertsuccess\expandafter{\tikzexternal@cursyscall}%
+ \pgfmath@smuggleone\pgf@filename
+ \endgroup
+ \fi
+ \ifx\pgf@filename\pgfutil@empty
+ \if1\tikzexternal@typeset@picture@on@failure
+ % error recovery: something did not work! Try to load it
+ % anyway. Perhaps it was just that shell-escape wasn't
+ % enabled.
+ \begingroup
+ \toks0={%
+ \tikzexternaldisable
+ }%
+ % FIXME : THIS WILL FAIL IF THERE IS '##' INSIDE OF '#1'!
+ % for example something like /.style={#1} in the picture environment *will* fail.
+ \toks1={%
+ \tikzpicture
+ #1%
+ }%
+ \toks2={%
+ \tikzexternal@TEXDIALECT@endpicture
+ \tikzexternalenable
+ }%
+ \xdef\tikzexternal@externalizefig@systemcall@next{%
+ \the\toks0
+ % try reading them again as if they were in the input file.
+ \noexpand\scantokens{\the\toks1 }%
+ \the\toks2
+ }%
+ \endgroup
+ \else
+ % Ah -- this picture failed, but the failure has already
+ % been handled somehow. Do not typeset it again!
+ %
+ % A use-case is that the picture has been rescheduled for
+ % \end{document}.
+ \gdef\tikzexternal@externalizefig@systemcall@next{\tikzexternal@closeenvironments}%
+ \fi
+ \else
+ % ok, take the image!
+ \gdef\tikzexternal@systemcall@reschedule@to@end@document{0}%
+ \expandafter\pgfincludeexternalgraphics\expandafter{\tikzexternal@curfilename}%
+ \if1\tikzexternal@systemcall@reschedule@to@end@document
+ \pgfutil@IfUndefined{AtVeryEndDocument}{%
+ }{%
+ \pgf@typeout{===== The previous system call resulted in undefined references inside of the output file. Rescheduling it for \string\end{document}. ========}%
+ \expandafter\tikzexternal@externalizefig@systemcall@reschedule\expandafter{\tikzexternal@cursyscall}%
+ }%
+ \fi
+ \gdef\tikzexternal@externalizefig@systemcall@next{\tikzexternal@closeenvironments}%
+ \fi
+ \tikzexternal@externalizefig@systemcall@next
+}%
+
+\def\tikzexternal@externalizefig@systemcall@call#1{%
+ \iftikzexternal@verboseio
+ \pgf@typeout{===== 'mode=convert with system call': Invoking '#1' ========}%
+ \fi
+ \pgfutil@shellescape{#1}%
+}%
+
+% Sets \iftikzexternal@file@isuptodate to false if one of the "force
+% remake" things is active.
+\def\tikzexternal@checkforceremake{%
+ \iftikzexternal@force@remake
+ \global\tikzexternal@file@isuptodatefalse
+ \else
+ \iftikzexternalremakenext
+ \global\tikzexternal@file@isuptodatefalse
+ \global\tikzexternalremakenextfalse
+ \fi
+ \fi
+}
+
+\pgfutil@IfUndefined{pdfmdfivesum}{%
+}{%
+ % predefine to this value. This does only make sense for pdftex.
+ % note that the latex library for 'external' loads \usepackage{pdftexcmds} which \let's this to \pdf@mdfivesum:
+ \let\tikzexternal@mdfivesum=\pdfmdfivesum
+}%
+
+\long\def\tikzexternal@computemdfivesum#1{%
+ \t@tikzexternal@tmpb={#1}%
+ \edef\tikzexternal@temp{\the\t@tikzexternal@tmpb}%
+ % \meaning results in a string of catcode 12 - which is expandable.
+ \edef\pgfretval{\tikzexternal@mdfivesum{\meaning\tikzexternal@temp}}%
+}
+\long\def\tikzexternal@computemdfivesum@diff@fallback#1{%
+ \t@tikzexternal@tmpb={#1}%
+ \edef\tikzexternal@temp{\the\t@tikzexternal@tmpb}%
+ % \meaning results in a string of catcode 12 - which is expandable.
+ \edef\pgfretval{\meaning\tikzexternal@temp}%
+}
+
+% Will be set dynamically, depending on 'up to date check'.
+%
+% It expands to code such that \tikzexternallastkey contains the
+% serialized version of '#1'.
+%
+% It is used as argument for \write{..}
+%
+% #1 the hash key to serialize.
+% \def\tikzexternal@hashfct@serialize
+\long\def\tikzexternal@hashfct@serialize@std#1{%
+ \noexpand\def\noexpand\tikzexternallastkey{#1}%
+}%
+
+% serializes using temporary token registers. Necessary if #1 contains
+% executable code.
+\long\def\tikzexternal@hashfct@serialize@tok#1{%
+ \noexpand\begingroup
+ % in order to allow '#' inside of the body, we have to use token registers:
+ \noexpand\toks0={#1}%
+ \noexpand\xdef\noexpand\tikzexternallastkey{\noexpand\the\noexpand\toks0 }%
+ \noexpand\endgroup
+}%
+
+\def\tikzexternal@check@uptodate@ext{.md5}
+
+\def\tikzexternal@check@uptodate@mode@warn@fallback{%
+ \message{Package tikz Warning: The key 'up to date check=md5' is impossible, there is no macro to compute MD5. Falling back to 'up to date check=diff'.}%
+ %
+ % warn only once:
+ \global\let\tikzexternal@check@uptodate@mode@warn@fallback=\relax
+}%
+
+% assigns the boolean \iftikzexternal@file@isuptodate
+\long\def\tikzexternal@check@uptodate@mode#1{%
+ \if1\tikzexternal@uptodate@mode
+ % up to date check=md5:
+ % check if we CAN compute MD5 sums:
+ \pgfutil@IfUndefined{tikzexternal@mdfivesum}{%
+ % we cannot compute md5 sums - fallback to diff.
+ \tikzexternal@check@uptodate@mode@warn@fallback
+ \def\tikzexternal@uptodate@mode{2}%
+ }{}%
+ \fi
+ %
+ \ifcase\tikzexternal@uptodate@mode
+ % up to date check=simple
+ % nothing to do -- file existence is checked anyway.
+ \let\tikzexternal@hashfct=\pgfutil@empty
+ \let\tikzexternal@hashfct@serialize=\pgfutil@empty
+ \or
+ % up to date check=md5
+ \let\tikzexternal@hashfct=\tikzexternal@computemdfivesum
+ \let\tikzexternal@hashfct@serialize=\tikzexternal@hashfct@serialize@std
+ \or
+ \let\tikzexternal@hashfct=\tikzexternal@computemdfivesum@diff@fallback
+ \let\tikzexternal@hashfct@serialize=\tikzexternal@hashfct@serialize@tok
+ \fi
+ \ifx\tikzexternal@hashfct\pgfutil@empty
+ \else
+ \tikzpicturedependsonfile{\tikzexternal@curfilename\tikzexternal@check@uptodate@ext}%
+ \tikzexternal@hashfct{#1}%
+ \let\tikzexternal@lastkey@new=\pgfretval
+ \begingroup
+ % no '@' token in this macro: avoid messing up the catcodes in input files:
+ \global\let\tikzexternallastkey=\pgfutil@empty
+ \openin\r@pgf@reada=\tikzexternal@curfilename\tikzexternal@check@uptodate@ext\relax %
+ \ifeof\r@pgf@reada
+ \else
+ % read first line...
+ \endlinechar=-1 % older versions did not have a '%' at the end-of-line. Avoid spurious spaces.
+ \read\r@pgf@reada to\pgf@tempa
+ % ... and execute it.
+ \pgf@tempa
+ % it should contain a definition of \tikzexternallastkey.
+ \fi
+ \closein\r@pgf@reada
+ %
+ \let\tikzexternal@lastkey=\tikzexternallastkey
+ \pgfmath@smuggleone\tikzexternal@lastkey
+ \endgroup
+ % normalize catcodes. Unfortunately, they cannot be expected to be the same.
+ % \meaning will use catcode 12 for each token:
+ \edef\tikzexternal@lastkey@normalized{\meaning\tikzexternal@lastkey}%
+ \edef\tikzexternal@lastkey@new@normalized{\meaning\tikzexternal@lastkey@new}%
+ \iftikzexternal@verboseuptodate
+ \pgf@typeout{Up-to-date check of \tikzexternal@curfilename: new \tikzexternal@lastkey@new@normalized; old \tikzexternal@lastkey@normalized.^^J}%
+ \fi
+ \ifx\tikzexternal@lastkey@normalized\tikzexternal@lastkey@new@normalized
+ \tikzexternal@file@isuptodatetrue
+ \else
+ \tikzexternal@file@isuptodatefalse
+ \immediate\openout\w@pgf@writea=\tikzexternal@curfilename\tikzexternal@check@uptodate@ext\relax%
+ \immediate\write\w@pgf@writea{\tikzexternal@hashfct@serialize{\tikzexternal@lastkey@new}\tikzexternal@PERCENTchar}%
+ \immediate\closeout\w@pgf@writea
+ \fi
+ \fi
+}
+
+% Checks whether the current picture needs to be externalized.
+%
+% This is the case if
+% a) there is no external image yet,
+% b) the picture has been invalidated manually.
+%
+% It returns \iftikzexternal@file@isuptodate accordingly.
+% #1: the picture-content
+\long\def\tikzexternal@externalizefig@systemcall@uptodatecheck#1{%
+ \tikzexternal@check@uptodate@mode{#1}%
+ \tikzexternal@checkforceremake
+ \iftikzexternal@file@isuptodate
+ % check if there is already a file.
+ % In that case, use it. If that is not the case, generate it and include it afterwards.
+ \gdef\pgf@filename{}%
+ \xdef\pgf@tempa{\noexpand\pgf@findfile\pgfsys@imagesuffixlist:+{\tikzexternal@curfilename}}%
+ \pgf@tempa
+ \ifx\pgf@filename\pgfutil@empty%
+ \global\tikzexternal@file@isuptodatefalse
+ \fi
+ \fi
+}%
+
+% \pgf@filename will be empty if the assertion failed.
+\def\tikzexternal@externalizefig@systemcall@assertsuccess#1{%
+ % check if there is a file now and raise an error message if not.
+ \gdef\pgf@filename{}%
+ \xdef\pgf@tempa{\noexpand\pgf@findfile\pgfsys@imagesuffixlist:+{\tikzexternal@curfilename}}%
+ \pgf@tempa
+ \ifx\pgf@filename\pgfutil@empty%
+ \tikzexternal@externalizefig@systemcall@handleexception{#1}%
+ \fi
+}%
+\def\tikzexternal@externalizefig@systemcall@handleexception@msg#1{%
+ \tikzerror{Sorry, the system call '#1' did NOT result in a usable output file '\tikzexternal@curfilename' (expected one of \pgfsys@imagesuffixlist). Please verify that you have enabled system calls. For pdflatex, this is 'pdflatex -shell-escape'. Sometimes it is also named 'write 18' or something like that. Or maybe the command simply failed? Error messages can be found in '\tikzexternal@curfilename.log'. If you continue now, I'll try to typeset the picture}{}%
+}
+\def\tikzexternal@externalizefig@systemcall@handleexception@retry@later#1{%
+ \gdef\tikzexternal@systemcall@reschedule@to@end@document{0}%
+ \expandafter\pgfexternalreaddpth\expandafter{\tikzexternal@curfilename}%
+ \if1\tikzexternal@systemcall@reschedule@to@end@document
+ \pgfutil@IfUndefined{AtVeryEndDocument}{%
+ \tikzexternal@externalizefig@systemcall@handleexception@msg{#1}%
+ }{%
+ \pgf@typeout{===== The last system call resulted in an EMPTY output file. Maybe it is part of \string\ref. Rescheduling it for \string\end{document}. ========}%
+ \gdef\tikzexternal@typeset@picture@on@failure{0}%
+ \tikzexternal@externalizefig@systemcall@reschedule{#1}%
+ }%
+ \else
+ \tikzexternal@externalizefig@systemcall@handleexception@msg{#1}%
+ \fi
+}
+
+% reschedules the externalization of the current file to
+% \AtVeryEndDocument.
+%
+% This hook allows to execute code AFTER the main .aux file is
+% finished; it will even re-read the main aux file.
+\def\tikzexternal@externalizefig@systemcall@reschedule#1{%
+ \t@tikzexternal@tmpb={%
+ \global\let\tikzexternal@externalizefig@systemcall@handleexception=\tikzexternal@externalizefig@systemcall@handleexception@msg%
+ % ... no auxlocks!
+ \tikzexternal@externalizefig@systemcall@call{#1}%
+ \tikzexternal@externalizefig@systemcall@assertsuccess{#1}%
+ }%
+ \xdef\pgfutil@tempa{%
+ \noexpand\def\noexpand\tikzexternal@curfilename{\tikzexternal@curfilename}%
+ \the\t@tikzexternal@tmpb
+ }%
+ \expandafter\AtVeryEndDocument\expandafter{\pgfutil@tempa}%
+ \gdef\tikzexternal@has@rescheduled@something{1}%
+}%
+\let\tikzexternal@externalizefig@systemcall@handleexception=\tikzexternal@externalizefig@systemcall@handleexception@retry@later%
+
+\def\tikzexternal@has@rescheduled@something{0}%
+\pgfutil@IfUndefined{AtVeryEndDocument}{}{%
+ \AtVeryEndDocument{%
+ \if1\tikzexternal@has@rescheduled@something
+ \pgf@typeout{===== tikzexternal: \string\end{document} reached. Working on rescheduled images to resolve references... ========}%
+ \fi
+ }%
+}
+
+% Overwrite error message of pgf.
+% This happens if the generated image was empty, i.e. if there was no \shipout.
+\def\pgfexternal@error@no@shipout{%
+ \begingroup
+ \begingroup
+ % overwrite .dpth file in order to flag the file as "need to be scheduled
+ % for \AtVeryEndDocument" :
+ \immediate\openout\pgf@plotwrite=\pgfactualjobname.dpth
+ \let\w@pgfexternal@auxout=\pgf@plotwrite
+ \pgfexternalstorecommand@isexporting{\gdef\noexpand\tikzexternal@systemcall@reschedule@to@end@document{1}}%
+ \immediate\closeout\pgf@plotwrite
+ \endgroup
+ \tikzexternal@assemble@systemcall{\pgfactualjobname}{\pgf@tempa}%
+ \toks0=\expandafter{\pgf@tempa}%
+ \tikzerror{Sorry, image externalization failed: the resulting image was EMPTY. I tried to externalize '\pgfactualjobname', but it seems there is no such image in the document!?
+ \if\tikzexternal@opmode4 ^^J
+\space\space You are currently using 'mode=convert with system call'. This problem can happen if the image (or one of the images preceding it) was declared inside of a \string\label{} (i.e. in the .aux file): 'convert with system call' has no access to the main aux file.^^J
+\space\space Possible solutions in this case:^^J
+\space\space (a) Try using 'mode=list and make',^^J
+\space\space (b) Issue the externalization command '\the\toks0' *manually* (also check the preceding externalized images, perhaps the file name sequence is not correct).^^J
+\space\space Repeat: the resulting image was EMPTY, your attention is required
+\else
+ \if\tikzexternal@opmode5 ^^J
+\space\space You are currently using 'mode=list and make'. Possible solutions:^^J
+\space\space (a) Try to delete `\tikzexternal@realjob.makefile'. Perhaps it is not up-to-date.^^J
+\space\space (b) Perhaps pictures are declared inside of \string\label{} and the .aux file is not up-to-date. Re-run latex, perhaps re-generate the graphics as well.^^J
+\space\space Repeat: the resulting image was EMPTY, your attention is required
+ \fi
+\fi}%
+ \endgroup
+}%
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrary3d.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrary3d.code.tex
new file mode 100644
index 0000000000..f39eaee866
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrary3d.code.tex
@@ -0,0 +1,108 @@
+% Copyright 2018 by Till Tantau
+%
+% 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{tikzlibrary3d.code.tex}
+
+
+
+% New coordinate systems:
+
+\tikzdeclarecoordinatesystem{xyz cylindrical}
+{%
+ \pgfset{/tikz/cs/.cd,angle=0,radius=0,z=0,#1}%
+ \pgfpointcylindrical{\tikz@cs@angle}{\tikz@cs@xradius}{\tikz@cs@z}%
+}%
+
+\tikzdeclarecoordinatesystem{xyz spherical}
+{%
+ \pgfset{/tikz/cs/.cd,angle=0,radius=0,latitude=0,longitude=0,#1}%
+ \pgfpointspherical{\tikz@cs@angle}{\tikz@cs@latitude}{\tikz@cs@xradius}%
+}%
+
+\pgfset{/tikz/cs/longitude/.store in=\tikz@cs@angle}%
+\pgfset{/tikz/cs/latitude/.store in=\tikz@cs@latitude}%
+
+
+% Options for transforming into a plane:
+
+\tikzoption{plane origin}{\def\tikz@plane@origin{\tikz@scan@one@point\pgfutil@firstofone#1}}%
+\tikzoption{plane x}{\def\tikz@plane@x{\tikz@scan@one@point\pgfutil@firstofone#1}}%
+\tikzoption{plane y}{\def\tikz@plane@y{\tikz@scan@one@point\pgfutil@firstofone#1}}%
+
+\let\tikz@plane@origin=\pgfpointorigin
+\def\tikz@plane@x{\pgfpointxy{1}{0}}%
+\def\tikz@plane@y{\pgfpointxy{0}{1}}%
+
+\tikzoption{canvas is plane}[]{
+ \tikz@canvas@is@plane
+}%
+\tikzoption{canvas is xy plane at z}[]{%
+ \def\tikz@plane@origin{\pgfpointxyz{0}{0}{#1}}%
+ \def\tikz@plane@x{\pgfpointxyz{1}{0}{#1}}%
+ \def\tikz@plane@y{\pgfpointxyz{0}{1}{#1}}%
+ \tikz@canvas@is@plane
+}%
+\tikzoption{canvas is yx plane at z}[]{%
+ \def\tikz@plane@origin{\pgfpointxyz{0}{0}{#1}}%
+ \def\tikz@plane@x{\pgfpointxyz{0}{1}{#1}}%
+ \def\tikz@plane@y{\pgfpointxyz{1}{0}{#1}}%
+ \tikz@canvas@is@plane
+}%
+\tikzoption{canvas is xz plane at y}[]{%
+ \def\tikz@plane@origin{\pgfpointxyz{0}{#1}{0}}%
+ \def\tikz@plane@x{\pgfpointxyz{1}{#1}{0}}%
+ \def\tikz@plane@y{\pgfpointxyz{0}{#1}{1}}%
+ \tikz@canvas@is@plane
+}%
+\tikzoption{canvas is zx plane at y}[]{%
+ \def\tikz@plane@origin{\pgfpointxyz{0}{#1}{0}}%
+ \def\tikz@plane@x{\pgfpointxyz{0}{#1}{1}}%
+ \def\tikz@plane@y{\pgfpointxyz{1}{#1}{0}}%
+ \tikz@canvas@is@plane
+}%
+\tikzoption{canvas is yz plane at x}[]{%
+ \def\tikz@plane@origin{\pgfpointxyz{#1}{0}{0}}%
+ \def\tikz@plane@x{\pgfpointxyz{#1}{1}{0}}%
+ \def\tikz@plane@y{\pgfpointxyz{#1}{0}{1}}%
+ \tikz@canvas@is@plane
+}%
+\tikzoption{canvas is zy plane at x}[]{%
+ \def\tikz@plane@origin{\pgfpointxyz{#1}{0}{0}}%
+ \def\tikz@plane@x{\pgfpointxyz{#1}{0}{1}}%
+ \def\tikz@plane@y{\pgfpointxyz{#1}{1}{0}}%
+ \tikz@canvas@is@plane
+}%
+
+
+
+% Transformation code
+
+\def\tikz@canvas@is@plane{
+ \pgf@process{\tikz@plane@x}%
+ \pgf@xa=\pgf@x%
+ \pgf@ya=\pgf@y%
+ \pgf@process{\tikz@plane@y}%
+ \pgf@xb=\pgf@x%
+ \pgf@yb=\pgf@y%
+ \pgf@process{\tikz@plane@origin}%
+ \edef\pgf@marshal{\noexpand\tikz@addtransform{%
+ \noexpand\pgftransformtriangle
+ {\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}
+ {\noexpand\pgfqpoint{\the\pgf@xa}{\the\pgf@ya}}
+ {\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}}
+ \noexpand\pgftransformscale{0.035146}%
+ \noexpand\pgfsetxvec{\noexpand\pgfpoint{1cm}{0cm}}%
+ \noexpand\pgfsetyvec{\noexpand\pgfpoint{0cm}{1cm}}%
+ \noexpand\pgfsetzvec{\noexpand\pgfpoint{0cm}{0cm}}%
+ }}%
+ \pgf@marshal%
+}%
+
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryangles.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryangles.code.tex
new file mode 100644
index 0000000000..2d6abbd2e9
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryangles.code.tex
@@ -0,0 +1,100 @@
+% Copyright 2019 by Till Tantau
+% Copyright 2019 by Kroum Tzanev
+%
+% 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{tikzlibraryangles.code.tex}
+
+
+\tikzset{
+ pics/angle/.style = {
+ setup code = \tikz@lib@angle@parse#1\pgf@stop,
+ code = {},
+ background code = \tikz@lib@angle@background#1\pgf@stop,
+ foreground code = \tikz@lib@angle@foreground#1\pgf@stop,
+ },
+ pics/right angle/.style = {
+ setup code = \tikz@lib@angle@parse#1\pgf@stop,
+ code = {},
+ background code = \tikz@lib@rightangle@background#1\pgf@stop,
+ foreground code = \tikz@lib@rightangle@foreground#1\pgf@stop,
+ },
+ pics/angle/.default=A--B--C,
+ angle eccentricity/.initial=.6,
+ angle radius/.initial=5mm,
+}%
+
+\def\tikz@lib@angle@background#1--#2--#3\pgf@stop{%
+ \path [name prefix ..] [pic actions, draw=none] (#2.center)
+ -- ++(\tikz@start@angle@temp:\tikz@lib@angle@rad pt)
+ arc [start angle=\tikz@start@angle@temp, end
+ angle=\tikz@end@angle@temp, radius=\tikz@lib@angle@rad pt] -- cycle;
+}%
+
+\def\tikz@lib@angle@foreground#1--#2--#3\pgf@stop{%
+ \path [name prefix ..] [pic actions, fill=none, shade=none]
+ ([shift={(\tikz@start@angle@temp:\tikz@lib@angle@rad pt)}]#2.center)
+ arc [start angle=\tikz@start@angle@temp, end
+ angle=\tikz@end@angle@temp, radius=\tikz@lib@angle@rad pt];
+ \ifx\tikzpictext\relax\else%
+ \def\pgf@temp{\node()[name prefix
+ ..,at={([shift={({.5*\tikz@start@angle@temp+.5*\tikz@end@angle@temp}:\pgfkeysvalueof{/tikz/angle
+ eccentricity}*\tikz@lib@angle@rad pt)}]#2.center)}]}
+ \expandafter\pgf@temp\expandafter[\tikzpictextoptions]{\tikzpictext};%
+ \fi
+}%
+
+\def\tikz@lib@rightangle@background#1--#2--#3\pgf@stop{%
+ \path [name prefix ..] [pic actions, draw=none] (#2.center)
+ -- ++(\tikz@start@angle@temp:\tikz@lib@angle@rad pt)
+ -- ++(\tikz@end@angle@temp:\tikz@lib@angle@rad pt)
+ -- ++(\tikz@start@angle@temp:-\tikz@lib@angle@rad pt)
+ -- cycle;
+}%
+
+\def\tikz@lib@rightangle@foreground#1--#2--#3\pgf@stop{%
+ \path [name prefix ..] [pic actions, fill=none, shade=none]
+ ([shift={(\tikz@start@angle@temp:\tikz@lib@angle@rad pt)}]#2.center)
+ -- ++(\tikz@end@angle@temp:\tikz@lib@angle@rad pt)
+ -- ++(\tikz@start@angle@temp:-\tikz@lib@angle@rad pt);
+ \ifx\tikzpictext\relax\else%
+ \def\pgf@temp{\node()[name prefix
+ ..,at={([shift={({.5*\tikz@start@angle@temp+.5*\tikz@end@angle@temp}:\pgfkeysvalueof{/tikz/angle
+ eccentricity}*1.4142136*\tikz@lib@angle@rad pt)}]#2.center)}]}
+ \expandafter\pgf@temp\expandafter[\tikzpictextoptions]{\tikzpictext};%
+ \fi
+}%
+
+\def\tikz@lib@angle@parse#1--#2--#3\pgf@stop{%
+ % Compute radius:
+ \pgfmathsetmacro\tikz@lib@angle@rad{\pgfkeysvalueof{/tikz/angle radius}}
+ \ifdim\tikz@lib@angle@rad pt>0pt\else\def\tikz@lib@angle@rad{12}\fi%
+ % Compute first coordinate:
+ \pgf@process{\pgfpointanchor{#2}{center}}%
+ \pgf@xa=\pgf@x%
+ \pgf@ya=\pgf@y%
+ \pgf@process{\pgfpointanchor{#1}{center}}%
+ \pgf@xb=\pgf@x%
+ \pgf@yb=\pgf@y%
+ \pgf@process{\pgfpointanchor{#3}{center}}%
+ \pgf@xc=\pgf@x%
+ \pgf@yc=\pgf@y%
+ \advance\pgf@xb by-\pgf@xa%
+ \advance\pgf@yb by-\pgf@ya%
+ \advance\pgf@xc by-\pgf@xa%
+ \advance\pgf@yc by-\pgf@ya%
+ \pgfmathsetmacro{\tikz@start@angle@temp}{atan2(\the\pgf@yb,\the\pgf@xb)}
+ \pgfmathsetmacro{\tikz@end@angle@temp}{atan2(\the\pgf@yc,\the\pgf@xc)}
+ \ifdim\tikz@end@angle@temp pt<\tikz@start@angle@temp pt%
+ \pgfmathsetmacro{\tikz@start@angle@temp}{\tikz@start@angle@temp-360}%
+ \fi%
+}%
+
+
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryanimations.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryanimations.code.tex
new file mode 100644
index 0000000000..7b3fc12bf1
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryanimations.code.tex
@@ -0,0 +1,904 @@
+% Copyright 2018 by Till Tantau
+%
+% 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{tikzlibraryanimations.code.tex}
+
+\usepgfmodule{animations}%
+
+
+
+% Scope syntax extension:
+
+\def\tikz@collect@scope@anims#1{%
+ \let\tikz@scope@anims\pgfutil@empty%
+ \let\tikz@collect@command#1%
+ \tikz@collect@scope@anims@parse%
+}%
+\def\tikz@collect@scope@anims@parse{%
+ \pgfutil@ifnextchar[{\tikz@collect@scope@anims@opt}{%
+ \pgfutil@ifnextchar:{\tikz@collect@scope@anims@go}{%
+ \tikz@collect@scope@anims@done}}%]
+}%
+\def\tikz@collect@scope@anims@done{%
+ \expandafter\tikz@collect@command\expandafter[\tikz@scope@anims]%
+}%
+\def\tikz@collect@scope@anims@opt[{%]
+ \expandafter\tikz@collect@command\expandafter[\tikz@scope@anims%]
+}%
+\def\tikz@collect@scope@anims@go:#1=#2{%
+ \expandafter\def\expandafter\tikz@scope@anims\expandafter{\tikz@scope@anims animate={myself:={:{#1}={#2}}},}%
+ \tikz@collect@scope@anims@parse%
+}%
+
+
+
+
+%
+% The main keys:
+%
+
+\def\tikzanimateset{\pgfqkeys{/tikz/animate}}%
+\tikzanimateset{
+ .code={
+ \pgfkeys{/handlers/first char syntax=true}
+ \pgfkeyssetvalue{/handlers/first char syntax/\expandafter\meaning\string"}{\tikz@animation@value}%
+ \def\tikz@anim@t{0}%
+ \def\tikz@anim@t@base{0}%
+ \def\tikz@anim@t@current{0}%
+ \tikzanimateset{#1}
+ },
+ scope/.code=\tikz@anim@scope{#1}{}{},
+ sync/.code=\tikz@anim@sync@scope{#1}{}{},
+ entry/.code=\tikz@anim@make@entry,
+ object/.code=\tikz@anim@set@object{#1},
+ attribute/.code=\tikz@anim@set@attr{#1},
+ id/.code=\tikz@anim@set@id{#1},
+ time/.code=\tikz@anim@set@time{#1},
+ value/.code=\tikz@anim@add{\tikz@anim@value{#1}},%
+ remember/.code=\pgfmathadd@{\tikz@anim@t}{\tikz@anim@t@base}\global\let#1\pgfmathresult,
+ resume/.code=\tikz@anim@resume{#1},
+ fork/.code={\tikz@anim@parse@time{#1}\pgfmathadd@\tikz@anim@t\tikz@anim@t@base\let\tikz@anim@t@base\pgfmathresult\def\tikz@anim@t{0}},
+ fork/.default = 0later,
+ base/.style={scope={/utils/exec=\let\tikz@animation@time\tikz@anim@base@text,#1,entry}},
+}%
+
+\tikzset{
+ make snapshot of/.code=\edef\tikz@temp{#1}\ifx\tikz@temp\pgfutil@empty\else\pgfsnapshot{#1}\fi,
+ make snapshot after/.code=\edef\tikz@temp{#1}\ifx\tikz@temp\pgfutil@empty\else\pgfsnapshotafter{#1}\fi,
+ make snapshot if necessary/.code=\ifpgfsysanimationsupported\else\pgfsnapshot{#1}\fi,
+ make snapshot if necessary/.default=0s,
+}%
+
+\def\tikz@anim@scope#1#2#3{%
+ {#2\tikzanimateset{#1}#3}%
+}%
+\def\tikz@anim@sync@scope#1#2#3{%
+ {%
+ #2%
+ \tikzanimateset{#1}%
+ #3%
+ \pgfmathadd@{\tikz@anim@t}{\tikz@anim@t@base}%
+ \expandafter%
+ }\expandafter\pgfmathsubtract@\expandafter{\pgfmathresult}{\tikz@anim@t@base}%
+ \tikz@anim@set@time{\pgfmathresult}%
+}%
+
+\def\tikz@anim@set@time#1{%
+ \tikz@anim@parse@time{#1}%
+ \let\tikz@anim@t@current\tikz@anim@t%
+ \pgfmathadd@\tikz@anim@t\tikz@anim@t@base%
+ \let\tikz@animation@time\pgfmathresult%
+}%
+
+\def\tikz@anim@value#1{%
+ \def\tikz@anim@result{#1}
+ \ifx\tikz@anim@result\pgf@special@current@text%
+ \else%
+ \ifx\tikz@animation@parser\relax%
+ \else%
+ \tikz@animation@parser{#1}%
+ \fi%
+ \fi%
+}%
+
+
+\def\tikz@anim@resume#1{%
+ \pgfparsetime{#1}%
+ \pgfmathsubtract@{\pgftimeresult}{\tikz@anim@t@base}%
+ \tikz@anim@set@time{\pgfmathresult}%
+}%
+
+
+% The object--attribute entries are of the following forms:
+%
+% objects:attributes
+% objects:attributes_id
+%
+
+\def\tikz@animation@syntax@check#1#2{%
+ \def\tikz@animation@rest{#1}%
+ \expandafter\pgfutil@in@\expandafter:\expandafter{\tikz@key}%
+ \ifpgfutil@in@%
+ \expandafter\tikz@anim@parse@colon\tikz@key\pgf@stop%
+ \else%
+ #2%
+ \fi%
+}%
+
+\def\tikz@anim@parse@colon#1:#2\pgf@stop{%
+ \expandafter\tikz@anim@sync@scope\expandafter{\tikz@animation@rest}{%
+ \tikz@anim@set@object{#1}%
+ \pgfutil@in@_{#2}%
+ \ifpgfutil@in@%
+ \tikz@anim@parse@under#2\pgf@stop%
+ \else%
+ \tikz@anim@parse@under#2_\pgf@stop%
+ \fi%
+ }{\tikz@anim@make@entry}%
+}%
+
+\def\tikz@anim@parse@under#1_#2\pgf@stop{%
+ \tikz@anim@set@attr{#1}%
+ \tikz@anim@set@id{#2}%
+}%
+
+\def\tikz@anim@set@attr#1{%
+ \pgfkeys@spdef\tikz@anim@a{#1}%
+ \ifx\tikz@anim@a\pgfutil@empty%
+ \else%
+ \let\tikz@anim@tl@attributes\tikz@anim@a%
+ \fi%
+}%
+
+\def\tikz@anim@set@id#1{%
+ \pgfkeys@spdef\tikz@anim@a{#1}%
+ \ifx\tikz@anim@a\pgfutil@empty%
+ \else%
+ \let\tikz@anim@tl@id\tikz@anim@a%
+ \fi%
+}%
+
+\def\tikz@anim@set@object#1{%
+ \pgfkeys@spdef\tikz@anim@a{#1}%
+ \ifx\tikz@anim@a\pgfutil@empty%
+ \else%
+ \let\tikz@anim@tl@objects\tikz@anim@a%
+ \fi%
+}%
+
+
+%
+% Parsing of values
+%
+
+\def\tikz@animation@value#1{%
+ \tikz@animation@value@parser#1\pgf@stop%
+}%
+
+\def\tikz@animation@value@parser"#1"{%
+ \def\tikz@animation@value@head{#1}%
+ \pgfutil@ifnextchar\pgf@stop{\tikz@animation@value@rest=}{%
+ \pgfutil@ifnextchar b\tikz@animation@value@rest@base\tikz@animation@value@rest%
+ }%
+}%
+\def\tikz@animation@value@rest=#1\pgf@stop{%
+ \tikz@anim@sync@scope{#1}{\expandafter\tikz@anim@add\expandafter{\expandafter\tikz@anim@value\expandafter{\tikz@animation@value@head}}}{\tikz@anim@make@entry}%
+}%
+
+\def\tikz@animation@value@rest@base base{%
+ \tikz@anim@sync@scope{}{\let\tikz@animation@time\tikz@anim@base@text\expandafter\tikz@anim@add\expandafter{\expandafter\tikz@anim@value\expandafter{\tikz@animation@value@head}}}{\tikz@anim@make@entry}%
+ \pgfutil@ifnextchar\pgf@stop{\tikz@animation@value@rest=}{\tikz@animation@value@rest}%
+}%
+
+
+
+
+%
+% The parsers
+%
+
+\def\tikz@anim@simple@parse#1{} % nothing to do, \def\tikz@anim@result{#1} is already done
+
+\def\tikz@anim@slant@parse#1{\pgfmathsetmacro\tikz@anim@result{atan(#1)}}%
+
+\def\tikz@anim@dashpattern@parse#1{%
+ \pgfmathsetmacro\tikz@anim@dash@phase{\tikz@dashphase}%
+ \def\tikz@dashpattern{}%
+ \expandafter\tikz@scandashon\pgfutil@gobble#1o\@nil%
+ \edef\tikz@anim@result{{\tikz@dashpattern}{\tikz@anim@dash@phase pt}}%
+}%
+\def\tikz@anim@dashoffset@parse#1{%
+ \pgfmathparse{#1}%
+ \edef\tikz@anim@result{{\tikz@dashpattern}{\pgfmathresult pt}}%
+}%
+\def\tikz@anim@dash@parse#1{%
+ \tikz@anim@dash@parse@#1\pgf@stop%
+}%
+\def\tikz@anim@dash@parse@#1phase#2\pgf@stop{%
+ \pgfmathsetmacro\tikz@anim@dash@phase{#2}%
+ \def\tikz@dashpattern{}%
+ \expandafter\tikz@scandashon\pgfutil@gobble#1o\@nil%
+ \edef\tikz@anim@result{{\tikz@dashpattern}{\tikz@anim@dash@phase pt}}%
+}%
+
+\def\tikz@anim@xshift@parse#1{\pgfmathparse{#1}\edef\tikz@anim@result{\noexpand\pgfqpoint{\pgfmathresult pt}{0pt}}}%
+\def\tikz@anim@yshift@parse#1{\pgfmathparse{#1}\edef\tikz@anim@result{\noexpand\pgfqpoint{0pt}{\pgfmathresult pt}}}%
+
+\def\tikz@anim@xscale@parse#1{\pgfmathparse{#1}\edef\tikz@anim@result{\pgfmathresult,1}}%
+\def\tikz@anim@yscale@parse#1{\pgfmathparse{#1}\edef\tikz@anim@result{1,\pgfmathresult}}%
+
+\def\tikz@anim@shift@parse#1{\tikz@scan@one@point\tikz@anim@do@shift#1}%
+\def\tikz@anim@do@shift#1{\def\tikz@anim@result{#1}}%
+
+\def\tikz@anim@position@parse#1{%
+ \begingroup%
+ \let\tikz@transform=\relax%
+ \pgf@xc-\pgf@pt@x%
+ \pgf@yc-\pgf@pt@y%
+ \pgfsettransform\tikz@anim@saved@transform%
+ \tikz@scan@one@point\tikz@anim@do@position#1}%
+\def\tikz@anim@do@position#1{%
+ \pgf@process{\pgfpointtransformed{#1}}%
+ \advance\pgf@x by\pgf@xc%
+ \advance\pgf@y by\pgf@yc%
+ \xdef\tikz@anim@temp{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}%
+ \endgroup%
+ \let\tikz@anim@result\tikz@anim@temp%
+}%
+
+\def\tikz@anim@view@parse#1{\tikz@anim@view@parse@#1\pgf@stop}%
+\def\tikz@anim@view@parse@{%
+ \pgfutil@ifnextchar({\tikz@scan@one@point\tikz@anim@view@parse@a}{\tikz@anim@view@node}%
+}%
+\def\tikz@anim@view@parse@a#1{%
+ \def\tikz@anim@result{{#1}}%
+ \pgfutil@ifnextchar r{\tikz@anim@view@parsed@rec}{\tikz@scan@one@point\tikz@anim@view@parse@b}%
+}%
+\def\tikz@anim@view@parsed@rec rectangle{\tikz@scan@one@point\tikz@anim@view@parse@b}%
+\def\tikz@anim@view@parse@b#1{%
+ \expandafter\def\expandafter\tikz@anim@result\expandafter{\tikz@anim@result{#1}}%
+ \pgfutil@ifnextchar\pgf@stop\pgfutil@gobble{\tikzerror{Wrong view syntax}}%
+}%
+\def\tikz@anim@view@node#1\pgf@stop{%
+ \expandafter\ifx\csname pgf@sh@ns@#1\endcsname\relax%
+ \tikzerror{Undefined node '#1'}%
+ \else%
+ % Compute a bounding box for the node:
+ {%
+ \pgf@process{\pgfpointanchor{#1}{west}}%
+ \pgf@xa\pgf@x \pgf@ya\pgf@y
+ \pgf@xb\pgf@x \pgf@yb\pgf@y
+ \pgf@process{\pgfpointanchor{#1}{north}}%
+ \ifdim\pgf@x<\pgf@xa \pgf@xa=\pgf@x\fi%
+ \ifdim\pgf@x>\pgf@xb \pgf@xb=\pgf@x\fi%
+ \ifdim\pgf@y<\pgf@ya \pgf@ya=\pgf@y\fi%
+ \ifdim\pgf@y>\pgf@yb \pgf@yb=\pgf@y\fi%
+ \pgf@process{\pgfpointanchor{#1}{south}}%
+ \ifdim\pgf@x<\pgf@xa \pgf@xa=\pgf@x\fi%
+ \ifdim\pgf@x>\pgf@xb \pgf@xb=\pgf@x\fi%
+ \ifdim\pgf@y<\pgf@ya \pgf@ya=\pgf@y\fi%
+ \ifdim\pgf@y>\pgf@yb \pgf@yb=\pgf@y\fi%
+ \pgf@process{\pgfpointanchor{#1}{east}}%
+ \ifdim\pgf@x<\pgf@xa \pgf@xa=\pgf@x\fi%
+ \ifdim\pgf@x>\pgf@xb \pgf@xb=\pgf@x\fi%
+ \ifdim\pgf@y<\pgf@ya \pgf@ya=\pgf@y\fi%
+ \ifdim\pgf@y>\pgf@yb \pgf@yb=\pgf@y\fi%
+ \xdef\tikz@anim@result{{\noexpand\pgfqpoint{\the\pgf@xa}{\the\pgf@ya}}{\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}}}
+ }%
+ \fi%
+}%
+
+\def\tikz@anim@path@parse#1{%
+ {%
+ \setbox0=\hbox{{% protext against side effects
+ \pgfinterruptpath%
+ \expandafter\tikz@scan@next@command#1\pgf@stop%
+ \pgfsyssoftpath@getcurrentpath\tikz@anim@result%
+ \pgfprocessround{\tikz@anim@result}{\tikz@anim@result}%
+ \global\let\tikz@anim@result\tikz@anim@result%
+ \endpgfinterruptpath%
+ }}%
+ }%
+}%
+
+% The special along parser
+
+
+\def\tikz@anim@along#1#2{%
+ % Parse the path...
+ {%
+ \setbox0=\hbox{{% protect against side effects
+ \pgfinterruptpath%
+ \pgf@relevantforpicturesizefalse%
+ \iftikz@anim@is@position%
+ \let\tikz@transform=\relax%
+ \pgf@x-\pgf@pt@x%
+ \pgf@y-\pgf@pt@y%
+ \edef\tikz@anim@along@shift{\pgf@xc\the\pgf@x\pgf@yc\the\pgf@y}%
+ \pgfsettransformentries#1%
+ \else%
+ \pgftransformreset%
+ \fi
+ \tikz@scan@next@command#2\pgf@stop%
+ \pgfsyssoftpath@getcurrentpath\tikz@anim@parsed@path%
+ \pgfprocessround{\tikz@anim@parsed@path}{\tikz@anim@parsed@path}%
+ \iftikz@anim@is@position%
+ \tikz@anim@shift@path%
+ \global\let\tikz@anim@parsed@path\tikz@anim@patched@path%
+ \else%
+ \global\let\tikz@anim@parsed@path\tikz@anim@parsed@path%
+ \fi%
+ \endpgfinterruptpath%
+ }}%
+ }%
+ \pgfanimationset{along softpath/.expand once=\tikz@anim@parsed@path}%
+}%
+
+\def\tikz@anim@shift@path{%
+ \let\tikz@anim@patched@path\pgfutil@empty%
+ \tikz@anim@along@shift%
+ \expandafter\tikz@anim@shift@path@\tikz@anim@parsed@path\pgf@stop%
+}%
+\def\tikz@anim@shift@path@{%
+ \pgfutil@ifnextchar\pgf@stop\pgfutil@gobble{%
+ \pgfutil@ifnextchar\bgroup\tikz@anim@shift@path@sub\tikz@anim@shift@path@copy}%
+}%
+\def\tikz@anim@shift@path@copy#1{%
+ \expandafter\def\expandafter\tikz@anim@patched@path\expandafter{\tikz@anim@patched@path#1}%
+ \tikz@anim@shift@path@%
+}%
+\def\tikz@anim@shift@path@sub#1#2{%
+ \pgf@x#1%
+ \pgf@y#2%
+ \advance\pgf@x by\pgf@xc%
+ \advance\pgf@y by\pgf@yc%
+ \edef\tikz@temp{{\the\pgf@x}{\the\pgf@y}}%
+ \expandafter\tikz@anim@shift@path@copy\expandafter{\tikz@temp}%
+}%
+
+
+
+\def\tikz@anim@parse@origin#1{%
+ \tikz@scan@one@point\tikz@anim@parse@origin@#1\relax%
+}%
+\def\tikz@anim@parse@origin@#1{\tikz@anim@add{\pgfanimationset{origin={#1}}}}%
+
+
+% Internals
+
+\def\tikz@anim@tl@objects{}%
+\def\tikz@anim@tl@attributes{}%
+\def\tikz@anim@tl@id{default}%
+
+\let\tikz@anim@tl@exec@options\pgfutil@empty
+\let\tikz@anim@tl@early@options\pgfutil@empty
+
+\def\tikz@anim@add@early#1{\expandafter\def\expandafter\tikz@anim@tl@early@options\expandafter{\tikz@anim@tl@early@options#1}}%
+\def\tikz@anim@add@once@early#1{%
+ \global\advance\tikz@anim@once@count by1\relax%
+ \expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter\tikz@anim@tl@early@options%
+ \expandafter\expandafter\expandafter{\expandafter\tikz@anim@tl@early@options\expandafter\tikz@anim@exec@once\expandafter{\the\tikz@anim@once@count}{#1}}%
+}%
+\def\tikz@anim@add#1{\expandafter\def\expandafter\tikz@anim@tl@exec@options\expandafter{\tikz@anim@tl@exec@options#1}}%
+\def\tikz@anim@add@once#1{%
+ \global\advance\tikz@anim@once@count by1\relax%
+ \expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter\tikz@anim@tl@exec@options%
+ \expandafter\expandafter\expandafter{\expandafter\tikz@anim@tl@exec@options\expandafter\tikz@anim@exec@once\expandafter{\the\tikz@anim@once@count}{#1}}%
+}%
+\newcount\tikz@anim@once@count%
+\def\tikz@anim@exec@once#1#2{%
+ \expandafter\ifx\csname tikz@anim@once@#1\endcsname\pgf@stop%
+ \else%
+ \expandafter\let\csname tikz@anim@once@#1\endcsname\pgf@stop%
+ #2%
+ \fi%
+}%
+
+\newif\iftikz@anim@do@entry
+
+\def\tikz@anim@make@entry{%
+ \tikz@anim@do@entrytrue%
+ \ifx\tikz@anim@tl@objects\pgfutil@empty\tikz@anim@do@entryfalse\fi%
+ \ifx\tikz@anim@tl@attributes\pgfutil@empty\tikz@anim@do@entryfalse\fi%
+ \ifx\tikz@anim@tl@exec@options\pgfutil@empty\ifx\tikz@anim@tl@early@options\pgfutil@empty\tikz@anim@do@entryfalse\fi\fi%
+ \iftikz@anim@do@entry%
+ \foreach\tikz@anim@tl@object in\tikz@anim@tl@objects{%
+ \expandafter\tikzanimationattributesset\expandafter{\tikz@anim@tl@attributes}%
+ }%
+ \fi%
+}%
+
+\def\tikzanimationattributesset#1{\pgfqkeys{/tikz/animate/attributes}{#1}}%
+
+\tikzanimationattributesset{
+ .unknown/.code={
+ \let\tikz@anim@attribute@name\pgfkeyscurrentname
+ \expandafter\let\expandafter\pgf@temp\csname tikz@anim@def@pgf@attr@\tikz@anim@attribute@name\endcsname%
+ \ifx\pgf@temp\relax%
+ \tikzerror{Unknown animation attribute '\tikz@anim@attribute@name'}%
+ \else%
+ \expandafter\tikz@timeline@config\expandafter\tikz@anim@tl@object\expandafter\tikz@anim@attribute@name\expandafter\tikz@anim@tl@id\expandafter{\tikz@anim@configs}%
+ \edef\pgf@marshal{\noexpand\tikz@timeline@entry{\tikz@anim@tl@object}{\tikz@anim@attribute@name}{\tikz@anim@tl@id}}%
+ \expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter\pgf@marshal\expandafter\expandafter\expandafter{\expandafter\pgf@marshal\expandafter{\tikz@anim@tl@early@options}}%
+ \expandafter\expandafter\expandafter\pgf@marshal\expandafter\expandafter\expandafter{\expandafter\expandafter\expandafter\tikz@anim@entry\expandafter\expandafter\expandafter{\expandafter\tikz@anim@tl@exec@options\expandafter\def\expandafter\tikz@animation@time\expandafter{\tikz@animation@time}}}%
+ \fi%
+ }
+}%
+\let\tikz@anim@configs\pgfutil@empty
+
+\def\tikz@anim@entry#1{%
+ % Reset splines and value:
+ \let\tikz@anim@result\pgfutil@empty%
+ \pgf@anim@reset@linear%
+ #1%
+ \ifx\tikz@anim@result\pgfutil@empty%
+ \else%
+ \ifx\tikz@animation@time\pgfutil@empty%
+ \else%
+ \ifx\tikz@animation@time\tikz@anim@base@text%
+ \expandafter\pgf@anim@base\expandafter{\tikz@anim@result}%
+ \else%
+ \expandafter\expandafter\expandafter\pgf@anim@entry%
+ \expandafter\expandafter\expandafter{\expandafter\tikz@animation@time\expandafter}\expandafter{\tikz@anim@result}%
+ \fi%
+ \fi%
+ \fi%
+}%
+\let\tikz@animation@time\pgfutil@empty%
+\def\tikz@anim@base@text{base}%
+
+\tikzanimateset{
+ .unknown/.code={%
+ \let\tikz@key\pgfkeyscurrentname%
+ \tikz@animation@syntax@check{#1}{\tikz@anim@options{#1}}%
+ }
+}%
+
+
+\def\tikz@anim@options#1{
+ \let\tikz@anim@key\pgfkeyscurrentname%
+ \pgfqkeys{/tikz/animate/options}{\tikz@anim@key/.try={#1}}%
+ \ifpgfkeyssuccess%
+ \else%
+ \def\tikz@anim@unparsed@value{#1}%
+ \expandafter\tikz@anim@time@test\tikz@anim@key\pgf@stop%
+ \fi%
+}%
+
+\tikzanimateset{
+ options/.cd,
+ name/.code=\tikz@anim@add{\pgfanimationset{name={#1}}},
+ forever/.code=\tikz@anim@add{\pgfanimationset{freeze at end}},
+ freeze/.code=\tikz@anim@add{\pgfanimationset{freeze at end}},
+ restart/.code=\tikz@anim@add{\pgfanimationset{restart={#1}}},
+ repeats/.code=\tikz@anim@add{\pgfanimationset{repeats={#1}}},
+ repeats/.default=,
+ repeat/.code=\tikz@anim@add{\pgfanimationset{repeats={#1}}},
+ repeat/.default=,
+ begin/.code=\tikz@anim@add@once{\pgfanimationset{begin={#1}}},
+ end/.code=\tikz@anim@add@once{\pgfanimationset{end={#1}}},
+ begin on/.code=\tikz@anim@event{begin}{#1},
+ end on/.code=\tikz@anim@event{begin}{#1},
+ begin snapshot/.code=\tikz@anim@add{\pgfanimationset{begin snapshot={#1}}},
+ origin/.code=\tikz@anim@parse@origin{#1},
+ transform/.code=\tikz@anim@add{\pgfanimationset{transform={\let\tikz@transform\relax\tikzset{#1}}}},
+ along/.code=\tikz@anim@handle@along#1\pgf@stop,
+ entry control/.code=\tikz@anim@add{\pgfanimationset{entry control={#1}}},
+ exit control/.code=\tikz@anim@add{\pgfanimationset{exit control={#1}}},
+ stay/.code=\tikz@anim@add{\pgfanimationset{stay}},
+ jump/.code=\tikz@anim@add{\pgfanimationset{jump}},
+ ease/.style={
+ entry control={1-(#1)}{1},
+ exit control={#1}{0}
+ },
+ ease/.default=0.5,
+ ease in/.style={
+ entry control={1-(#1)}{1},
+ },
+ ease in/.default=0.5,
+ ease out/.style={
+ exit control={#1}{0},
+ },
+ ease out/.default=0.5,
+ arrows/.code=\tikz@anim@add@early{\pgfanimationset{arrows={#1}}},
+ shorten >/.code=\tikz@anim@add@early{\pgfanimationset{shorten >={#1}}},
+ shorten </.code=\tikz@anim@add@early{\pgfanimationset{snorten <={#1}}},
+}%
+\newif\iftikz@anim@along
+
+\def\tikz@anim@t{0}%
+
+\def\tikz@anim@handle@along#1{%
+ \pgfutil@ifnextchar s{\tikz@anim@handle@sloped{#1}}{\tikz@anim@handle@upright{#1}}%
+}%
+\def\tikz@anim@handle@sloped#1sloped{%
+ \pgfgettransform\tikz@anim@trans@pre%
+ \expandafter\tikz@anim@add@once%
+ \expandafter{%
+ \expandafter\tikz@anim@along\expandafter{\tikz@anim@trans@pre}{#1}%
+ \pgfsysanimkeycanvastransform{%
+ \pgf@xc\pgf@pt@x%
+ \pgf@yc\pgf@pt@y%
+ \pgftransformreset%
+ \pgf@pt@x\pgf@xc%
+ \pgf@pt@y\pgf@yc%
+ {\pgflowlevelsynccm}%
+ }{\pgftransforminvert\pgflowlevelsynccm}%
+ \pgfanimationset{rotate along=true}%
+ }%
+ \def\tikz@anim@configs{\tikz@anim@alongtrue}%
+ \tikz@anim@handle@in%
+}%
+\def\tikz@anim@handle@upright#1upright{%
+ \pgfgettransform\tikz@anim@trans@pre%
+ \expandafter\tikz@anim@add@once%
+ \expandafter{%
+ \expandafter\tikz@anim@along\expandafter{\tikz@anim@trans@pre}{#1}%
+ \pgfsysanimkeycanvastransform{}{}%
+ }%
+ \def\tikz@anim@configs{\tikz@anim@alongtrue}%
+ \tikz@anim@handle@in%
+}%
+\def\tikz@anim@handle@in{%
+ \pgfutil@ifnextchar i{\tikz@anim@handle@in@yes}{\tikz@anim@handle@in@no}%
+}%
+\def\tikz@anim@handle@in@no\pgf@stop{}%
+\def\tikz@anim@handle@in@yes in#1\pgf@stop{%
+ \tikzanimateset{scope={time=0,value=0,entry,time=#1,value=1,entry}}%
+}%
+
+
+
+\def\tikz@anim@event#1#2{%
+ {%
+ % evaluate #2 once to determine the id now
+ \let\pgf@anim@id\pgfutil@empty%
+ \pgfqkeys{/pgf/animation/events}{#2}%
+ \expandafter}%
+ \expandafter\def\expandafter\tikz@anim@temp@id\expandafter{\pgf@anim@id}%
+ \ifx\tikz@anim@temp@id\pgfutil@empty%
+ \def\tikz@temp{#1 on={of id=\tikz@anim@current@id,#2}}%
+ \else
+ \expandafter\tikz@anim@event@setter\expandafter{\tikz@anim@temp@id}{#1}{#2}%
+ \fi%
+ \expandafter\tikz@anim@add@once\expandafter{\expandafter\pgfanimationset\expandafter{\tikz@temp}}%
+}%
+\def\tikz@anim@event@setter#1#2#3{%
+ \def\tikz@temp{#2 on={#3,of id=#1}}%
+}%
+
+\def\tikz@anim@time@test#1#2\pgf@stop{%
+ \edef\tikz@temp{\meaning#1}%
+ \expandafter\ifx\csname tikz@anim@test@\tikz@temp\endcsname\relax%
+ \tikzerror{I do not know the timing key '#1#2' to which you passed '\tikz@anim@unparsed@value'}%
+ \else%
+ \expandafter\tikz@anim@sync@scope\expandafter{\tikz@anim@unparsed@value}{\tikz@anim@set@time{#1#2}}{\tikz@anim@make@entry}%
+ \fi%
+}%
+
+\def\tikz@anim@parse@time#1{%
+ \pgfutil@in@{later\pgf@stop}{#1\pgf@stop}%
+ \ifpgfutil@in@%
+ \tikz@anim@parse@later#1\pgf@stop%
+ \else%
+ \pgfparsetime{#1}\let\tikz@anim@t\pgftimeresult%
+ \fi%
+}%
+\def\tikz@anim@parse@later#1later\pgf@stop{%
+ \pgfparsetime{#1+\tikz@anim@t@current}\let\tikz@anim@t\pgftimeresult%
+}%
+
+\expandafter\let\csname tikz@anim@test@the character 0\endcsname\pgfutil@empty
+\expandafter\let\csname tikz@anim@test@the character 1\endcsname\pgfutil@empty
+\expandafter\let\csname tikz@anim@test@the character 2\endcsname\pgfutil@empty
+\expandafter\let\csname tikz@anim@test@the character 3\endcsname\pgfutil@empty
+\expandafter\let\csname tikz@anim@test@the character 4\endcsname\pgfutil@empty
+\expandafter\let\csname tikz@anim@test@the character 5\endcsname\pgfutil@empty
+\expandafter\let\csname tikz@anim@test@the character 6\endcsname\pgfutil@empty
+\expandafter\let\csname tikz@anim@test@the character 7\endcsname\pgfutil@empty
+\expandafter\let\csname tikz@anim@test@the character 8\endcsname\pgfutil@empty
+\expandafter\let\csname tikz@anim@test@the character 9\endcsname\pgfutil@empty
+\expandafter\let\csname tikz@anim@test@the character -\endcsname\pgfutil@empty
+\expandafter\let\csname tikz@anim@test@the character +\endcsname\pgfutil@empty
+\expandafter\let\csname tikz@anim@test@the character .\endcsname\pgfutil@empty
+\expandafter\let\csname tikz@anim@test@the character (\endcsname\pgfutil@empty
+
+
+
+
+
+% Configure an animation attribute
+%
+% #1 = tikz attribute name
+% #2 = configuration
+%
+% Description:
+%
+% Sets up internals for the tikz attribute.
+
+\def\tikzanimationdefineattribute#1#2{%
+ \expandafter\def\csname tikz@anim@def@pgf@attr@#1\endcsname{#1}%
+ \expandafter\let\csname tikz@anim@def@no@node@#1\endcsname\pgfutil@empty
+ \expandafter\let\csname tikz@anim@def@is@node@#1\endcsname\pgfutil@empty
+ \expandafter\let\csname tikz@anim@def@code@#1\endcsname\pgfutil@empty
+ \expandafter\let\csname tikz@anim@def@parser@#1\endcsname\tikz@anim@simple@parse
+ \def\tikz@anim@attr{#1}%
+ \pgfkeys{/tikz/animate/@attrdef/.cd,#2}%
+}%
+
+\pgfkeys{/tikz/animate/@attrdef/.cd,
+ pgf attribute name/.code=\expandafter\def\csname tikz@anim@def@pgf@attr@\tikz@anim@attr\endcsname{#1},
+ pgf attribute name scope/.code=\expandafter\def\csname tikz@anim@def@pgf@attr@@scope@\tikz@anim@attr\endcsname{#1},
+ pgf attribute name node/.code=\expandafter\def\csname tikz@anim@def@pgf@attr@@node@\tikz@anim@attr\endcsname{#1},
+ scope type/.code=\expandafter\def\csname tikz@anim@def@no@node@\tikz@anim@attr\endcsname{#1},
+ node type/.code=\expandafter\def\csname tikz@anim@def@is@node@\tikz@anim@attr\endcsname{#1},
+ code/.code=\expandafter\def\csname tikz@anim@def@code@\tikz@anim@attr\endcsname{#1},
+ setup/.code=\expandafter\def\csname tikz@anim@def@setup@\tikz@anim@attr\endcsname{#1},
+ parser/.code=\expandafter\def\csname tikz@anim@def@parser@\tikz@anim@attr\endcsname{#1},
+}%
+
+
+% Configure an animation attribute list
+%
+% #1 = tikz attribute list name
+% #2 = list of tikz attributes
+%
+% Description:
+%
+% Sets up internals for the tikz attribute.
+
+\def\tikzanimationdefineattributelist#1#2{%
+ \tikzanimationattributesset{#1/.style={#2}}%
+}%
+
+
+
+
+% Definition of the tikz attributes
+
+
+\tikzanimationdefineattributelist{color}{@color,text}%
+\tikzanimationdefineattribute{@color}{pgf attribute name=color,node type=.background}%
+\tikzanimationdefineattribute{dash pattern}{pgf attribute name=dash,parser=dashpattern, node type=.background}%
+\tikzanimationdefineattribute{dash phase}{pgf attribute name=dash,parser=dashoffset, node type=.background}%
+\tikzanimationdefineattribute{dash}{parser=dash, node type=.background}%
+\tikzanimationdefineattribute{draw opacity}{pgf attribute name=stroke opacity}%
+\tikzanimationdefineattribute{draw}{pgf attribute name=stroke, node type=.background}%
+\tikzanimationdefineattribute{fill opacity}{}%
+\tikzanimationdefineattribute{fill}{node type=.background}%
+\tikzanimationdefineattribute{line width}{node type=.background}%
+\tikzanimationdefineattribute{path}{pgf attribute name=softpath, scope type=.path, node type=.background.path, parser=path}%
+\tikzanimationdefineattribute{opacity}{}%
+\tikzanimationdefineattribute{position}{%
+ pgf attribute name=\iftikz@anim@along motion\else translate\fi,
+ parser=\iftikz@anim@along simple\else position\fi,
+ setup=\tikz@anim@position@setup,
+}%
+\tikzanimationdefineattribute{rotate}{}%
+\tikzanimationdefineattribute{scale}{}%
+\tikzanimationdefineattribute{shift}{
+ pgf attribute name=\iftikz@anim@along motion\else translate\fi,
+ parser=\iftikz@anim@along simple\else shift\fi
+}%
+\tikzanimationdefineattribute{stage}{}%
+\tikzanimationdefineattribute{text opacity}{pgf attribute name=fill opacity, node type=.text, pgf attribute name scope=none}%
+\tikzanimationdefineattribute{text}{pgf attribute name=color, node type=.text, pgf attribute name scope=none}%
+\tikzanimationdefineattribute{view}{scope type=.view, parser=view}%
+\tikzanimationdefineattribute{visible}{}%
+\tikzanimationdefineattribute{xshift}{pgf attribute name=translate, parser=xshift}%
+\tikzanimationdefineattribute{xscale}{pgf attribute name=scale, parser=xscale}%
+\tikzanimationdefineattribute{xskew}{}%
+\tikzanimationdefineattribute{xslant}{pgf attribute name=xskew, parser=slant}%
+\tikzanimationdefineattribute{yshift}{pgf attribute name=translate, parser=yshift}%
+\tikzanimationdefineattribute{yskew}{}%
+\tikzanimationdefineattribute{yslant}{pgf attribute name=yskew, parser=slant}%
+\tikzanimationdefineattribute{yscale}{pgf attribute name=scale, parser=yscale}%
+
+
+\def\tikz@anim@position@setup{%
+ \pgfgettransform\tikz@anim@saved@transform%
+ \expandafter\def\expandafter\tikz@temp\expandafter{%
+ \expandafter\def\expandafter\tikz@anim@saved@transform\expandafter{\tikz@anim@saved@transform}%
+ \pgfsysanimkeycanvastransform{}{}%
+ \tikz@anim@is@positiontrue%
+ }%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\tikz@anim@initial@options%
+ \expandafter\expandafter\expandafter{\expandafter\tikz@temp\tikz@anim@initial@options}%
+}%
+\newif\iftikz@anim@is@position
+
+
+% The TikZ animation callbacks
+%
+% Description:
+%
+% The callbacks called by tikz.code.tex whenever an object is
+% created. These callbacks will add the accumulated animation code.
+
+\def\tikz@anim@id@hook{%
+ \expandafter\ifx\csname tikz@anim@att@\tikz@id@name\endcsname\relax%
+ % No named animation:
+ % Now, check for auto animation:
+ \expandafter\ifx\csname tikz@anim@att@\tikz@auto@id\endcsname\relax%
+ \else%
+ % Auto animation%
+ \ifx\tikz@id@name\pgfutil@empty% Id set?
+ % No, so set it
+ \def\tikz@id@name{@auto}%
+ \fi%
+ \pgfidrefnextuse\tikz@anim@current@id\tikz@id@name%
+ \csname tikz@anim@att@\tikz@auto@id\endcsname%
+ \expandafter\global\expandafter\let\csname tikz@anim@att@\tikz@auto@id\endcsname\relax%
+ \fi%
+ \else%
+ % Named animation:
+ \pgfidrefnextuse\tikz@anim@current@id\tikz@id@name%
+ \csname tikz@anim@att@\tikz@id@name\endcsname%
+ \csname tikz@anim@att@\tikz@auto@id\endcsname% and unnamed animation
+ \expandafter\global\expandafter\let\csname tikz@anim@att@\tikz@id@name\endcsname\relax%
+ \expandafter\global\expandafter\let\csname tikz@anim@att@\tikz@auto@id\endcsname\relax%
+ \fi%
+}%
+
+% Add hook:
+\expandafter\def\expandafter\tikz@id@hook\expandafter{\tikz@id@hook\tikz@anim@id@hook}%
+
+
+
+% Attaches an animation to a named object (named in tikz)
+%
+% #1 = name of the object. If equal to the special text "myself", the
+% next created object is meant.
+% #2 = Animation code. When this code is executed, the following
+% things will be setup:
+%
+% \iftikz@is@node will be set to true or false
+% depending on whether the name references a node.
+%
+% \tikz@id@name will be set to the name of the object,
+% typically #1, except when #1 was ".", in this case another
+% name may have been used by the user, which will be used
+% instead.
+%
+% Description:
+%
+% After the call, the next time an object named #1 is created in TikZ
+% (using name=#1), the code #2 will be executed inside a scope to
+% create an animation of the object.
+
+\def\tikzanimationattachto#1#2{%
+ {%
+ \def\tikz@anim@name{#1}%
+ \ifx\tikz@anim@name\pgfutil@empty%
+ \tikzerror{Trying to attach an animation to an unnamed object. This should not happen.}%
+ \else%
+ \expandafter\ifx\csname tikz@anim@att@\tikz@anim@name\endcsname\relax%
+ \expandafter\gdef\csname tikz@anim@att@\tikz@anim@name\endcsname{#2}%
+ \else%
+ \expandafter\let\expandafter\tikz@temp\csname tikz@anim@att@\tikz@anim@name\endcsname%
+ \expandafter\def\expandafter\tikz@temp\expandafter{\tikz@temp#2}%
+ \expandafter\global\expandafter\let\csname tikz@anim@att@\tikz@anim@name\endcsname\tikz@temp%
+ \fi%
+ \fi%
+ }%
+}%
+\def\tikz@auto@id{myself}%
+\expandafter\let\csname tikz@anim@att@\tikz@auto@id\endcsname\relax%
+
+
+% Add config code to a timeline
+%
+% #1 = The object (may be "myself")
+% #2 = The attribute (see pgfanimateattribute)
+% #3 = Timeline sequence identifier
+% #4 = code
+%
+% Description:
+%
+% This commands adds the code to the timeline configuration, which is
+% code that gets executed before the rest of entries of the timeline
+% are executed.
+
+\def\tikz@timeline@config#1#2#3#4{%
+ \expandafter\def\expandafter\tikz@temp\expandafter{\csname tikz@a@conf@#1@#2@#3\endcsname}%
+ \expandafter\ifx\tikz@temp\relax%
+ \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\gdef\expandafter\expandafter\expandafter\tikz@temp\expandafter\expandafter\expandafter{\expandafter\expandafter\expandafter\global\expandafter\let\tikz@temp\relax}%
+ \fi%
+ \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\gdef\expandafter\expandafter\expandafter\tikz@temp\expandafter\expandafter\expandafter{\tikz@temp#4}%
+}%
+
+
+
+% Add a timeline entry
+%
+% #1 = The object (may be "myself")
+% #2 = The attribute (see pgfanimateattribute)
+% #3 = Timeline sequence identifier
+% #4 = early code
+% #5 = later code
+%
+% Description:
+%
+% This command stores an option with a timeline of an object. For each
+% object--attribute--identifier tuple a timeline can be created, for
+% which the values of #4 and #5 are collected. Later on, \pgfanimateattribute
+% will be called for the pgf attribute associated with tikz attribute,
+% the type associated with it and initial code, followed by the
+% accumulated values of #4 and then the accumulated values of #5.
+
+\def\tikz@timeline@entry#1#2#3#4#5{%
+ % First, does the object have an animation already attached?
+ \expandafter\ifx\csname tikz@a@tlo@#1\endcsname\relax%
+ % No, first entry!
+ % Create call:
+ \edef\pgf@marshal{\noexpand\tikzanimationattachto{#1}{\expandafter\noexpand\csname tikz@a@tlo@#1\endcsname}}%
+ \pgf@marshal%
+ \expandafter\gdef\csname tikz@a@tlo@#1\endcsname{\tikz@anim@cleanup{#1}}%
+ \fi%
+ % Second, does the timeline exist?
+ \expandafter\ifx\csname tikz@a@tlc@#1@#2@#3\endcsname\relax%
+ % No, first entry!
+ \def\tikz@anim@initial@early@options{#4}%
+ \def\tikz@anim@initial@options{#5}%
+ \csname tikz@anim@def@setup@#2\endcsname%
+ % Create timeline...
+ \expandafter\global\expandafter\let\csname tikz@a@tlc@#1@#2@#3\endcsname\tikz@anim@initial@options%
+ \expandafter\global\expandafter\let\csname tikz@a@tld@#1@#2@#3\endcsname\tikz@anim@initial@early@options%
+ % ...and add to calls
+ \expandafter\let\expandafter\pgf@temp\csname tikz@a@tlo@#1\endcsname%
+ \expandafter\def\expandafter\pgf@temp@name\expandafter{\tikz@anim@create{#1}{#2}{#3}}%
+ \expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter\pgf@temp\expandafter\expandafter\expandafter{\expandafter\pgf@temp\pgf@temp@name}%
+ \expandafter\global\expandafter\let\csname tikz@a@tlo@#1\endcsname\pgf@temp%
+ \else%
+ % Add to timeline:
+ \expandafter\let\expandafter\pgf@temp\csname tikz@a@tld@#1@#2@#3\endcsname%
+ \expandafter\def\expandafter\pgf@temp\expandafter{\pgf@temp#4}%
+ \expandafter\global\expandafter\let\csname tikz@a@tld@#1@#2@#3\endcsname\pgf@temp%
+ \expandafter\let\expandafter\pgf@temp\csname tikz@a@tlc@#1@#2@#3\endcsname%
+ \expandafter\def\expandafter\pgf@temp\expandafter{\pgf@temp#5}%
+ \expandafter\global\expandafter\let\csname tikz@a@tlc@#1@#2@#3\endcsname\pgf@temp%
+ \fi%
+}%
+
+
+\def\tikz@anim@cleanup#1{%
+ \expandafter\global\expandafter\let\csname tikz@a@tlo@#1\endcsname\relax%
+}%
+
+\def\tikz@anim@create#1#2#3{%
+ \csname tikz@a@conf@#1@#2@#3\endcsname%
+ \iftikz@is@node%
+ \expandafter\let\expandafter\tikz@temp\csname tikz@anim@def@pgf@attr@@node@#2\endcsname%
+ \else%
+ \expandafter\let\expandafter\tikz@temp\csname tikz@anim@def@pgf@attr@@scope@#2\endcsname%
+ \fi%
+ \ifx\tikz@temp\relax%
+ \expandafter\let\expandafter\tikz@temp\csname tikz@anim@def@pgf@attr@#2\endcsname%
+ \fi%
+ \expandafter\pgfanimateattributecode\expandafter{\tikz@temp}{%
+ \iftikz@is@node%
+ \edef\tikz@anim@whom{\tikz@id@name\csname tikz@anim@def@is@node@#2\endcsname}%
+ \else%
+ \edef\tikz@anim@whom{\tikz@id@name\csname tikz@anim@def@no@node@#2\endcsname}%
+ \fi%
+ \pgfanimationset{whom=\tikz@anim@whom}%
+ \expandafter\let\expandafter\tikz@animation@parser\csname tikz@anim@\csname tikz@anim@def@parser@#2\endcsname @parse\endcsname%
+ \csname tikz@anim@def@code@#2\endcsname%
+ \csname tikz@a@tld@#1@#2@#3\endcsname%
+ \csname tikz@a@tlc@#1@#2@#3\endcsname%
+ }%
+ \expandafter\global\expandafter\let\csname tikz@a@tlc@#1@#2@#3\endcsname\relax%
+ \expandafter\global\expandafter\let\csname tikz@a@tld@#1@#2@#3\endcsname\relax%
+}%
+
+
+
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryarrows.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryarrows.code.tex
new file mode 100644
index 0000000000..b3f1728e44
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryarrows.code.tex
@@ -0,0 +1,14 @@
+% Copyright 2018 by Till Tantau
+%
+% 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{tikzlibraryarrows.code.tex}
+
+\usepgflibrary{arrows}%
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryautomata.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryautomata.code.tex
new file mode 100644
index 0000000000..690e0fd63a
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryautomata.code.tex
@@ -0,0 +1,105 @@
+% Copyright 2018 by Till Tantau
+%
+% 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{tikzlibraryautomata.code.tex}
+
+\usetikzlibrary{shapes.multipart}%
+
+% Styles for states:
+
+\tikzset{every state/.style= {}}%
+
+\tikzset{state without output/.style= {circle,draw,minimum size=2.5em,every state}}%
+\tikzset{state with output/.style= {circle split,draw,minimum size=2.5em,every state}}%
+
+\tikzset{accepting by arrow/.style= {after node path=
+{
+ {
+ [to path=
+ {
+ [->,double=none,every accepting by arrow]
+ --
+ ([shift=(\tikz@accepting@angle:\tikz@accepting@distance)]\tikztostart.\tikz@accepting@angle)
+ node [shape=rectangle,anchor=\tikz@accepting@anchor] {\tikz@accepting@text}
+ }]
+ edge ()
+ }
+}}}%
+\tikzset{every accepting by arrow/.style={}}%
+\tikzset{accepting by double/.style= {double,outer sep=.5\pgflinewidth+.3pt}} % .3pt is half double width distance
+
+\tikzset{initial by arrow/.style= {after node path=
+{
+ {
+ [to path=
+ {
+ [->,double=none,every initial by arrow]
+ ([shift=(\tikz@initial@angle:\tikz@initial@distance)]\tikztostart.\tikz@initial@angle)
+ node [shape=rectangle,anchor=\tikz@initial@anchor] {\tikz@initial@text}
+ -- (\tikztostart)}]
+ edge ()
+ }
+}}}%
+\tikzset{every initial by arrow/.style={}}%
+
+\tikzset{initial by diamond/.style={shape=diamond}}%
+
+
+\tikzoption{initial text}{\tikzaddafternodepathoption{\def\tikz@initial@text{#1}}}%
+\tikzoption{accepting text}{\tikzaddafternodepathoption{\def\tikz@accepting@text{#1}}}%
+
+\tikzoption{initial where}{\tikzaddafternodepathoption{\csname tikz@initial@compute@#1\endcsname}}%
+\tikzoption{accepting where}{\tikzaddafternodepathoption{\csname tikz@accepting@compute@#1\endcsname}}%
+
+\tikzoption{initial distance}{\tikzaddafternodepathoption{\def\tikz@initial@distance{#1}}}%
+\tikzoption{accepting distance}{\tikzaddafternodepathoption{\def\tikz@accepting@distance{#1}}}%
+
+\def\tikz@initial@text{start}%
+\def\tikz@accepting@text{}%
+
+\def\tikz@initial@distance{3ex}%
+\def\tikz@accepting@distance{3ex}%
+
+\def\tikz@initial@compute@above{\def\tikz@initial@angle{90}\def\tikz@initial@anchor{south}}%
+\def\tikz@initial@compute@below{\def\tikz@initial@angle{270}\def\tikz@initial@anchor{north}}%
+\def\tikz@initial@compute@left{\def\tikz@initial@angle{180}\def\tikz@initial@anchor{east}}%
+\def\tikz@initial@compute@right{\def\tikz@initial@angle{0}\def\tikz@initial@anchor{west}}%
+
+\def\tikz@initial@angle{180}%
+\def\tikz@initial@anchor{east}%
+
+\def\tikz@accepting@compute@above{\def\tikz@accepting@angle{90}\def\tikz@accepting@anchor{south}}%
+\def\tikz@accepting@compute@below{\def\tikz@accepting@angle{270}\def\tikz@accepting@anchor{north}}%
+\def\tikz@accepting@compute@left{\def\tikz@accepting@angle{180}\def\tikz@accepting@anchor{east}}%
+\def\tikz@accepting@compute@right{\def\tikz@accepting@angle{0}\def\tikz@accepting@anchor{west}}%
+
+\def\tikz@accepting@angle{0}%
+\def\tikz@accepting@anchor{west}%
+
+
+\tikzset{initial above/.style= {initial by arrow,initial where=above}}%
+\tikzset{initial below/.style= {initial by arrow,initial where=below}}%
+\tikzset{initial left/.style= {initial by arrow,initial where=left}}%
+\tikzset{initial right/.style= {initial by arrow,initial where=right}}%
+
+\tikzset{accepting above/.style= {accepting by arrow,accepting where=above}}%
+\tikzset{accepting below/.style= {accepting by arrow,accepting where=below}}%
+\tikzset{accepting left/.style= {accepting by arrow,accepting where=left}}%
+\tikzset{accepting right/.style= {accepting by arrow,accepting where=right}}%
+
+
+% Defaults:
+
+\tikzset{state/.style= {state without output}}%
+\tikzset{accepting/.style= {accepting by double}}%
+\tikzset{initial/.style= {initial by arrow}}%
+
+
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarybabel.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarybabel.code.tex
new file mode 100644
index 0000000000..e24439f75f
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarybabel.code.tex
@@ -0,0 +1,17 @@
+% Copyright 2018 by Till Tantau
+%
+% 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{tikzlibrarybabel.code.tex}
+
+\tikzset{
+ handle active characters in code,
+ handle active characters in nodes,
+}%
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarybackgrounds.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarybackgrounds.code.tex
new file mode 100644
index 0000000000..1a42a4b40e
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarybackgrounds.code.tex
@@ -0,0 +1,148 @@
+% Copyright 2018 by Till Tantau
+%
+% 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{tikzlibrarybackgrounds.code.tex}
+
+
+% Layers
+
+\pgfdeclarelayer{background}%
+\pgfsetlayers{background,main}%
+
+
+% Switch command
+\tikzset{on background layer/.style={
+ execute at begin scope={%
+ \pgfonlayer{background}%
+ \let\tikz@options=\pgfutil@empty%
+ \tikzset{every on background layer/.try,#1}%
+ \tikz@options},
+ execute at end scope={\endpgfonlayer}
+ }
+}%
+
+
+% Main style
+
+\tikzset{background rectangle/.style= {draw}}%
+\tikzset{background top/.style= {draw}}%
+\tikzset{background bottom/.style= {draw}}%
+\tikzset{background left/.style= {draw}}%
+\tikzset{background right/.style= {draw}}%
+\tikzset{background grid/.style= {help lines,draw}}%
+
+\tikzoption{inner frame sep}{\def\tikz@framexsep{#1}\def\tikz@frameysep{#1}}%
+\tikzoption{inner frame xsep}{\def\tikz@framexsep{#1}}%
+\tikzoption{inner frame ysep}{\def\tikz@frameysep{#1}}%
+\def\tikz@framexsep{1ex}%
+\def\tikz@frameysep{1ex}%
+
+\tikzoption{outer frame sep}{\def\tikz@outerframexsep{#1}\def\tikz@outerframeysep{#1}}%
+\tikzoption{outer frame xsep}{\def\tikz@outerframexsep{#1}}%
+\tikzoption{outer frame ysep}{\def\tikz@outerframeysep{#1}}%
+\def\tikz@outerframexsep{0ex}%
+\def\tikz@outerframeysep{0ex}%
+
+
+% Looseness
+
+\tikzset{loose background/.style= {inner frame sep=2ex}}%
+\tikzset{tight background/.style= {inner frame sep=0ex}}%
+
+
+
+% Showing background styles
+
+\tikzset{framed/.style= {style=show background rectangle}}%
+\tikzset{gridded/.style= {style=show background grid}}%
+
+\tikzset{show background rectangle/.style={execute at end picture=\tikz@background@framed}}%
+\tikzset{show background top/.style= {execute at end picture=\tikz@background@top}}%
+\tikzset{show background bottom/.style= {execute at end picture=\tikz@background@bottom}}%
+\tikzset{show background left/.style= {execute at end picture=\tikz@background@left}}%
+\tikzset{show background right/.style= {execute at end picture=\tikz@background@right}}%
+\tikzset{show background grid/.style= {execute at end picture=\tikz@background@grid}}%
+
+
+% Implementation
+
+\def\tikz@background@save{%
+ \pgftransformreset%
+ \ifx\tikz@bg@minx\@undefined%
+ \pgf@xb=\pgf@picminx%
+ \pgf@yb=\pgf@picminy%
+ \pgf@xc=\pgf@picmaxx%
+ \pgf@yc=\pgf@picmaxy%
+ \pgfmathsetlength{\pgf@x}{\tikz@framexsep}%
+ \pgfmathsetlength{\pgf@y}{\tikz@frameysep}%
+ \advance\pgf@xb by-\pgf@x%
+ \advance\pgf@yb by-\pgf@y%
+ \advance\pgf@xc by\pgf@x%
+ \advance\pgf@yc by\pgf@y%
+ \edef\tikz@bg@minx{\the\pgf@xb}%
+ \edef\tikz@bg@miny{\the\pgf@yb}%
+ \edef\tikz@bg@maxx{\the\pgf@xc}%
+ \edef\tikz@bg@maxy{\the\pgf@yc}%
+ \pgfmathsetlength{\pgf@x}{\tikz@outerframexsep}%
+ \pgfmathsetlength{\pgf@y}{\tikz@outerframeysep}%
+ \advance\pgf@xb by-\pgf@x%
+ \advance\pgf@yb by-\pgf@y%
+ \advance\pgf@xc by\pgf@x%
+ \advance\pgf@yc by\pgf@y%
+ \edef\tikz@bg@outerminx{\the\pgf@xb}%
+ \edef\tikz@bg@outerminy{\the\pgf@yb}%
+ \edef\tikz@bg@outermaxx{\the\pgf@xc}%
+ \edef\tikz@bg@outermaxy{\the\pgf@yc}%
+ \fi%
+}%
+
+\def\tikz@background@framed{%
+ \tikz@background@save%
+ \pgfonlayer{background}
+ \path[style=background rectangle] (\tikz@bg@minx,\tikz@bg@miny) rectangle (\tikz@bg@maxx,\tikz@bg@maxy);
+ \endpgfonlayer
+}%
+
+\def\tikz@background@top{%
+ \tikz@background@save%
+ \pgfonlayer{background}
+ \path[style=background top] (\tikz@bg@outerminx,\tikz@bg@maxy) -- (\tikz@bg@outermaxx,\tikz@bg@maxy);
+ \endpgfonlayer
+}%
+
+\def\tikz@background@bottom{%
+ \tikz@background@save%
+ \pgfonlayer{background}
+ \path[style=background bottom] (\tikz@bg@outerminx,\tikz@bg@miny) -- (\tikz@bg@outermaxx,\tikz@bg@miny);
+ \endpgfonlayer
+}%
+
+\def\tikz@background@left{%
+ \tikz@background@save%
+ \pgfonlayer{background}
+ \path[style=background left] (\tikz@bg@minx,\tikz@bg@outerminy) -- (\tikz@bg@minx,\tikz@bg@outermaxy);
+ \endpgfonlayer
+}%
+
+\def\tikz@background@right{%
+ \tikz@background@save%
+ \pgfonlayer{background}
+ \path[style=background right] (\tikz@bg@maxx,\tikz@bg@outerminy) -- (\tikz@bg@maxx,\tikz@bg@outermaxy);
+ \endpgfonlayer
+}%
+
+\def\tikz@background@grid{%
+ \tikz@background@save%
+ \pgfonlayer{background}
+ \path[style=background grid] (\tikz@bg@minx,\tikz@bg@miny) grid (\tikz@bg@maxx,\tikz@bg@maxy);
+ \endpgfonlayer
+}%
+
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarybending.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarybending.code.tex
new file mode 100644
index 0000000000..169995bcde
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarybending.code.tex
@@ -0,0 +1,15 @@
+% Copyright 2018 by Till Tantau
+%
+% 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{tikzlibrarybending.code.tex}
+
+\usepgfmodule{bending}%
+\tikzset{arrows=[flex]}%
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarycalc.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarycalc.code.tex
new file mode 100644
index 0000000000..373ea7752d
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarycalc.code.tex
@@ -0,0 +1,618 @@
+% Copyright 2019 by Till Tantau
+%
+% 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{tikzlibrarycalc.code.tex}
+
+%
+%
+% Part I: The let path command
+%
+%
+
+
+%
+% Syntax: let \p{name1} = (coord), \p{name2} = (coord), ... in ...
+%
+% Currently (this may get more fancy in the future), the (coord)s are
+% evaluated one by one. If the first evaluates to, say, (10pt,20pt),
+% the macro \p{name1} is set to "10pt,20pt" (without parentheses), the
+% macro \x{name1} is set to "10pt" and the macro \y{name1} is set to
+% "20pt".
+%
+% If you use a number for {name}, you need no parentheses, so you
+% could write:
+%
+% \draw let
+% \p1 = (1,1),
+% \p2 = ($ 2.5*(3,2) $)
+% in
+% (\x1,\x2) -- (\y1,\y2);
+
+\def\tikz@let@command et{%
+ \let\p=\tikz@cc@dop%
+ \let\x=\tikz@cc@dox%
+ \let\y=\tikz@cc@doy%
+ \let\n=\tikz@cc@don%
+ \pgfutil@ifnextchar i{\tikz@cc@stop@let}{\tikz@cc@handle@line}%
+}%
+\def\tikz@cc@handle@line{%
+ \pgfutil@ifnextchar\p{%
+ \tikz@cc@handle@coor%
+ }{%
+ \pgfutil@ifnextchar\n{%
+ \tikz@cc@handle@num%
+ }{%
+ \pgfutil@ifnextchar i{%
+ \tikz@cc@stop@let
+ }{%
+ \tikzerror{``\string\p'' or ``\string\n'' expected}%
+ }%
+ }%
+ }%
+}%
+\def\tikz@cc@handle@num\n#1#2=#3{%
+ \pgfmathparse{#3}%
+ \expandafter\edef\csname tikz@cc@n@#1\endcsname{\pgfmathresult\ifpgfmathunitsdeclared pt\fi}
+ \pgfutil@ifnextchar,{\tikz@cc@handle@nextline}{\tikz@cc@stop@let}%
+}%
+\def\tikz@cc@handle@coor\p#1#2={%
+ \def\tikz@cc@coord@name{#1}%
+ \tikz@scan@one@point\tikz@cc@dolet%
+}%
+\def\tikz@cc@dolet#1{%
+ \pgf@process{#1}%
+ \expandafter\edef\csname tikz@cc@p@\tikz@cc@coord@name\endcsname{\the\pgf@x,\the\pgf@y}%
+ \expandafter\edef\csname tikz@cc@x@\tikz@cc@coord@name\endcsname{\the\pgf@x}%
+ \expandafter\edef\csname tikz@cc@y@\tikz@cc@coord@name\endcsname{\the\pgf@y}%
+ \pgfutil@ifnextchar,{\tikz@cc@handle@nextline}{\tikz@cc@stop@let}%
+}%
+\def\tikz@cc@handle@nextline,{%
+ \tikz@cc@handle@line%
+}%
+\def\tikz@cc@stop@let in{%
+ \tikz@scan@next@command%
+}%
+
+\def\tikz@cc@dop#1{\csname tikz@cc@p@#1\endcsname}%
+\def\tikz@cc@dox#1{\csname tikz@cc@x@#1\endcsname}%
+\def\tikz@cc@doy#1{\csname tikz@cc@y@#1\endcsname}%
+\def\tikz@cc@don#1{\csname tikz@cc@n@#1\endcsname}%
+
+
+
+%
+%
+% Part II: The ($...$) parser
+%
+%
+
+\def\tikz@parse@calculator#1(${%$
+ \def\tikz@cc@command{#1}%
+ \begingroup%
+ %
+ % Parse main computation. It's a series of optional factors in front
+ % of coordinates.
+ %
+ \pgf@xa=0pt% We accumulate the result in here.
+ \pgf@ya=0pt%
+ \tikz@cc@parse+%
+}%
+
+\def\tikz@cc@parse{%
+ \pgfutil@ifnextchar${%$
+ % Ok, we found the end...
+ \tikz@cc@end%
+ }
+ {\pgfutil@ifnextchar+{%
+ % Ok, we found a coordinate...
+ \tikz@cc@add%
+ }{%
+ \pgfutil@ifnextchar-{%
+ \tikz@cc@sub%
+ }{%
+ \tikzerror{+ or - expected}%
+ \tikz@cc@end$%$
+ }%
+ }%
+ }%
+}%
+
+%
+% The end is reached with $
+%
+\def\tikz@cc@end$#1){%$
+ \xdef\tikz@marshal{\noexpand\pgfqpoint{\the\pgf@xa}{\the\pgf@ya}}%
+ \endgroup%
+ \expandafter\tikz@cc@command\expandafter{\tikz@marshal}%
+}%
+
+
+%
+% Another coordinate with +/-, possibly with a factor
+%
+\def\tikz@cc@add+{%
+ \def\tikz@cc@factor{1}%
+ \tikz@cc@factororcoordinate%
+}%
+\def\tikz@cc@sub-{%
+ \def\tikz@cc@factor{-1}%
+ \tikz@cc@factororcoordinate%
+}%
+
+%
+% Check for a factor: If we see a (, its a coordinate...
+%
+\def\tikz@cc@factororcoordinate{%
+ \pgfutil@ifnextchar({%)
+ % Ok, found coordinate
+ \tikz@cc@coordinate%
+ }{%
+ \tikz@cc@parse@factor%
+ }%
+}%
+
+%
+% ... otherwise it's a factor. It ends at ...*(
+%
+\def\tikz@cc@parse@factor#1*({%
+ \pgfmathparse{#1*\tikz@cc@factor}%
+ \let\tikz@cc@factor=\pgfmathresult%
+ \tikz@cc@coordinate(%)
+}%
+
+\def\tikz@cc@coordinate{%
+ \tikz@scan@absolute\tikz@cc@after@coordinate%
+}%
+\def\tikz@cc@after@coordinate#1{%
+ \pgf@process{#1}%
+ \pgf@xb=\pgf@x%
+ \pgf@yb=\pgf@y%
+ \tikz@cc@mid@checks%
+}%
+
+
+%
+% A coordinate can be followed by !...!(...)
+%
+
+\def\tikz@cc@mid@checks{%
+ \ifnum\the\catcode`\!=\active\relax
+ \expandafter\tikz@cc@mid@checks@active
+ \else
+ \expandafter\tikz@cc@mid@checks@nonactive
+ \fi
+}%
+
+\def\tikz@cc@mid@checks@nonactive{%
+ \pgfutil@ifnextchar!{%
+ \tikz@cc@mid@nonactive%
+ }{%
+ \advance\pgf@xa by\tikz@cc@factor\pgf@xb
+ \advance\pgf@ya by\tikz@cc@factor\pgf@yb
+ \tikz@cc@parse%
+ }%
+}%
+
+\def\tikz@cc@mid@nonactive!{%
+ \pgfutil@ifnextchar({%
+ \tikz@scan@one@point\tikz@cc@project%
+ }{%
+ \tikz@cc@mid@num@nonactive%
+ }%
+}%
+
+\begingroup
+ \catcode`\!=\active
+ \gdef\tikz@cc@mid@checks@active{%
+ \pgfutil@ifnextchar!{%
+ \tikz@cc@mid@active%
+ }{%
+ \advance\pgf@xa by\tikz@cc@factor\pgf@xb
+ \advance\pgf@ya by\tikz@cc@factor\pgf@yb
+ \tikz@cc@parse%
+ }%
+ }%
+
+ \gdef\tikz@cc@mid@active!{%
+ \pgfutil@ifnextchar({%
+ \tikz@scan@one@point\tikz@cc@project%
+ }{%
+ \tikz@cc@mid@num@active%
+ }%
+ }%
+\endgroup
+
+%
+% Partway case: (coord a)!number!(coord b)
+%
+% Returns the position that is at <number> fraction on the way from a
+% to b. This, (a)!0!(b) is (a), (a)!.5!(b) is the middle and (a)!1!(b)
+% is (b)
+%
+
+\def\tikz@cc@mid@num@nonactive#1!{\tikz@cc@mid@num{#1}}%
+
+\begingroup
+ \catcode`\!=\active
+ \gdef\tikz@cc@mid@num@active#1!{\tikz@cc@mid@num{#1}}%
+\endgroup
+
+\def\tikz@cc@mid@num#1{%
+ \pgfmathparse{#1}%
+ \ifpgfmathunitsdeclared%
+ \let\tikz@cc@mid@unit=\pgfmathresult%
+ \expandafter\tikz@cc@scan@rot\expandafter\tikz@cc@after@unit%
+ \else%
+ \let\tikz@cc@mid@factor=\pgfmathresult%
+ \pgfmathparse{1-\tikz@cc@mid@factor}%
+ \let\tikz@cc@mid@factor@one=\pgfmathresult%
+ \expandafter\tikz@cc@scan@rot\expandafter\tikz@cc@after@num%
+ \fi%
+}%
+
+\def\tikz@cc@after@num#1{%
+ \pgf@process{#1}%
+ \pgf@xb=\tikz@cc@mid@factor@one\pgf@xb%
+ \pgf@yb=\tikz@cc@mid@factor@one\pgf@yb%
+ \advance\pgf@xb by\tikz@cc@mid@factor\pgf@x%
+ \advance\pgf@yb by\tikz@cc@mid@factor\pgf@y%
+ \tikz@cc@mid@checks%
+}%
+
+
+
+%
+% Distance case: (coord a)!dimension!(coord b)
+%
+% Returns the position that is at <dimension> removed from (coord a)
+% in the direction of (coord b).
+%
+
+\def\tikz@cc@after@unit#1{%
+ \pgf@process{#1}%
+ \advance\pgf@x by-\pgf@xb%
+ \advance\pgf@y by-\pgf@yb%
+ \pgf@process{\pgfpointnormalised{}}%
+ \advance\pgf@xb by\tikz@cc@mid@unit\pgf@x%
+ \advance\pgf@yb by\tikz@cc@mid@unit\pgf@y%
+ \tikz@cc@mid@checks%
+}%
+
+%
+% Projection case: (a)!(p)!(b)
+%
+% Projection of p on line from a to b
+%
+\def\tikz@cc@project#1{%
+ \pgf@process{#1}%
+ % Save in c
+ \pgf@xc=\pgf@x%
+ \pgf@yc=\pgf@y%
+ \begingroup
+ \ifnum\the\catcode`\!=\active
+ \def\tikz@next{%
+ \endgroup
+ \expandafter\tikz@cc@scan@rot\expandafter\tikz@cc@after@project
+ \tikz@cc@scan@ex@active}%
+ \else
+ \def\tikz@next{%
+ \endgroup
+ \expandafter\tikz@cc@scan@rot\expandafter\tikz@cc@after@project
+ \tikz@cc@scan@ex@nonactive}%
+ \fi
+ \tikz@next%
+}%
+
+\def\tikz@cc@scan@ex@nonactive!{}%
+
+\begingroup
+ \catcode`\!=\active
+ \gdef\tikz@cc@scan@ex@active!{}%
+\endgroup
+
+\def\tikz@cc@after@project#1{%
+ \pgf@process{#1}%
+ % Ok, now we need to project (xc,yc) on the line (xb,xc) to (x,y)
+ \advance\pgf@x by-\pgf@xb%
+ \advance\pgf@y by-\pgf@yb%
+ \advance\pgf@xc by-\pgf@xb%
+ \advance\pgf@yc by-\pgf@yb%
+ \pgf@process{\pgfpointnormalised{}}%
+ % Scalar product
+ \pgf@xc=\pgf@sys@tonumber{\pgf@xc}\pgf@x%
+ \advance\pgf@xc by\pgf@sys@tonumber{\pgf@yc}\pgf@y%
+ % and add
+ \advance\pgf@xb by\pgf@sys@tonumber{\pgf@xc}\pgf@x%
+ \advance\pgf@yb by\pgf@sys@tonumber{\pgf@xc}\pgf@y%
+ \tikz@cc@mid@checks%
+}%
+
+%
+% Rotational scanner: radius:(x)
+%
+
+\def\tikz@cc@scan@rot#1{%
+ \pgfutil@ifnextchar({%)
+ \tikz@scan@one@point#1% normal
+ }%
+ {%
+ \def\tikz@cc@scan@rot@cmd{#1}%
+ \ifnum\the\catcode`\:=\active\relax
+ \expandafter\tikz@cc@scan@one@rot@active%
+ \else
+ \expandafter\tikz@cc@scan@one@rot@nonactive%
+ \fi
+ }%
+}%
+
+\def\tikz@cc@scan@one@rot@nonactive#1:{%
+ \def\tikz@cc@scan@rot@angle{#1}%
+ \tikz@scan@one@point\tikz@cc@handle@rot%
+}%
+
+\begingroup
+ \catcode`\:=\active
+ \gdef\tikz@cc@scan@one@rot@active#1:{%
+ \def\tikz@cc@scan@rot@angle{#1}%
+ \tikz@scan@one@point\tikz@cc@handle@rot%
+ }%
+\endgroup
+
+\def\tikz@cc@handle@rot#1{%
+ \pgf@process{#1}%
+ % Ok, now we need to rotate x/y around xb/xb by ...rot@angle
+ {%
+ \pgftransformreset%
+ % Save them...
+ \pgf@xc=\pgf@x%
+ \pgf@yc=\pgf@y%
+ \pgftransformshift{\pgfqpoint{\pgf@xb}{\pgf@yb}}%
+ \pgftransformrotate{\tikz@cc@scan@rot@angle}%
+ \pgftransformshift{\pgfqpoint{-\pgf@xb}{-\pgf@yb}}%
+ \pgfpointtransformed{\pgfqpoint{\pgf@xc}{\pgf@yc}}%
+ \expandafter
+ }%
+ \edef\tikz@marshal{\noexpand\tikz@cc@scan@rot@cmd{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}}%
+ \tikz@marshal%
+}%
+
+
+
+
+%
+%
+% Part III: Calculation coordinate systems
+%
+%
+
+% Tangent cs: Keys are a node and a point. Depending on the type of
+% node, the appropriate tangent computation should be done.
+
+\tikzdeclarecoordinatesystem{tangent}
+{%
+ \tikzset{cs/.cd,#1}%
+ \expandafter\ifx\csname tikz@tangent@\tikz@cs@type\endcsname\relax%
+ \tikzerror{I do not know how to compute the tangent to
+ a \tikz@cs@type}%
+ \pgfpointorigin%
+ \else%
+ \expandafter\tikz@scan@one@point\expandafter\tikz@lib@do@tangent\tikz@cs@point%
+ \fi%
+}%
+
+\tikzset{cs/node/.code=\tikz@cs@unpack{\tikz@cs@node}{\tikz@cs@type}{#1}}%
+\tikzset{cs/point/.store in=\tikz@cs@point}%
+
+\def\tikz@lib@do@tangent{\csname tikz@tangent@\tikz@cs@type\endcsname}%
+
+\def\tikz@tangent@coordinate#1{%
+ \pgfpointanchor{\tikz@cs@node}{center}%
+}%
+
+\def\tikz@tangent@circle#1{%
+ {%
+ % Step 1: Compute the transformed position of the input:
+ \pgf@process{\pgfpointtransformed{#1}}%
+ \pgf@xa=\pgf@x%
+ \pgf@ya=\pgf@y%
+ %
+ % Step 2: Compute vector from center of circle to transformed #1
+ %
+ \pgf@process{\pgfpointtransformed{\pgfpointanchor{\tikz@cs@node}{center}}}%
+ \advance\pgf@xa by-\pgf@x%
+ \advance\pgf@ya by-\pgf@y%
+ %
+ % Step 2: Reset transformations, they distract...
+ %
+ \pgftransformreset%
+ %
+ % Step 3: Transform to the center of the circle.
+ %
+ \pgftransformshift{\pgfpointanchor{\tikz@cs@node}{center}}%
+ %
+ % Step 4: Compute the radius
+ %
+ \pgf@process{\pgfpointanchor{\tikz@cs@node}{east}}%
+ \pgf@xc=\pgf@x%
+ %
+ % Now, (xa,ya) is a point. Compute the tangent from this point to
+ % a circle around the origin of radius xc.
+ %
+ % acos(radius/veclen(xa,ya)) is the angle of the tangent.
+ \pgfmathparse{veclen(\the\pgf@xa,\the\pgf@ya)}
+ \pgfmathparse{acos(\the\pgf@xc/\pgfmathresult)}
+ \ifnum\pgfkeysvalueof{/tikz/cs/solution}>1\relax%
+ \pgfmathparse{0-\pgfmathresult}%
+ \fi%
+ \let\tikz@lib@temp=\pgfmathresult%
+ %
+ % Now \pgfmathparse contains the desired angle. Use this to
+ % compute the correct position on the circle...
+ %
+ % But, first, rotate to the point.
+ \pgf@process{\pgfpointnormalised{\pgfqpoint{\pgf@xa}{\pgf@ya}}}%
+ \pgf@ya=-\pgf@y%
+ \pgftransformcm{\pgf@sys@tonumber{\pgf@x}}{\pgf@sys@tonumber{\pgf@y}}{\pgf@sys@tonumber{\pgf@ya}}{\pgf@sys@tonumber{\pgf@x}}{\pgfpointorigin}%
+ % Finally, rotate...
+ \pgf@process{\pgfpointtransformed{\pgfpointpolar{\tikz@lib@temp}{\the\pgf@xc}}}%
+ %
+ % Ok, undo transformations...
+ }%
+ % \pgf@x, \pgf@y have been smuggled outside by \pgf@process
+ {%
+ \pgftransforminvert%
+ \pgf@process{\pgfpointtransformed{}}%
+ }%
+}%
+
+
+% Implementation of intersections
+
+
+\def\tikz@intersect@circle@and@circle{%
+ {%
+ \pgftransformreset% transformations only confuse us, here...
+ %
+ % Compute origin and radius of first circle
+ %
+ \pgf@process{\pgfpointanchor{\tikz@cs@node@a}{center}}%
+ \pgf@xa=\pgf@x%
+ \pgf@ya=\pgf@y%
+ \pgf@process{\pgfpointanchor{\tikz@cs@node@a}{east}}%
+ \advance\pgf@x by-\pgf@xa%
+ \pgf@xc=\pgf@x% ok, pgf@xc is first radius, (xa,ya) is center
+ %
+ % Compute origin and radius of second circle
+ %
+ \pgf@process{\pgfpointanchor{\tikz@cs@node@b}{center}}%
+ \pgf@xb=\pgf@x%
+ \pgf@yb=\pgf@y%
+ \pgf@process{\pgfpointanchor{\tikz@cs@node@b}{east}}%
+ \advance\pgf@x by-\pgf@xb%
+ \pgf@yc=\pgf@x% \pgf@yc is second radius, (xb,yb) is center
+ %
+ \pgf@process{%
+ \pgfpointintersectionofcircles{\pgfqpoint{\pgf@xa}{\pgf@ya}}{\pgfqpoint{\pgf@xb}{\pgf@yb}}{\pgf@xc}{\pgf@yc}{\pgfkeysvalueof{/tikz/cs/solution}}%
+ }%
+ }%
+ % \pgf@x, \pgf@y have been smuggled outside by \pgf@process,
+ % reinstall transformations...
+ {%
+ \pgftransforminvert%
+ \pgf@process{\pgfpointtransformed{}}%
+ }%
+}%
+
+
+\def\tikz@intersect@line@and@circle{%
+ {%
+ %
+ % Step 1: Get line
+ %
+ \expandafter\tikz@scan@one@point\expandafter\tikz@parse@line\tikz@cs@line@a%
+ \pgf@process{\pgfpointtransformed{}}%
+ \pgf@xb=\pgf@x%
+ \pgf@yb=\pgf@y%
+ \pgf@process{\pgfpointtransformed{\pgfqpoint{\pgf@xc}{\pgf@yc}}}%
+ \pgf@xa=\pgf@x%
+ \pgf@ya=\pgf@y%
+ %
+ % Step 2: Subtract center of circle
+ %
+ \pgf@process{\pgfpointtransformed{\pgfpointanchor{\tikz@cs@node@b}{center}}}%
+ \advance\pgf@xa by-\pgf@x%
+ \advance\pgf@ya by-\pgf@y%
+ \advance\pgf@xb by-\pgf@x%
+ \advance\pgf@yb by-\pgf@y%
+ %
+ % Step 3: Reset transformations, they distract...
+ %
+ \pgftransformreset%
+ %
+ % Step 4: Transform to the center of the circle.
+ %
+ \pgftransformshift{\pgfpointanchor{\tikz@cs@node@b}{center}}%
+ %
+ % Step 5: Compute the radius
+ %
+ \pgf@process{\pgfpointanchor{\tikz@cs@node@b}{east}}%
+ \edef\tikz@lib@saved@radius{\pgf@sys@tonumber{\pgf@x}}%
+ %
+ % Step 6: Compute projection of origin on line (xa,ya) -- (xb,yb),
+ % store in (xa,ya)
+ \pgf@x=\pgf@xb%
+ \pgf@y=\pgf@yb%
+ \advance\pgf@x by-\pgf@xa%
+ \advance\pgf@y by-\pgf@ya%
+ \pgf@process{\pgfpointnormalised{}}%
+ % Scalar product
+ \pgf@xc=\pgf@sys@tonumber{\pgf@xa}\pgf@x%
+ \advance\pgf@xc by\pgf@sys@tonumber{\pgf@ya}\pgf@y%
+ \pgf@xc=-\pgf@xc%
+ % and add
+ \advance\pgf@xa by\pgf@sys@tonumber{\pgf@xc}\pgf@x%
+ \advance\pgf@ya by\pgf@sys@tonumber{\pgf@xc}\pgf@y%
+ %
+ % Now, we have a triangle with a right angle at (xa,ya). The
+ % second point of the triangle is the origin. The third point is
+ % sought.
+ % Save x/y
+ \pgf@xc=\pgf@x%
+ \pgf@yc=\pgf@y%
+ % Square radius
+ \pgf@xb=\tikz@lib@saved@radius pt%
+ %
+ % First, make numbers smaller, in case they are too large
+ %
+ \c@pgf@counta=1\relax%
+ \loop%
+ \ifdim\pgf@xb>50pt%
+ \multiply\c@pgf@counta by2\relax%
+ \divide\pgf@xa by2\relax%
+ \divide\pgf@ya by2\relax%
+ \divide\pgf@xb by2\relax%
+ \repeat%
+ \pgf@xb=\pgf@sys@tonumber{\pgf@xb}\pgf@xb%
+ % Subtract xa^2 + ya^2
+ \pgf@yb=\pgf@sys@tonumber{\pgf@xa}\pgf@xa%
+ \advance\pgf@xb by-\pgf@yb%
+ \pgf@yb=\pgf@sys@tonumber{\pgf@ya}\pgf@ya%
+ \advance\pgf@xb by-\pgf@yb%
+ % Square root
+ \ifdim\pgf@xb<0pt%
+ \pgf@xb=0pt%
+ \fi%
+ \pgfmathsqrt@{\pgf@sys@tonumber{\pgf@xb}}%
+ \pgfmathmultiply@{\pgfmathresult}{\the\c@pgf@counta}%
+ \multiply\pgf@xa by\c@pgf@counta\relax%
+ \multiply\pgf@ya by\c@pgf@counta\relax%
+ \ifnum\pgfkeysvalueof{/tikz/cs/solution}>1\relax%
+ \pgfmathsubtract{0}{\pgfmathresult}%
+ \fi%
+ % Ok, now add things...
+ \advance\pgf@xa by \pgfmathresult\pgf@xc%
+ \advance\pgf@ya by \pgfmathresult\pgf@yc%
+ \pgf@process{\pgfpointtransformed{\pgfqpoint{\pgf@xa}{\pgf@ya}}}%
+ % Ok, undo transformations...
+ }%
+ % \pgf@x, \pgf@y have been smuggled outside by \pgf@process
+ {%
+ \pgftransforminvert%
+ \pgf@process{\pgfpointtransformed{}}%
+ }%
+}%
+
+\def\tikz@intersect@circle@and@line{%
+ % Swap
+ {%
+ \let\tikz@cs@node@b=\tikz@cs@node@a%
+ \let\tikz@cs@line@a=\tikz@cs@line@b%
+ \tikz@intersect@line@and@circle%
+ }%
+}%
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarycalendar.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarycalendar.code.tex
new file mode 100644
index 0000000000..98cdffe154
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarycalendar.code.tex
@@ -0,0 +1,444 @@
+% Copyright 2018 by Till Tantau
+%
+% 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{tikzlibrarycalendar.code.tex}
+
+
+\pgfutil@usemodule{pgfcalendar}
+
+
+%
+% General options (these options affect all calendars typeset unsind \calendar):
+%
+% Start, end, and code executed for each current date
+%
+
+\tikzoption{dates}{\tikz@lib@cal@parse#1\relax}
+\def\tikz@lib@cal@parse#1to#2\relax{%
+ \def\tikz@lib@cal@start{#1}
+ \def\tikz@lib@cal@end{#2}%
+}
+\tikzoption{execute at begin day scope}{\expandafter\def\expandafter\tikz@atbegin@day\expandafter{\tikz@atbegin@day#1}}
+\tikzoption{execute at end day scope}{%
+ \def\pgf@temp{#1}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\tikz@atend@day%
+ \expandafter\expandafter\expandafter{\expandafter\pgf@temp\tikz@atend@day}}
+\tikzoption{execute before day scope}{\expandafter\def\expandafter\tikz@before@day\expandafter{\tikz@before@day#1}}
+\tikzoption{execute after day scope}{\expandafter\def\expandafter\tikz@after@day\expandafter{\tikz@after@day#1}}
+
+\let\tikz@atbegin@day=\pgfutil@empty
+\let\tikz@atend@day=\pgfutil@empty
+\let\tikz@before@day=\pgfutil@empty
+\let\tikz@after@day=\pgfutil@empty
+
+
+
+%
+% Options affecting some calendars:
+%
+
+%
+% Shifts and skips
+%
+
+% Shift between days
+
+\tikzoption{day xshift}{\def\tikz@lib@cal@xshift{#1}}
+\tikzoption{day yshift}{\def\tikz@lib@cal@yshift{#1}}
+
+\def\tikz@lib@cal@yshift{3ex}
+\def\tikz@lib@cal@xshift{3.5ex}
+
+
+% Shift between months
+
+\tikzoption{month xshift}{\def\tikz@lib@cal@month@xshift{#1}}
+\tikzoption{month yshift}{\def\tikz@lib@cal@month@yshift{#1}}
+
+\def\tikz@lib@cal@month@yshift{9ex}
+\def\tikz@lib@cal@month@xshift{9ex}
+
+
+
+
+% Templates for typesetting days, month, years
+
+\tikzoption{day code}{\def\tikzdaycode{#1}}
+\tikzoption{day text}{\def\tikzdaytext{#1}}
+\tikzoption{days}{\tikzset{every day/.append style={#1}}}
+\tikzset{every day/.style={anchor=base east}}
+
+\tikzoption{month code}{\def\tikzmonthcode{#1}}
+\tikzoption{month text}{\def\tikzmonthtext{#1}}
+\tikzset{every month/.style={}}
+
+\tikzoption{year code}{\def\tikzyearcode{#1}}
+\tikzoption{year text}{\def\tikzyeartext{#1}}
+\tikzset{every year/.style={}}
+
+\def\tikzdaycode{\node[name=\pgfcalendarsuggestedname,every day]{\tikzdaytext};}
+\def\tikzmonthcode{\node[every month]{\tikzmonthtext};}
+\def\tikzyearcode{\node[every year]{\tikzyeartext};}
+
+\def\tikzdaytext{\%d-}
+\def\tikzmonthtext{\%mt}
+\def\tikzyeartext{\%y0}
+
+
+% Internal option for storing the "width" of a calendar as a number of
+% days
+
+\tikzoption{tikz@lib@cal@width}{\def\tikz@lib@cal@width{#1}}
+
+\def\tikz@lib@cal@width{1}
+
+%
+% Days on a line
+%
+
+\tikzset{day list downward/.style={%
+ execute before day scope={
+ \ifdate{day of month=1}{\ifdate{equals=\pgfcalendarbeginiso}{}
+ {%
+ % On first of month, except when first date in calendar.
+ \pgfmathsetlength{\pgf@y}{\tikz@lib@cal@month@yshift}%
+ \pgftransformyshift{-\pgf@y}
+ }%
+ }{}%
+ },
+ execute after day scope={\pgfmathsetlength{\pgf@y}{\tikz@lib@cal@yshift}\pgftransformyshift{-\pgf@y}},
+ tikz@lib@cal@width=1
+}}
+\tikzset{day list upward/.style={%
+ execute before day scope={
+ \ifdate{day of month=1}{\ifdate{equals=\pgfcalendarbeginiso}{}
+ {%
+ % On first of month, except when first date in calendar.
+ \pgftransformyshift{\tikz@lib@cal@month@yshift}%
+ }%
+ }{}%
+ },
+ execute after day scope={\pgftransformyshift\tikz@lib@cal@yshift},
+ tikz@lib@cal@width=1
+}}
+\tikzset{day list right/.style={%
+ execute before day scope={
+ \ifdate{day of month=1}{\ifdate{equals=\pgfcalendarbeginiso}{}
+ {%
+ % On first of month, except when first date in calendar.
+ \pgftransformxshift{\tikz@lib@cal@month@xshift}%
+ }%
+ }{}%
+ },
+ execute after day scope={\pgftransformxshift\tikz@lib@cal@xshift},
+ tikz@lib@cal@width=30% not quite right, but close enough in most cases...
+}}
+
+\tikzset{day list left/.style={%
+ execute before day scope={
+ \ifdate{day of month=1}{\ifdate{equals=\pgfcalendarbeginiso}{}
+ {%
+ % On first of month, except when first date in calendar.
+ \pgfmathsetlength{\pgf@x}{\tikz@lib@cal@month@xshift}
+ \pgftransformxshift{-\pgf@x}%
+ }%
+ }{}%
+ },
+ execute after day scope={
+ \pgfmathsetlength{\pgf@x}{\tikz@lib@cal@xshift}
+ \pgftransformxshift{-\pgf@x}%
+ },
+ tikz@lib@cal@width=30% not quite right, but close enough in most cases...
+}}
+
+
+
+%
+% Week list
+%
+
+\tikzset{week list/.style={%
+ execute before day scope={%
+ \ifdate{day of month=1}{\ifdate{equals=\pgfcalendarbeginiso}{}
+ {%
+ % On first of month, except when first date in calendar.
+ \pgfmathsetlength{\pgf@y}{\tikz@lib@cal@month@yshift}%
+ \pgftransformyshift{-\pgf@y}
+ }%
+ }{}%
+ },
+ execute at begin day scope={%
+ \pgfmathsetlength\pgf@x{\tikz@lib@cal@xshift}%
+ \pgf@x=\pgfcalendarcurrentweekday\pgf@x%
+ \pgftransformxshift{\pgf@x}%
+ },
+ execute after day scope={%
+ \ifdate{Sunday}{%
+ \pgfmathsetlength{\pgf@y}{\tikz@lib@cal@yshift}%
+ \pgftransformyshift{-\pgf@y}
+ }{}%
+ },
+ tikz@lib@cal@width=7
+}}
+
+
+
+%
+% Month list
+%
+
+\tikzset{month list/.style={%
+ execute before day scope={%
+ \ifdate{day of month=1}{\ifdate{equals=\pgfcalendarbeginiso}{}
+ {%
+ % On first of month, except when first date in calendar.
+ \pgfmathsetlength{\pgf@y}{\tikz@lib@cal@month@yshift}%
+ \pgftransformyshift{-\pgf@y}
+ }%
+ }{}%
+ \ifdate{day of month=1}
+ {%
+ \edef\tikz@lib@cal@month@list@start{\pgfcalendarcurrentweekday}%
+ }{}%
+ \ifdate{equals=\pgfcalendarbeginiso}%
+ {%
+ % Computer day of week for start of month
+ {%
+ \c@pgf@counta=\pgfcalendarcurrentjulian%
+ \advance\c@pgf@counta by-\pgfcalendarcurrentday%
+ \advance\c@pgf@counta by1\relax%
+ \pgfcalendarjuliantoweekday{\c@pgf@counta}{\c@pgf@countb}%
+ \xdef\pgf@temp{\the\c@pgf@countb}%
+ }%
+ \let\tikz@lib@cal@month@list@start=\pgf@temp%
+ }{}%
+ },
+ execute at begin day scope={%
+ \pgfmathsetlength\pgf@xa{\tikz@lib@cal@xshift}%
+ \pgf@xb=\pgfcalendarcurrentday\pgf@xa%
+ \advance\pgf@xb by\tikz@lib@cal@month@list@start\pgf@xa%
+ \advance\pgf@xb by-\pgf@xa\relax%
+ \pgftransformxshift{\pgf@xb}%
+ },
+ tikz@lib@cal@width=37
+}}
+
+
+
+
+%
+% Month labels
+%
+
+\tikzset{month label left/.style={%
+ execute before day scope={\ifdate{day of month=1}{\tikzmonthcode}{}},
+ every month/.append style={anchor=base east,xshift=-3.5ex}
+}}
+
+\tikzset{month label left vertical/.style={%
+ execute before day scope={\ifdate{day of month=1}{\tikzmonthcode}{}},
+ every month/.append style={anchor=base east,xshift=-4.5ex,yshift=2.25ex,rotate=90}
+}}
+
+\tikzset{month label right/.style={%
+execute before day scope={\ifdate{day of month=1}{%
+ {%
+ \pgfmathsetlength{\pgf@xa}{\tikz@lib@cal@xshift}%
+ \pgftransformxshift{\tikz@lib@cal@width\pgf@xa}%
+ \pgftransformxshift{-\pgf@xa}%
+ \tikzmonthcode%
+ }}{}},
+ every month/.append style={anchor=base west,xshift=1ex}
+}}
+
+\tikzset{month label right vertical/.style={%
+ execute before day scope={\ifdate{day of month=1}{%
+ {%
+ \pgfmathsetlength{\pgf@xa}{\tikz@lib@cal@xshift}%
+ \pgftransformxshift{\tikz@lib@cal@width\pgf@xa}%
+ \pgftransformxshift{-\pgf@xa}%
+ \tikzmonthcode%
+ }}{}},
+ every month/.append style={anchor=base west,xshift=2ex,yshift=2.25ex,rotate=-90}
+}}
+
+\tikzset{month label above centered/.style={%
+ execute before day scope={%
+ \ifdate{day of month=1}{%
+ {
+ \pgfmathsetlength{\pgf@xa}{\tikz@lib@cal@xshift}%
+ \pgf@xb=\tikz@lib@cal@width\pgf@xa%
+ \advance\pgf@xb by-\pgf@xa%
+ \pgf@xb=.5\pgf@xb%
+ \pgftransformxshift{\pgf@xb}%
+ \pgftransformxshift{-1.5ex}%
+ \pgfmathsetlength{\pgf@y}{\tikz@lib@cal@yshift}%
+ \pgftransformyshift{1.25\pgf@y}
+ \tikzmonthcode%
+ }
+ }{}},
+ every month/.append style={anchor=base}
+}}
+
+\tikzset{month label above left/.style={%
+ execute before day scope={%
+ \ifdate{day of month=1}{%
+ {
+ \pgftransformxshift{-3.25ex}%
+ \pgfmathsetlength{\pgf@y}{\tikz@lib@cal@yshift}%
+ \pgftransformyshift{1.25\pgf@y}
+ \tikzmonthcode%
+ }
+ }{}},
+ every month/.append style={anchor=base west}
+}}
+
+
+
+\tikzset{month label above right/.style={%
+ execute before day scope={%
+ \ifdate{day of month=1}{%
+ {
+ \pgfmathsetlength{\pgf@xa}{\tikz@lib@cal@xshift}%
+ \pgf@xb=\tikz@lib@cal@width\pgf@xa%
+ \advance\pgf@xb by-\pgf@xa%
+ \pgftransformxshift{\pgf@xb}%
+ \pgfmathsetlength{\pgf@y}{\tikz@lib@cal@yshift}%
+ \pgftransformyshift{1.25\pgf@y}
+ \tikzmonthcode%
+ }
+ }{}},
+ every month/.append style={anchor=base east}
+}}
+
+\tikzset{month label below centered/.style={%
+ execute before day scope={%
+ \ifdate{day of month=1}{%
+ {
+ \pgfmathsetlength{\pgf@xa}{\tikz@lib@cal@xshift}%
+ \pgf@xb=\tikz@lib@cal@width\pgf@xa%
+ \advance\pgf@xb by-\pgf@xa%
+ \pgf@xb=.5\pgf@xb%
+ \pgftransformxshift{\pgf@xb}%
+ \pgftransformxshift{-1.5ex}%
+ \pgfmathsetlength{\pgf@y}{\tikz@lib@cal@yshift}%
+ \pgftransformyshift{-1.25\pgf@y}
+ \tikzmonthcode%
+ }
+ }{}},
+ every month/.append style={anchor=base}
+}}
+
+\tikzset{month label below left/.style={%
+ execute before day scope={%
+ \ifdate{day of month=1}{%
+ {
+ \pgftransformxshift{-3.25ex}%
+ \pgfmathsetlength{\pgf@y}{\tikz@lib@cal@yshift}%
+ \pgftransformyshift{-1.25\pgf@y}
+ \tikzmonthcode%
+ }
+ }{}},
+ every month/.append style={anchor=base west}
+}}
+
+
+
+%
+% Code of the actual \calendar command (tikz.code.tex contains \let\calendar=\tikz@lib@cal@calendar):
+%
+
+\def\tikz@lib@cal@calendar{%
+ \begingroup%
+ \let\tikz@lib@cal@ifs=\pgfutil@empty%
+ \tikz@resetexpandcount
+ \tikzset{name=,at={(0,0)}}%
+ \let\%=\pgfcalendarshorthand%
+ \tikzset{every calendar/.try}%
+ \tikz@lib@cal@scanner%
+}
+
+\def\tikz@lib@cal@scanner{%
+ \afterassignment\tikz@lib@cal@handle\let\pgf@let@token=%
+}
+
+\def\tikz@lib@cal@handle{%
+ \pgfutil@switch\pgfutil@ifx\pgf@let@token{%
+ {;}{\let\pgfutil@next\tikz@lib@cal@stop}%
+ {(}{\let\pgfutil@next\tikz@lib@cal@name}%)
+ {a}{\let\pgfutil@next\tikz@lib@cal@at}%
+ {[}{\let\pgfutil@next\tikz@lib@cal@option}%]
+ {i}{\let\pgfutil@next\tikz@lib@cal@if}%
+ }{\tikz@resetexpandcount\pgfutil@next}{\tikz@lib@cal@expand}%
+}
+\def\tikz@lib@cal@expand{%
+ \advance\tikz@expandcount by -1
+ \ifnum\tikz@expandcount<0\relax%
+ \tikzerror{Giving up on this calendar}%
+ \let\pgfutil@next=\tikz@lib@cal@end%
+ \else%
+ \let\pgfutil@next=\tikz@lib@cal@@expand
+ \fi%
+ \pgfutil@next}
+
+\def\tikz@lib@cal@@expand{\expandafter\tikz@lib@cal@scanner\pgf@let@token}
+
+
+\def\tikz@lib@cal@name#1){%
+ \tikzset{name=#1}%
+ \tikz@lib@cal@scanner%
+}
+\def\tikz@lib@cal@at t#1(#2){%
+ \tikzset{at={(#2)}}%
+ \tikz@lib@cal@scanner%
+}
+\def\tikz@lib@cal@option#1]{%
+ \tikzset{#1}%
+ \tikz@lib@cal@scanner%
+}
+\def\tikz@lib@cal@if f#1(#2){%
+ \pgfutil@ifnextchar[{\tikz@lib@cal@if@opt{#2}}{\tikz@lib@cal@if@code{#2}}}%}
+
+\def\tikz@lib@cal@if@opt#1[#2]{\tikz@lib@cal@if@code{#1}{\tikzset{#2}}}
+\def\tikz@lib@cal@if@code#1#2{%
+ \pgfutil@ifnextchar e{\tikz@lib@cal@if@else{#1}{#2}}{\tikz@lib@cal@if@else{#1}{#2}else{}}}
+
+\def\tikz@lib@cal@if@else#1#2else{%
+ \pgfutil@ifnextchar[{\tikz@lib@cal@if@else@opt{#1}{#2}}{\tikz@lib@cal@if@else@code{#1}{#2}}}%}
+\def\tikz@lib@cal@if@else@opt#1#2[#3]{\tikz@lib@cal@if@else@code{#1}{#2}{\tikzset{#3}}}
+\def\tikz@lib@cal@if@else@code#1#2#3{%
+ \expandafter\def\expandafter\tikz@lib@cal@ifs\expandafter{\tikz@lib@cal@ifs\ifdate{#1}{#2}{#3}}%
+ \tikz@lib@cal@scanner%
+}
+\def\tikz@lib@cal@stop{%
+ \pgftransformshift{\tikz@node@at}%
+ \expandafter\pgfcalendar\expandafter{\tikz@fig@name}{\tikz@lib@cal@start}{\tikz@lib@cal@end}%
+ {%
+ \tikz@before@day%
+ \scope%
+ \tikz@atbegin@day%
+ \tikz@lib@cal@ifs%
+ \tikzdaycode%
+ \tikz@atend@day%
+ \endscope%
+ \tikz@after@day%
+ }%
+ \endgroup%
+}
+
+\tikzoption{if}{%
+ \let\tikz@lib@cal@scanner@orig=\tikz@lib@cal@scanner%
+ \let\tikz@lib@cal@scanner=\relax%
+ \tikz@lib@cal@if f#1\relax%
+ \let\tikz@lib@cal@scanner=\tikz@lib@cal@scanner@orig}
+
+
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarychains.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarychains.code.tex
new file mode 100644
index 0000000000..1d85b27c45
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarychains.code.tex
@@ -0,0 +1,214 @@
+% Copyright 2018 by Till Tantau
+%
+% 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{tikzlibrarychains.code.tex}
+
+\usetikzlibrary{positioning}%
+
+\tikzset{start chain/.default=,
+ start chain/.code={%
+ \tikz@lib@chain@parse{#1}%
+ \ifx\tikz@lib@chain@name\pgfutil@empty%
+ \def\tikz@lib@chain@name{chain}%
+ \fi%
+ \ifx\tikz@lib@chain@direction\relax%
+ \let\tikz@lib@chain@direction=\tikz@lib@chain@default@direction%
+ \fi%
+ \expandafter\ifx\csname tikz@lib@chain@active@\tikz@lib@chain@name\endcsname\relax%
+ \expandafter\let\csname tikz@lib@chain@active@\tikz@lib@chain@name\endcsname=\pgfutil@empty% does not matter
+ \expandafter\global\expandafter\let\csname tikz@lib@chain@exists@\tikz@lib@chain@name\endcsname=\pgfutil@empty% does not matter
+ % Setup chain parameters
+ \expandafter\gdef\csname tikz@lib@chain@count@\tikz@lib@chain@name\endcsname{0}%
+ \expandafter\global\expandafter\let\csname tikz@lib@chain@dir@\tikz@lib@chain@name\endcsname\tikz@lib@chain@direction%
+ \let\tikz@lib@current@chain=\tikz@lib@chain@name%
+ \let\chainin=\tikz@lib@chainin%
+ \else%
+ \tikzerror{Chain ``\tikz@lib@chain@name'' is already active}%
+ \fi%
+ },
+ continue chain/.default=,
+ continue chain/.code={%
+ \tikz@lib@chain@parse{#1}%
+ \ifx\tikz@lib@chain@name\pgfutil@empty%
+ \let\tikz@lib@chain@name\tikz@lib@current@chain%
+ \fi%
+ \expandafter\ifx\csname tikz@lib@chain@exists@\tikz@lib@chain@name\endcsname\relax%
+ \tikzerror{Unknown chain ``#1''}%
+ \else%
+ \let\tikz@lib@current@chain=\tikz@lib@chain@name%
+ \expandafter\let\csname tikz@lib@chain@active@\tikz@lib@chain@name\endcsname=\pgfutil@empty% does not matter
+ \ifx\tikz@lib@chain@direction\relax%
+ % Just restart...
+ \else%
+ % Setup chain parameters
+ \expandafter\global\expandafter\let\csname tikz@lib@chain@dir@\tikz@lib@chain@name\endcsname\tikz@lib@chain@direction%
+ \fi%
+ \fi%
+ },
+ join/.code=\tikz@lib@parse@join{#1},
+ join/.default={}%
+}%
+
+\def\tikz@lib@chain@parse#1{%
+ \pgfutil@in@{going }{#1}%
+ \ifpgfutil@in@%
+ \tikz@lib@chain@going#1\pgf@stop%
+ \else%
+ \pgfutil@in@{placed }{#1}%
+ \ifpgfutil@in@%
+ \tikz@lib@chain@positioning#1\pgf@stop%
+ \else%
+ \def\tikz@lib@chain@name{#1}%
+ \let\tikz@lib@chain@direction\relax%
+ \fi%
+ \fi%
+}%
+
+\def\tikz@lib@chain@going#1going #2\pgf@stop{%
+ \def\tikz@lib@chain@name{#1}%
+ \ifx\tikz@lib@chain@name\pgfutil@empty%
+ \else%
+ \tikz@lib@chain@strip#1\pgf@stop%%
+ \fi%
+ \tikz@lib@chain@is@goingtrue%
+ \def\tikz@lib@chain@direction{%
+ \ifx\tikzchainprevious\pgfutil@empty%
+ \else%
+ \tikz@lib@chain@place{#2}%
+ \fi%
+ }%
+}%
+
+\def\tikz@lib@chain@positioning#1placed #2\pgf@stop{%
+ \def\tikz@lib@chain@name{#1}%
+ \ifx\tikz@lib@chain@name\pgfutil@empty%
+ \else%
+ \tikz@lib@chain@strip#1\pgf@stop%%
+ \fi%
+ \tikz@lib@chain@is@goingfalse%
+ \def\tikz@lib@chain@direction{\tikz@lib@chain@place{#2}}%
+}%
+\newif\iftikz@lib@chain@is@going
+
+
+\tikzset{/tikz/chain default direction/.code=%
+ {%
+ \tikz@lib@chain@parse{#1}%
+ \let\tikz@lib@chain@default@direction=\tikz@lib@chain@direction%
+ },%
+ /tikz/chain default direction=going right
+}%
+
+\def\tikz@lib@current@chain{chain}%
+
+\pgfutil@g@addto@macro\tikz@node@reset@hook{\let\tikz@lib@chain@caller=\relax}%
+\pgfutil@g@addto@macro\tikz@node@begin@hook{\tikz@lib@chain@caller}%
+
+\tikzset{
+ on chain/.default=,
+ on chain/.code=\tikz@lib@on@chain{#1}%
+}%
+\def\tikz@lib@on@chain#1{%
+ \tikz@lib@chain@parse{#1}%
+ \ifx\tikz@lib@chain@name\pgfutil@empty%
+ \let\tikz@lib@chain@name\tikz@lib@current@chain%
+ \fi%
+ \expandafter\ifx\csname tikz@lib@chain@exists@\tikz@lib@chain@name\endcsname\relax%
+ \tikzerror{Unknown chain ``\tikz@lib@chain@name''}%
+ \else%
+ \c@pgf@counta\csname tikz@lib@chain@count@\tikz@lib@chain@name\endcsname\relax%
+ \ifnum\c@pgf@counta=0\relax%
+ \global\let\tikzchainprevious=\pgfutil@empty%
+ \else
+ \xdef\tikzchainprevious{\tikz@lib@chain@name-\the\c@pgf@counta}%
+ \fi%
+ \advance\c@pgf@counta by1\relax%
+ \xdef\tikzchaincount{\the\c@pgf@counta}%
+ \ifx\tikz@lib@chain@direction\relax%
+ \csname tikz@lib@chain@dir@\tikz@lib@chain@name\endcsname% use default
+ \else%
+ \tikz@lib@chain@direction%
+ \fi%
+ \edef\tikz@lib@chain@caller{\noexpand\tikz@lib@chain@last@found{\tikz@lib@chain@name}}%
+ \fi%
+}%
+\def\tikz@lib@chain@last@found#1{%
+ % Increase the count and set name, if necessary.
+ \c@pgf@counta\csname tikz@lib@chain@count@#1\endcsname\relax%
+ \advance\c@pgf@counta by1\relax%
+ \xdef\tikzchaincurrent{#1-\the\c@pgf@counta}%
+ \expandafter\xdef\csname tikz@lib@chain@count@#1\endcsname{\the\c@pgf@counta}%
+ \ifnum\c@pgf@counta=1\relax%
+ \tikzset{alias/.expanded={#1-begin}} % Define pseudostart
+ \fi%
+ \tikzset{alias/.expanded={#1-end}} % Define pseudostart
+ \tikzset{alias/.expanded={#1-\the\c@pgf@counta}} % Define pseudostart
+ \tikz@lib@chain@direction%
+ \tikzset{every on chain/.try}%
+}%
+
+
+\def\tikz@lib@chain@place#1{%
+ \pgfutil@in@{=}{#1}%
+ \ifpgfutil@in@%
+ \tikzset{#1}%
+ \else%
+ \tikzset{#1=of \tikzchainprevious}%
+ \fi%
+}%
+
+\def\tikz@lib@chain@strip#1 \pgf@stop{%
+ \def\tikz@lib@chain@name{#1}%
+}%
+
+\def\tikz@lib@parse@join#1{%
+ \def\tikz@temp{#1}%
+ \ifx\tikz@temp\pgfutil@empty%
+ \tikz@lib@parse@join@by by \pgf@stop%
+ \else%
+ \pgfutil@in@{with }{#1}%
+ \ifpgfutil@in@%
+ \pgfutil@in@{by }{#1}%
+ \ifpgfutil@in@%
+ \tikz@lib@parse@join@with@by#1\pgf@stop%
+ \else%
+ \tikz@lib@parse@join@with@by#1 by \pgf@stop%
+ \fi%
+ \else%
+ \tikz@lib@parse@join@by#1\pgf@stop%
+ \fi%
+ \fi%
+}%
+\def\tikz@lib@parse@join@with@by with #1 by #2\pgf@stop{%
+ \tikzset{after node path={(#1)edge[every join,#2](\tikzchaincurrent)}}%
+}%
+\def\tikz@lib@parse@join@by by #1\pgf@stop{%
+ \tikzset{after node path={\ifx\tikzchainprevious\pgfutil@empty\else (\tikzchainprevious)edge[every join,#1](\tikzchaincurrent)\fi}}%
+}%
+\tikzset{every join/.style=}%
+
+
+\def\tikz@lib@chainin#1(#2){\pgfutil@ifnextchar[{\tikz@lib@chainin@{#2}}{\tikz@lib@chainin@{#2}[]}}%]%
+\def\tikz@lib@chainin@#1[#2]{\path[late options={name=#1,on chain,every chain in/.try,#2}]}%
+
+
+%
+% Branches
+%
+
+\tikzset{start branch/.code={%
+ % save last node on current chain:
+ \let\tikz@lib@save@current\tikz@lib@current@chain%
+ \pgfkeysalso{/tikz/start chain/.expand once=\tikz@lib@current@chain/#1}%
+ \path[late options={name=\tikz@lib@save@current-end,on chain}];%
+ }%
+}%
+\tikzset{continue branch/.style={continue chain/.expand once=\tikz@lib@current@chain/#1}}%
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarydecorations.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarydecorations.code.tex
new file mode 100644
index 0000000000..bfe8863efc
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarydecorations.code.tex
@@ -0,0 +1,194 @@
+% Copyright 2018 by 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.
+
+\usepgfmodule{decorations}%
+
+% Define the basic decoration stuff for tikz. Load more libraries to
+% "actually use" decorations
+
+\tikzset{decorate/.is if=tikz@decoratepath,
+ /pgf/decoration/name/.store in=\tikz@decoration@name,
+ /pgf/decoration/.unknown/.code=%
+ \pgfifdecoration{\pgfkeyscurrentname}{\edef\tikz@decoration@name{\pgfkeyscurrentname}}
+ {\pgfifmetadecoration{\pgfkeyscurrentname}{\edef\tikz@decoration@name{\pgfkeyscurrentname}}
+ % Fully expand `\pgfkeyscurrentname' before being used in first-arg of
+ % `/errors/unknown key'.
+ {\pgfkeys{/errors/unknown
+ key/.expanded={/pgf/decoration/\pgfkeyscurrentname}{\pgfutil@unexpanded{#1}}}}},%
+ /pgf/decoration/raise/.code={\def\tikz@dec@shift{\pgftransformyshift{#1}}\tikz@dec@trans},
+ /pgf/decoration/mirror/.code={%
+ \csname if#1\endcsname
+ \def\tikz@dec@mirror{\pgftransformyscale{-1}}%
+ \else%
+ \let\tikz@dec@mirror=\relax%
+ \fi%
+ \tikz@dec@trans%
+ },
+ /pgf/decoration/mirror/.default=true,
+ /pgf/decoration/transform/.code={%
+ {%
+ \pgftransformreset%
+ \def\tikz@transform{}%
+ \pgfkeysalso{/tikz/.cd, #1}%
+ \expandafter\gdef\expandafter\tikz@g@temptransform\expandafter{\tikz@transform}%
+ }%
+ \let\tikz@dec@user@transform=\tikz@g@temptransform%
+ \tikz@dec@trans%
+ },%
+ /pgf/decoration/pre/.initial=lineto,
+ /pgf/decoration/post/.initial=lineto,
+ /pgf/decoration/pre length/.initial=0pt,
+ /pgf/decoration/post length/.initial=0pt,
+}%
+
+\let\tikz@decoration@name=\tikz@nonetext
+
+\def\tikz@dec@trans{\pgfsetdecorationsegmenttransformation{\tikz@dec@user@transform\tikz@dec@mirror\tikz@dec@shift}}%
+\let\tikz@dec@user@transform=\relax
+\let\tikz@dec@shift=\relax
+\let\tikz@dec@mirror=\relax
+
+\pgfdeclaremetadecoration{tikz@internal}{pre}{%
+ \state{pre}[width=\pgfkeysvalueof{/pgf/decoration/pre length}, next state=main]
+ {
+ \tikz@dec@trans
+ \decoration{\pgfkeysvalueof{/pgf/decoration/pre}}
+ }%
+ \state{main}[width=\pgfmetadecoratedremainingdistance-\pgfkeysvalueof{/pgf/decoration/post length}, next state=final]
+ {
+ \tikz@dec@trans
+ \decoration{\tikz@decoration@name}
+ }%
+ \state{final}
+ {
+ \tikz@dec@trans
+ \decoration{\pgfkeysvalueof{/pgf/decoration/post}}
+ }%
+}%
+
+
+\newif\iftikz@metadecoration
+
+\def\tikz@lib@dec@addtomacro#1#2{\expandafter\def\expandafter#1\expandafter{#1#2}}%
+
+\def\tikz@lib@decoration[#1]{%
+ \begingroup%
+ % Just to be on the save side...
+ %
+ % Now, let's parse the options:
+ \tikzset{#1}%
+ %
+ \ifx\tikz@decoration@name\tikz@nonetext%
+ % Ok, let's forget about this decoration stuff...
+ \else
+ \expandafter\tikz@lib@do@dec%
+ \fi%
+ % Now, we expect a brace.
+ \pgfutil@ifnextchar\bgroup{%
+ \begingroup%
+ \tikz@auto@end@pathfalse%
+ \aftergroup\tikz@enddecoration%
+ \afterassignment\tikz@scan@next@command%
+ \let\tikz@lib@next% gobble \bgroup%
+ }%
+ {%
+ \tikzerror{A decoration must begin with a brace}%
+ \tikz@enddecoration%
+ }%
+}%
+\def\tikz@lib@do@dec{%
+ % Ok, now what?
+ \pgfifmetadecoration{\tikz@decoration@name}%
+ {\expandafter\pgfmetadecoration\expandafter{\tikz@decoration@name}}%
+ {%
+ \pgfifdecoration{\tikz@decoration@name}%
+ {\tikz@lib@dec@startdecoration}%
+ {\tikzerror{Unknown (meta-)decoration '\tikz@decoration@name'. Perhaps you
+ misspelled it?}}%
+ }%
+ \ifx\pgfdecorateexistingpath\pgfutil@empty%
+ \pgfpathmoveto{\pgfqpoint{\the\tikz@lastxsaved}{\the\tikz@lastysaved}}%
+ \fi%
+}%
+\newbox\tikz@lib@dec@box
+\def\tikz@enddecoration{%
+ \global\setbox\tikz@lib@dec@box=\box\tikz@tempbox%
+ \ifx\tikz@decoration@name\tikz@nonetext%
+ % ignore this.
+ \else
+ % Ok, now what?
+ \iftikz@metadecoration%
+ \endpgfmetadecoration%
+ \else%
+ \tikz@lib@dec@stopdecoration%
+ \fi%
+ \fi
+ \endgroup%
+ \setbox\tikz@tempbox=\box\tikz@lib@dec@box%
+}%
+
+
+\def\tikz@lib@dec@decorate@path{%
+ \ifx\tikz@decoration@name\tikz@nonetext%
+ \else%
+ \pgfgetpath\tikz@lib@dec@currentpath%
+ \pgfsetpath\pgfutil@empty%
+ \pgfifmetadecoration{\tikz@decoration@name}
+ {
+ \expandafter\pgfmetadecoration\expandafter{\tikz@decoration@name}%
+ \pgfsetpath\tikz@lib@dec@currentpath%
+ \endpgfmetadecoration%
+ }
+ {
+ \pgfifdecoration{\tikz@decoration@name}
+ {
+ \tikz@lib@dec@startdecoration%
+ \pgfsetpath\tikz@lib@dec@currentpath%
+ \tikz@lib@dec@stopdecoration%
+ }
+ {
+ \tikzerror{Unknown (meta-)decoration '\tikz@decoration@name'. Perhaps
+ you misspelled it?}
+ }
+ }
+ \fi%
+}%
+
+\def\tikz@lib@dec@zpttext{0pt}%
+
+\newif\iftikz@lib@dec@temp
+\def\tikz@lib@dec@startdecoration{%
+ \pgfkeysgetvalue{/pgf/decoration/pre length}{\tikz@lib@pre}%
+ \pgfkeysgetvalue{/pgf/decoration/post length}{\tikz@lib@post}%
+ \tikz@lib@dec@tempfalse%
+ \ifx\tikz@lib@pre\tikz@lib@dec@zpttext%
+ \ifx\tikz@lib@post\tikz@lib@dec@zpttext%
+ \else%
+ \tikz@lib@dec@temptrue%
+ \fi%
+ \else%
+ \tikz@lib@dec@temptrue%
+ \fi%
+ \iftikz@lib@dec@temp%
+ \pgfmetadecoration{tikz@internal}%
+ \else%
+ \expandafter\pgfdecoration\expandafter{\expandafter{\tikz@decoration@name}{\pgfdecoratedpathlength}{}{}}%
+ \fi%
+}%
+
+\def\tikz@lib@dec@stopdecoration{%
+ \iftikz@lib@dec@temp%
+ \endpgfmetadecoration%
+ \else%
+ \endpgfdecoration%
+ \fi%
+}%
+
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarydecorations.footprints.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarydecorations.footprints.code.tex
new file mode 100644
index 0000000000..10bc743f24
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarydecorations.footprints.code.tex
@@ -0,0 +1,13 @@
+% Copyright 2018 by 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.
+
+\usetikzlibrary{decorations}%
+\usepgflibrary{decorations.footprints}%
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarydecorations.fractals.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarydecorations.fractals.code.tex
new file mode 100644
index 0000000000..4ef2342784
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarydecorations.fractals.code.tex
@@ -0,0 +1,13 @@
+% Copyright 2018 by 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.
+
+\usetikzlibrary{decorations}%
+\usepgflibrary{decorations.fractals}%
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarydecorations.markings.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarydecorations.markings.code.tex
new file mode 100644
index 0000000000..04f3e571b1
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarydecorations.markings.code.tex
@@ -0,0 +1,31 @@
+% Copyright 2018 by 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.
+
+\usetikzlibrary{decorations}%
+\usepgflibrary{decorations.markings}%
+
+% Upgrade \arrow command
+\def\pgf@lib@dec@doarrowhead{%
+ \pgfutil@ifnextchar[{\tikz@lib@dec@doarrowhead}{\tikz@lib@dec@doarrowhead[]}%]
+}%
+\def\tikz@lib@dec@doarrowhead[#1]#2{%
+ \scope[#1]
+ \pgf@lib@dec@arrowhead{1}{#2}%
+ \endscope
+}%
+\def\pgf@lib@dec@doarrowheadrev{%
+ \pgfutil@ifnextchar[{\tikz@lib@dec@doarrowheadrev}{\tikz@lib@dec@doarrowheadrev[]}%]
+}%
+\def\tikz@lib@dec@doarrowheadrev[#1]#2{%
+ \scope[#1]
+ \pgf@lib@dec@arrowhead{-1}{#2}%
+ \endscope
+}%
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarydecorations.pathmorphing.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarydecorations.pathmorphing.code.tex
new file mode 100644
index 0000000000..5bc38b1dc8
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarydecorations.pathmorphing.code.tex
@@ -0,0 +1,13 @@
+% Copyright 2018 by 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.
+
+\usetikzlibrary{decorations}%
+\usepgflibrary{decorations.pathmorphing}%
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarydecorations.pathreplacing.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarydecorations.pathreplacing.code.tex
new file mode 100644
index 0000000000..4f52ff9a1e
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarydecorations.pathreplacing.code.tex
@@ -0,0 +1,36 @@
+% Copyright 2018 by 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.
+
+\usetikzlibrary{decorations}%
+\usepgflibrary{decorations.pathreplacing}%
+
+
+\def\tikz@lib@dec@installinputsegmentpoints{%
+ \pgf@process{\pgf@decorate@inputsegment@first}%
+ \edef\tikzinputsegmentfirst{\the\pgf@x,\the\pgf@y}%
+ %
+ \pgf@process{\pgf@decorate@inputsegment@last}%
+ \edef\tikzinputsegmentlast{\the\pgf@x,\the\pgf@y}%
+ %
+ \pgf@process{\pgf@decorate@inputsegment@supporta}%
+ \edef\tikzinputsegmentsupporta{\the\pgf@x,\the\pgf@y}%
+ %
+ \pgf@process{\pgf@decorate@inputsegment@supportb}%
+ \edef\tikzinputsegmentsupportb{\the\pgf@x,\the\pgf@y}%
+}%
+
+\pgfkeys{
+ /pgf/decoration/.cd,
+ moveto code/.code=\def\pgfdecoratedinputsegmentmovetocode{\tikz@lib@dec@installinputsegmentpoints#1},
+ lineto code/.code=\def\pgfdecoratedinputsegmentlinetocode{\tikz@lib@dec@installinputsegmentpoints#1},
+ curveto code/.code=\def\pgfdecoratedinputsegmentcurvetocode{\tikz@lib@dec@installinputsegmentpoints#1},
+ closepath code/.code=\def\pgfdecoratedinputsegmentclosepathcode{\tikz@lib@dec@installinputsegmentpoints#1}
+}%
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarydecorations.shapes.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarydecorations.shapes.code.tex
new file mode 100644
index 0000000000..3074a03905
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarydecorations.shapes.code.tex
@@ -0,0 +1,13 @@
+% Copyright 2018 by 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.
+
+\usetikzlibrary{decorations}%
+\usepgflibrary{decorations.shapes}%
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarydecorations.text.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarydecorations.text.code.tex
new file mode 100644
index 0000000000..030135d8f5
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarydecorations.text.code.tex
@@ -0,0 +1,704 @@
+% Copyright 2018 by 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.
+
+\usetikzlibrary{decorations}%
+\usepgflibrary{decorations.text}%
+
+
+% Code for the `text effects along path' decoration
+
+% Some text constants
+% To do: merge these with existing text constants
+\def\tikz@lib@dec@te@space@text{space}%
+\def\tikz@lib@dec@align@left@text{left}%
+\def\tikz@lib@dec@align@right@text{right}%
+\def\tikz@lib@dec@align@center@text{center}%
+\def\tikz@lib@dec@te@none@text{none}%
+
+% Some ifs
+\newif\iftikz@lib@dec@te@pathfromtext%
+\newif\iftikz@lib@dec@te@segmentfromwidth%
+\newif\iftikz@lib@dec@te@scaletexttopath%
+\newif\iftikz@lib@dec@te@fittexttopath%
+\newif\iftikz@lib@dec@te@wordsep%
+\newif\iftikz@lib@dec@te@finalletter%
+
+
+% Utility macros
+% To do: integrate with existing pgf macros
+\def\tikz@lib@dec@te@addto@macro#1#2{%
+ \expandafter\def\expandafter#1\expandafter{#1#2}%
+}%
+
+\def\tikz@lib@dec@te@namelet#1#2{%
+ \expandafter\expandafter\expandafter\let\expandafter\expandafter\csname\expandafter#1\expandafter\endcsname\expandafter=\csname#2\endcsname%
+}%
+
+\def\tikz@lib@dec@te@advancecountmacro#1#2{%
+ \pgfutil@tempcnta=#1\relax%
+ \advance\pgfutil@tempcnta by#2\relax%
+ \edef#1{\the\pgfutil@tempcnta}%
+}%
+
+\def\tikz@lib@dec@te@advancedimenmacro#1#2{%
+ \pgf@x=#1\relax%
+ \advance\pgf@x by#2\relax%
+ \edef#1{\the\pgf@x}%
+}%
+
+% Macros for defining and updating text parameters
+\def\tikz@lib@dec@te@start@parameters#1{%
+ \expandafter\let\csname tikz@lib@dec@te@character@#1\endcsname=\pgfutil@empty%
+}%
+
+\def\tikz@lib@dec@te@addto@parameters#1#2{%
+ \expandafter\tikz@lib@dec@te@addto@macro\expandafter%
+ {\csname tikz@lib@dec@te@character@#1\endcsname}{#2}%
+}%
+\def\tikz@lib@dec@te@addmacroto@parameters#1#2{%
+ \def\tikz@lib@dec@te@marshal{\expandafter\tikz@lib@dec@te@addto@macro\expandafter%
+ {\csname tikz@lib@dec@te@character@#1\endcsname}}%
+ \expandafter\tikz@lib@dec@te@marshal\expandafter{\expandafter\def\expandafter#2\expandafter{#2}}%
+}%
+
+\def\tikz@lib@dec@te@getparameters#1{\csname tikz@lib@dec@te@character@#1\endcsname}%
+
+
+
+\let\tikz@lib@dec@te@textoptions=\pgfutil@empty
+\let\tikz@lib@dec@te@widthoptions=\pgfutil@empty
+\let\tikz@lib@dec@te@charactercountvar=\pgfutil@empty
+\let\tikz@lib@dec@te@charactertotalvar=\pgfutil@empty
+\let\tikz@lib@dec@te@lettercountvar=\pgfutil@empty
+\let\tikz@lib@dec@te@lettertotalvar=\pgfutil@empty
+\let\tikz@lib@dec@te@wordcountvar=\pgfutil@empty
+\let\tikz@lib@dec@te@wordctotalvar=\pgfutil@empty
+\let\tikz@lib@dec@te@transformtext=\pgfutil@empty%
+
+
+% Keys... lots of them...
+\pgfkeys{/pgf/decoration/text effects/.cd,
+ .unknown/.code={\let\tikz@lib@dec@te@key@tmp=\pgfkeyscurrentname%
+ \pgfkeysalso{/tikz/\tikz@lib@dec@te@key@tmp={#1}}},
+ path from text/.is if=tikz@lib@dec@te@pathfromtext,
+ path from text angle/.store in=\tikz@lib@dec@te@pathfromtextangle,
+ path from text angle=0,
+ fit text to path/.is if=tikz@lib@dec@te@fittexttopath,
+ characters/.style={/pgf/decoration/text effects/every character/.style={#1}},
+ characters/.append/.code={\pgfkeysalso{/pgf/decoration/text effects/every character/.append style={#1}}},
+ character widths/.code={\pgfkeysalso{/pgf/decoration/text effects/every character width/.style={#1}}},
+ character widths/.append/.code={\pgfkeysalso{/pgf/decoration/text effects/every character width/.append style={#1}}},
+ character count/.store in=\tikz@lib@dec@te@charactercountvar,
+ character count=,
+ character total/.store in=\tikz@lib@dec@te@charactertotalvar,
+ character total=,
+ letter count/.store in=\tikz@lib@dec@te@lettercountvar,
+ letter count=,
+ letter total/.store in=\tikz@lib@dec@te@lettertotalvar,
+ letter total=,
+ word count/.store in=\tikz@lib@dec@te@wordcountvar,
+ word count=,
+ word total/.store in=\tikz@lib@dec@te@wordtotalvar,
+ word total=,
+ %
+ style characters/.code args={#1 with #2}{\tikz@lib@dec@te@parse@stylecharacters{#1}{#2}},
+ text along path/.style={
+ inner xsep=0pt,
+ anchor=base,
+ transform shape
+ },
+ segment from width/.is if=tikz@lib@dec@te@segmentfromwidth,
+ segment from width=true,
+ word separator/.code={%
+ \def\tikz@lib@dec@te@tmp{#1}%
+ \ifx\tikz@lib@dec@te@tmp\tikz@lib@dec@te@space@text%
+ \let\tikz@lib@dec@te@wordsep=\tikz@lib@dec@te@spacetoken%
+ \else%
+ \def\tikz@lib@dec@te@wordsep{#1}
+ \fi},
+ word separator=space,
+ character command/.code={%
+ \def\tikz@lib@dec@te@tmp{#1}%
+ \ifx\tikz@lib@dec@te@tmp\pgfutil@empty%
+ \def\tikz@lib@dec@te@charactercommand{\tikz@lib@dec@te@charactertypesetonly}%
+ \else%
+ \def\tikz@lib@dec@te@charactercommand{#1}%
+ \fi%
+ },
+ character command=,
+ every character width/.style={/pgf/decoration/text effects/every character/.try},
+ every character/.style={},
+ reverse text/.code={\tikz@lib@dec@te@addto@macro\tikz@lib@dec@te@transformtext%
+ {\tikz@lib@dec@te@reversetext}},
+ group letters into words/.code={\tikz@lib@dec@te@addto@macro\tikz@lib@dec@te@transformtext%
+ {\tikz@lib@dec@te@groupletters}},
+ group letters/.code={\tikz@lib@dec@te@addto@macro\tikz@lib@dec@te@transformtext%
+ {\tikz@lib@dec@te@groupletters}},
+ replace characters/.code args={#1 with #2}{\tikz@lib@dec@te@parse@replacecharacters{#1}{#2}},
+ scale text to path/.is if=tikz@lib@dec@te@scaletexttopath,
+ fit text to path/.is if=tikz@lib@dec@te@fittexttopath,
+ repeat text/.store in=\tikz@lib@dec@te@repeattext,
+ repeat text/.default=-1,
+ repeat text=0,
+}%
+
+
+\def\tikz@lib@dec@te@charactertypesetonly#1{#1}%
+
+\tikzset{%
+ text effects/.code={\pgfkeysalso{/pgf/decoration/text effects/.cd,#1}},
+}%
+
+
+
+
+
+
+% Prepare the decoration text
+%
+% This sets up all the character/letter/word, counts/totals
+% and calculates the default width of the characters/text
+% (which may be modified later).
+%
+\def\tikz@lib@dec@te@preparetext{%
+ % Step 1: scan all the characters in the decoration text
+ \let\tikz@lib@dec@te@text=\pgfdecorationtext%
+ \tikz@lib@dec@te@scancharacters{%
+ \expandafter\let\csname tikz@lib@dec@te@character@\tikz@lib@dec@te@scancount @token\endcsname=%
+ \tikz@lib@dec@te@character%
+ }%
+ \let\tikz@lib@dec@te@charactertotalcount=\tikz@lib@dec@te@scancount%
+ % Step 2: reverse and/or group characters/letters.
+ \ifx\tikz@lib@dec@te@transformtext\pgfutil@empty%
+ \else%
+ \tikz@lib@dec@te@transformtext%
+ \fi%
+ % Step 3: get the character/letter/word counts
+ \def\tikz@lib@dec@te@charactercount{0}%
+ \def\tikz@lib@dec@te@wordcount{0}%
+ \def\tikz@lib@dec@te@wordsepcount{0}%
+ \def\tikz@lib@dec@te@lettercount{0}%
+ \def\tikz@lib@dec@te@lastcharacter{0}%
+ \pgfmathloop%
+ \ifnum\pgfmathcounter>\tikz@lib@dec@te@charactertotalcount%
+ \ifnum\tikz@lib@dec@te@lettercount>0\relax%
+ \tikz@lib@dec@te@addto@parameters{\tikz@lib@dec@te@lastcharactercount}{\tikz@lib@dec@te@finallettertrue}%
+ \fi
+ \else%
+ \expandafter\let\expandafter\tikz@lib@dec@te@character\expandafter=\csname tikz@lib@dec@te@character@\pgfmathcounter @token\endcsname%
+ \tikz@lib@dec@te@advancecountmacro{\tikz@lib@dec@te@charactercount}{1}%
+ \tikz@lib@dec@te@start@parameters{\tikz@lib@dec@te@charactercount}%
+ \tikz@lib@dec@te@addmacroto@parameters{\tikz@lib@dec@te@charactercount}{\tikz@lib@dec@te@charactercount}%
+ \ifx\tikz@lib@dec@te@character\tikz@lib@dec@te@wordsep%
+ \tikz@lib@dec@te@advancecountmacro{\tikz@lib@dec@te@wordsepcount}{1}%
+ \ifnum\tikz@lib@dec@te@lettercount>0\relax%
+ \tikz@lib@dec@te@addto@parameters{\tikz@lib@dec@te@lastcharactercount}{\tikz@lib@dec@te@finallettertrue}%
+ \fi
+ \def\tikz@lib@dec@te@lettercount{0}%
+ \tikz@lib@dec@te@addto@parameters{\tikz@lib@dec@te@charactercount}{\tikz@lib@dec@te@wordseptrue}%
+ \else
+ \ifnum\tikz@lib@dec@te@lettercount=0\relax%
+ \tikz@lib@dec@te@advancecountmacro\tikz@lib@dec@te@wordcount{1}%
+ \fi%
+ \tikz@lib@dec@te@addto@parameters{\tikz@lib@dec@te@charactercount}{\tikz@lib@dec@te@finalletterfalse}%
+ \tikz@lib@dec@te@advancecountmacro{\tikz@lib@dec@te@lettercount}{1}%
+ \tikz@lib@dec@te@addto@parameters{\tikz@lib@dec@te@charactercount}{\tikz@lib@dec@te@wordsepfalse}%
+ \expandafter\let\csname tikz@lib@dec@te@word \tikz@lib@dec@te@wordcount @lettercount\endcsname=\tikz@lib@dec@te@lettercount%
+ \fi%
+ \tikz@lib@dec@te@addmacroto@parameters{\tikz@lib@dec@te@charactercount}{\tikz@lib@dec@te@lettercount}%
+ \tikz@lib@dec@te@addmacroto@parameters{\tikz@lib@dec@te@charactercount}{\tikz@lib@dec@te@wordcount}%
+ \tikz@lib@dec@te@addmacroto@parameters{\tikz@lib@dec@te@charactercount}{\tikz@lib@dec@te@character}%
+ \let\tikz@lib@dec@te@lastcharactercount=\pgfmathcounter%
+ \repeatpgfmathloop%
+ \let\tikz@lib@dec@te@wordtotal=\tikz@lib@dec@te@wordcount%
+ % Step 4: add character/letter/word totals
+ \pgfmathloop
+ \ifnum\pgfmathcounter>\tikz@lib@dec@te@charactertotalcount%
+ \else%
+ \tikz@lib@dec@te@addmacroto@parameters{\pgfmathcounter}{\tikz@lib@dec@te@charactertotalcount}%
+ \tikz@lib@dec@te@addmacroto@parameters{\pgfmathcounter}{\tikz@lib@dec@te@wordtotal}%
+ \expandafter\let\expandafter\tikz@lib@dec@te@lettertotalcount\expandafter=\csname tikz@lib@dec@te@word \tikz@lib@dec@te@wordcount @lettercount\endcsname%
+ \tikz@lib@dec@te@addmacroto@parameters{\pgfmathcounter}{\tikz@lib@dec@te@lettertotalcount}%
+ \repeatpgfmathloop%
+ % Step 5: calculate the the text and character width
+ % but do not add to the parameters yet.
+ \def\tikz@lib@dec@te@textwidth{0pt}%
+ \pgfmathloop%
+ \ifnum\pgfmathcounter>\tikz@lib@dec@te@charactertotalcount%
+ \else%
+ \def\tikz@lib@dec@te@characterwidth{0pt}%
+ \tikz@lib@dec@te@getcharacterwidth{\pgfmathcounter}%
+ \expandafter\let\csname tikz@lib@dec@te@character@\pgfmathcounter @width\endcsname=\tikz@lib@dec@te@characterwidth%
+ \pgf@x=\tikz@lib@dec@te@characterwidth\relax%
+ \pgf@x=0.5\pgf@x%
+ \expandafter\edef\csname tikz@lib@dec@te@character@\pgfmathcounter @prewidth\endcsname{\the\pgf@x}%
+ \expandafter\edef\csname tikz@lib@dec@te@character@\pgfmathcounter @postwidth\endcsname{\the\pgf@x}%
+ \tikz@lib@dec@te@advancedimenmacro{\tikz@lib@dec@te@textwidth}{\tikz@lib@dec@te@characterwidth}%
+ \repeatpgfmathloop%
+}%
+
+% Does the category code of the space matter?
+\def\tikz@lib@dec@te@spacetoken{ }%
+
+\let\tikz@lib@dec@te@wordsep=\tikz@lib@dec@te@spacetoken
+
+
+% Scan and count the characters in \tikz@lib@dec@te@text
+%
+% Create macros \tikz@lib@dec@te@character@<n>@token containing
+% the nth character.
+%
+% Total number of characters is store in
+% \tikz@lib@dec@te@chractertotal@count
+%
+\def\tikz@lib@dec@te@scancharacters#1{%
+ \def\tikz@lib@dec@te@@@scancharacters@process{#1}%
+ \def\tikz@lib@dec@te@scancount{0}%
+ \expandafter\tikz@lib@dec@te@@scancharacters\tikz@lib@dec@te@text\tikz@lib@dec@te@scancharacters}%
+
+\def\tikz@lib@dec@te@@scancharacters{%
+ \futurelet\tikz@lib@dec@te@token\tikz@lib@dec@te@@@scancharacters}%
+
+\def\tikz@lib@dec@te@@@scancharacters{%
+ \ifx\tikz@lib@dec@te@token\tikz@lib@dec@te@scancharacters%
+ \let\tikz@lib@dec@te@next=\tikz@lib@dec@te@@@@scancharacters%
+ \else%
+ \tikz@lib@dec@te@advancecountmacro\tikz@lib@dec@te@scancount{1}%
+ \ifx\tikz@lib@dec@te@token\pgfutil@sptoken%
+ \let\tikz@lib@dec@te@next=\tikz@lib@dec@te@@@scancharacters@space%
+ \else%
+ \ifx\tikz@lib@dec@te@token\bgroup%
+ \let\tikz@lib@dec@te@next=\tikz@lib@dec@te@@@scancharacters@bgroup%
+ \else%
+ \let\tikz@lib@dec@te@next=\tikz@lib@dec@te@@@scancharacters@normal%
+ \fi%
+ \fi%
+ \fi%
+ \tikz@lib@dec@te@next%
+}%
+
+\def\tikz@lib@dec@te@@@scancharacters@space{%
+ \let\tikz@lib@dec@te@character=\tikz@lib@dec@te@spacetoken%
+ \tikz@lib@dec@te@@@scancharacters@process%
+ \pgfutil@ifnextchar x\tikz@lib@dec@te@@scancharacters\tikz@lib@dec@te@@scancharacters%
+}%
+
+\def\tikz@lib@dec@te@@@scancharacters@bgroup#1{%
+ \def\tikz@lib@dec@te@character{{#1}}%
+ \tikz@lib@dec@te@@@scancharacters@process%
+ \tikz@lib@dec@te@@scancharacters%
+}%
+
+\def\tikz@lib@dec@te@@@scancharacters@normal#1{%
+ \def\tikz@lib@dec@te@character{#1}%
+ \tikz@lib@dec@te@@@scancharacters@process%
+ \tikz@lib@dec@te@@scancharacters%
+}%
+
+
+\def\tikz@lib@dec@te@@@@scancharacters#1\tikz@lib@dec@te@scancharacters{}%
+
+
+% Reverse the order of the scanned characters in the text
+% (Actually reverse the ordering of the macros containing the characters)
+\def\tikz@lib@dec@te@reversetext{%
+ \c@pgf@counta=\tikz@lib@dec@te@charactertotalcount%
+ \pgfmathloop%
+ \ifnum\pgfmathcounter>\c@pgf@counta%
+ \else%
+ \tikz@lib@dec@te@namelet{tikz@lib@dec@te@tmp}{tikz@lib@dec@te@character@\pgfmathcounter @token}%
+ \tikz@lib@dec@te@namelet{tikz@lib@dec@te@character@\pgfmathcounter @token}{tikz@lib@dec@te@character@\the\c@pgf@counta @token}%
+ \tikz@lib@dec@te@namelet{tikz@lib@dec@te@character@\the\c@pgf@counta @token}{tikz@lib@dec@te@tmp}%
+ \advance\c@pgf@counta by-1\relax%
+ \repeatpgfmathloop%
+}%
+
+% Group letters (i.e., anything that isn't the word separator)
+% as single characters (words).
+\def\tikz@lib@dec@te@groupletters{%
+ \c@pgf@counta=0\relax%
+ \let\tikz@lib@dec@te@tmp=\pgfutil@empty%
+ \let\tikz@lib@dec@te@@tmp=\pgfutil@empty%
+ \pgfmathloop%
+ \ifnum\pgfmathcounter>\tikz@lib@dec@te@charactertotalcount%
+ \ifx\tikz@lib@dec@te@@tmp\pgfutil@empty%
+ \else%
+ \advance\c@pgf@counta by1\relax%
+ \tikz@lib@dec@te@namelet{tikz@lib@dec@te@character@\the\c@pgf@counta @token}{tikz@lib@dec@te@@tmp}%
+ \fi%
+ \else%
+ \tikz@lib@dec@te@namelet{tikz@lib@dec@te@tmp}{tikz@lib@dec@te@character@\pgfmathcounter @token}%
+ \ifx\tikz@lib@dec@te@tmp\tikz@lib@dec@te@wordsep%
+ \advance\c@pgf@counta by1\relax%
+ \tikz@lib@dec@te@namelet{tikz@lib@dec@te@character@\the\c@pgf@counta @token}{tikz@lib@dec@te@@tmp}%
+ \let\tikz@lib@dec@te@@tmp=\pgfutil@empty%
+ \advance\c@pgf@counta by1\relax%
+ \tikz@lib@dec@te@namelet{tikz@lib@dec@te@character@\the\c@pgf@counta @token}{tikz@lib@dec@te@wordsep}%
+ \else%
+ \expandafter\tikz@lib@dec@te@addto@macro\expandafter{\expandafter\tikz@lib@dec@te@@tmp\expandafter}\expandafter{\tikz@lib@dec@te@tmp}%
+ \fi%
+ \repeatpgfmathloop%
+ \edef\tikz@lib@dec@te@charactertotalcount{\the\c@pgf@counta}%
+}%
+
+
+% Get width of node containing only the current character.
+\def\tikz@lib@dec@te@getcharacterwidth#1{%
+ \csname tikz@lib@dec@te@character@#1\endcsname%
+ \tikz@lib@dec@te@getoptions{every character width/.try}%
+ \let\tikz@lib@dec@te@lastcharacterwidth=\tikz@lib@dec@te@characterwidth%
+ \pgfpositionnodelater\tikz@lib@dec@te@@getcharacterwidth%
+ \pgfutil@ifundefined{tikz@lib@dec@te@character@replacements@\meaning\tikz@lib@dec@te@character @code}{%
+ \expandafter\node\expandafter[\tikz@lib@dec@te@options,scale=\tikz@lib@dec@scaledcharacterwidthfactor]%
+ {\hbox{\tikz@lib@dec@te@charactercommand{\tikz@lib@dec@te@character}}};%
+ \let\tikz@lib@dec@te@characterwidth=\tikz@lib@dec@te@characterwidth@tmp%
+ }{%
+ \tikz@lib@dec@te@getcharacter@replacementwidth{\tikz@lib@dec@te@character}%
+ \let\tikz@lib@dec@te@characterwidth=\tikz@lib@dec@te@character@replacementwidth%
+ }%
+}%
+
+% Update the character parameters with the widths.
+\def\tikz@lib@dec@te@addwidthstoparameters{%
+ \pgfmathloop%
+ \ifnum\pgfmathcounter>\tikz@lib@dec@te@charactertotalcount%
+ \else%
+ \tikz@lib@dec@te@namelet{tikz@lib@dec@te@characterwidth}{tikz@lib@dec@te@character@\pgfmathcounter @width}%
+ \tikz@lib@dec@te@namelet{tikz@lib@dec@te@characterprewidth}{tikz@lib@dec@te@character@\pgfmathcounter @prewidth}%
+ \tikz@lib@dec@te@namelet{tikz@lib@dec@te@characterpostwidth}{tikz@lib@dec@te@character@\pgfmathcounter @postwidth}%
+ \tikz@lib@dec@te@addmacroto@parameters{\pgfmathcounter}{\tikz@lib@dec@te@characterwidth}%
+ \tikz@lib@dec@te@addmacroto@parameters{\pgfmathcounter}{\tikz@lib@dec@te@characterprewidth}%
+ \tikz@lib@dec@te@addmacroto@parameters{\pgfmathcounter}{\tikz@lib@dec@te@characterpostwidth}%
+ \repeatpgfmathloop%
+}%
+
+% Get the options to applied to a character node.
+
+\def\tikz@lib@dec@te@addoptions#1{%
+ \expandafter\def\expandafter\tikz@lib@dec@te@options\expandafter{\tikz@lib@dec@te@options,#1}%
+}%
+
+\def\tikz@lib@dec@te@getoptions#1{%
+ \let\tikz@lib@dec@te@lastcharactercommand=\tikz@lib@dec@te@charactercommand%
+ \def\tikz@lib@dec@te@options{/pgf/decoration/text effects/.cd}%
+ \tikz@lib@dec@te@addoptions{#1}%
+ \let\tikzdecorationcharactercount=\tikz@lib@dec@te@charactercount%
+ \let\tikzdecorationcharactertotal=\tikz@lib@dec@te@charactertotalcount%
+ \let\tikzdecorationlettercount=\tikz@lib@dec@te@lettercount%
+ \let\tikzdecorationlettertotal=\tikz@lib@dec@te@lettertotalcount%
+ \let\tikzdecorationwordcount=\tikz@lib@dec@te@wordcount%
+ \let\tikzdecorationwordtotal=\tikz@lib@dec@te@wordtotal%
+ \let\tikzdecorationcharacter=\tikz@lib@dec@te@character%
+ %
+ % Define the count variables (if required)
+ \ifx\tikz@lib@dec@te@charactercountvar\pgfutil@empty%
+ \else%
+ \expandafter\let\tikz@lib@dec@te@charactercountvar=\tikz@lib@dec@te@charactercount%
+ \fi%
+ %
+ \ifx\tikz@lib@dec@te@charactertotalvar\pgfutil@empty%
+ \else%
+ \expandafter\let\tikz@lib@dec@te@charactertotalvar=\tikz@lib@dec@te@charactertotalcount%
+ \fi%
+ %
+ \ifx\tikz@lib@dec@te@wordcountvar\pgfutil@empty%
+ \else%
+ \expandafter\let\tikz@lib@dec@te@wordcountvar=\tikz@lib@dec@te@wordcount%
+ \fi%
+ %
+ \ifx\tikz@lib@dec@te@wordtotalvar\pgfutil@empty%
+ \else%
+ \expandafter\let\tikz@lib@dec@te@wordtotalvar=\tikz@lib@dec@te@wordtotal%
+ \fi%
+ %
+ \ifx\tikz@lib@dec@te@lettercountvar\pgfutil@empty%
+ \else%
+ \expandafter\let\tikz@lib@dec@te@lettercountvar=\tikz@lib@dec@te@lettercount%
+ \fi%
+ %
+ \ifx\tikz@lib@dec@te@lettertotalvar\pgfutil@empty%
+ \else%
+ \expandafter\let\tikz@lib@dec@te@lettertotalvar=\tikz@lib@dec@te@lettetotal%
+ \fi%
+ %
+ \edef\tikz@lib@dec@te@tmp{character \tikz@lib@dec@te@charactercount/.try,%
+ character {\meaning\tikz@lib@dec@te@character}/.try}%
+ \expandafter\tikz@lib@dec@te@addoptions\expandafter{\tikz@lib@dec@te@tmp}%
+ \ifx\tikz@lib@dec@te@character\tikz@lib@dec@te@wordsep%
+ \tikz@lib@dec@te@addoptions{/pgf/decoration/text effects/every word separator/.try}%
+ \else%
+ \ifnum\tikz@lib@dec@te@wordcount>0\relax%
+ \edef\tikz@lib@dec@te@tmp{every word/.try, word \tikz@lib@dec@te@wordcount/.try}%
+ \expandafter\tikz@lib@dec@te@addoptions\expandafter{\tikz@lib@dec@te@tmp}%
+ \ifnum\tikz@lib@dec@te@lettercount>0\relax%
+ \edef\tikz@lib@dec@te@tmp{every letter/.try,every \tikz@lib@dec@te@lettercount\space letter/.try}%
+ \expandafter\tikz@lib@dec@te@addoptions\expandafter{\tikz@lib@dec@te@tmp}%
+ \ifnum\tikz@lib@dec@te@lettercount=1\relax%
+ \edef\tikz@lib@dec@te@tmp{every first letter/.try}%
+ \expandafter\tikz@lib@dec@te@addoptions\expandafter{\tikz@lib@dec@te@tmp}%
+ \fi%
+ \iftikz@lib@dec@te@finalletter%
+ \tikz@lib@dec@te@addoptions{every final letter/.try}%
+ \fi%
+ \fi%
+ \fi%
+ \fi%
+}%
+
+% Called by `late positioning' of the node
+% to get the width of the bounding box
+% of a character.
+\def\tikz@lib@dec@te@@getcharacterwidth{%
+ \iftikz@lib@dec@te@segmentfromwidth%
+ \pgf@x=\pgfpositionnodelatermaxx\relax%
+ \advance\pgf@x by-\pgfpositionnodelaterminx\relax%
+ \else%
+ \pgf@x=\pgfpositionnodelatermaxy\relax%
+ \advance\pgf@x by-\pgfpositionnodelaterminy\relax%
+ \fi%
+ \xdef\tikz@lib@dec@te@characterwidth@tmp{\the\pgf@x}%
+}%
+
+
+\def\tikz@lib@dec@te@drawcharacter{%
+ \csname tikz@lib@dec@te@character@\tikz@lib@dec@te@charactercount\endcsname%
+ \tikz@lib@dec@te@getoptions{every character/.try}%
+ \pgfpositionnodelater\relax%
+ \pgfutil@ifundefined{tikz@lib@dec@te@character@replacements@\meaning\tikz@lib@dec@te@character @code}{%
+ \expandafter\node\expandafter[\tikz@lib@dec@te@options, scale=\tikz@lib@dec@scaledcharacterwidthfactor]{\hbox{\tikz@lib@dec@te@charactercommand{\tikz@lib@dec@te@character}}};%
+ }{\tikz@lib@dec@te@drawcharacter@replacement{\tikz@lib@dec@te@character}}%
+}%
+
+% Replace the character #1 with a character@replacement
+%
+\def\tikz@lib@dec@te@drawcharacter@replacement#1{%
+ \pgfscope%
+ \expandafter\tikzset\expandafter{\tikz@lib@dec@te@options}%
+ \csname tikz@lib@dec@te@character@replacements@\meaning#1@code\endcsname%
+ \endpgfscope%
+}%
+
+% Get the width of the character@replacement associated with
+% the character #1
+%
+\newbox\tikz@lib@dec@te@box
+\def\tikz@lib@dec@te@getcharacter@replacementwidth#1{%
+ \pgfinterruptpicture%
+ \setbox\tikz@lib@dec@te@box=\hbox{%
+ \pgfpicture
+ \expandafter\tikzset\expandafter{\tikz@lib@dec@te@options}%
+ \csname tikz@lib@dec@te@character@replacements@\meaning#1@code\endcsname%
+ \endpgfpicture}%
+ \xdef\tikz@lib@dec@te@character@replacementwidth{\the\wd\tikz@lib@dec@te@box}%
+ \endpgfinterruptpicture%
+}%
+
+\def\tikz@lib@dec@scaledcharacterwidthfactor{1}%
+
+% Set up the decoration
+\def\tikz@lib@dec@te@state@setup@precomputation{%
+ \def\tikz@lib@te@alignshift{0pt}%
+ \iftikz@lib@dec@te@pathfromtext%
+ % The width of the text and characters has already been calculated.
+ \else%
+ \let\tikz@lib@dec@te@text=\pgfdecorationtext%
+ % Get the character tokens and the total number of characters.
+ \tikz@lib@dec@te@preparetext%
+ \iftikz@lib@dec@te@scaletexttopath%
+ % OK, *scaling* text to path is easy.
+ % Simply divide the path length by the text width to
+ % obtain the scaling factor which will be applied
+ % "at the last minute"...
+ \pgfmathdivide{\pgfdecoratedpathlength}{\tikz@lib@dec@te@textwidth}%
+ \let\tikz@lib@dec@scaledcharacterwidthfactor=\pgfmathresult%
+ \expandafter\pgfkeys\expandafter{\tikz@lib@dec@te@tmp}%
+ % ... and recalculate the (pre and post) widths.
+ \pgfmathloop
+ \ifnum\pgfmathcounter>\tikz@lib@dec@te@charactertotalcount%
+ \else%
+ \pgf@x=\csname tikz@lib@dec@te@character@\pgfmathcounter @prewidth\endcsname\relax%
+ \pgf@x=\tikz@lib@dec@scaledcharacterwidthfactor\pgf@x%
+ \expandafter\edef\csname tikz@lib@dec@te@character@\pgfmathcounter @prewidth\endcsname{\the\pgf@x}%
+ %
+ \pgf@x=\csname tikz@lib@dec@te@character@\pgfmathcounter @postwidth\endcsname\relax%
+ \pgf@x=\tikz@lib@dec@scaledcharacterwidthfactor\pgf@x%
+ \expandafter\edef\csname tikz@lib@dec@te@character@\pgfmathcounter @postwidth\endcsname{\the\pgf@x}%
+ \repeatpgfmathloop%
+ % Update parameters with thewidths.
+ \tikz@lib@dec@te@addwidthstoparameters%
+ \let\tikz@lib@dec@te@textwidth=\pgfdecoratedpathlength%
+ \else%
+ \iftikz@lib@dec@te@fittexttopath%
+ % *Fitting* text is less easy.
+ % The pre and post width of all except the first and last characters
+ % must be recalculated.
+ % Only the post width of the first character and the pre width
+ % of the final character are scaled as these characters should be
+ % fixed and the start and end of the path, respectively.
+ %
+ % We hope that the decoration engine is accurate enough to position
+ % the last word correctly.
+ \pgf@x=\pgfdecoratedpathlength%
+ \pgf@xa=\csname tikz@lib@dec@te@character@1@postwidth\endcsname\relax%
+ \pgf@xb=\csname tikz@lib@dec@te@character@\tikz@lib@dec@te@charactertotalcount @prewidth\endcsname\relax%
+ \advance\pgf@x by-\pgf@xa%
+ \advance\pgf@x by-\pgf@xb%
+ \pgf@y=\tikz@lib@dec@te@textwidth\relax%
+ \advance\pgf@y by-\pgf@xa%
+ \advance\pgf@y by-\pgf@xb%
+ %
+ \pgfmathdivide{\the\pgf@x}{\the\pgf@y}%
+ \let\tikz@lib@dec@characterwidthscale=\pgfmathresult%
+ \pgfmathloop
+ \ifnum\pgfmathcounter>\tikz@lib@dec@te@charactertotalcount\relax%
+ \else%
+ \ifnum\pgfmathcounter>1\relax%
+ \pgf@x=\csname tikz@lib@dec@te@character@\pgfmathcounter @prewidth\endcsname\relax%
+ \pgf@x=\tikz@lib@dec@characterwidthscale\pgf@x%
+ \expandafter\edef\csname tikz@lib@dec@te@character@\pgfmathcounter @prewidth\endcsname{\the\pgf@x}%
+ \fi%
+ \ifnum\pgfmathcounter<\tikz@lib@dec@te@charactertotalcount\relax%
+ \pgf@x=\csname tikz@lib@dec@te@character@\pgfmathcounter @postwidth\endcsname\relax%
+ \pgf@x=\tikz@lib@dec@characterwidthscale\pgf@x%
+ \expandafter\edef\csname tikz@lib@dec@te@character@\pgfmathcounter @postwidth\endcsname{\the\pgf@x}%
+ \fi%
+ \repeatpgfmathloop%
+ % Update parameters with widths.
+ \tikz@lib@dec@te@addwidthstoparameters%
+ \let\tikz@lib@dec@te@textwidth=\pgfdecoratedpathlength%
+ \else%
+ % Calculate the distance to move along the path for alignment.
+ \pgfkeysgetvalue{/pgf/decoration/text align/align}{\tikz@lib@dec@align}%
+ \ifx\tikz@lib@dec@align\tikz@lib@dec@align@center@text%
+ \pgf@x=\pgfdecoratedpathlength\relax%
+ \advance\pgf@x by-\tikz@lib@dec@te@textwidth\relax%
+ \ifdim\pgf@x<0pt\relax%
+ \pgf@x=0pt\relax%
+ \fi%
+ \divide\pgf@x by2\relax%
+ % Adjust the pre-width of the first character...
+ \pgf@xa=\csname tikz@lib@dec@te@character@1@prewidth\endcsname\relax%
+ \advance\pgf@xa by\pgf@x%
+ \expandafter\edef\csname tikz@lib@dec@te@character@1@prewidth\endcsname{\the\pgf@xa}%
+ % ...and the post-width of the last character.
+ \pgf@xa=\csname tikz@lib@dec@te@character@\tikz@lib@dec@te@charactertotalcount @postwidth\endcsname\relax%
+ \advance\pgf@xa by\pgf@x%
+ \expandafter\edef\csname tikz@lib@dec@te@character@\tikz@lib@dec@te@charactertotalcount @postwidth\endcsname{\the\pgf@xa}%
+ \else%
+ \ifx\tikz@lib@dec@align\tikz@lib@dec@align@right@text%
+ \pgf@x=\pgfdecoratedpathlength\relax%
+ \advance\pgf@x by-\tikz@lib@dec@te@textwidth\relax%
+ \ifdim\pgf@x<0pt\relax%
+ \pgf@x=0pt\relax%
+ \fi%
+ % Adjust the pre-width of the first character...
+ \pgf@xa=\csname tikz@lib@dec@te@character@1@prewidth\endcsname\relax%
+ \advance\pgf@xa by\pgf@x%
+ \expandafter\edef\csname tikz@lib@dec@te@character@1@prewidth\endcsname{\the\pgf@xa}%
+ \fi%
+ \fi%
+ \tikz@lib@dec@te@addwidthstoparameters%
+ \fi%
+ \fi%
+ \fi%
+}%
+
+
+% Evil hack into the decoration code.
+%
+% If the path contains single move to and the `path from text'
+% key is set to true. The width of the text is calculated here
+% and the (straight line) path automatically calculated.
+%
+\def\pgf@decorate@path@check@moveto#1{%
+ \expandafter\pgf@decorate@path@@check@moveto#1\pgf@decorate@stop\pgf@decorate@@stop}%
+
+\def\pgf@decorate@token@stop{\pgf@decorate@stop}%
+\def\pgf@decorate@path@@check@moveto#1#2#3#4\pgf@decorate@@stop#5#6{%
+ \def\pgf@decorate@temp{#4}%
+ \pgf@x=#2\relax%
+ \pgf@y=#3\relax%
+ \ifx\pgf@decorate@temp\pgf@decorate@token@stop%
+ \iftikz@lib@dec@te@pathfromtext%
+ % Get the start position...
+ \pgfextract@process\tikz@lib@dec@te@pathstart{}%
+ \tikz@lib@dec@te@preparetext%
+ \tikz@lib@dec@te@addwidthstoparameters%
+ % ... and create a lineto path of the correct length.
+ \pgfsetpath\pgfutil@empty%
+ \pgfpathmoveto{\tikz@lib@dec@te@pathstart}%
+ \pgfpathlineto{\pgfpointadd{\tikz@lib@dec@te@pathstart}%
+ {\pgfpointpolar{\tikz@lib@dec@te@pathfromtextangle}{\tikz@lib@dec@te@textwidth}}}%
+ \pgfgetpath\pgfdecoratedpath%
+ \pgfsetpath\pgfutil@empty%
+ \else%
+ #5%
+ \fi%
+ \else%
+ \tikz@lib@dec@te@pathfromtextfalse%
+ #6%
+ \fi%
+}%
+
+
+\pgfdeclaredecoration{text effects along path}{setup}{%
+ \state{setup}[width=+0pt, next state=scan, persistent precomputation={%
+ \tikz@lib@dec@te@state@setup@precomputation%
+ \def\tikz@lib@dec@te@charactercount{0}%
+ }]{}%
+ %
+\state{scan}[width=+0pt, next state=pre token, persistent precomputation={%
+ \tikz@lib@dec@te@advancecountmacro\tikz@lib@dec@te@charactercount{1}%
+ % Usual switch to final state is based on distance.
+ % Here we also need it to be on the number of the
+ % current character.
+ \ifnum\tikz@lib@dec@te@charactercount>\tikz@lib@dec@te@charactertotalcount\relax%
+ \ifnum\tikz@lib@dec@te@repeattext=0\relax%
+ \def\pgf@decorate@next@state{final}%
+ \else%
+ \tikz@lib@dec@te@advancecountmacro\tikz@lib@dec@te@repeattext{-1}%
+ \def\tikz@lib@dec@te@charactercount{1}%
+ \fi%
+ \fi%
+ % Install parameters for this character.
+ \csname tikz@lib@dec@te@character@\tikz@lib@dec@te@charactercount\endcsname%
+}]{}%
+%
+\state{pre token}[width=+\tikz@lib@dec@te@characterprewidth, next state=token]{}%
+\state{token}[width=+0pt, next state=post token]
+{%
+ \tikz@lib@dec@te@drawcharacter%
+}%
+\state{post token}[width=+\tikz@lib@dec@te@characterpostwidth, next state=scan]{}%
+}%
+
+
+% Parse styles for individual characters
+% #1 a string of characters (e.g., aieou{\"U}{\"a"})
+% #2 the options for to apply to each character.
+%
+\def\tikz@lib@dec@te@parse@stylecharacters#1#2{%
+ \def\tikz@lib@dec@te@text{#1}%
+ \tikz@lib@dec@te@scancharacters{%
+ \pgfkeysalso{/pgf/decoration/text effects/character {\meaning\tikz@lib@dec@te@character}/.style={#2}}%
+ }%
+}%
+
+% Parse replacement code for for individual characters
+% #1 a string of characters (e.g., aieou{\"U}{\"a"})
+% #2 the code to execute to each character.
+%
+\def\tikz@lib@dec@te@parse@replacecharacters#1#2{%
+ \def\tikz@lib@dec@te@text{#1}%
+ \tikz@lib@dec@te@scancharacters{%
+ \expandafter\def\csname tikz@lib@dec@te@character@replacements@\meaning\tikz@lib@dec@te@character @code\endcsname{#2}%
+ }%
+}%
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryer.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryer.code.tex
new file mode 100644
index 0000000000..acb9b04997
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryer.code.tex
@@ -0,0 +1,40 @@
+% Copyright 2018 by Till Tantau
+%
+% 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{tikzlibraryer.code.tex}
+
+\usetikzlibrary{shapes.geometric}%
+
+% Styles for entity types:
+
+\tikzset{every entity/.style= {}}%
+\tikzset{entity/.style= {rectangle,draw,
+ minimum height=2\baselineskip,
+ minimum width=4\baselineskip,every entity}}%
+
+
+% Styles for relationship types:
+
+\tikzset{every relationship/.style= {}}%
+\tikzset{relationship/.style= {diamond,draw,
+ minimum size=1.5\baselineskip,
+ inner sep=1pt,
+ every relationship}}%
+
+
+% Styles for relationship types:
+
+\tikzset{every attribute/.style= {}}%
+\tikzset{attribute/.style= {minimum size=1.5\baselineskip,ellipse,draw,every attribute}}%
+\tikzset{key attribute/.style= {font=\itshape,attribute}}%
+
+
+
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryfadings.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryfadings.code.tex
new file mode 100644
index 0000000000..bddc83cb5c
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryfadings.code.tex
@@ -0,0 +1,48 @@
+% Copyright 2018 by Till Tantau
+%
+% 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{tikzlibraryfadings.code.tex}
+
+\usepgflibrary{fadings}%
+
+%
+% Environments for creating fadings
+%
+
+\def\tikzfadingfrompicture{%
+ \begingroup%
+ \setbox\pgfpic=\hbox\bgroup%
+ \tikzpicture%
+}%
+\def\endtikzfadingfrompicture{%
+ \global\let\tikz@smuggle=\tikz@fig@name%
+ \endtikzpicture
+ \egroup%
+ \pgfdeclarefading{\tikz@smuggle}{\box\pgfpic}%
+ \endgroup%
+}%
+
+% This makes it easier to maintain compatibility with the external lib:
+\def\starttikzfadingfrompicture{\tikzfadingfrompicture}%
+\def\stopttikzfadingfrompicture{\endtikzfadingfrompicture}%
+
+\def\tikzfading[#1]{%
+ {%
+ \setbox\pgfpic=\hbox{%
+ \tikzset{#1}%
+ \global\let\tikz@smuggle=\tikz@fig@name%
+ \tikz{%
+ \useasboundingbox(0,0) (100bp,100bp);
+ \node at (50bp,50bp) [rotate=\tikz@shade@angle]
+ {\pgfuseshading{\tikz@shading}};
+ }%
+ }%
+ \pgfdeclarefading{\tikz@smuggle}{\box\pgfpic}%
+ }%
+}%
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryfit.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryfit.code.tex
new file mode 100644
index 0000000000..b104a519c3
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryfit.code.tex
@@ -0,0 +1,132 @@
+% Copyright 2018 by Till Tantau
+%
+% 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{tikzlibraryfit.code.tex}
+
+\pgfqkeys{/tikz}{%
+ fit/.code=\tikz@lib@fit{#1},
+ rotate fit/.code={%
+ \pgfmathsetmacro\tikz@lib@fit@rotate{#1}%
+ \pgfkeysalso{/tikz/rotate=\tikz@lib@fit@rotate}%
+ },
+}%
+
+\def\tikz@lib@fit@rotate{0}%
+
+\def\tikz@lib@fit#1{%
+ \pgf@xb=-16000pt\relax%
+ \pgf@xa=16000pt\relax%
+ \pgf@yb=-16000pt\relax%
+ \pgf@ya=16000pt\relax%
+ %
+ % Now iterate over the coordinates
+ \tikz@lib@fit@scan#1\pgf@stop%
+ % Now, let's see what has happened
+ \ifdim\pgf@xa>\pgf@xa%
+ % Nothing... Ok, let's just ignore this.
+ \else%
+ % Ok, compute center and width and height
+ \pgf@x=\pgf@xb%
+ \advance\pgf@x by-\pgf@xa%
+ \pgf@y=\pgf@yb%
+ \advance\pgf@y by-\pgf@ya%
+ \advance\pgf@xa by.5\pgf@x%
+ \advance\pgf@ya by.5\pgf@y%
+ \ifdim\tikz@lib@fit@rotate pt=0pt\relax%
+ {%
+ \pgftransforminvert%
+ \pgf@pos@transform{\pgf@xa}{\pgf@ya}%
+ \global\pgf@xa\pgf@xa
+ \global\pgf@ya\pgf@ya
+ }
+ \else%
+ \pgf@xc=\pgf@x%
+ \pgf@yc=\pgf@y%
+ {%
+ \pgf@xc=\pgf@xa%
+ \pgf@yc=\pgf@ya%
+ \pgftransforminvert%
+ \pgf@pos@transform{\pgf@xc}{\pgf@yc}%
+ \pgftransformreset%
+ \pgftransformrotate{\tikz@lib@fit@rotate}%
+ \pgf@pos@transform{\pgf@xc}{\pgf@yc}%
+ \global\pgf@x=\pgf@xc%
+ \global\pgf@y=\pgf@yc%
+ }%
+ \pgf@xa=\pgf@x%
+ \pgf@ya=\pgf@y%
+ \pgf@x=\pgf@xc%
+ \pgf@y=\pgf@yc%
+ \fi%
+ \edef\tikz@node@at{\noexpand\pgfqpoint{\the\pgf@xa}{\the\pgf@ya}}%
+ \pgfkeysalso{/tikz/anchor=center,/tikz/text badly centered}%
+ \pgfkeysalso{/tikz/text width/.expanded=\the\pgf@x}%
+ \pgf@x=\pgf@y%
+ \pgf@y=.5\pgf@y%
+ \pgfkeysalso{
+ /tikz/transform shape=false,
+ /tikz/text height/.expanded=\the\pgf@y-.5\dp\pgfnodeparttextbox,
+ /tikz/text depth/.expanded=\the\pgf@x-\noexpand\the\ht\pgfnodeparttextbox}%
+ \pgfkeysalso{every fit/.try}%
+ \fi%
+}%
+
+\def\tikz@lib@fit@scan{%
+ \pgfutil@ifnextchar\pgf@stop{\pgfutil@gobble}
+ {\tikz@scan@one@point\tikz@lib@fit@scan@handle}}%
+
+\def\tikz@lib@fit@scan@handle#1{%
+ \iftikz@shapeborder%
+ % Ok, fit all four external anchors, if they exist
+ \tikz@lib@fit@adjust{\pgfpointanchor{\tikz@shapeborder@name}{west}}%
+ \tikz@lib@fit@adjust{\pgfpointanchor{\tikz@shapeborder@name}{east}}%
+ \tikz@lib@fit@adjust{\pgfpointanchor{\tikz@shapeborder@name}{north}}%
+ \tikz@lib@fit@adjust{\pgfpointanchor{\tikz@shapeborder@name}{south}}%
+ \else%
+ \tikz@lib@fit@adjust{#1}%
+ \fi%
+ \tikz@lib@fit@scan%
+}%
+
+\def\tikz@lib@fit@adjust#1{%
+ \ifdim\tikz@lib@fit@rotate pt=0pt\relax%
+ \pgf@process{\pgfpointtransformed{#1}}%
+ \else%
+ {%
+ \pgf@process{\pgfpointtransformed{#1}}%
+ \pgf@xc=\pgf@x%
+ \pgf@yc=\pgf@y%
+ \pgfgettransform\tikz@lib@fit@transform%
+ \pgftransforminvert%
+ \pgf@pos@transform{\pgf@xc}{\pgf@yc}%
+ \pgftransformreset%
+ \pgftransformrotate{-\tikz@lib@fit@rotate}%
+ \pgf@pos@transform{\pgf@xc}{\pgf@yc}%
+ \pgfsettransform\tikz@lib@fit@transform%
+ \pgf@pos@transform{\pgf@xc}{\pgf@yc}%
+ \global\pgf@x=\pgf@xc%
+ \global\pgf@y=\pgf@yc%
+ }%
+ \fi%
+ \ifdim\pgf@x<\pgf@xa%
+ \pgf@xa=\pgf@x%
+ \fi%
+ \ifdim\pgf@y<\pgf@ya%
+ \pgf@ya=\pgf@y%
+ \fi%
+ \ifdim\pgf@x>\pgf@xb%
+ \pgf@xb=\pgf@x%
+ \fi%
+ \ifdim\pgf@y>\pgf@yb%
+ \pgf@yb=\pgf@y%
+ \fi%
+}%
+
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryfixedpointarithmetic.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryfixedpointarithmetic.code.tex
new file mode 100644
index 0000000000..76616a6ddd
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryfixedpointarithmetic.code.tex
@@ -0,0 +1,10 @@
+% Copyright 2018 by 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.
+
+\usepgflibrary{fixedpointarithmetic}%
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryfolding.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryfolding.code.tex
new file mode 100644
index 0000000000..4974fffa50
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryfolding.code.tex
@@ -0,0 +1,2444 @@
+% Copyright 2018 by Till Tantau
+% Copyright 2018 by Nico Van Cleemput
+%
+% 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{tikzlibraryfolding.code.tex}
+
+
+%
+% Length of a standard line in a folding
+%
+
+\tikzoption{folding line length}{\pgfmathsetlength\tikz@lib@fold@length{#1}}%
+\newdimen\tikz@lib@fold@length
+\tikz@lib@fold@length=2cm
+
+
+% Faces
+% -----
+
+\def\tikz@lib@fold@triangle#1#2#3#4{%
+ \scope[xshift=.5\tikz@lib@fold@length,yshift=.28868\tikz@lib@fold@length]
+ #1
+ \endscope
+ \scope[shift={(60:\tikz@lib@fold@length)},rotate=-60]
+ #2
+ \endscope
+ \scope[xshift=\tikz@lib@fold@length,rotate=180]
+ #3
+ \endscope
+ \scope[rotate=60]
+ #4
+ \endscope
+}%
+
+\def\tikz@lib@fold@square#1#2#3#4#5{%
+ \scope[xshift=.5\tikz@lib@fold@length,yshift=.5\tikz@lib@fold@length]
+ #1
+ \endscope
+ \scope[yshift=\tikz@lib@fold@length]
+ #2
+ \endscope
+ \scope[xshift=\tikz@lib@fold@length,yshift=\tikz@lib@fold@length,rotate=-90]
+ #3
+ \endscope
+ \scope[xshift=\tikz@lib@fold@length,rotate=180]
+ #4
+ \endscope
+ \scope[rotate=90]
+ #5
+ \endscope
+}%
+
+\def\tikz@lib@fold@squarerhombusr#1#2#3#4#5{% right leaning "square-of-two" rhombus
+ \scope[xshift=.63\tikz@lib@fold@length,yshift=.4755\tikz@lib@fold@length,xslant=0.34]
+ #1
+ \endscope
+ \scope[shift={(70.529:\tikz@lib@fold@length)}]
+ #2
+ \endscope
+ \scope[shift={(35.264:1.63299\tikz@lib@fold@length)},rotate=-109.471]
+ #3
+ \endscope
+ \scope[xshift=\tikz@lib@fold@length,rotate=180]
+ #4
+ \endscope
+ \scope[rotate=70.529]
+ #5
+ \endscope
+}%
+
+\def\tikz@lib@fold@squarerhombusl#1#2#3#4#5{% left leaning "square-of-two" rhombus
+ \scope[xshift=.33\tikz@lib@fold@length,yshift=.4755\tikz@lib@fold@length,xslant=-0.34]
+ #1
+ \endscope
+ \scope[shift={(109.471:\tikz@lib@fold@length)}]
+ #2
+ \endscope
+ \scope[shift={(54.736:1.1547\tikz@lib@fold@length)},rotate=-70.529]
+ #3
+ \endscope
+ \scope[xshift=\tikz@lib@fold@length,rotate=180]
+ #4
+ \endscope
+ \scope[rotate=109.471]
+ #5
+ \endscope
+}%
+
+\def\tikz@lib@fold@goldenrhombusr#1#2#3#4#5{% right leaning golden rhombus
+ \scope[xshift=.724\tikz@lib@fold@length,yshift=.447\tikz@lib@fold@length, xslant=0.447]
+ #1
+ \endscope
+ \scope[shift={(63.435:\tikz@lib@fold@length)}]
+ #2
+ \endscope
+ \scope[shift={(31.717:1.701\tikz@lib@fold@length)},rotate=-116.565]
+ #3
+ \endscope
+ \scope[xshift=\tikz@lib@fold@length,rotate=180]
+ #4
+ \endscope
+ \scope[rotate=63.435]
+ #5
+ \endscope
+}%
+
+\def\tikz@lib@fold@goldenrhombusl#1#2#3#4#5{% left leaning golden rhombus
+ \scope[xshift=.276\tikz@lib@fold@length,yshift=.447\tikz@lib@fold@length, xslant=-0.447]
+ #1
+ \endscope
+ \scope[shift={(116.565:\tikz@lib@fold@length)}]
+ #2
+ \endscope
+ \scope[shift={(58.283:1.051\tikz@lib@fold@length)},rotate=-63.435]
+ #3
+ \endscope
+ \scope[xshift=\tikz@lib@fold@length,rotate=180]
+ #4
+ \endscope
+ \scope[rotate=116.565]
+ #5
+ \endscope
+}%
+
+\def\tikz@lib@fold@pentagon#1#2#3#4#5#6{%
+ \scope[xshift=.5\tikz@lib@fold@length,yshift=0.68819\tikz@lib@fold@length]
+ #1
+ \endscope
+ \scope[shift={(108:\tikz@lib@fold@length)},shift={(36:\tikz@lib@fold@length)},rotate=-36]
+ #2
+ \endscope
+ \scope[xshift=\tikz@lib@fold@length,shift={(72:\tikz@lib@fold@length)},rotate=-108]
+ #3
+ \endscope
+ \scope[xshift=\tikz@lib@fold@length,rotate=180]
+ #4
+ \endscope
+ \scope[rotate=108]
+ #5
+ \endscope
+ \scope[shift={(108:\tikz@lib@fold@length)},rotate=36]
+ #6
+ \endscope
+}%
+
+\def\tikz@lib@fold@hexagon#1#2#3#4#5#6#7{%
+ \scope
+ [shift={(60:\tikz@lib@fold@length)}]
+ #1
+ \endscope
+ \scope
+ [shift={(120:\tikz@lib@fold@length)},
+ shift={(60:\tikz@lib@fold@length)}]
+ #2
+ \endscope
+ \scope
+ [shift={(120:\tikz@lib@fold@length)},
+ shift={(60:\tikz@lib@fold@length)},
+ xshift=\tikz@lib@fold@length,
+ rotate=-60]
+ #3
+ \endscope
+ \scope
+ [xshift=\tikz@lib@fold@length,
+ shift={(60:\tikz@lib@fold@length)},
+ rotate=-120]
+ #4
+ \endscope
+ \scope
+ [xshift=\tikz@lib@fold@length,
+ rotate=180]
+ #5
+ \endscope
+ \scope
+ [rotate=120]
+ #6
+ \endscope
+ \scope
+ [shift={(120:\tikz@lib@fold@length)},
+ rotate=60]
+ #7
+ \endscope
+}%
+
+\def\tikz@lib@fold@octagon#1#2#3#4#5#6#7#8#9{%
+ \scope[xshift=.5\tikz@lib@fold@length,yshift=1.20711\tikz@lib@fold@length]
+ #1
+ \endscope
+ \scope[yshift=2.41421\tikz@lib@fold@length]
+ #2
+ \endscope
+ \scope[xshift=\tikz@lib@fold@length,yshift=2.41421\tikz@lib@fold@length,rotate=-45]
+ #3
+ \endscope
+ \scope[xshift=1.70711\tikz@lib@fold@length,yshift=1.70711\tikz@lib@fold@length,rotate=-90]
+ #4
+ \endscope
+ \scope[xshift=1.70711\tikz@lib@fold@length,yshift=.70711\tikz@lib@fold@length,rotate=-135]
+ #5
+ \endscope
+ \scope[xshift=\tikz@lib@fold@length,rotate=180]
+ #6
+ \endscope
+ \scope[rotate=135]
+ #7
+ \endscope
+ \scope[xshift=-.70711\tikz@lib@fold@length,yshift=.70711\tikz@lib@fold@length,rotate=90]
+ #8
+ \endscope
+ \scope[xshift=-.70711\tikz@lib@fold@length,yshift=1.70711\tikz@lib@fold@length,rotate=45]
+ #9
+ \endscope
+}%
+
+\def\tikz@lib@fold@decagon#1#2#3#4#5#6#7{%
+ \scope[shift={(72:1.61803\tikz@lib@fold@length)}] %decagon inside a circle with radius the golden ratio has side length 1
+ #1
+ \endscope
+ \scope
+ [shift={(36:\tikz@lib@fold@length)},
+ shift={(72:\tikz@lib@fold@length)},
+ shift={(108:\tikz@lib@fold@length)},
+ shift={(144:\tikz@lib@fold@length)}]
+ #2
+ \endscope
+ \scope
+ [xshift=\tikz@lib@fold@length,
+ shift={(36:\tikz@lib@fold@length)},
+ shift={(72:\tikz@lib@fold@length)},
+ shift={(108:\tikz@lib@fold@length)},
+ shift={(144:\tikz@lib@fold@length)},
+ rotate=-36]
+ #3
+ \endscope
+ \scope
+ [xshift=\tikz@lib@fold@length,
+ shift={(36:\tikz@lib@fold@length)},
+ shift={(72:\tikz@lib@fold@length)},
+ shift={(108:\tikz@lib@fold@length)},
+ rotate=-72]
+ #4
+ \endscope
+ \scope
+ [xshift=\tikz@lib@fold@length,
+ shift={(36:\tikz@lib@fold@length)},
+ shift={(72:\tikz@lib@fold@length)},
+ rotate=-108]
+ #5
+ \endscope
+ \scope
+ [xshift=\tikz@lib@fold@length,
+ shift={(36:\tikz@lib@fold@length)},
+ rotate=-144]
+ #6
+ \endscope
+ \scope
+ [xshift=\tikz@lib@fold@length,
+ rotate=180]
+ #7
+ \endscope
+ \tikz@lib@fold@decagonbis
+}%
+
+\def\tikz@lib@fold@decagonbis#1#2#3#4{%
+ \scope
+ [rotate=144]
+ #1
+ \endscope
+ \scope
+ [shift={(144:\tikz@lib@fold@length)},
+ rotate=108]
+ #2
+ \endscope
+ \scope
+ [shift={(144:\tikz@lib@fold@length)},
+ shift={(108:\tikz@lib@fold@length)},
+ rotate=72]
+ #3
+ \endscope
+ \scope
+ [shift={(144:\tikz@lib@fold@length)},
+ shift={(108:\tikz@lib@fold@length)},
+ shift={(72:\tikz@lib@fold@length)},
+ rotate=36]
+ #4
+ \endscope
+}%
+
+\def\tikz@lib@fold@path{\draw[every fold](0,0) -- (\tikz@lib@fold@length,0pt);}%
+\def\tikz@lib@fold@cut@path{\draw[every cut](0,0) -- (\tikz@lib@fold@length,0pt);}%
+\def\tikz@lib@fold@ear@path{
+ \path[every ear] (0,0) -- (.5\tikz@lib@fold@length,.2\tikz@lib@fold@length) --(\tikz@lib@fold@length,0pt) --(0,0) -- cycle;
+ \draw[every fold](0,0) -- (\tikz@lib@fold@length,0pt);
+ \draw[every cut] (0,0) -- (.5\tikz@lib@fold@length,.2\tikz@lib@fold@length) --(\tikz@lib@fold@length,0pt);}%
+\def\tikz@lib@fold@ear@custom@left@path#1{
+ \path[every ear] (0,0) -- (#1:.66\tikz@lib@fold@length) -- (\tikz@lib@fold@length,0pt) --(0,0) -- cycle;
+ \draw[every fold](0,0) -- (\tikz@lib@fold@length,0pt);
+ \draw[every cut] (0,0) -- (#1:.66\tikz@lib@fold@length) -- (\tikz@lib@fold@length,0pt);}%
+\def\tikz@lib@fold@ear@custom@right@path#1{
+ \path[every ear] (0,0) -- (\tikz@lib@fold@length,0pt) -- ++(-#1:-.66\tikz@lib@fold@length) --(0,0) -- cycle;
+ \draw[every fold](0,0) -- (\tikz@lib@fold@length,0pt);
+ \draw[every cut] (\tikz@lib@fold@length,0pt) -- ++(-#1:-.66\tikz@lib@fold@length) -- (0,0);}%
+
+\tikzset{every ear/.style={}}%
+\tikzset{every cut/.style={}}%
+\tikzset{every fold/.style={help lines}}%
+
+\tikzoption{face 1}{\def\tikz@lib@fold@face@A{#1}}%
+\tikzoption{face 2}{\def\tikz@lib@fold@face@B{#1}}%
+\tikzoption{face 3}{\def\tikz@lib@fold@face@C{#1}}%
+\tikzoption{face 4}{\def\tikz@lib@fold@face@D{#1}}%
+\tikzoption{face 5}{\def\tikz@lib@fold@face@E{#1}}%
+\tikzoption{face 6}{\def\tikz@lib@fold@face@F{#1}}%
+\tikzoption{face 7}{\def\tikz@lib@fold@face@G{#1}}%
+\tikzoption{face 8}{\def\tikz@lib@fold@face@H{#1}}%
+\tikzoption{face 9}{\def\tikz@lib@fold@face@I{#1}}%
+\tikzoption{face 10}{\def\tikz@lib@fold@face@J{#1}}%
+\tikzoption{face 11}{\def\tikz@lib@fold@face@K{#1}}%
+\tikzoption{face 12}{\def\tikz@lib@fold@face@L{#1}}%
+\tikzoption{face 13}{\def\tikz@lib@fold@face@M{#1}}%
+\tikzoption{face 14}{\def\tikz@lib@fold@face@N{#1}}%
+\tikzoption{face 15}{\def\tikz@lib@fold@face@O{#1}}%
+\tikzoption{face 16}{\def\tikz@lib@fold@face@P{#1}}%
+\tikzoption{face 17}{\def\tikz@lib@fold@face@Q{#1}}%
+\tikzoption{face 18}{\def\tikz@lib@fold@face@R{#1}}%
+\tikzoption{face 19}{\def\tikz@lib@fold@face@S{#1}}%
+\tikzoption{face 20}{\def\tikz@lib@fold@face@T{#1}}%
+\tikzoption{face 21}{\def\tikz@lib@fold@face@U{#1}}%
+\tikzoption{face 22}{\def\tikz@lib@fold@face@V{#1}}%
+\tikzoption{face 23}{\def\tikz@lib@fold@face@W{#1}}%
+\tikzoption{face 24}{\def\tikz@lib@fold@face@X{#1}}%
+\tikzoption{face 25}{\def\tikz@lib@fold@face@Y{#1}}%
+\tikzoption{face 26}{\def\tikz@lib@fold@face@Z{#1}}%
+\tikzoption{face 27}{\def\tikz@lib@fold@face@AA{#1}}%
+\tikzoption{face 28}{\def\tikz@lib@fold@face@AB{#1}}%
+\tikzoption{face 29}{\def\tikz@lib@fold@face@AC{#1}}%
+\tikzoption{face 30}{\def\tikz@lib@fold@face@AD{#1}}%
+\tikzoption{face 31}{\def\tikz@lib@fold@face@AE{#1}}%
+\tikzoption{face 32}{\def\tikz@lib@fold@face@AF{#1}}%
+\tikzoption{face 33}{\def\tikz@lib@fold@face@AG{#1}}%
+\tikzoption{face 34}{\def\tikz@lib@fold@face@AH{#1}}%
+\tikzoption{face 35}{\def\tikz@lib@fold@face@AI{#1}}%
+\tikzoption{face 36}{\def\tikz@lib@fold@face@AJ{#1}}%
+\tikzoption{face 37}{\def\tikz@lib@fold@face@AK{#1}}%
+\tikzoption{face 38}{\def\tikz@lib@fold@face@AL{#1}}%
+\tikzoption{face 39}{\def\tikz@lib@fold@face@AM{#1}}%
+\tikzoption{face 40}{\def\tikz@lib@fold@face@AN{#1}}%
+\tikzoption{face 41}{\def\tikz@lib@fold@face@AO{#1}}%
+\tikzoption{face 42}{\def\tikz@lib@fold@face@AP{#1}}%
+\tikzoption{face 43}{\def\tikz@lib@fold@face@AQ{#1}}%
+\tikzoption{face 44}{\def\tikz@lib@fold@face@AR{#1}}%
+\tikzoption{face 45}{\def\tikz@lib@fold@face@AS{#1}}%
+\tikzoption{face 46}{\def\tikz@lib@fold@face@AT{#1}}%
+\tikzoption{face 47}{\def\tikz@lib@fold@face@AU{#1}}%
+\tikzoption{face 48}{\def\tikz@lib@fold@face@AV{#1}}%
+\tikzoption{face 49}{\def\tikz@lib@fold@face@AW{#1}}%
+\tikzoption{face 50}{\def\tikz@lib@fold@face@AX{#1}}%
+\tikzoption{face 51}{\def\tikz@lib@fold@face@AY{#1}}%
+\tikzoption{face 52}{\def\tikz@lib@fold@face@AZ{#1}}%
+\tikzoption{face 53}{\def\tikz@lib@fold@face@BA{#1}}%
+\tikzoption{face 54}{\def\tikz@lib@fold@face@BB{#1}}%
+\tikzoption{face 55}{\def\tikz@lib@fold@face@BC{#1}}%
+\tikzoption{face 56}{\def\tikz@lib@fold@face@BD{#1}}%
+\tikzoption{face 57}{\def\tikz@lib@fold@face@BE{#1}}%
+\tikzoption{face 58}{\def\tikz@lib@fold@face@BF{#1}}%
+\tikzoption{face 59}{\def\tikz@lib@fold@face@BG{#1}}%
+\tikzoption{face 60}{\def\tikz@lib@fold@face@BH{#1}}%
+\tikzoption{face 61}{\def\tikz@lib@fold@face@BI{#1}}%
+\tikzoption{face 62}{\def\tikz@lib@fold@face@BJ{#1}}%
+\tikzoption{face 63}{\def\tikz@lib@fold@face@BK{#1}}%
+\tikzoption{face 64}{\def\tikz@lib@fold@face@BL{#1}}%
+\tikzoption{face 65}{\def\tikz@lib@fold@face@BM{#1}}%
+\tikzoption{face 66}{\def\tikz@lib@fold@face@BN{#1}}%
+\tikzoption{face 67}{\def\tikz@lib@fold@face@BO{#1}}%
+\tikzoption{face 68}{\def\tikz@lib@fold@face@BP{#1}}%
+\tikzoption{face 69}{\def\tikz@lib@fold@face@BQ{#1}}%
+\tikzoption{face 70}{\def\tikz@lib@fold@face@BR{#1}}%
+\tikzoption{face 71}{\def\tikz@lib@fold@face@BS{#1}}%
+\tikzoption{face 72}{\def\tikz@lib@fold@face@BT{#1}}%
+\tikzoption{face 73}{\def\tikz@lib@fold@face@BU{#1}}%
+\tikzoption{face 74}{\def\tikz@lib@fold@face@BV{#1}}%
+\tikzoption{face 75}{\def\tikz@lib@fold@face@BW{#1}}%
+\tikzoption{face 76}{\def\tikz@lib@fold@face@BX{#1}}%
+\tikzoption{face 77}{\def\tikz@lib@fold@face@BY{#1}}%
+\tikzoption{face 78}{\def\tikz@lib@fold@face@BZ{#1}}%
+\tikzoption{face 79}{\def\tikz@lib@fold@face@CA{#1}}%
+\tikzoption{face 80}{\def\tikz@lib@fold@face@CB{#1}}%
+\tikzoption{face 81}{\def\tikz@lib@fold@face@CC{#1}}%
+\tikzoption{face 82}{\def\tikz@lib@fold@face@CD{#1}}%
+\tikzoption{face 83}{\def\tikz@lib@fold@face@CE{#1}}%
+\tikzoption{face 84}{\def\tikz@lib@fold@face@CF{#1}}%
+\tikzoption{face 85}{\def\tikz@lib@fold@face@CG{#1}}%
+\tikzoption{face 86}{\def\tikz@lib@fold@face@CH{#1}}%
+\tikzoption{face 87}{\def\tikz@lib@fold@face@CI{#1}}%
+\tikzoption{face 88}{\def\tikz@lib@fold@face@CJ{#1}}%
+\tikzoption{face 89}{\def\tikz@lib@fold@face@CK{#1}}%
+\tikzoption{face 90}{\def\tikz@lib@fold@face@CL{#1}}%
+\tikzoption{face 91}{\def\tikz@lib@fold@face@CM{#1}}%
+\tikzoption{face 92}{\def\tikz@lib@fold@face@CN{#1}}%
+
+
+\let\tikz@lib@fold@face@A=\pgfutil@empty
+\let\tikz@lib@fold@face@B=\pgfutil@empty
+\let\tikz@lib@fold@face@C=\pgfutil@empty
+\let\tikz@lib@fold@face@D=\pgfutil@empty
+\let\tikz@lib@fold@face@E=\pgfutil@empty
+\let\tikz@lib@fold@face@F=\pgfutil@empty
+\let\tikz@lib@fold@face@G=\pgfutil@empty
+\let\tikz@lib@fold@face@H=\pgfutil@empty
+\let\tikz@lib@fold@face@I=\pgfutil@empty
+\let\tikz@lib@fold@face@J=\pgfutil@empty
+\let\tikz@lib@fold@face@K=\pgfutil@empty
+\let\tikz@lib@fold@face@L=\pgfutil@empty
+\let\tikz@lib@fold@face@M=\pgfutil@empty
+\let\tikz@lib@fold@face@N=\pgfutil@empty
+\let\tikz@lib@fold@face@O=\pgfutil@empty
+\let\tikz@lib@fold@face@P=\pgfutil@empty
+\let\tikz@lib@fold@face@Q=\pgfutil@empty
+\let\tikz@lib@fold@face@R=\pgfutil@empty
+\let\tikz@lib@fold@face@S=\pgfutil@empty
+\let\tikz@lib@fold@face@T=\pgfutil@empty
+\let\tikz@lib@fold@face@U=\pgfutil@empty
+\let\tikz@lib@fold@face@V=\pgfutil@empty
+\let\tikz@lib@fold@face@W=\pgfutil@empty
+\let\tikz@lib@fold@face@X=\pgfutil@empty
+\let\tikz@lib@fold@face@Y=\pgfutil@empty
+\let\tikz@lib@fold@face@Z=\pgfutil@empty
+\let\tikz@lib@fold@face@AA=\pgfutil@empty
+\let\tikz@lib@fold@face@AB=\pgfutil@empty
+\let\tikz@lib@fold@face@AC=\pgfutil@empty
+\let\tikz@lib@fold@face@AD=\pgfutil@empty
+\let\tikz@lib@fold@face@AE=\pgfutil@empty
+\let\tikz@lib@fold@face@AF=\pgfutil@empty
+\let\tikz@lib@fold@face@AG=\pgfutil@empty
+\let\tikz@lib@fold@face@AH=\pgfutil@empty
+\let\tikz@lib@fold@face@AI=\pgfutil@empty
+\let\tikz@lib@fold@face@AJ=\pgfutil@empty
+\let\tikz@lib@fold@face@AK=\pgfutil@empty
+\let\tikz@lib@fold@face@AL=\pgfutil@empty
+\let\tikz@lib@fold@face@AM=\pgfutil@empty
+\let\tikz@lib@fold@face@AN=\pgfutil@empty
+\let\tikz@lib@fold@face@AO=\pgfutil@empty
+\let\tikz@lib@fold@face@AP=\pgfutil@empty
+\let\tikz@lib@fold@face@AQ=\pgfutil@empty
+\let\tikz@lib@fold@face@AR=\pgfutil@empty
+\let\tikz@lib@fold@face@AS=\pgfutil@empty
+\let\tikz@lib@fold@face@AT=\pgfutil@empty
+\let\tikz@lib@fold@face@AU=\pgfutil@empty
+\let\tikz@lib@fold@face@AV=\pgfutil@empty
+\let\tikz@lib@fold@face@AW=\pgfutil@empty
+\let\tikz@lib@fold@face@AX=\pgfutil@empty
+\let\tikz@lib@fold@face@AY=\pgfutil@empty
+\let\tikz@lib@fold@face@AZ=\pgfutil@empty
+\let\tikz@lib@fold@face@BA=\pgfutil@empty
+\let\tikz@lib@fold@face@BB=\pgfutil@empty
+\let\tikz@lib@fold@face@BC=\pgfutil@empty
+\let\tikz@lib@fold@face@BD=\pgfutil@empty
+\let\tikz@lib@fold@face@BE=\pgfutil@empty
+\let\tikz@lib@fold@face@BF=\pgfutil@empty
+\let\tikz@lib@fold@face@BG=\pgfutil@empty
+\let\tikz@lib@fold@face@BH=\pgfutil@empty
+\let\tikz@lib@fold@face@BI=\pgfutil@empty
+\let\tikz@lib@fold@face@BJ=\pgfutil@empty
+\let\tikz@lib@fold@face@BK=\pgfutil@empty
+\let\tikz@lib@fold@face@BL=\pgfutil@empty
+\let\tikz@lib@fold@face@BM=\pgfutil@empty
+\let\tikz@lib@fold@face@BN=\pgfutil@empty
+\let\tikz@lib@fold@face@BO=\pgfutil@empty
+\let\tikz@lib@fold@face@BP=\pgfutil@empty
+\let\tikz@lib@fold@face@BQ=\pgfutil@empty
+\let\tikz@lib@fold@face@BR=\pgfutil@empty
+\let\tikz@lib@fold@face@BS=\pgfutil@empty
+\let\tikz@lib@fold@face@BT=\pgfutil@empty
+\let\tikz@lib@fold@face@BU=\pgfutil@empty
+\let\tikz@lib@fold@face@BV=\pgfutil@empty
+\let\tikz@lib@fold@face@BW=\pgfutil@empty
+\let\tikz@lib@fold@face@BX=\pgfutil@empty
+\let\tikz@lib@fold@face@BY=\pgfutil@empty
+\let\tikz@lib@fold@face@BZ=\pgfutil@empty
+\let\tikz@lib@fold@face@CA=\pgfutil@empty
+\let\tikz@lib@fold@face@CB=\pgfutil@empty
+\let\tikz@lib@fold@face@CC=\pgfutil@empty
+\let\tikz@lib@fold@face@CD=\pgfutil@empty
+\let\tikz@lib@fold@face@CE=\pgfutil@empty
+\let\tikz@lib@fold@face@CF=\pgfutil@empty
+\let\tikz@lib@fold@face@CG=\pgfutil@empty
+\let\tikz@lib@fold@face@CH=\pgfutil@empty
+\let\tikz@lib@fold@face@CI=\pgfutil@empty
+\let\tikz@lib@fold@face@CJ=\pgfutil@empty
+\let\tikz@lib@fold@face@CK=\pgfutil@empty
+\let\tikz@lib@fold@face@CL=\pgfutil@empty
+\let\tikz@lib@fold@face@CM=\pgfutil@empty
+\let\tikz@lib@fold@face@CN=\pgfutil@empty
+
+
+\tikzset{numbered faces/.style={%
+ face 1={\node{1};},
+ face 2={\node{2};},
+ face 3={\node{3};},
+ face 4={\node{4};},
+ face 5={\node{5};},
+ face 6={\node{6};},
+ face 7={\node{7};},
+ face 8={\node{8};},
+ face 9={\node{9};},
+ face 10={\node{10};},
+ face 11={\node{11};},
+ face 12={\node{12};},
+ face 13={\node{13};},
+ face 14={\node{14};},
+ face 15={\node{15};},
+ face 16={\node{16};},
+ face 17={\node{17};},
+ face 18={\node{18};},
+ face 19={\node{19};},
+ face 20={\node{20};},
+ face 21={\node{21};},
+ face 22={\node{22};},
+ face 23={\node{23};},
+ face 24={\node{24};},
+ face 25={\node{25};},
+ face 26={\node{26};},
+ face 27={\node{27};},
+ face 28={\node{28};},
+ face 29={\node{29};},
+ face 30={\node{30};},
+ face 31={\node{31};},
+ face 32={\node{32};},
+ face 33={\node{33};},
+ face 34={\node{34};},
+ face 35={\node{35};},
+ face 36={\node{36};},
+ face 37={\node{37};},
+ face 38={\node{38};},
+ face 39={\node{39};},
+ face 40={\node{40};},
+ face 41={\node{41};},
+ face 42={\node{42};},
+ face 43={\node{43};},
+ face 44={\node{44};},
+ face 45={\node{45};},
+ face 46={\node{46};},
+ face 47={\node{47};},
+ face 48={\node{48};},
+ face 49={\node{49};},
+ face 50={\node{50};},
+ face 51={\node{51};},
+ face 52={\node{52};},
+ face 53={\node{53};},
+ face 54={\node{54};},
+ face 55={\node{55};},
+ face 56={\node{56};},
+ face 57={\node{57};},
+ face 58={\node{58};},
+ face 59={\node{59};},
+ face 60={\node{60};},
+ face 61={\node{61};},
+ face 62={\node{62};},
+ face 63={\node{63};},
+ face 64={\node{64};},
+ face 65={\node{65};},
+ face 66={\node{66};},
+ face 67={\node{67};},
+ face 68={\node{68};},
+ face 69={\node{69};},
+ face 70={\node{70};},
+ face 71={\node{71};},
+ face 72={\node{72};},
+ face 73={\node{73};},
+ face 74={\node{74};},
+ face 75={\node{75};},
+ face 76={\node{76};},
+ face 77={\node{77};},
+ face 78={\node{78};},
+ face 79={\node{79};},
+ face 80={\node{80};},
+ face 81={\node{81};},
+ face 82={\node{82};},
+ face 83={\node{83};},
+ face 84={\node{84};},
+ face 85={\node{85};},
+ face 86={\node{86};},
+ face 87={\node{87};},
+ face 88={\node{88};},
+ face 89={\node{89};},
+ face 90={\node{90};},
+ face 91={\node{91};},
+ face 92={\node{92};}}}%
+
+% The foldings defined here:
+
+\tikzset{
+ pics/dodecahedron folding/.style = {code=\tikzfoldingdodecahedron[];},
+ pics/tetrahedron folding/.style = {code=\tikzfoldingtetrahedron[];},
+ pics/tetrahedron truncated folding/.style = {code=\tikzfoldingtruncatedtetrahedron[];},
+ pics/cube folding/.style = {code=\tikzfoldingcube[];},
+ pics/cube truncated folding/.style = {code=\tikzfoldingtruncatedcube[];},
+ pics/octahedron folding/.style = {code=\tikzfoldingoctahedron[];},
+ pics/octahedron truncated folding/.style = {code=\tikzfoldingtruncatedoctahedron[];},
+ pics/dodecahedron folding/.style = {code=\tikzfoldingdodecahedron[];},
+ pics/dodecahedron' folding/.style = {code=\tikzfoldingalternatedodecahedron[];},
+ pics/dodecahedron rhombic folding/.style = {code=\tikzfoldingrhombicdodecahedron[];},
+ pics/dodecahedron golden folding/.style = {code=\tikzfoldinggoldenrhombicdodecahedron[];},
+ pics/cuboctahedron folding/.style = {code=\tikzfoldingcuboctahedron[];},
+ pics/cuboctahedron truncated folding/.style = {code=\tikzfoldingtruncatedcuboctahedron[];},
+ pics/icosahedron folding/.style = {code=\tikzfoldingicosahedron[];},
+ pics/rhombicuboctahedron folding/.style = {code=\tikzfoldingrhombicuboctahedron[];},
+ pics/snub cube folding/.style = {code=\tikzfoldingsnubcube[];},
+ pics/icosidodecahedron folding/.style = {code=\tikzfoldingicosidodecahedron[];}
+}%
+
+
+
+% Platonic solids
+% ---------------
+
+\def\tikzfoldingdodecahedron#1[#2]#3;{%
+ \begingroup%
+ \tikzset{#2}%
+ \tikz@lib@fold@pentagon
+ {\tikz@lib@fold@face@A}
+ {\tikz@lib@fold@pentagon
+ {\tikz@lib@fold@face@B}
+ {\tikz@lib@fold@pentagon
+ {\tikz@lib@fold@face@C}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@pentagon
+ {\tikz@lib@fold@face@D}
+ {\tikz@lib@fold@pentagon
+ {\tikz@lib@fold@face@E}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@pentagon
+ {\tikz@lib@fold@face@F}
+ {\tikz@lib@fold@pentagon
+ {\tikz@lib@fold@face@G}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@pentagon
+ {\tikz@lib@fold@face@H}
+ {\tikz@lib@fold@pentagon
+ {\tikz@lib@fold@face@I}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@pentagon
+ {\tikz@lib@fold@face@J}
+ {\tikz@lib@fold@pentagon
+ {\tikz@lib@fold@face@K}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@pentagon
+ {\tikz@lib@fold@face@L}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ }
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ \endgroup
+}%
+
+%alternative dodecahedron: larger format possible
+
+\def\tikzfoldingalternatedodecahedron#1[#2]#3;{%
+ \begingroup%
+ \tikzset{#2}%
+ \tikz@lib@fold@pentagon
+ {\tikz@lib@fold@face@A}
+ {\tikz@lib@fold@pentagon
+ {\tikz@lib@fold@face@B}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@pentagon
+ {\tikz@lib@fold@face@C}
+ {\tikz@lib@fold@pentagon
+ {\tikz@lib@fold@face@D}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@pentagon
+ {\tikz@lib@fold@face@E}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@pentagon
+ {\tikz@lib@fold@face@F}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@pentagon
+ {\tikz@lib@fold@face@G}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ }
+ }
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@pentagon
+ {\tikz@lib@fold@face@H}
+ {\tikz@lib@fold@pentagon
+ {\tikz@lib@fold@face@I}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@pentagon
+ {\tikz@lib@fold@face@J}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@pentagon
+ {\tikz@lib@fold@face@K}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@pentagon
+ {\tikz@lib@fold@face@L}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ }
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@ear@path}
+ \endgroup
+}%
+
+
+%tetrahedron
+
+\def\tikzfoldingtetrahedron#1[#2]#3;{%
+ \begingroup%
+ \tikzset{#2}%
+ \tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@A}
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@B}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@C}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@D}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ \endgroup
+}%
+
+%cube
+
+\def\tikzfoldingcube#1[#2]#3;{%
+ \begingroup%
+ \tikzset{#2}%
+ \tikz@lib@fold@square{\tikz@lib@fold@face@A}
+ {
+ \tikz@lib@fold@square{\tikz@lib@fold@face@B}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {
+ \tikz@lib@fold@square{\tikz@lib@fold@face@C}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {
+ \tikz@lib@fold@square{\tikz@lib@fold@face@D}
+ {
+ \tikz@lib@fold@square{\tikz@lib@fold@face@E}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {
+ \tikz@lib@fold@square{\tikz@lib@fold@face@F}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ \endgroup
+}%
+
+
+%octahedron
+
+\def\tikzfoldingoctahedron#1[#2]#3;{%
+ \begingroup%
+ \tikzset{#2}%
+ \tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@A}
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@B}
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@C}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@D}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@E}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ }
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@F}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@G}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@H}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ }
+ \endgroup
+}%
+
+
+%icosahedron
+
+\def\tikzfoldingicosahedron#1[#2]#3;{%
+ \begingroup%
+ \tikzset{#2}%
+ \tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@A}
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@B}
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@C}
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@D}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@E}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@F}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@G}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ }
+ }
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@H}
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@I}
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@J}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@K}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@L}
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@M}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@N}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ }
+ }
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@O}
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@P}
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@Q}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@R}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@S}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@T}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ }
+ }
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ \endgroup
+}%
+
+% Archimedean solids
+% ------------------
+
+%truncated tetrahedron
+
+\def\tikzfoldingtruncatedtetrahedron#1[#2]#3;{%
+ \begingroup%
+ \tikzset{#2}%
+ \tikz@lib@fold@hexagon
+ {\tikz@lib@fold@face@A}
+ {\tikz@lib@fold@hexagon
+ {\tikz@lib@fold@face@B}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@C}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@hexagon
+ {\tikz@lib@fold@face@D}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@E}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@hexagon
+ {\tikz@lib@fold@face@F}
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@G}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@H}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ \endgroup
+}%
+
+%cuboctahedron
+
+\def\tikzfoldingcuboctahedron#1[#2]#3;{%
+ \begingroup%
+ \tikzset{#2}%
+ \tikz@lib@fold@square
+ {\tikz@lib@fold@face@A}
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@B}
+ {\tikz@lib@fold@square
+ {\tikz@lib@fold@face@C}
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@D}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@square
+ {\tikz@lib@fold@face@E}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ }
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@F}
+ {\tikz@lib@fold@square
+ {\tikz@lib@fold@face@G}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@H}
+ {\tikz@lib@fold@square
+ {\tikz@lib@fold@face@I}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@J}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@K}
+ {\tikz@lib@fold@square
+ {\tikz@lib@fold@face@L}
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@M}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@N}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ \endgroup
+}%
+
+%truncated cube
+
+\def\tikzfoldingtruncatedcube#1[#2]#3;{%
+ \begingroup%
+ \tikzset{#2}%
+ \tikz@lib@fold@octagon
+ {\tikz@lib@fold@face@A}
+ {\tikz@lib@fold@octagon
+ {\tikz@lib@fold@face@B}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@C}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@D}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@E}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@F}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ }
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@octagon
+ {\tikz@lib@fold@face@G}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@H}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@octagon
+ {\tikz@lib@fold@face@I}
+ {\tikz@lib@fold@octagon
+ {\tikz@lib@fold@face@J}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@K}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@L}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@octagon
+ {\tikz@lib@fold@face@M}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@N}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@cut@path}
+ \endgroup
+}%
+
+
+%truncated octahedron
+
+\def\tikzfoldingtruncatedoctahedron#1[#2]#3;{%
+ \begingroup%
+ \tikzset{#2}%
+ \tikz@lib@fold@hexagon
+ {\tikz@lib@fold@face@A}
+ {\tikz@lib@fold@hexagon
+ {\tikz@lib@fold@face@B}
+ {\tikz@lib@fold@square
+ {\tikz@lib@fold@face@C}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@hexagon
+ {\tikz@lib@fold@face@D}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@square
+ {\tikz@lib@fold@face@E}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@square
+ {\tikz@lib@fold@face@F}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@hexagon
+ {\tikz@lib@fold@face@G}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ }
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@square
+ {\tikz@lib@fold@face@H}
+ {\tikz@lib@fold@hexagon
+ {\tikz@lib@fold@face@I}
+ {\tikz@lib@fold@hexagon
+ {\tikz@lib@fold@face@J}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@square
+ {\tikz@lib@fold@face@K}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@hexagon
+ {\tikz@lib@fold@face@L}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@hexagon
+ {\tikz@lib@fold@face@M}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@square
+ {\tikz@lib@fold@face@N}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ }
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@cut@path}
+ \endgroup
+}%
+
+
+%rhombicuboctahedron
+
+\def\tikzfoldingrhombicuboctahedron#1[#2]#3;{%
+ \begingroup%
+ \tikzset{#2}%
+ \tikz@lib@fold@square
+ {\tikz@lib@fold@face@A}
+ {\tikz@lib@fold@square
+ {\tikz@lib@fold@face@B}
+ {\tikz@lib@fold@square
+ {\tikz@lib@fold@face@C}
+ {\tikz@lib@fold@square
+ {\tikz@lib@fold@face@D}
+ {\tikz@lib@fold@square
+ {\tikz@lib@fold@face@E}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@square
+ {\tikz@lib@fold@face@F}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@square
+ {\tikz@lib@fold@face@G}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ }
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@H}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@I}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ }
+ {\tikz@lib@fold@square
+ {\tikz@lib@fold@face@J}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@square
+ {\tikz@lib@fold@face@K}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ }
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@L}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@M}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ }
+ {\tikz@lib@fold@square
+ {\tikz@lib@fold@face@N}
+ {\tikz@lib@fold@square
+ {\tikz@lib@fold@face@O}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@square
+ {\tikz@lib@fold@face@P}
+ {\tikz@lib@fold@square
+ {\tikz@lib@fold@face@Q}
+ {\tikz@lib@fold@square
+ {\tikz@lib@fold@face@R}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@S}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@T}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ }
+ {\tikz@lib@fold@square
+ {\tikz@lib@fold@face@U}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@square
+ {\tikz@lib@fold@face@V}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ }
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@W}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@triangle
+ {\tikz@lib@fold@face@X}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ }
+ {\tikz@lib@fold@square
+ {\tikz@lib@fold@face@Y}
+ {\tikz@lib@fold@square
+ {\tikz@lib@fold@face@Z}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ \endgroup
+}%
+
+%truncated cuboctahedron
+
+\def\tikzfoldingtruncatedcuboctahedron#1[#2]#3;{%
+ \begingroup%
+ \tikzset{#2}%
+ \tikz@lib@fold@square
+ {\tikz@lib@fold@face@A}
+ {\tikz@lib@fold@octagon
+ {\tikz@lib@fold@face@B}
+ {\tikz@lib@fold@square
+ {\tikz@lib@fold@face@C}
+ {\tikz@lib@fold@octagon
+ {\tikz@lib@fold@face@D}
+ {\tikz@lib@fold@square
+ {\tikz@lib@fold@face@E}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@hexagon
+ {\tikz@lib@fold@face@F}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@ear@custom@right@path{15}}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@hexagon
+ {\tikz@lib@fold@face@G}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@custom@left@path{15}}
+ {\tikz@lib@fold@ear@path}
+ }
+ }
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@square
+ {\tikz@lib@fold@face@H}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@square
+ {\tikz@lib@fold@face@I}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@hexagon
+ {\tikz@lib@fold@face@J}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@ear@custom@right@path{15}}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@custom@left@path{15}}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@hexagon
+ {\tikz@lib@fold@face@K}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@ear@custom@right@path{15}}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@custom@left@path{15}}
+ {\tikz@lib@fold@ear@path}
+ }
+ }
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@square
+ {\tikz@lib@fold@face@L}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@square
+ {\tikz@lib@fold@face@M}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@hexagon
+ {\tikz@lib@fold@face@N}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@ear@custom@right@path{15}}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@custom@left@path{15}}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@octagon
+ {\tikz@lib@fold@face@O}
+ {\tikz@lib@fold@square
+ {\tikz@lib@fold@face@P}
+ {\tikz@lib@fold@octagon
+ {\tikz@lib@fold@face@Q}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@square
+ {\tikz@lib@fold@face@R}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@square
+ {\tikz@lib@fold@face@S}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@hexagon
+ {\tikz@lib@fold@face@T}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@ear@custom@right@path{15}}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@custom@left@path{15}}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@hexagon
+ {\tikz@lib@fold@face@U}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@ear@custom@right@path{15}}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@custom@left@path{15}}
+ {\tikz@lib@fold@ear@path}
+ }
+ }
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@square
+ {\tikz@lib@fold@face@V}
+ {\tikz@lib@fold@octagon
+ {\tikz@lib@fold@face@W}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@square
+ {\tikz@lib@fold@face@X}
+ {\tikz@lib@fold@octagon
+ {\tikz@lib@fold@face@Y}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@hexagon
+ {\tikz@lib@fold@face@Z}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@ear@custom@right@path{15}}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@custom@left@path{15}}
+ {\tikz@lib@fold@ear@path}
+ }
+ \endgroup
+}%
+
+%snub cube
+
+\def\tikzfoldingsnubcube#1[#2]#3;{%
+ \begingroup%
+ \tikzset{#2}%
+ \tikz@lib@fold@square{\tikz@lib@fold@face@A}
+ {
+ \tikz@lib@fold@triangle{\tikz@lib@fold@face@B}
+ {
+ \tikz@lib@fold@triangle{\tikz@lib@fold@face@C}
+ {
+ \tikz@lib@fold@triangle{\tikz@lib@fold@face@D}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {
+ \tikz@lib@fold@square{\tikz@lib@fold@face@E}
+ {
+ \tikz@lib@fold@triangle{\tikz@lib@fold@face@F}
+ {
+ \tikz@lib@fold@triangle{\tikz@lib@fold@face@G}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@path}
+ {
+ \tikz@lib@fold@triangle{\tikz@lib@fold@face@H}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ }
+ {
+ \tikz@lib@fold@triangle{\tikz@lib@fold@face@I}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@path}
+ {
+ \tikz@lib@fold@triangle{\tikz@lib@fold@face@J}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ }
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {
+ \tikz@lib@fold@triangle{\tikz@lib@fold@face@K}
+ {
+ \tikz@lib@fold@triangle{\tikz@lib@fold@face@L}
+ {
+ \tikz@lib@fold@triangle{\tikz@lib@fold@face@M}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {
+ \tikz@lib@fold@square{\tikz@lib@fold@face@N}
+ {
+ \tikz@lib@fold@triangle{\tikz@lib@fold@face@O}
+ {
+ \tikz@lib@fold@triangle{\tikz@lib@fold@face@P}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@path}
+ {
+ \tikz@lib@fold@triangle{\tikz@lib@fold@face@Q}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ }
+ {
+ \tikz@lib@fold@triangle{\tikz@lib@fold@face@R}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@path}
+ {
+ \tikz@lib@fold@triangle{\tikz@lib@fold@face@S}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ }
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {
+ \tikz@lib@fold@triangle{\tikz@lib@fold@face@T}
+ {
+ \tikz@lib@fold@triangle{\tikz@lib@fold@face@U}
+ {
+ \tikz@lib@fold@triangle{\tikz@lib@fold@face@V}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {
+ \tikz@lib@fold@square{\tikz@lib@fold@face@W}
+ {
+ \tikz@lib@fold@triangle{\tikz@lib@fold@face@X}
+ {
+ \tikz@lib@fold@triangle{\tikz@lib@fold@face@Y}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@path}
+ {
+ \tikz@lib@fold@triangle{\tikz@lib@fold@face@Z}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ }
+ {
+ \tikz@lib@fold@triangle{\tikz@lib@fold@face@AA}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@path}
+ {
+ \tikz@lib@fold@triangle{\tikz@lib@fold@face@AB}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ }
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {
+ \tikz@lib@fold@triangle{\tikz@lib@fold@face@AC}
+ {
+ \tikz@lib@fold@triangle{\tikz@lib@fold@face@AD}
+ {
+ \tikz@lib@fold@triangle{\tikz@lib@fold@face@AE}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {
+ \tikz@lib@fold@square{\tikz@lib@fold@face@AF}
+ {
+ \tikz@lib@fold@triangle{\tikz@lib@fold@face@AG}
+ {
+ \tikz@lib@fold@triangle{\tikz@lib@fold@face@AH}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@path}
+ {
+ \tikz@lib@fold@triangle{\tikz@lib@fold@face@AI}
+ {
+ \tikz@lib@fold@square{\tikz@lib@fold@face@AJ}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ }
+ {
+ \tikz@lib@fold@triangle{\tikz@lib@fold@face@AK}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@path}
+ {
+ \tikz@lib@fold@triangle{\tikz@lib@fold@face@AL}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ }
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ \endgroup
+}%
+
+% icosidodecahedron
+
+\def\tikzfoldingicosidodecahedron#1[#2]#3;{%
+ \begingroup%
+ \tikzset{#2}%
+ \tikz@lib@fold@pentagon{\tikz@lib@fold@face@A}
+ {
+ \tikz@lib@fold@triangle{\tikz@lib@fold@face@B}
+ {
+ \tikz@lib@fold@pentagon{\tikz@lib@fold@face@C}
+ {
+ \tikz@lib@fold@triangle{\tikz@lib@fold@face@D}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@ear@custom@right@path{24}}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ {
+ \tikz@lib@fold@triangle{\tikz@lib@fold@face@E}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {
+ \tikz@lib@fold@triangle{\tikz@lib@fold@face@F}
+ {
+ \tikz@lib@fold@pentagon{\tikz@lib@fold@face@G}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@ear@custom@right@path{24}}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ {
+ \tikz@lib@fold@triangle{\tikz@lib@fold@face@H}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {
+ \tikz@lib@fold@pentagon{\tikz@lib@fold@face@I}
+ {\tikz@lib@fold@ear@path}
+ {
+ \tikz@lib@fold@triangle{\tikz@lib@fold@face@J}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ }
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {
+ \tikz@lib@fold@triangle{\tikz@lib@fold@face@K}
+ {\tikz@lib@fold@ear@custom@right@path{24}}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {
+ \tikz@lib@fold@triangle{\tikz@lib@fold@face@L}
+ {
+ \tikz@lib@fold@pentagon{\tikz@lib@fold@face@M}
+ {
+ \tikz@lib@fold@triangle{\tikz@lib@fold@face@N}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {
+ \tikz@lib@fold@pentagon{\tikz@lib@fold@face@O}
+ {
+ \tikz@lib@fold@triangle{\tikz@lib@fold@face@P}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ }
+ {\tikz@lib@fold@ear@custom@right@path{24}}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ {
+ \tikz@lib@fold@triangle{\tikz@lib@fold@face@Q}
+ {\tikz@lib@fold@ear@custom@right@path{24}}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ }
+ {\tikz@lib@fold@path}
+ {
+ \tikz@lib@fold@pentagon{\tikz@lib@fold@face@R}
+ {
+ \tikz@lib@fold@triangle{\tikz@lib@fold@face@S}
+ {
+ \tikz@lib@fold@pentagon{\tikz@lib@fold@face@T}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@ear@custom@right@path{24}}
+ {\tikz@lib@fold@path}
+ {
+ \tikz@lib@fold@triangle{\tikz@lib@fold@face@U}
+ {
+ \tikz@lib@fold@pentagon{\tikz@lib@fold@face@V}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@ear@custom@right@path{24}}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {
+ \tikz@lib@fold@triangle{\tikz@lib@fold@face@W}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {
+ \tikz@lib@fold@triangle{\tikz@lib@fold@face@X}
+ {\tikz@lib@fold@ear@custom@right@path{24}}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ {
+ \tikz@lib@fold@triangle{\tikz@lib@fold@face@Y}
+ {
+ \tikz@lib@fold@pentagon{\tikz@lib@fold@face@Z}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@ear@custom@right@path{24}}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ }
+ }
+ {
+ \tikz@lib@fold@triangle{\tikz@lib@fold@face@AA}
+ {
+ \tikz@lib@fold@pentagon{\tikz@lib@fold@face@AB}
+ {
+ \tikz@lib@fold@triangle{\tikz@lib@fold@face@AC}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {
+ \tikz@lib@fold@pentagon{\tikz@lib@fold@face@AD}
+ {
+ \tikz@lib@fold@triangle{\tikz@lib@fold@face@AE}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ }
+ {\tikz@lib@fold@ear@custom@right@path{24}}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ {
+ \tikz@lib@fold@triangle{\tikz@lib@fold@face@AF}
+ {\tikz@lib@fold@ear@custom@right@path{24}}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ \endgroup
+}%
+
+%rhombic (Catalan) dodecahedron ("type 1" - spheric)
+\def\tikzfoldingrhombicdodecahedron#1[#2]#3;{%
+ \begingroup%
+ \tikzset{#2}%
+ \tikz@lib@fold@squarerhombusr{\tikz@lib@fold@face@B}
+ {\tikz@lib@fold@squarerhombusl{\scope[rotate=90]\tikz@lib@fold@face@C\endscope}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@squarerhombusr{\tikz@lib@fold@face@E}
+ {\tikz@lib@fold@squarerhombusl{\scope[rotate=90]\tikz@lib@fold@face@F\endscope}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@squarerhombusr{\scope[rotate=180]\tikz@lib@fold@face@D\endscope}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ }
+ {\tikz@lib@fold@squarerhombusl{\scope[rotate=-90]\tikz@lib@fold@face@H\endscope}
+ {\tikz@lib@fold@squarerhombusr{\scope[rotate=180]\tikz@lib@fold@face@G\endscope}
+ {\tikz@lib@fold@squarerhombusl{\scope[rotate=-90]\tikz@lib@fold@face@L\endscope}
+ {\tikz@lib@fold@squarerhombusr{\scope[rotate=180]\tikz@lib@fold@face@K\endscope}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@squarerhombusl{\scope[rotate=90]\tikz@lib@fold@face@J\endscope}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@squarerhombusl{\tikz@lib@fold@face@H}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@squarerhombusr{\tikz@lib@fold@face@F}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ \endgroup
+}%
+
+%golden rhombic dodecahedron ("type 2" - flattened)
+\def\tikzfoldinggoldenrhombicdodecahedron#1[#2]#3;{%
+ \begingroup%
+ \tikzset{#2}%
+ \tikz@lib@fold@goldenrhombusr{\tikz@lib@fold@face@A}
+ {\tikz@lib@fold@goldenrhombusl{\scope[rotate=180]\tikz@lib@fold@face@B\endscope}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@path}
+ }
+ {\tikz@lib@fold@goldenrhombusr{\scope[rotate=180]\tikz@lib@fold@face@E\endscope}
+ {\tikz@lib@fold@goldenrhombusl{\tikz@lib@fold@face@H}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@goldenrhombusl{\tikz@lib@fold@face@G}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ }
+ {\tikz@lib@fold@goldenrhombusl{\scope[rotate=180]\tikz@lib@fold@face@D\endscope}
+ {\tikz@lib@fold@goldenrhombusr{\tikz@lib@fold@face@I}
+ {\tikz@lib@fold@goldenrhombusl{\tikz@lib@fold@face@L}
+ {\tikz@lib@fold@goldenrhombusr{\scope[rotate=180]\tikz@lib@fold@face@K\endscope}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@goldenrhombusl{\scope[rotate=180]\tikz@lib@fold@face@J\endscope}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@path}
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@goldenrhombusr{\tikz@lib@fold@face@F}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@path}
+ }
+ {\tikz@lib@fold@goldenrhombusr{\scope[rotate=180]\tikz@lib@fold@face@C\endscope}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ \endgroup
+}%
+
+%rhombic tricontahedron
+
+\def\tikzfoldingrhombictricontahedron#1[#2]#3;{%
+ \begingroup%
+ \tikzset{#2}%
+ \tikz@lib@fold@goldenrhombusr{\tikz@lib@fold@face@A}
+ { \tikz@lib@fold@goldenrhombusl{\tikz@lib@fold@face@B}
+ { \tikz@lib@fold@goldenrhombusr{\tikz@lib@fold@face@F}
+ { \tikz@lib@fold@goldenrhombusl{\tikz@lib@fold@face@I}
+ { \tikz@lib@fold@goldenrhombusr{\tikz@lib@fold@face@J}
+ { \tikz@lib@fold@goldenrhombusl{\tikz@lib@fold@face@K}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@path}
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@path}
+ { \tikz@lib@fold@goldenrhombusr{\tikz@lib@fold@face@H}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ }
+ { \tikz@lib@fold@goldenrhombusl{\tikz@lib@fold@face@G}
+ { \tikz@lib@fold@goldenrhombusr{\tikz@lib@fold@face@L}
+ { \tikz@lib@fold@goldenrhombusl{\tikz@lib@fold@face@N}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ { \tikz@lib@fold@goldenrhombusr{\tikz@lib@fold@face@M}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ }
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@path}
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ { \tikz@lib@fold@goldenrhombusr{\tikz@lib@fold@face@C}
+ { \tikz@lib@fold@goldenrhombusl{\tikz@lib@fold@face@N}
+ { \tikz@lib@fold@goldenrhombusr{\tikz@lib@fold@face@N}
+ { \tikz@lib@fold@goldenrhombusl{\tikz@lib@fold@face@N}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ { \tikz@lib@fold@goldenrhombusr{\tikz@lib@fold@face@N}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ }
+ { \tikz@lib@fold@goldenrhombusl{\tikz@lib@fold@face@D}
+ { \tikz@lib@fold@goldenrhombusr{\tikz@lib@fold@face@D}
+ { \tikz@lib@fold@goldenrhombusl{\tikz@lib@fold@face@D}
+ { \tikz@lib@fold@goldenrhombusr{\tikz@lib@fold@face@D}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ { \tikz@lib@fold@goldenrhombusr{\tikz@lib@fold@face@D}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ }
+ { \tikz@lib@fold@goldenrhombusl{\tikz@lib@fold@face@D}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ { \tikz@lib@fold@goldenrhombusr{\tikz@lib@fold@face@E}
+ { \tikz@lib@fold@goldenrhombusl{\tikz@lib@fold@face@E}
+ { \tikz@lib@fold@goldenrhombusr{\tikz@lib@fold@face@E}
+ { \tikz@lib@fold@goldenrhombusl{\tikz@lib@fold@face@E}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@path}
+ }
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ { \tikz@lib@fold@goldenrhombusr{\tikz@lib@fold@face@E}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ }
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@cut@path}
+ }
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@path}
+ { \tikz@lib@fold@goldenrhombusr{\tikz@lib@fold@face@E}
+ { \tikz@lib@fold@goldenrhombusl{\tikz@lib@fold@face@E}
+ { \tikz@lib@fold@goldenrhombusr{\tikz@lib@fold@face@E}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@path}
+ }
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@ear@path}
+ }
+ {\tikz@lib@fold@ear@path}
+ {\tikz@lib@fold@path}
+ {\tikz@lib@fold@path}
+ }
+ }
+ \endgroup
+}%
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryfpu.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryfpu.code.tex
new file mode 100644
index 0000000000..36e0afe133
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryfpu.code.tex
@@ -0,0 +1,10 @@
+% Copyright 2008/2018 by Christian Feuersaenger
+%
+% This file may be distributed and/or modified
+%
+% 1. under the LaTeX Project Public License and/or
+% 2. under the GNU General Public License.
+%
+% See the file doc/generic/pgf/licenses/LICENSE for more details.
+
+\usepgflibrary{fpu}%
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryintersections.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryintersections.code.tex
new file mode 100644
index 0000000000..cf94f92367
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryintersections.code.tex
@@ -0,0 +1,148 @@
+% Copyright 2019 by Mark Wibrow
+%
+% This file may be distributed and/or modified
+%
+% 1. under the LaTeX Project Public License and/or
+% 2. under the GNU Free Documentation License.
+%
+% See the file doc/generic/pgf/licenses/LICENSE for more details.
+
+\usepgflibrary{intersections}%
+
+% FIXME : the 'name path global' is not reset properly - and some
+% following 'name path' will append to it rather that reset it.
+
+\pgfkeys{%
+ /tikz/name path global/.code={%
+ % reset any "old" variables inherited from some other path
+ % - we do not accidentally want to append to an old path with the
+ % same name (or if someone provided the option twice)...
+ \expandafter\global\expandafter\let\csname tikz@intersect@path@name@#1\endcsname=\relax
+ \tikz@key@name@path{#1}{\gdef}%
+ },
+ /tikz/name path local/.code={%
+ \pgfkeys{/tikz/name path={#1}}%
+ },
+ /tikz/name path/.code={%
+ % hm. Do we need this "reset old option" as in 'name path global'
+ % for this case as well?
+ \tikz@key@name@path{#1}{\def}%
+ },
+}%
+
+% #1: the name to assign.
+% #2: one of '\def' or '\gdef'.
+\def\tikz@key@name@path#1#2{%
+ \tikz@addmode{%
+ \pgfsyssoftpath@getcurrentpath\tikz@intersect@temppath@round%
+ \pgfprocessround\tikz@intersect@temppath@round\tikz@intersect@temppath%
+ \ifx\tikz@intersect@namedpaths\pgfutil@empty%
+ \else%
+ \tikz@intersect@namedpaths%
+ \fi%
+ \tikz@intersect@addto@path@names{#1}{#2}%
+ }%
+}%
+
+% #1: the name to assign.
+% #2: one of '\def' or '\gdef'.
+\def\tikz@intersect@addto@path@names#1#2{%
+ \edef\tikz@marshal{#2\expandafter\noexpand\csname tikz@intersect@path@name@#1\endcsname}%
+ \expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter\tikz@marshal%
+ \expandafter\expandafter\expandafter{\expandafter\tikz@marshal\expandafter{\tikz@intersect@temppath}}%
+ \expandafter\pgfutil@g@addto@macro\expandafter\tikz@intersect@namedpaths\expandafter{\tikz@marshal}%
+}%
+
+% at the end of evey \path command ...
+\let\tikz@finish@orig=\tikz@finish
+\def\tikz@finish{%
+ \tikz@finish@orig%
+ \tikz@intersect@finish%
+}%
+
+% ... make the named path variables available
+\def\tikz@intersect@finish{%
+ \tikz@intersect@namedpaths%
+}%
+
+\let\tikz@intersect@namedpaths=\pgfutil@empty
+\let\tikz@intersect@path@a=\pgfutil@empty
+\let\tikz@intersect@path@b=\pgfutil@empty
+\let\tikz@intersect@name=\pgfutil@empty
+\let\tikz@intersect@total=\pgfutil@empty
+
+\tikzset{
+ every scope/.append style={
+ execute at begin scope={\let\tikz@intersect@namedpaths@outside\tikz@intersect@namedpaths},
+ execute at end scope={\global\let\tikz@intersect@namedpaths\tikz@intersect@namedpaths@outside},
+ },
+ name intersections/.code={%
+ \tikzset{/tikz/intersection/.cd,
+ by=,
+ #1}%
+ \pgfutil@ifundefined{tikz@intersect@path@name@\tikz@intersect@path@a}{%
+ \tikzerror{I do not know the path named `\tikz@intersect@path@a'. Perhaps you misspelt it}}%
+ {\pgfutil@ifundefined{tikz@intersect@path@name@\tikz@intersect@path@b}{%
+ \tikzerror{I do not know the path named `\tikz@intersect@path@b'. Perhaps you misspelt it}}%
+ {%
+ \pgfintersectionofpaths%
+ {%
+ \expandafter\pgfsetpath\csname tikz@intersect@path@name@\tikz@intersect@path@a\endcsname%
+ }%
+ {%
+ \expandafter\pgfsetpath\csname tikz@intersect@path@name@\tikz@intersect@path@b\endcsname%
+ }%
+ \ifx\tikz@intersect@total\pgfutil@empty%
+ \else%
+ \expandafter\let\tikz@intersect@total=\pgfintersectionsolutions%
+ \fi%
+ \ifx\tikz@intersect@name\pgfutil@empty%
+ \def\tikz@intersect@@name{intersection}%
+ \else%
+ \let\tikz@intersect@@name=\tikz@intersect@name%
+ \fi%
+ \pgfmathloop%
+ \ifnum\pgfmathcounter>\pgfintersectionsolutions\relax%
+ \else%
+ \path[reset cm]\pgfextra{\pgftransformshift{\pgfpointintersectionsolution{\pgfmathcounter}}}%
+ coordinate (\tikz@intersect@@name-\pgfmathcounter);
+ \repeatpgfmathloop%
+ \ifx\tikz@intersect@by\pgfutil@empty%
+ \else%
+ \foreach\tikz@intersect@name[count=\tikz@intersection@count] in \tikz@intersect@by%
+ {\expandafter\tikz@intersect@name@parse\tikz@intersect@name\pgf@stop}%
+ \fi%
+ }%
+ }%
+ },%
+ intersection/.cd,
+ of/.code=\tikz@intersect@path@names@parse#1\tikz@stop,%
+ name/.store in=\tikz@intersect@name,
+ total/.store in=\tikz@intersect@total,
+ by/.store in=\tikz@intersect@by,
+ sort by/.code=\edef\tikz@intersect@sort@by{#1}\tikz@intersect@check@sort@by%
+}%
+
+
+\def\tikz@intersect@check@sort@by{%
+ \ifx\tikz@intersect@sort@by\tikz@intersect@path@a%
+ \pgfintersectionsortbyfirstpath%
+ \else%
+ \ifx\tikz@intersect@sort@by\tikz@intersect@path@b%
+ \pgfintersectionsortbysecondpath%
+ \else%
+ \pgf@intersect@sortfalse%
+ \fi%
+ \fi%
+}%
+\def\tikz@intersect@path@names@parse#1 and #2\tikz@stop{%
+ \def\tikz@intersect@path@a{#1}%
+ \def\tikz@intersect@path@b{#2}%
+}%
+
+\def\tikz@intersect@name@parse{\pgfutil@ifnextchar[\tikz@intersect@name@parse@opt{\tikz@intersect@name@parse@opt[]}}%}
+\def\tikz@intersect@name@parse@opt[#1]#2\pgf@stop{%
+ \coordinate [#1] (#2) at (\tikz@intersect@@name-\tikz@intersection@count);
+}%
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarylindenmayersystems.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarylindenmayersystems.code.tex
new file mode 100644
index 0000000000..6763c733e9
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarylindenmayersystems.code.tex
@@ -0,0 +1,81 @@
+% Copyright 2018 by 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.
+
+\usepgflibrary{lindenmayersystems}%
+
+\def\tikz@@lsystem-system{%
+ \pgfutil@ifnextchar[{\tikz@lsystem@options}{\tikz@lsystem@options[]}}%
+
+\def\tikz@lsystem indenmayer system{%
+ \pgfutil@ifnextchar[{\tikz@lsystem@options}{\tikz@lsystem@options[]}}%
+
+\def\tikz@lsystem@options[#1]{%
+ \tikzset{#1}%
+ \ifx\tikz@lsystem@rules\pgfutil@empty%
+ \else%
+ \tikz@lsystem@declare%
+ \def\tikz@lsystem@name{tikz@temp}%
+ \fi%
+ \ifx\tikz@lsystem@anchor\pgfutil@empty%
+ \pgfpathmoveto{\pgfqpoint{\tikz@lastxsaved}{\tikz@lastysaved}}%
+ \pgflindenmayersystem{\tikz@lsystem@name}{\tikz@lsystem@axiom}{\tikz@lsystem@order}%
+ \else%
+ \pgfextract@process\tikz@lsystem@pos{\pgfqpoint{\tikz@lastxsaved}{\tikz@lastysaved}}%
+ \setbox\pgfnodeparttextbox=\hbox{%
+ \pgfinterruptpicture%
+ \pgfpicture%
+ \pgfpathmoveto{\pgfpointorigin}%
+ \pgflindenmayersystem{\tikz@lsystem@name}{\tikz@lsystem@axiom}{\tikz@lsystem@order}%
+ \begingroup%
+ \tikz@finish%
+ \endpgfpicture%
+ \endpgfinterruptpicture%
+ }%
+ {%
+ \pgftransformshift{\tikz@lsystem@pos}%
+ \tikzset{inner sep=0pt, outer sep=0pt, minimum size=0pt}%
+ \pgfmultipartnode{rectangle}{\tikz@lsystem@anchor}{lindenmayer system}{\pgfusepath{discard}}%
+ }%
+ \fi%
+ \tikz@scan@next@command}%
+
+\tikzset{%
+ lindenmayer system/.style={/pgf/lindenmayer system/.cd, #1,/tikz/.cd},
+ l-system/.style={lindenmayer system={#1}},
+}%
+\pgfkeys{/pgf/lindenmayer system/.cd,
+ name/.code=\edef\tikz@lsystem@name{#1}\let\tikz@lsystem@rules=\pgfutil@empty,%
+ axiom/.store in=\tikz@lsystem@axiom,%
+ order/.store in=\tikz@lsystem@order,
+ .unknown/.code={%
+ \pgfutil@ifundefined{pgf@lsystem@\pgfkeyscurrentname}{%
+ \pgfkeys{/errors/unknown key={/pgf/lindenmayer system/\pgfkeyscurrentname}{#1}}%
+ \let\tikz@lsystem@name=\pgfutil@empty%
+ }%
+ {\edef\tikz@lsystem@name{\pgfkeyscurrentname}}
+ },%
+ anchor/.store in=\tikz@lsystem@anchor,%
+ rule set/.store in=\tikz@lsystem@rules
+}%
+\let\tikz@lsystem@anchor=\pgfutil@empty%
+\let\tikz@lsystem@rules=\pgfutil@empty%
+
+\def\tikz@lsystem@declare{%
+ \expandafter\let\csname pgf@lsystem@tikz@temp\endcsname=\relax%
+ \pgfdeclarelindenmayersystem{tikz@temp}{%
+ \expandafter\tikz@lsystem@parse@rules\tikz@lsystem@rules,\tikz@stop,%
+ }%
+}%
+\def\tikz@lsystem@parse@rules#1,{%
+ \ifx#1\tikz@stop%
+ \else%
+ \rule{#1}%
+ \expandafter\tikz@lsystem@parse@rules%
+ \fi%
+}%
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarymath.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarymath.code.tex
new file mode 100644
index 0000000000..ec00bc4b8a
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarymath.code.tex
@@ -0,0 +1,731 @@
+% Copyright 2019 by 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.
+
+\usetikzlibrary{fpu}
+
+\edef\tikz@math@at@catcode{\the\catcode`\@}%
+\catcode`\@=11
+
+\def\tikz@math@gobblespaces#1{\pgfutil@ifnextchar x{#1}{#1}}%
+
+\def\tikz@math@meaning@macro{macro}%
+\def\tikz@math@meaning@dimen{dimen}%
+\def\tikz@math@meaning@count{count}%
+\def\tikz@math@meaning@null{null}%
+
+\def\tikz@math@getmeaning#1{\expandafter\tikz@math@@getmeaning\meaning#1\tikz@math@getmeaning@stop}%
+
+\def\tikz@math@@getmeaning#1#2#3#4#5\tikz@math@getmeaning@stop{%
+ \if#1u% undefined
+ \let\tikz@math@meaning=\tikz@math@meaning@macro%
+ \else%
+ \if#1m%
+ \let\tikz@math@meaning=\tikz@math@meaning@macro%
+ \else%
+ \if#2d%
+ \let\tikz@math@meaning=\tikz@math@meaning@dimen%
+ \else%
+ \if#2c%
+ \let\tikz@math@meaning=\tikz@math@meaning@count%
+ \else%
+ \if#3k% A skip. Treat like a dimen.
+ \let\tikz@math@meaning=\tikz@math@meaning@dimen%
+ \else%
+ \let\tikz@math@meaning=\tikz@math@meaning@null%
+ \fi%
+ \fi%
+ \fi%
+ \fi%
+ \fi%
+}%
+
+\def\tikz@math@firstoftwo#1#2{#1}%
+\def\tikz@math@secondoftwo#1#2{#2}%
+
+
+\def\tikz@math@getvarstring#1{%
+ \begingroup%
+ \escapechar=-1\relax%
+ \expandafter\tikz@math@@getvarstring\string#1\tikz@math}%
+
+\def\tikz@math@@getvarstring#1\tikz@math#2{%
+ \endgroup%
+ \def#2{#1}%
+}%
+
+\long\def\tikz@math@collecttosemicolon@other#1#2;{%
+ \def\tikz@math@collected{#2}#1}%
+\def\tikz@math@semicolon@other{;}%
+
+{\catcode`\;=13
+\long\gdef\tikz@math@collecttosemicolon@active#1#2;{%
+ \def\tikz@math@collected{#2}#1}%
+\gdef\tikz@math@semicolon@active{;}%
+}%
+
+
+\def\tikz@math@setvartype#1#2{%
+ \expandafter\let\csname tikz@math@var@vartype@\string#1\endcsname=#2%
+}%
+
+
+\def\tikz@math@getvartype#1#2{%
+ \def\tikz@math@marshal{\let#1=}%
+ \expandafter\tikz@math@marshal\csname
+ tikz@math@var@vartype@\string#2\endcsname%
+}%
+
+
+
+\def\tikz@math@ifvarcoordinate#1{%
+ \expandafter\ifx\csname
+ tikz@math@var@vartype@\string#1\endcsname\tikz@math@keyword@coordinate%
+ \let\tikz@math@next=\tikz@math@firstoftwo%
+ \else%
+ \let\tikz@math@next=\tikz@math@secondoftwo%
+ \fi%
+ \tikz@math@next%
+}%
+
+\def\tikz@math@ifvarinteger#1{%
+ \expandafter\ifx\csname
+ tikz@math@var@vartype@\string#1\endcsname\tikz@math@keyword@integer%
+ \let\tikz@math@next=\tikz@math@firstoftwo%
+ \else%
+ \let\tikz@math@next=\tikz@math@secondoftwo%
+ \fi%
+ \tikz@math@next%
+}%
+
+
+\def\tikz@math@setvarindexed#1{%
+ \expandafter\let\csname
+ tikz@math@var@subtype@\string#1\endcsname=\tikz@math@subtype@indexed%
+}%
+
+\def\tikz@math@clearvarindexed#1{%
+ \expandafter\let\csname tikz@math@var@subtype@\string#1\endcsname=\relax%
+}%
+
+\def\tikz@math@ifvarindexed#1{%
+ \expandafter\ifx\csname tikz@math@var@subtype@\string#1\endcsname\relax%
+ \let\tikz@math@next=\tikz@math@secondoftwo%
+ \else%
+ \let\tikz@math@next=\tikz@math@firstoftwo%
+ \fi%
+ \tikz@math@next%
+}%
+
+\def\tikz@math@stop{@}%
+
+\let\tikz@math@parse@hook@before=\pgfutil@empty
+\let\tikz@math@parse@hook@after=\pgfutil@empty
+
+\def\tikz@math{%
+ \ifnum\catcode`\;=13\relax%
+ \let\tikz@math@semicolon=\tikz@math@semicolon@active%
+ \let\tikz@math@collecttosemicolon=\tikz@math@collecttosemicolon@active%
+ \else%
+ \let\tikz@math@semicolon=\tikz@math@semicolon@other%
+ \let\tikz@math@collecttosemicolon=\tikz@math@collecttosemicolon@other%
+ \fi%
+ \tikz@math@parse@hook@before%
+ \tikz@@math}%
+
+
+
+
+\long\def\tikz@@math#1{%
+ \def\tikz@math@marshal{\tikz@math@parse#1}%
+ \expandafter\expandafter\expandafter\tikz@math@marshal\expandafter\tikz@math@stop\tikz@math@semicolon}%
+
+\def\tikz@math@parse{\pgfutil@ifnextchar\bgroup\tikz@math@@parse@bgroup\tikz@math@@parse@nobgroup}%
+
+
+\def\tikz@math@@parse@bgroup{%
+ \tikz@math@collecttosemicolon{%
+ % MW: Don't know how reliable this test is.
+ \ifx\pgf@selectfontorig\tikz@math@undefined%
+ \begingroup\tikz@math@collected\endgroup%
+ \else%
+ \begingroup\csname nullfont\endcsname\tikz@math@collected\endgroup%
+ \fi\tikz@math@parse}}%
+
+
+
+\def\tikz@math@@parse@nobgroup{\tikz@math@collecttosemicolon{\tikz@math@@parse@@nobgroup}}%
+
+\def\tikz@math@@parse@@nobgroup{%
+ \let\tikz@math@tmp=\tikz@math@collected%
+ \ifx\tikz@math@tmp\tikz@math@stop%
+ \def\tikz@math@next{\expandafter\tikz@math@parse@finish\tikz@math@semicolon}%
+ \else%
+ \def\tikz@math@next{\expandafter\expandafter\expandafter\tikz@math@parse@keyword@check\expandafter\tikz@math@tmp\tikz@math@semicolon}%
+ \fi%
+ \tikz@math@next%
+}%
+
+\def\tikz@math@parse@finish{%
+ \tikz@math@collecttosemicolon{\tikz@math@parse@hook@after}%
+}%
+
+
+
+\newif\iftikz@math@let
+\def\tikz@math@parse@keyword@check#1{%
+ \tikz@math@letfalse%
+ \tikz@math@getmeaning{#1}%
+ \ifx\tikz@math@meaning\tikz@math@meaning@null%
+ \let\tikz@math@next=\tikz@math@parse@keyword%
+ \else%
+ \let\tikz@math@next=\tikz@math@parse@nokeyword%
+ \fi%
+ \tikz@math@next#1}%
+
+
+\def\tikz@math@parse@keyword{%
+ \let\tikz@math@parsed@keyword=\pgfutil@empty%
+ \futurelet\tikz@math@parse@token\tikz@math@@parse@keyword}%
+
+\def\tikz@math@@parse@keyword{%
+ \ifx\tikz@math@parse@token\pgfutil@sptoken%
+ \let\tikz@math@next=\tikz@math@@@parse@keyword%
+ \else%
+ \ifx\tikz@math@parse@token(%
+ \let\tikz@math@next=\tikz@math@@@parse@keyword%
+ \else%
+ \ifx\tikz@math@parse@token\bgroup%
+ \let\tikz@math@next=\tikz@math@@@parse@keyword%
+ \else%
+ \let\tikz@math@next=\tikz@math@@@@parse@keyword%
+ \fi%
+ \fi%
+ \fi%
+ \tikz@math@next}%
+
+\def\tikz@math@error#1{\pgfutil@packageerror{tikz}{tikz math library: #1}{}}%
+
+\def\tikz@math@@@parse@keyword{%
+ \expandafter\ifx\csname tikz@math@process@keyword@\tikz@math@parsed@keyword\endcsname\relax%
+ \expandafter\ifx\csname pgfmath\tikz@math@parsed@keyword\endcsname\relax%
+ \tikz@math@error{Unknown function or keyword '\tikz@math@parsed@keyword'}%
+ \else%
+ \def\tikz@math@next{\tikz@math@collecttosemicolon{\tikz@math@function@noassign}}%
+ \fi%
+ \else%
+ \expandafter\def\expandafter\tikz@math@next\expandafter{\csname tikz@math@process@keyword@\tikz@math@parsed@keyword\endcsname}%
+ \fi%
+ \tikz@math@next}%
+
+\def\tikz@math@@@@parse@keyword#1{%
+ \edef\tikz@math@parsed@keyword{\tikz@math@parsed@keyword#1}%
+ \futurelet\tikz@math@parse@token\tikz@math@@parse@keyword%
+}%
+
+\def\tikz@math@function@noassign{%
+ \pgfmathparse{\tikz@math@parsed@keyword\tikz@math@collected}%
+ \tikz@math@parse%
+}%
+
+
+
+
+\def\tikz@math@process@keyword@count{\tikz@math@collecttosemicolon{\tikz@math@process@keyword@@count}}%
+\def\tikz@math@process@keyword@@count{%
+\def\tikz@math@assign@register{\csname newcount\endcsname}%
+\expandafter\tikz@math@gobblespaces\expandafter\tikz@math@process@registers\tikz@math@collected,@,}%
+
+\def\tikz@math@process@keyword@length{\tikz@math@collecttosemicolon{\tikz@math@process@keyword@@length}}%
+\def\tikz@math@process@keyword@@length{%
+\def\tikz@math@assign@register{\csname newdimen\endcsname}%
+\expandafter\tikz@math@gobblespaces\expandafter\tikz@math@process@registers\tikz@math@collected,@,}%
+
+
+\def\tikz@math@process@registers#1#2,{%
+ \def\tikz@math@var{#1}%
+ \ifx\tikz@math@var\tikz@math@stop%
+ \let\tikz@math@next=\tikz@math@parse%
+ \else%
+ \tikz@math@assign@register#1\relax%
+ \let\tikz@math@next=\tikz@math@process@registers%
+ \fi%
+ \tikz@math@gobblespaces\tikz@math@next%
+}%
+
+
+\def\tikz@math@process@keyword@if#1then{%
+ \def\tikz@math@if@condition{#1}%
+ \tikz@math@gobblespaces\tikz@math@parse@if@iftrue%
+}%
+\def\tikz@math@parse@if@iftrue#1{%
+ \def\tikz@math@if@trueaction{#1}%
+ \pgfutil@ifnextchar e{\tikz@math@parse@else}{\tikz@math@if@doif}}%
+
+\def\tikz@math@parse@else else{\tikz@math@gobblespaces\tikz@math@if@doifelse}%
+
+\def\tikz@math@if@doif{\tikz@math@collecttosemicolon{\tikz@math@if@@doif}}%
+
+\def\tikz@math@if@@doif{%
+ \pgfmathparse{\tikz@math@if@condition}%
+ \ifpgfmathfloatparseactive%
+ \pgfmathfloattofixed{\pgfmathresult}%
+ \fi%
+ \ifdim\pgfmathresult pt=0pt\relax%
+ \else%
+ \expandafter\tikz@math\expandafter{\tikz@math@if@trueaction}%
+ \fi%
+ \tikz@math@parse%
+}%
+\def\tikz@math@if@doifelse{\tikz@math@collecttosemicolon{\tikz@math@if@@doifelse}}%
+\def\tikz@math@if@@doifelse{%
+ \pgfmathparse{\tikz@math@if@condition}%
+ \ifpgfmathfloatparseactive%
+ \pgfmathfloattofixed{\pgfmathresult}%
+ \fi%
+ \let\tikz@math@if@falseaction=\tikz@math@collected%
+ \ifdim\pgfmathresult pt=0pt\relax%
+ \expandafter\tikz@math\expandafter{\tikz@math@if@falseaction}%
+ \else%
+ \expandafter\tikz@math\expandafter{\tikz@math@if@trueaction}%
+ \fi%
+ \tikz@math@parse%
+}%
+\def\tikz@math@process@keyword@let{%
+ \tikz@math@lettrue%
+ \tikz@math@gobblespaces\tikz@math@parse@nokeyword%
+}%
+
+
+\def\tikz@math@parse@nokeyword#1{%
+ \def\tikz@math@var{#1}%
+ \tikz@math@getvarstring{#1}\tikz@math@varstring%
+ \let\tikz@math@vartype=\pgfutil@empty%
+ \ifx\tikz@math@var\tikz@math@stop%
+ \let\tikz@math@next=\tikz@math@parse@finish%
+ \else%
+ \ifx\tikz@math@semicolon\tikz@math@var%
+ \let\tikz@math@next=\tikz@math@parse%
+ \else%
+ \let\tikz@math@next=\tikz@math@parse@index@check%
+ \fi%
+ \fi%
+ \tikz@math@next}%
+
+\def\tikz@math@parse@index@check{%
+ \pgfutil@ifnextchar={\tikz@math@parse@noindex}{\tikz@math@parse@index}}%
+
+\def\tikz@math@parse@noindex{%
+ \expandafter\tikz@math@clearvarindexed\tikz@math@var%
+ \let\tikz@math@current@index=\pgfutil@empty%
+ \tikz@math@parse@afterindex%
+}%
+
+\def\tikz@math@parse@index#1{%
+ \def\tikz@math@tmp{#1}%
+ \expandafter\tikz@math@setvarindexed\tikz@math@var% {}
+ \edef\tikz@math@current@index{#1}%
+ \tikz@math@parse@afterindex%
+}%
+\def\tikz@math@parse@afterindex#1={\tikz@math@gobblespaces\tikz@math@parse@assignment}%
+
+\def\tikz@math@parse@assignment{\tikz@math@collecttosemicolon{\tikz@math@parse@@assignment}}%
+\def\tikz@math@parse@@assignment{%
+ \expandafter\expandafter\expandafter\tikz@math@doassignment\expandafter\expandafter\expandafter%
+ {\expandafter\tikz@math@var\expandafter}\expandafter{\tikz@math@collected}%
+ \tikz@math@parse%
+}%
+
+\def\tikz@math@dollar@char{$}%
+\def\tikz@math@dollar@char{$}% For annoying syntax highlighters
+
+\def\tikz@math@doassignment#1#2{%
+ \tikz@math@ifvarcoordinate{#1}{%
+ \def\tikz@math@var{#1}% Unfortunately, we must do this again.
+ \tikz@math@getvarstring{#1}\tikz@math@varstring% And this
+ \expandafter\pgfutil@in@\tikz@math@dollar@char{#2}%
+ \edef\tikz@math@expression{#2}%
+ \ifpgfutil@in@%
+ \expandafter\tikz@scan@one@point\expandafter\tikz@math@assign@coordinate\tikz@math@expression%
+ \else%
+ \expandafter\ifx\csname tikz@library@calc@loaded\endcsname\relax%
+ \expandafter\tikz@scan@one@point\expandafter\tikz@math@assign@coordinate\tikz@math@expression%
+ \else%
+ \expandafter\tikz@scan@one@point\expandafter\tikz@math@assign@coordinate\expandafter%
+ (\expandafter$\tikz@math@expression$)%
+ \fi%
+ \fi%
+ }{%
+ \iftikz@math@let% Not really a let
+ \ifx\tikz@math@current@index\pgfutil@empty%
+ \edef#1{#2}%
+ \else%
+ \edef\tikz@math@tmp{#2}%
+ \expandafter\expandafter\expandafter\tikz@math@assign@index\expandafter\expandafter\expandafter%
+ {\expandafter\tikz@math@varstring\expandafter}\expandafter{\tikz@math@tmp}%
+ \fi%
+ \tikz@math@letfalse%
+ \else%
+ \ifx\tikz@math@current@index\pgfutil@empty%
+ \tikz@math@getmeaning{#1}%
+ \ifx\tikz@math@meaning\tikz@math@meaning@dimen%
+ \pgfmathsetlength{#1}{#2}%
+ \let\tikz@math@last@assigned@value=\pgfmathresult%
+ \else%
+ \ifx\tikz@math@meaning\tikz@math@meaning@count%
+ \pgfmathsetcount{#1}{#2}%
+ \let\tikz@math@last@assigned@value=\pgfmathresult%
+ \else%
+ \tikz@math@ifvarinteger{#1}{\pgfmathparse{int(#2)}}{\pgfmathparse{#2}}%
+ \let\tikz@math@last@assigned@value=\pgfmathresult%
+ \let#1=\pgfmathresult%
+ \fi%
+ \fi%
+ \else%
+ \tikz@math@ifvarinteger{#1}{\pgfmathparse{int(#2)}}{\pgfmathparse{#2}}%
+ \expandafter\tikz@math@assign@index\expandafter{\tikz@math@varstring}\pgfmathresult%
+ \let\tikz@math@last@assigned@value=\pgfmathresult%
+ \fi%
+ \fi%
+ }%
+}%
+
+
+
+\def\tikz@math@assign@index#1#2{%
+ \expandafter\def\csname#1\endcsname##1{\csname
+ tikz@math@var@indexed@#1@##1\endcsname}%
+ \expandafter\edef\csname
+ tikz@math@var@indexed@#1@\tikz@math@current@index\endcsname{#2}\relax%
+}%
+
+
+
+\def\tikz@math@assign@coordinate#1{%
+ \pgf@process{#1}%
+ \ifx\tikz@math@current@index\pgfutil@empty%
+ \expandafter\edef\csname\tikz@math@varstring\endcsname{\the\pgf@x,\the\pgf@y}%
+ \expandafter\edef\csname\tikz@math@varstring x\endcsname{\the\pgf@x}%
+ \expandafter\edef\csname\tikz@math@varstring y\endcsname{\the\pgf@y}%
+ \else%
+ \expandafter\tikz@math@assign@index\expandafter{\tikz@math@varstring}{\the\pgf@x,\the\pgf@y}%
+ \expandafter\tikz@math@assign@index\expandafter{\tikz@math@varstring x}{\the\pgf@x}%
+ \expandafter\tikz@math@assign@index\expandafter{\tikz@math@varstring y}{\the\pgf@y}%
+ \fi%
+}%
+
+
+
+\def\tikz@math@keyword@coordinate{coordinate}%
+\def\tikz@math@process@keyword@coordinate{%
+ \let\tikz@math@vartype=\tikz@math@keyword@coordinate%
+ \tikz@math@gobblespaces\tikz@math@process@vartypes%
+}%
+
+\def\tikz@math@keyword@integer{integer}%
+\def\tikz@math@process@keyword@integer{%
+ \let\tikz@math@vartype=\tikz@math@keyword@integer%
+ \tikz@math@gobblespaces\tikz@math@process@vartypes%
+}%
+\def\tikz@math@process@keyword@int{%
+ \tikz@math@process@keyword@integer%
+}%
+
+\def\tikz@math@keyword@real{real}%
+\def\tikz@math@process@keyword@real{%
+ \let\tikz@math@vartype=\tikz@math@keyword@real%
+ \tikz@math@gobblespaces\tikz@math@process@vartypes%
+}%
+
+\def\tikz@math@process@keyword@point{\tikz@math@process@keyword@coordinate}%
+
+
+\def\tikz@math@process@vartypes{\tikz@math@collecttosemicolon{\tikz@math@process@@vartypes}}%
+
+\def\tikz@math@process@@vartypes{%
+ \expandafter\tikz@math@@process@vartypes\tikz@math@collected,@,\tikz@math%
+}%
+
+\def\tikz@math@@process@vartypes#1#2,{%
+ \def\tikz@math@var{#1}%
+ \tikz@math@getvarstring{#1}\tikz@math@varstring%
+ \ifx\tikz@math@var\tikz@math@stop%
+ \let\tikz@math@next=\tikz@math@@@process@vartypes%
+ \else%
+ \expandafter\tikz@math@setvartype\tikz@math@var\tikz@math@vartype%
+ \def\tikz@math@next{\tikz@math@gobblespaces\tikz@math@@process@vartypes}%
+ \fi%
+ \tikz@math@next%
+}%
+
+\def\tikz@math@process@keyword@print{\tikz@math@collecttosemicolon{\tikz@math@process@keyword@@print}}%
+\def\tikz@math@process@keyword@@print{%
+ \begingroup\tikz@math@collected\endgroup\tikz@math@parse%
+}%
+
+\def\tikz@math@@@process@vartypes#1\tikz@math{%
+ \tikz@math@parse%
+}%
+
+\newcount\tikz@math@for@depth
+
+\def\tikz@math@for@namedef#1{\expandafter\def\csname tikz@math@for@def@#1@\the\tikz@math@for@depth\endcsname}%
+\def\tikz@math@for@nameedef#1{\expandafter\edef\csname tikz@math@for@def@#1@\the\tikz@math@for@depth\endcsname}%
+\def\tikz@math@for@namelet#1{\expandafter\let\csname tikz@math@for@def@#1@\the\tikz@math@for@depth\endcsname}%
+
+\def\tikz@math@for@namegetvalue#1#2{%
+ \def\tikz@math@marshal{\let#2=}%
+ \expandafter\tikz@math@marshal\csname tikz@math@for@def@#1@\the\tikz@math@for@depth\endcsname}%
+
+\def\tikz@math@process@keyword@for{%
+ \tikz@math@for%
+}%
+
+\def\tikz@math@for@external{%
+ \ifnum\catcode`\;=13\relax%
+ \let\tikz@math@semicolon=\tikz@math@semicolon@active%
+ \let\tikz@math@collecttosemicolon=\tikz@math@collecttosemicolon@active%
+ \else%
+ \let\tikz@math@semicolon=\tikz@math@semicolon@other%
+ \let\tikz@math@collecttosemicolon=\tikz@math@collecttosemicolon@other%
+ \fi
+ \advance\tikz@math@for@depth by1\relax%
+ \tikz@math@for@namedef{execute}{\tikz@math@for@external@execute}%
+ \tikz@math@for@namedef{finished}{\relax}%
+ \tikz@math@gobblespaces\tikz@math@for@parsevar}%
+
+\def\tikz@math@for@external@execute#1{#1}%
+
+\def\tikz@math@for{%
+ \advance\tikz@math@for@depth by1\relax%
+ \tikz@math@for@namedef{execute}{\tikz@math}%
+ \tikz@math@for@namedef{finished}{\tikz@math@parse}%
+ \tikz@math@gobblespaces\tikz@math@for@parsevar}%
+
+
+\def\tikz@math@for@parsevar#1{%
+ \tikz@math@for@namedef{var}{#1}%
+ \tikz@math@for@parsein}%
+
+\def\tikz@math@getindex#1{%
+ \tikz@math@@getindex#1\tikz@math@getindex\tikz@math@@getindex%
+}%
+
+\def\tikz@math@@getindex#1#2\tikz@math@@getindex{#1}%
+
+\def\tikz@math@for@parsein#1in{%
+ \def\tikz@math@tmp{#1}%
+ \ifx\tikz@math@tmp\pgfutil@empty%
+ \tikz@math@for@namedef{index}{}%
+ \else%
+ \tikz@math@for@nameedef{index}{\tikz@math@getindex{#1}}%
+ \fi%
+ \tikz@math@gobblespaces\tikz@math@for@parselist%
+}%
+
+
+\long\def\tikz@math@for@parselist#1{%
+ \edef\tikz@math@for@list{#1}%
+ \tikz@math@gobblespaces{%
+ \tikz@math@collecttosemicolon{\tikz@math@for@parseaction}}}%
+
+\def\tikz@math@for@parseaction{%
+ \tikz@math@for@namedef{prevvalue}{}%
+ \tikz@math@for@namedef{prevprevvalue}{}%
+ \tikz@math@for@namelet{action}=\tikz@math@collected%
+ \expandafter\tikz@math@for@scan\tikz@math@for@list,\tikz@math,\tikz@@math%
+}%
+
+\def\tikz@math@token{\tikz@math}%
+
+
+\def\tikz@math@for@scan#1,{%
+ \def\tikz@math@for@value{#1}%
+ \ifx\tikz@math@for@value\tikz@math@token%
+ \let\tikz@math@next=\tikz@math@for@scan@end%
+ \else%
+ \ifx\tikz@math@for@value\pgfutil@empty%
+ \let\tikz@math@next=\tikz@math@for@scan@end%
+ \else%
+ \pgfutil@in@{...}{#1}%
+ \ifpgfutil@in@%
+ \let\tikz@math@next=\tikz@math@for@scan@dots%
+ \else%
+ \tikz@math@for@namegetvalue{var}{\tikz@math@var}%
+ \tikz@math@for@namegetvalue{index}{\tikz@math@current@index}%
+ \tikz@math@for@namegetvalue{action}{\tikz@math@action}%
+ \expandafter\tikz@math@getvarstring\expandafter{\tikz@math@var}\tikz@math@varstring%
+ \expandafter\tikz@math@doassignment\expandafter{\tikz@math@var}{#1}%
+ \tikz@math@for@namelet{value}=\tikz@math@last@assigned@value%
+ \tikz@math@for@namegetvalue{execute}{\tikz@math@execute}%
+ \expandafter\tikz@math@execute\expandafter{\tikz@math@action}%
+ \tikz@math@for@namegetvalue{prevvalue}{\tikz@math@prevvalue}%
+ \tikz@math@for@namelet{prevprevvalue}=\tikz@math@prevvalue%
+ \tikz@math@for@namegetvalue{value}{\tikz@math@value}%
+ \tikz@math@for@namelet{prevvalue}=\tikz@math@value%
+ \let\tikz@math@next=\tikz@math@for@scan%
+ \fi%
+ \fi%
+ \fi%
+ \tikz@math@next%
+}%
+
+\newdimen\tikz@math@dimen
+
+\def\tikz@math@for@scan@dots#1,{%
+ \pgfmathparse{#1}\let\tikz@math@value=\pgfmathresult%
+ \tikz@math@for@nameedef{endvalue}{\tikz@math@value}%
+ \tikz@math@for@namegetvalue{prevvalue}{\tikz@math@prevvalue}%
+ \tikz@math@for@namegetvalue{prevprevvalue}{\tikz@math@prevprevvalue}%
+ \tikz@math@dimen=\tikz@math@prevvalue pt\relax%
+ \ifx\tikz@math@prevprevvalue\pgfutil@empty%
+ \ifdim\tikz@math@prevvalue pt<\tikz@math@value pt\relax%%
+ \def\tikz@math@step{1pt}%
+ \else%
+ \def\tikz@math@step{-1pt}%
+ \fi%
+ \else%
+ \tikz@math@dimen=\tikz@math@prevvalue pt\relax%
+ \advance\tikz@math@dimen by-\tikz@math@prevprevvalue pt\relax%
+ \edef\tikz@math@step{\the\tikz@math@dimen}%
+ \fi%
+ \ifdim\tikz@math@step<0pt\relax%
+ \tikz@math@for@namedef{comparitor}{<}%
+ \else%
+ \tikz@math@for@namedef{comparitor}{>}%
+ \fi%
+ \tikz@math@for@nameedef{step}{\tikz@math@step}%
+ \tikz@math@for@doloop%
+}%
+
+\def\tikz@math@for@doloop{%
+ \tikz@math@for@namegetvalue{prevvalue}{\tikz@math@prevvalue}%
+ \tikz@math@for@namegetvalue{step}{\tikz@math@step}%
+ \tikz@math@for@namegetvalue{comparitor}{\tikz@math@comparitor}%
+ \tikz@math@for@namegetvalue{endvalue}{\tikz@math@endvalue}%
+ \tikz@math@dimen=\tikz@math@prevvalue pt\relax%
+ \advance\tikz@math@dimen by\tikz@math@step\relax%
+ \ifdim\tikz@math@dimen\tikz@math@comparitor\tikz@math@endvalue pt\relax%
+ \let\tikz@math@next=\tikz@math@for@endloop%
+ \else%
+ \tikz@math@for@nameedef{value}{\pgfmath@tonumber{\tikz@math@dimen}}%
+ \tikz@math@for@namegetvalue{var}{\tikz@math@var}%
+ \expandafter\tikz@math@getvarstring\expandafter{\tikz@math@var}\tikz@math@varstring%
+ \tikz@math@for@namegetvalue{index}{\tikz@math@current@index}%
+ \tikz@math@for@namegetvalue{action}{\tikz@math@action}%
+ \tikz@math@for@namegetvalue{value}{\tikz@math@value}%
+ \expandafter\expandafter\expandafter\tikz@math@doassignment\expandafter\expandafter\expandafter%
+ {\expandafter\tikz@math@var\expandafter}\expandafter{\tikz@math@value}%
+ \tikz@math@for@namegetvalue{execute}{\tikz@math@execute}%
+ \expandafter\tikz@math@execute\expandafter{\tikz@math@action}%
+ \tikz@math@for@namegetvalue{prevvalue}{\tikz@math@prevvalue}%
+ \tikz@math@for@namelet{prevprevvalue}=\tikz@math@prevvalue%
+ \tikz@math@for@namegetvalue{value}{\tikz@math@value}%
+ \tikz@math@for@namelet{prevvalue}=\tikz@math@value%
+ \let\tikz@math@next=\tikz@math@for@doloop%
+ \fi%
+ \tikz@math@next%
+}%
+
+\def\tikz@math@for@endloop{%
+\tikz@math@for@scan}%
+
+
+
+
+\def\tikz@math@for@scan@end#1\tikz@@math{%
+\tikz@math@for@namegetvalue{finished}{\tikz@math@next}%
+\advance\tikz@math@for@depth by-1\relax%
+\tikz@math@next}%
+
+
+
+
+
+\def\tikz@math@process@keyword@return{%
+ \tikz@math@collecttosemicolon{\pgfmathparse{\tikz@math@collected}\tikz@math@parse}}%
+
+\def\tikz@math@process@keyword@function{\tikz@math@collecttosemicolon{\tikz@math@process@keyword@@function}}%
+\def\tikz@math@process@keyword@@function{%
+ \let\tikz@math@function@name=\pgfutil@empty%
+ \let\tikz@math@function@arguments=\pgfutil@empty%
+ \let\tikz@math@function@body=\pgfutil@empty%
+ \expandafter\expandafter\expandafter\tikz@math@@declarefunction\expandafter\tikz@math@collected\tikz@math@semicolon%
+}%
+
+\def\tikz@math@@declarefunction{%
+ \pgfutil@ifnextchar\bgroup\tikz@math@@@collectbody\tikz@math@@@declarefunction}%
+
+
+\def\tikz@math@@@declarefunction#1{%
+ \if#1(%)
+ \let\tikz@math@next=\tikz@math@@@collectarguments%
+ \else%
+ \expandafter\def\expandafter\tikz@math@function@name\expandafter{\tikz@math@function@name#1}%
+ \let\tikz@math@next=\tikz@math@@declarefunction%
+ \fi%
+ \tikz@math@next%
+}%
+\def\tikz@math@@@collectarguments#1){%
+ \def\tikz@math@function@arguments{#1}%
+ \tikz@math@@declarefunction%
+}%
+
+\newtoks\tikz@math@toks
+\tikz@math@toks={#}%
+\edef\tikz@math@char@hash{\the\tikz@math@toks}%
+\tikz@math@toks={}%
+
+\def\tikz@math@@@collectbody{\tikz@math@collecttosemicolon{\tikz@math@@@@collectbody}}%
+
+\def\tikz@math@@@@collectbody{%
+ \tikz@math@toks={}%
+ \c@pgf@counta=0\relax%
+ \ifx\tikz@math@function@arguments\pgfutil@empty%
+ \else%
+ \expandafter\tikz@math@createargumentlist\tikz@math@function@arguments,,%
+ \expandafter\tikz@math@addto@toks\expandafter{\tikz@math@collected}%
+ \fi%
+ \edef\tikz@math@local@temp{%
+ \noexpand\pgfmathdeclarefunction{\tikz@math@function@name}{\the\c@pgf@counta}%
+ {\noexpand\def\noexpand\return{0}\noexpand\tikz@math{\the\tikz@math@toks}}%
+ }%
+ \tikz@math@local@temp
+ \tikz@math@parse%
+}%
+
+\def\tikz@math@addto@toks#1{%
+ \expandafter\tikz@math@toks\expandafter{\the\tikz@math@toks#1}}%
+
+\def\tikz@math@createargumentlist{%
+ \pgfutil@ifnextchar
+ x\tikz@math@@createargumentlist\tikz@math@@createargumentlist}%
+
+\def\tikz@math@comma{,}%
+\def\tikz@math@@createargumentlist#1,{%
+ \def\tikz@math@tmp{#1}%
+ \ifx\tikz@math@tmp\pgfutil@empty%
+ \let\tikz@math@next=\relax%
+ \else%
+ \advance\c@pgf@counta by1\relax%
+ \tikz@math@addto@toks{#1=}%
+ \expandafter\expandafter\expandafter\tikz@math@addto@toks\expandafter\expandafter\expandafter%
+ {\expandafter\tikz@math@char@hash\the\c@pgf@counta;}%
+ \let\tikz@math@next=\tikz@math@createargumentlist%
+ \fi%
+ \tikz@math@next%
+}%
+
+
+
+\let\tikzmath=\tikz@math
+\tikzset{evaluate/.code={\tikz@math{#1}}}%
+\let\tikzmathfor=\tikz@math@for@external
+
+
+\catcode`\@=\tikz@math@at@catcode\relax
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarymatrix.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarymatrix.code.tex
new file mode 100644
index 0000000000..5118189376
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarymatrix.code.tex
@@ -0,0 +1,144 @@
+% Copyright 2018 by Till Tantau
+%
+% 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{tikzlibrarymatrix.code.tex}
+
+
+% A matrix of nodes contains a node in each cell.
+
+\tikzset{matrix of nodes/.style={%
+ matrix,%
+ cells={anchor=base},%
+ execute at begin cell=\tikz@lib@matrix@start@cell,%
+ execute at end cell=\tikz@lib@matrix@end@cell,%
+ execute at empty cell=\tikz@lib@matrix@empty@cell,
+ execute at begin matrix=\iftikz@handle@active@code\tikz@orig@shorthands\fi,%
+}}%
+
+\def\tikz@lib@matrix@empty@cell{\iftikz@lib@matrix@empty\node[name=\tikzmatrixname-\the\pgfmatrixcurrentrow-\the\pgfmatrixcurrentcolumn]{};\fi}%
+
+\newif\iftikz@lib@matrix@plain
+
+\def\tikz@lib@matrix@start@cell{%
+ \pgfutil@ifnextchar|{\tikz@lib@matrix@with@options}{\tikz@lib@matrix@normal@start@cell}}%
+
+\def\tikz@lib@matrix@with@options|#1|{\tikz@lib@matrix@plainfalse\node%
+ [name=\tikzmatrixname-\the\pgfmatrixcurrentrow-\the\pgfmatrixcurrentcolumn]#1\bgroup\tikz@lib@matrix@startup}%
+
+
+\def\tikz@lib@matrix@normal@start@cell{\pgfutil@ifnextchar\let{\tikz@lib@matrix@check}{\tikz@lib@matrix@plainfalse\node
+ [name=\tikzmatrixname-\the\pgfmatrixcurrentrow-\the\pgfmatrixcurrentcolumn]\bgroup\tikz@lib@matrix@startup}}%
+
+\def\tikz@lib@matrix@check#1{% evil hackery to find out about start of path
+ \pgfutil@ifnextchar\tikz@signal@path{\tikz@lib@matrix@plaintrue\let}{\tikz@lib@matrix@plainfalse\node
+ [name=\tikzmatrixname-\the\pgfmatrixcurrentrow-\the\pgfmatrixcurrentcolumn]\bgroup\tikz@lib@matrix@startup\let}%
+}%
+
+\def\tikz@lib@matrix@end@cell{%
+ \iftikz@lib@matrix@plain%
+ \else%
+ \expandafter\egroup\expandafter;%
+ \fi%
+}%
+
+\def\tikz@lib@matrix@startup{%
+ \pgfutil@ifnextchar\bgroup{%
+ % Save meaning of \\:
+ \let\tikz@lib@matrix@saved@eol=\\%
+ % Now smuggle meaning inside following group.
+ \let\\=\pgfmatrixendrow%
+ \afterassignment\tikz@lib@matrix@smuggle%
+ \let\tikz@next}
+ {\let\\=\pgfmatrixendrow}%
+}%
+\def\tikz@lib@matrix@smuggle{%
+ \bgroup%
+ \let\\=\tikz@lib@matrix@saved@eol%
+}%
+
+
+% Fill empty nodes in a matrix of nodes
+
+\newif\iftikz@lib@matrix@empty
+
+\tikzoption{nodes in empty cells}[true]{\csname tikz@lib@matrix@empty#1\endcsname}%
+
+
+% Same as a matrix of nodes, but switch on math mode in each cell
+\tikzset{matrix of math nodes/.style={%
+ matrix of nodes,
+ nodes={%
+ execute at begin node=$,%
+ execute at end node=$%
+ }%
+}}%
+
+
+
+% Provide a delimiter
+
+\tikzoption{left delimiter}{\tikzset{append after command={\tikz@delimiter%
+ {south east}%
+ {south west}%
+ {every delimiter,every left delimiter}%
+ {south}%
+ {north}%
+ {#1}%
+ {.}%
+ {\pgf@y}}}}%
+
+\tikzoption{right delimiter}{\tikzset{append after command={\tikz@delimiter%
+ {south west}%
+ {south east}%
+ {every delimiter,every right delimiter}%
+ {south}%
+ {north}%
+ {.}%
+ {#1}%
+ {\pgf@y}}}}%
+
+\tikzoption{above delimiter}{\tikzset{append after command={\tikz@delimiter%
+ {south east}%
+ {north west}%
+ {every delimiter,every above delimiter,rotate=-90}%
+ {west}%
+ {east}%
+ {#1}%
+ {.}%
+ {\pgf@x}}}}%
+
+\tikzoption{below delimiter}{\tikzset{append after command={\tikz@delimiter%
+ {south west}%
+ {south west}%
+ {every delimiter,every below delimiter,rotate=-90}%
+ {west}%
+ {east}%
+ {.}%
+ {#1}%
+ {\pgf@x}}}}%
+
+\def\tikz@delimiter#1#2#3#4#5#6#7#8{%
+ \bgroup
+ \pgfextra{\let\tikz@save@last@fig@name=\tikz@last@fig@name\tikz@node@is@a@labelfalse}%
+ node[outer sep=0pt,inner sep=0pt,draw=none,fill=none,anchor=#1,at=(\tikz@last@fig@name.#2),#3]
+ {%
+ {\nullfont\pgf@process{\pgfpointdiff{\pgfpointanchor{\tikz@last@fig@name}{#4}}{\pgfpointanchor{\tikz@last@fig@name}{#5}}}}%
+ $\left#6\vcenter{\hrule height .5#8 depth .5#8 width0pt}\right#7$%
+ }
+ \pgfextra{\global\let\tikz@last@fig@name=\tikz@save@last@fig@name}%
+ \egroup%
+}%
+
+\tikzset{every delimiter/.style={}}%
+\tikzset{every left delimiter/.style={}}%
+\tikzset{every right delimiter/.style={}}%
+\tikzset{every above delimiter/.style={}}%
+\tikzset{every below delimiter/.style={}}%
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarymindmap.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarymindmap.code.tex
new file mode 100644
index 0000000000..ff5959c4f3
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarymindmap.code.tex
@@ -0,0 +1,417 @@
+% Copyright 2018 by Till Tantau
+%
+% 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{tikzlibrarymindmap.code.tex}
+
+
+\usetikzlibrary{trees,decorations}%
+
+
+% A decoration for connecting circle nodes
+%
+% Parameters: start radius, end radius, amplitude, angle
+
+\pgfdeclaredecoration{circle connection bar}{initial}
+{%
+ \state{initial}[width=0pt,next state=bar]
+ {
+ {
+ \pgftransformxshift{-\pgfkeysvalueof{/pgf/decoration/start radius}}%
+ \pgfpathmoveto{\pgfpointpolar{\pgfdecorationsegmentangle}{\pgfkeysvalueof{/pgf/decoration/start radius}}}
+ \pgfpatharc{\pgfdecorationsegmentangle}{-\pgfdecorationsegmentangle}{\pgfkeysvalueof{/pgf/decoration/start radius}}
+ \pgfutil@tempcnta=-\pgfdecorationsegmentangle\relax
+ \advance\pgfutil@tempcnta by90\relax
+ \pgfmathsetlength\pgfutil@tempdima{\pgfkeysvalueof{/pgf/decoration/start radius}}
+ \pgfmathsetlength\pgfutil@tempdimb{\pgfdecorationsegmentamplitude}
+ \pgfpathcurveto
+ {\pgfpointadd
+ {\pgfpointpolar{-\pgfdecorationsegmentangle}{\pgfkeysvalueof{/pgf/decoration/start radius}}}
+ {\pgfpointpolar{\the\pgfutil@tempcnta}{.25\pgfutil@tempdima}}}
+ {\pgfqpoint{1.25\pgfutil@tempdima}{-.5\pgfutil@tempdimb}}
+ {\pgfqpoint{1.5\pgfutil@tempdima}{-.5\pgfutil@tempdimb}}
+ \pgfpathlineto{\pgfpoint{1.5\pgfutil@tempdima}{.5\pgfutil@tempdimb}}
+ \pgfutil@tempcnta=\pgfdecorationsegmentangle\relax
+ \advance\pgfutil@tempcnta by-90\relax
+ \pgfpathcurveto
+ {\pgfpoint{1.25\pgfutil@tempdima}{.5\pgfutil@tempdimb}}
+ {\pgfpointadd
+ {\pgfpointpolar{\pgfdecorationsegmentangle}{\pgfkeysvalueof{/pgf/decoration/start radius}}}
+ {\pgfpointpolar{\the\pgfutil@tempcnta}{.25\pgfutil@tempdima}}}
+ {\pgfpointpolar{\pgfdecorationsegmentangle}{\pgfkeysvalueof{/pgf/decoration/start radius}}}
+ \pgfpathclose
+ }
+ }%
+ \state{bar}[width=0pt,next state=end]
+ {
+ \pgfmathsetlength\pgfutil@tempdima{\pgfkeysvalueof{/pgf/decoration/start radius}}%
+ \pgfmathsetlength\pgfutil@tempdimb{\pgfkeysvalueof{/pgf/decoration/end radius}}%
+ \pgfmathsetlength\pgf@xc{\pgfdecorationsegmentamplitude}%
+ \pgfpathrectangle
+ {\pgfqpoint{.5\pgfutil@tempdima}{-.5\pgf@xc}}
+ {\pgfpoint{\pgfdecoratedremainingdistance+-.5\pgfutil@tempdimb+-.5\pgfutil@tempdima}{\pgf@xc}}
+ }%
+ \state{end}[width=0pt,next state=final]
+ {
+ {
+ \pgftransformxshift{\pgfdecoratedremainingdistance}%
+ \pgftransformxscale{-1}%
+ \pgftransformxshift{-\pgfkeysvalueof{/pgf/decoration/end radius}}%
+ \pgfpathmoveto{\pgfpointpolar{\pgfdecorationsegmentangle}{\pgfkeysvalueof{/pgf/decoration/end radius}}}
+ \pgfpatharc{\pgfdecorationsegmentangle}{-\pgfdecorationsegmentangle}{\pgfkeysvalueof{/pgf/decoration/end radius}}
+ \pgfutil@tempcnta=-\pgfdecorationsegmentangle\relax
+ \advance\pgfutil@tempcnta by90\relax
+ \pgfmathsetlength\pgfutil@tempdima{\pgfkeysvalueof{/pgf/decoration/end radius}}
+ \pgfmathsetlength\pgfutil@tempdimb{\pgfdecorationsegmentamplitude}%
+ \pgfpathcurveto
+ {\pgfpointadd
+ {\pgfpointpolar{-\pgfdecorationsegmentangle}{\pgfkeysvalueof{/pgf/decoration/end radius}}}
+ {\pgfpointpolar{\the\pgfutil@tempcnta}{.25\pgfutil@tempdima}}}
+ {\pgfqpoint{1.25\pgfutil@tempdima}{-.5\pgfutil@tempdimb}}
+ {\pgfqpoint{1.5\pgfutil@tempdima}{-.5\pgfutil@tempdimb}}
+ \pgfpathlineto{\pgfpoint{1.5\pgfutil@tempdima}{.5\pgfutil@tempdimb}}
+ \pgfutil@tempcnta=\pgfdecorationsegmentangle\relax
+ \advance\pgfutil@tempcnta by-90\relax
+ \pgfpathcurveto
+ {\pgfpoint{1.25\pgfutil@tempdima}{.5\pgfutil@tempdimb}}
+ {\pgfpointadd
+ {\pgfpointpolar{\pgfdecorationsegmentangle}{\pgfkeysvalueof{/pgf/decoration/end radius}}}
+ {\pgfpointpolar{\the\pgfutil@tempcnta}{.25\pgfutil@tempdima}}}
+ {\pgfpointpolar{\pgfdecorationsegmentangle}{\pgfkeysvalueof{/pgf/decoration/end radius}}}
+ \pgfpathclose
+ }
+ }%
+ \state{final}
+ {}%
+}%
+
+
+
+\pgfkeys{/pgf/decoration/angle=20}%
+
+% To paths for connecting circle nodes
+
+\tikzset{circle connection bar/.style=
+{to path={
+ \pgfextra{%
+ \tikz@lib@mindmap@check{\tikztostart}%
+ \tikz@compute@circle@radii\tikz@compute@segmentamplitude%
+ }
+ [every circle connection bar]
+ decorate [decoration=circle connection bar]
+ { -- (\tikztotarget) \tikztonodes}
+},
+append after command={[fill=\tikz@concept@color,draw=none]}
+}}%
+\tikzset{every circle connection bar/.style={}}%
+
+\def\tikz@compute@circle@radii{%
+ \pgf@process{\pgfpointtransformed{\pgfpointanchor{\tikztostart}{center}}}%
+ \pgf@xa=\pgf@x%
+ \pgf@process{\pgfpointtransformed{\pgfpointanchor{\tikztostart}{west}}}%
+ \advance\pgf@xa by-\pgf@x%
+ \pgfkeys{/pgf/decoration/start radius/.expanded=\the\pgf@xa}%
+ \pgf@process{\pgfpointtransformed{\pgfpointanchor{\tikztotarget}{center}}}%
+ \pgf@xa=\pgf@x%
+ \pgf@process{\pgfpointtransformed{\pgfpointanchor{\tikztotarget}{west}}}%
+ \advance\pgf@xa by-\pgf@x%
+ \pgfkeys{/pgf/decoration/end radius/.expanded=\the\pgf@xa}%
+}%
+\def\tikz@compute@segmentamplitude{%
+ \pgf@x=\pgfkeysvalueof{/pgf/decoration/start radius}\relax%
+ \ifdim\pgf@x>\pgfkeysvalueof{/pgf/decoration/end radius}\relax%
+ \pgf@x=\pgfkeysvalueof{/pgf/decoration/end radius}\relax%
+ \fi%
+ \pgf@x=.175\pgf@x\relax%
+ \edef\pgfdecorationsegmentamplitude{\the\pgf@x}%
+}%
+
+
+
+% Check whether start and end are nodes!
+
+\def\tikz@lib@mindmap@check#1{%
+ \pgfutil@ifundefined{pgf@sh@ns@#1}%
+ {\tikzerror{You are attempting to connect two things by a circle
+ connection bar where one is not a node}}{%
+ \expandafter\ifx\csname pgf@sh@ns@#1\endcsname\tikz@lib@coordinate@text%
+ \tikzerror{You are attempting to connect node of shape
+ 'coordinate' by a circle connection bar. The shape should be
+ 'circle' or something similar, instead.}
+ \fi%
+ }
+}%
+
+\def\tikz@lib@coordinate@text{coordinate}%
+
+
+% Switch color in a mindmap
+
+\tikzoption{circle connection bar switch color}{\tikz@parse@switch#1\pgf@unique}%
+\def\tikz@parse@switch from (#1) to (#2)\pgf@unique{%
+ \tikzset{to path={%
+ \pgfextra{%
+ \tikz@lib@mindmap@check{\tikztostart}%
+ \tikz@compute@circle@radii\tikz@compute@segmentamplitude%
+ \global\let\tikz@lib@save@start=\tikztostart%
+ \global\let\tikz@lib@save@target=\tikztotarget%
+ \pgfkeysgetvalue{/pgf/decoration/start radius}\pgf@temp%
+ \global\let\tikz@lib@saved@start@radius=\pgf@temp%
+ \pgfkeysgetvalue{/pgf/decoration/end radius}\pgf@temp%
+ \global\let\tikz@lib@saved@end@radius=\pgf@temp%
+ }%
+ [every circle connection bar]
+ decorate [decoration=circle connection bar]
+ { -- (\tikztotarget) \tikztonodes}
+ },
+ append after command={
+ [fill=none,draw=none,path picture=\tikz@lib@shade@pic]
+ \pgfextra{
+ \pgfutil@colorlet{tikz@switch@from}{#1}%
+ \pgfutil@colorlet{tikz@switch@to}{#2}%
+ }}
+ }
+}%
+
+\def\tikz@lib@shade@pic{%
+ % We have to draw the shading...
+ % compute start point:
+ \pgftransformreset%
+ \pgf@process{\pgfpointnormalised{\pgfpointdiff{\pgfpointanchor{\tikz@lib@save@start}{center}}{\pgfpointanchor{\tikz@lib@save@target}{center}}}}%
+ \edef\tikz@lib@mm@vec{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}%
+ \pgfmathsetlength\pgf@xc{\tikz@lib@saved@start@radius}
+ \pgf@process{\pgfpointadd{\pgfpointtransformed{\pgfpointanchor{\tikz@lib@save@start}{center}}}
+ {\pgfpointscale{\pgf@sys@tonumber{\pgf@xc}}{\tikz@lib@mm@vec}}}
+ \edef\tikz@lib@mm@start{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}%
+ \pgfmathsetlength\pgf@xc{\tikz@lib@saved@end@radius}
+ \pgf@process{\pgfpointdiff{\tikz@lib@mm@start}{\pgfpointadd{\pgfpointtransformed{\pgfpointanchor{\tikz@lib@save@target}{center}}}
+ {\pgfpointscale{-\pgf@sys@tonumber{\pgf@xc}}{\tikz@lib@mm@vec}}}}
+ \edef\tikz@lib@mm@end{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}%
+ \pgftransformshift{\tikz@lib@mm@start}
+ \pgflowlevelsynccm
+ \pgf@process{\tikz@lib@mm@vec}
+ {
+ \pgf@xa=-\pgf@x%
+ \pgftransformcm{\pgf@sys@tonumber{\pgf@x}}{\pgf@sys@tonumber{\pgf@y}}%
+ {\pgf@sys@tonumber{\pgf@y}}{\pgf@sys@tonumber{\pgf@xa}}%
+ {\pgfpointorigin}%
+ \pgf@process{\pgfpointtransformed{\tikz@lib@mm@end}}%
+ \expandafter
+ }
+ \edef\tikz@lib@mm@length{\the\pgf@x}%
+ \pgf@process{\tikz@lib@mm@vec}
+ \pgf@ya=-\pgf@y%
+ \pgftransformcm{\pgf@sys@tonumber{\pgf@x}}{\pgf@sys@tonumber{\pgf@y}}%
+ {\pgf@sys@tonumber{\pgf@ya}}{\pgf@sys@tonumber{\pgf@x}}%
+ {\pgfpointorigin}%
+ % Y scale:
+ \pgfmathsetlength\pgf@y{\tikz@lib@saved@start@radius}%
+ \pgfmathsetlength\pgf@ya{\tikz@lib@saved@end@radius}%
+ \ifdim\pgf@y<\pgf@ya%
+ \pgf@y=\pgf@ya%
+ \fi%
+ \pgf@y=0.01992528\pgf@y%
+ \pgftransformyscale{\pgf@sys@tonumber{\pgf@y}}%
+ \pgfpathrectanglecorners
+ {\pgfpoint{-\tikz@lib@saved@start@radius}{-50bp}}
+ {\pgfpoint{1pt}{50bp}}
+ \pgfsetfillcolor{tikz@switch@from}
+ \pgfusepath{fill}
+ \pgfpathrectanglecorners
+ {\pgfpoint{\tikz@lib@mm@length+\tikz@lib@saved@end@radius}{-50bp}}
+ {\pgfpoint{\tikz@lib@mm@length-1pt}{50bp}}
+ \pgfsetfillcolor{tikz@switch@to}
+ \pgfusepath{fill}
+ % X scale:
+ \pgf@x=\tikz@lib@mm@length%
+ \pgf@x=0.009962\pgf@x%
+ \pgftransformxscale{\pgf@sys@tonumber{\pgf@x}}%
+ \pgftransformxshift{50bp}
+ \pgflowlevelsynccm%
+ \pgfuseshading{tikz@shade@bar}
+}%
+
+\tikzoption{concept color}{%
+ \let\tikz@old@concept@color=\tikz@concept@color%
+ \def\tikz@edge@to@parent@path{
+ (\tikzparentnode)
+ to[circle connection bar switch color=from (\tikz@old@concept@color) to (#1)]
+ (\tikzchildnode)}
+ \def\tikz@concept@color{#1}%
+}%
+
+\pgfdeclarehorizontalshading[tikz@switch@from,tikz@switch@to]{tikz@shade@bar}{100bp}{%
+ color(0pt)=(tikz@switch@from);
+ color(100bp)=(tikz@switch@to)}%
+
+
+
+
+% A concept node
+
+\tikzset{concept/.style= {circle,fill=\tikz@concept@color,draw=\tikz@concept@color,every concept}}%
+\tikzset{every concept/.style= {}}%
+
+\def\tikz@concept@color{black}%
+
+\tikzset{tikz@concept@setting/.style={edge from parent path={(\tikzparentnode) to [circle connection bar] (\tikzchildnode)}}}%
+\tikzset{tikz@concept@color@set/.style={}}%
+
+
+\tikzset{extra concept/.style= {concept color=black!50,level 2 concept,concept,every extra concept}}%
+\tikzset{every extra concept/.style={}}%
+
+\tikzset{concept connection/.style={line width=1mm,shorten <=2mm,shorten >=2mm,cap=round,draw=black!50}}%
+
+
+% A mindmap
+
+\tikzset{mindmap/.style=
+ {fill,draw,very thick,outer sep=0pt,inner sep=1pt,%
+ every child/.append style={style=tikz@concept@setting,style=tikz@concept@color@set},%
+ root concept,
+ level 1/.append style={level 1 concept},
+ level 2/.append style={level 2 concept},
+ level 3/.append style={level 3 concept},
+ level 4/.append style={level 4 concept},
+ text centered,%
+ segment angle=20,
+ style=every mindmap,
+ }}%
+\tikzset{every mindmap/.style={}}%
+
+
+\tikzset{root concept/.style= {minimum size=4cm,text width=3.5cm,font=\pgfutil@font@large}}%
+\tikzset{level 1 concept/.style={minimum size=2.25cm,
+ level distance=5cm,
+ text width=2cm,
+ sibling angle=60,
+ font=\pgfutil@font@small}}%
+\tikzset{level 2 concept/.style={minimum size=1.75cm,%
+ level distance=2.9cm,%
+ text width=1.5cm,%
+ sibling angle=60,%
+ font=\pgfutil@font@footnotesize}}%
+\tikzset{level 3 concept/.style={minimum size=1.15cm,%
+ text width=1cm,%
+ level distance=2.4cm,%
+ sibling angle=30,%
+ font=\pgfutil@font@tiny}}%
+\tikzset{level 4 concept/.style={minimum size=0.9cm,%
+ text width=0.7cm,
+ level distance=1.85cm,%
+ sibling angle=30,%
+ font=\pgfutil@font@tiny}}%
+
+\tikzset{small mindmap/.style=
+ {%
+ root concept/.style={minimum size=2.3cm,text width=2.1cm,font=\pgfutil@font@footnotesize},
+ level 1 concept/.style={%
+ minimum size=1.5cm,
+ level distance=2.8cm,
+ text width=1.4cm,
+ sibling angle=75,
+ font=\pgfutil@font@scriptsize},%
+ level 2 concept/.style={%
+ minimum size=1.1cm,%
+ level distance=2.2cm,%
+ text width=1.1cm,%
+ sibling angle=60,%
+ font=\pgfutil@font@tiny},%
+ level 3 concept/.style={%
+ level 2 concept,
+ sibling angle=30,%
+ font=\pgfutil@font@tiny},%
+ level 4 concept/.style={%
+ level 3 concept,
+ },
+ mindmap,%
+ line width=2pt,
+ }}%
+
+\tikzset{large mindmap/.style=
+ {%
+ root concept/.style={minimum size=5.6cm,text width=4.5cm,font=\pgfutil@font@Large},
+ level 1 concept/.style={%
+ minimum size=3.2cm,
+ level distance=7cm,
+ text width=2.8cm,
+ sibling angle=60,
+ font=},%
+ level 2 concept/.style={%
+ minimum size=2.45cm,%
+ level distance=4cm,%
+ text width=2.2cm,%
+ sibling angle=60,%
+ font=\pgfutil@font@small%
+ },%
+ level 3 concept/.style={%
+ minimum size=1.63cm,%
+ text width=1.4cm,%
+ level distance=3.38cm,%
+ sibling angle=30,%
+ font=\pgfutil@font@scriptsize},%
+ level 4 concept/.style={%
+ minimum size=1.27cm,%
+ text width=1cm,
+ level distance=2.60cm,%
+ sibling angle=30,%
+ font=\pgfutil@font@tiny},%
+ mindmap,%
+ line width=2pt,
+ }}%
+
+\tikzset{huge mindmap/.style=
+ {%
+ root concept/.style={minimum size=8cm,text width=7cm,font=\pgfutil@font@huge},
+ level 1 concept/.style={%
+ minimum size=4.5cm,
+ level distance=10cm,
+ text width=4cm,
+ sibling angle=60,
+ font=\pgfutil@font@large},%
+ level 2 concept/.style={%
+ minimum size=3.5cm,%
+ level distance=5.8cm,%
+ text width=3cm,%
+ sibling angle=60,%
+ font=%
+ },%
+ level 3 concept/.style={%
+ minimum size=2.3cm,%
+ text width=2cm,%
+ level distance=4.8cm,%
+ sibling angle=30,%
+ font=\pgfutil@font@footnotesize},%
+ level 4 concept/.style={%
+ minimum size=1.7cm,%
+ text width=1.4cm,
+ level distance=3.7cm,%
+ sibling angle=30,%
+ font=\pgfutil@font@scriptsize},%
+ mindmap,%
+ line width=3pt,
+ }}%
+
+
+% Annotations
+
+\tikzset{annotation/.style={shape=rectangle,
+ minimum size=0pt,
+ text width=3.5cm,
+ outer sep=1.5mm,
+ inner sep=1mm,
+ text badly ragged,
+ rounded corners,
+ font=\pgfutil@font@tiny,
+ every annotation}}%
+\tikzset{every annotation/.style={}}%
+
+
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarypatterns.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarypatterns.code.tex
new file mode 100644
index 0000000000..8ef495bbba
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarypatterns.code.tex
@@ -0,0 +1,31 @@
+% Copyright 2018 by Till Tantau
+%
+% 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{tikzlibrarypatterns.code.tex}
+
+\usepgflibrary{patterns}%
+
+\tikzoption{pattern color}{\edef\tikz@pattern@color{#1}}%
+\tikzoption{pattern}[]{%
+ \edef\tikz@temp{#1}%
+ \ifx\tikz@temp\tikz@nonetext%
+ \tikz@addmode{\tikz@mode@fillfalse}%
+ \else%
+ \ifx\tikz@temp\pgfutil@empty%
+ \else%
+ \tikz@addoption{\pgfsetfillpattern{#1}{\tikz@pattern@color}}%
+ \def\tikz@pattern{#1}%
+ \fi%
+ \tikz@addmode{\tikz@mode@filltrue}%
+ \fi%
+}%
+\def\tikz@pattern@color{black}%
+\def\tikz@pattern{dots}%
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarypatterns.meta.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarypatterns.meta.code.tex
new file mode 100644
index 0000000000..de96fd9093
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarypatterns.meta.code.tex
@@ -0,0 +1,98 @@
+% Copyright 2019 by 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.
+
+\usepgflibrary{patterns.meta}%
+
+\tikzset{%
+ pattern color/.code=\edef\tikz@pattern@color{#1},
+ pattern/.code={%
+ \edef\tikz@temp{#1}%
+ \ifx\tikz@temp\tikz@nonetext%
+ \tikz@addmode{\tikz@mode@fillfalse}%
+ \else%
+ \ifx\tikz@temp\pgfutil@empty%
+ \else%
+ \tikz@addoption{\pgfsetfillpattern{#1}{\tikz@pattern@color}}%
+ \def\tikz@pattern{#1}%
+ \fi%
+ \tikz@addmode{\tikz@mode@filltrue}%
+ \fi%
+ }
+}%
+
+\def\tikz@pattern@color{black}%
+\def\tikz@pattern{}%
+
+\tikzset{patterns/.cd,
+ .unknown/.code={%
+ \let\tikz@pat@key=\pgfkeyscurrentname%
+ \pgfkeys{/pgf/patterns/\tikz@pat@key/.try={#1}}%
+ },
+ bottom left/.style={/pgf/patterns/bottom left={\tikz@scan@one@point\pgf@pat@process#1}},
+ top right/.style={/pgf/patterns/top right={\tikz@scan@one@point\pgf@pat@process#1}},
+ bounding box/.style args={#1(#2)#3and#4(#5)#6}{%
+ /tikz/patterns/bottom left={(#2)},
+ /tikz/patterns/top right={#4(#5)},
+ },
+ tile size/.style={/pgf/patterns/tile size={\tikz@scan@one@point\pgf@pat@process#1}},
+ tile transformation/.style={/pgf/patterns/tile transformation={%
+ \let\tikz@transform=\relax\pgfkeys{/tikz/.cd,#1}}%
+ },
+ infer tile bounding box/.code={
+ \def\pgf@pat@codeafter{%
+ \xdef\tikz@pat@installbb{%
+ \noexpand\pgfkeys{/tikz/patterns/bounding box={%
+ (\the\pgf@picminx-#1,\the\pgf@picminy-#1) and
+ (\the\pgf@picmaxx+#1,\the\pgf@picmaxy+#1)
+ },
+ /tikz/patterns/tile size={%
+ (\the\pgf@picmaxx-\the\pgf@picminx,
+ \the\pgf@picmaxy-\the\pgf@picminy)}}}%
+ }%
+ \let\pgf@pat@declarepost=\tikz@pat@installbb%
+ },
+ infer tile bounding box/.default=0pt,
+}%
+
+\def\tikzdeclarepattern#1{%
+ \begingroup%
+ \def\pgf@pat@codebefore{%
+ \let\tikz@transform=\relax%
+ \pgftransformreset% <- Hmm?
+ \tikz@declarepattern@install%
+ \ifnum\pgf@pat@type=0\relax%
+ \let\pgfsetstrokecolor=\pgfutil@gobble%
+ \let\pgfsetfillcolor=\pgfutil@gobble%
+ \fi%
+ \def\tikz@fig{\tikzerror{You cannot use `\string\node' inside a pattern}}%
+ \def\tikz@edge@plain{\tikzerror{You cannot use `edge' inside a pattern}}%
+ \def\tikz@to{\tikzerror{You cannot use `to' paths inside a pattern}}%
+ \tikzset{pattern/.code={\tikzerror{You cannot nest patterns}},
+ pattern color/.style={pattern}}%
+ }%
+ \pgfdeclarepattern{/tikz/patterns/.cd,#1}%
+ \endgroup%
+ }%
+
+\def\tikz@declarepattern@install{%
+ \let\tikz@compat@color@set=\tikz@compat@color@set@insidepatttern%
+ \tikz@installcommands%
+}%
+
+\let\tikz@compat@color@set@orig=\tikz@compat@color@set
+\def\tikz@compat@color@set@insidepatttern#1{%
+ \tikz@compat@color@set@orig{#1}%
+ \pgfsetfillcolor{#1}\pgfsetstrokecolor{#1}%
+}%
+
+
+%%% Local Variables:
+%%% mode: latex
+%%% TeX-master: t
+%%% End:
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryperspective.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryperspective.code.tex
new file mode 100644
index 0000000000..f9651ea973
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryperspective.code.tex
@@ -0,0 +1,111 @@
+% Copyright 2019 by Max Snippe
+%
+% 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{tikzlibraryperspective.code.tex}
+
+% Initialize affine transformation matrix for perspective view
+% [aa ab ac 0]
+% [ba bb bc 0]
+% [ca cb cc 0]
+% [da db dc 1]
+\pgfmathsetmacro\pgf@H@tpp@aa{+1}
+ \pgfmathsetmacro\pgf@H@tpp@ab{+0}
+ \pgfmathsetmacro\pgf@H@tpp@ac{+0}
+\pgfmathsetmacro\pgf@H@tpp@ba{+0}
+ \pgfmathsetmacro\pgf@H@tpp@bb{+1}
+ \pgfmathsetmacro\pgf@H@tpp@bc{+0}
+\pgfmathsetmacro\pgf@H@tpp@ca{+0}
+ \pgfmathsetmacro\pgf@H@tpp@cb{+0}
+ \pgfmathsetmacro\pgf@H@tpp@cc{+1}
+\pgfmathsetmacro\pgf@H@tpp@da{+0}
+ \pgfmathsetmacro\pgf@H@tpp@db{+0}
+ \pgfmathsetmacro\pgf@H@tpp@dc{+0}
+
+\def\pgfpointperspectivexyz#1#2#3{%
+ \pgfmathsetmacro\pgf@pp@w%
+ { \pgf@H@tpp@da*(#1) + \pgf@H@tpp@db*(#2) + \pgf@H@tpp@dc*(#3) + 1}
+ \pgfmathsetmacro\pgf@pp@x%
+ {(\pgf@H@tpp@aa*(#1) + \pgf@H@tpp@ab*(#2) + \pgf@H@tpp@ac*(#3))/\pgf@pp@w}
+ \pgfmathsetmacro\pgf@pp@y%
+ {(\pgf@H@tpp@ba*(#1) + \pgf@H@tpp@bb*(#2) + \pgf@H@tpp@bc*(#3))/\pgf@pp@w}
+ \pgfmathsetmacro\pgf@pp@z%
+ {(\pgf@H@tpp@ca*(#1) + \pgf@H@tpp@cb*(#2) + \pgf@H@tpp@cc*(#3))/\pgf@pp@w}
+%
+ \pgf@x=\pgf@pp@x\pgf@xx%
+ \advance\pgf@x by \pgf@pp@y\pgf@yx%
+ \advance\pgf@x by \pgf@pp@z\pgf@zx%
+ \pgf@y=\pgf@pp@x\pgf@xy%
+ \advance\pgf@y by \pgf@pp@y\pgf@yy%
+ \advance\pgf@y by \pgf@pp@z\pgf@zy}
+
+\tikzdeclarecoordinatesystem{three point perspective}
+{%
+ \tikzset{cs/.cd,x=0,y=0,z=0,#1}%
+ \pgfpointperspectivexyz{\tikz@cs@x}{\tikz@cs@y}{\tikz@cs@z}
+}
+\tikzaliascoordinatesystem{tpp}{three point perspective}
+
+\pgfkeys{
+ /perspective/.cd,
+ p/.code args={(#1,#2,#3)}{
+ \pgfmathparse{ifthenelse(#1,int(1),int(0))}
+ \ifnum\pgfmathresult=0\else
+ \pgfmathsetmacro\pgf@H@tpp@ba{#2/#1}
+ \pgfmathsetmacro\pgf@H@tpp@ca{#3/#1}
+ \pgfmathsetmacro\pgf@H@tpp@da{ 1/#1}
+ \fi
+ },
+ q/.code args={(#1,#2,#3)}{
+ \pgfmathparse{ifthenelse(#2,int(1),int(0))}
+ \ifnum\pgfmathresult=0\else
+ \pgfmathsetmacro\pgf@H@tpp@ab{#1/#2}
+ \pgfmathsetmacro\pgf@H@tpp@cb{#3/#2}
+ \pgfmathsetmacro\pgf@H@tpp@db{ 1/#2}
+ \fi
+ },
+ r/.code args={(#1,#2,#3)}{
+ \pgfmathparse{ifthenelse(#3,int(1),int(0))}
+ \ifnum\pgfmathresult=0\else
+ \pgfmathsetmacro\pgf@H@tpp@ac{#1/#3}
+ \pgfmathsetmacro\pgf@H@tpp@bc{#2/#3}
+ \pgfmathsetmacro\pgf@H@tpp@dc{ 1/#3}
+ \fi
+ },
+}
+
+\tikzset{
+ perspective/.append code={\pgfkeys{/perspective/.cd,#1}},
+ perspective/.default={
+ p={(10,0,0)},
+ q={(0,10,0)},
+ r={(0,0,20)}},
+}
+
+\tikzset{
+ 3d view/.code 2 args={%
+ % Set elevation and azimuth angles
+ \pgfmathsetmacro\pgf@view@az{#1}%
+ \pgfmathsetmacro\pgf@view@el{#2}%
+ % Calculate projections of rotation matrix
+ \pgfmathsetmacro\pgf@xvec@x{cos(\pgf@view@az)}%
+ \pgfmathsetmacro\pgf@xvec@y{-sin(\pgf@view@az)*sin(\pgf@view@el)}%
+ \pgfmathsetmacro\pgf@yvec@x{sin(\pgf@view@az)}%
+ \pgfmathsetmacro\pgf@yvec@y{cos(\pgf@view@az)*sin(\pgf@view@el)}%
+ \pgfmathsetmacro\pgf@zvec@x{+0}%
+ \pgfmathsetmacro\pgf@zvec@y{cos(\pgf@view@el)}%
+ % Set base vectors
+ \pgfsetxvec{\pgfpoint{\pgf@xvec@x cm}{\pgf@xvec@y cm}}%
+ \pgfsetyvec{\pgfpoint{\pgf@yvec@x cm}{\pgf@yvec@y cm}}%
+ \pgfsetzvec{\pgfpoint{\pgf@zvec@x cm}{\pgf@zvec@y cm}}%
+ },
+ 3d view/.default={-30}{15},
+ isometric view/.style={3d view={-45}{atan(1/sqrt(2))}},
+}
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarypetri.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarypetri.code.tex
new file mode 100644
index 0000000000..80c34c175e
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarypetri.code.tex
@@ -0,0 +1,146 @@
+% Copyright 2018 by Till Tantau
+%
+% 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{tikzlibrarypetri.code.tex}
+
+
+% Styles for places:
+
+\tikzset{every place/.style= {}}%
+\tikzset{place/.style= {circle,draw,inner sep=0pt,
+ minimum size=5ex,
+ every place}}%
+
+
+% Styles for transition:
+
+\tikzset{every transition/.style= {}}%
+\tikzset{transition/.style= {rectangle,draw,inner sep=0pt,
+ minimum size=4mm,
+ every transition}}%
+
+
+% Styles for relationship types:
+
+\tikzset{pre/.style= {<-,shorten <=1pt}}%
+\tikzset{post/.style= {->,shorten >=1pt}}%
+\tikzset{pre and post/.style= {<->,shorten >=1pt,shorten <=1pt}}%
+
+
+
+% Styles for marks:
+
+\tikzset{every token/.style= {}}%
+\tikzset{token/.style= {fill=black,draw=none,circle,
+ inner sep=0.5pt,minimum size=1ex,
+ text=white,font=\pgfutil@font@tiny,every token}}%
+
+\tikzoption{token distance}{\def\tikz@token@distance{#1}}%
+\def\tikz@token@distance{1.5ex}%
+
+\tikzset{children are tokens/.style= {growth function=\tikz@grow@tokens,edge from parent path=}}%
+
+\tikzoption{tokens}{%
+ \ifnum#1>0\relax%
+ \tikzset{append after command={}
+ {[children are tokens]child foreach \tikz@dummy in {1,...,#1} {node[token]{}}}}%
+ \fi}%
+
+\tikzoption{colored tokens}{%
+ \tikzset{append after command={}%
+ {[children are tokens]child foreach \tikz@child@color in {#1} {node[token,\tikz@child@color]{}}}}%
+ }%
+
+\tikzoption{structured tokens}{%
+ \tikzset{append after command={}%
+ {[children are tokens]child foreach \tikzpetrichildname in {#1} {node[token]{\tikzpetrichildname}}}}%
+ }%
+
+
+\def\tikz@grow@tokens{%
+ \pgfmathsetlength{\pgf@xa}{\tikz@token@distance}%
+ \pgfmathsetlength{\pgf@ya}{\tikz@token@distance}%
+ \pgf@xc=0pt%
+ \pgf@yc=0pt%
+ \csname tikz@grow@tokens@placer@\the\tikznumberofchildren @\the\tikznumberofcurrentchild\endcsname%
+ \pgftransformshift{\pgfqpoint{\pgf@xc}{\pgf@yc}}%
+}%
+
+\def\tikz@def@grow@tokens#1#2#3#4{%
+ \expandafter\def\csname tikz@grow@tokens@placer@#1@#2\endcsname{%
+ \pgf@xc=#3\pgf@xa%
+ \pgf@yc=#4\pgf@ya}%
+}%
+
+
+% Single token
+\tikz@def@grow@tokens{1}{1}{0}{0}%
+
+% Two tokens
+\tikz@def@grow@tokens{2}{1}{-.5}{0}%
+\tikz@def@grow@tokens{2}{2}{.5}{0}%
+
+% Three tokens
+\tikz@def@grow@tokens{3}{1}{0} {0.57}%
+\tikz@def@grow@tokens{3}{2}{-.5}{-.306025}%
+\tikz@def@grow@tokens{3}{3}{.5} {-.306025}%
+
+% Four tokens
+\tikz@def@grow@tokens{4}{1}{-.5}{.5}%
+\tikz@def@grow@tokens{4}{2}{.5}{.5}%
+\tikz@def@grow@tokens{4}{3}{-.5}{-.5}%
+\tikz@def@grow@tokens{4}{4}{.5}{-.5}%
+
+% Five tokens
+\tikz@def@grow@tokens{5}{1}{0}{.85}%
+\tikz@def@grow@tokens{5}{2}{-0.808398}{0.26266}%
+\tikz@def@grow@tokens{5}{3}{0.808398}{0.26266}%
+\tikz@def@grow@tokens{5}{4}{-0.499617}{-0.687664}%
+\tikz@def@grow@tokens{5}{5}{0.499617}{-0.687664}%
+
+% Six tokens
+\tikz@def@grow@tokens{6}{1}{-1}{.5}%
+\tikz@def@grow@tokens{6}{2}{0}{.5}%
+\tikz@def@grow@tokens{6}{3}{1}{.5}%
+\tikz@def@grow@tokens{6}{4}{-1}{-.5}%
+\tikz@def@grow@tokens{6}{5}{0}{-.5}%
+\tikz@def@grow@tokens{6}{6}{1}{-.5}%
+
+% Seven tokens
+\tikz@def@grow@tokens{7}{1}{0}{1}%
+\tikz@def@grow@tokens{7}{2}{-1}{.5}%
+\tikz@def@grow@tokens{7}{3}{0}{0}%
+\tikz@def@grow@tokens{7}{4}{1}{.5}%
+\tikz@def@grow@tokens{7}{5}{-1}{-.5}%
+\tikz@def@grow@tokens{7}{6}{0}{-1}%
+\tikz@def@grow@tokens{7}{7}{1}{-.5}%
+
+% Eight tokens
+\tikz@def@grow@tokens{8}{1}{-.5}{1}%
+\tikz@def@grow@tokens{8}{2}{.5}{1}%
+\tikz@def@grow@tokens{8}{3}{-1}{0}%
+\tikz@def@grow@tokens{8}{4}{0}{0}%
+\tikz@def@grow@tokens{8}{5}{1}{0}%
+\tikz@def@grow@tokens{8}{6}{-1}{-1}%
+\tikz@def@grow@tokens{8}{7}{0}{-1}%
+\tikz@def@grow@tokens{8}{8}{1}{-1}%
+
+% Eight tokens
+\tikz@def@grow@tokens{9}{1}{-1}{1}%
+\tikz@def@grow@tokens{9}{2}{0}{1}%
+\tikz@def@grow@tokens{9}{3}{1}{1}%
+\tikz@def@grow@tokens{9}{4}{-1}{0}%
+\tikz@def@grow@tokens{9}{5}{0}{0}%
+\tikz@def@grow@tokens{9}{6}{1}{0}%
+\tikz@def@grow@tokens{9}{7}{-1}{-1}%
+\tikz@def@grow@tokens{9}{8}{0}{-1}%
+\tikz@def@grow@tokens{9}{9}{1}{-1}%
+
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryplothandlers.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryplothandlers.code.tex
new file mode 100644
index 0000000000..e6db2b62ff
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryplothandlers.code.tex
@@ -0,0 +1,14 @@
+% Copyright 2018 by Till Tantau
+%
+% 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{tikzlibraryplothandlers.code.tex}
+
+\usepgflibrary{plothandlers}%
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryplotmarks.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryplotmarks.code.tex
new file mode 100644
index 0000000000..15eea57201
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryplotmarks.code.tex
@@ -0,0 +1,14 @@
+% Copyright 2018 by Till Tantau
+%
+% 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{tikzlibraryplotmarks.code.tex}
+
+\usepgflibrary{plotmarks}%
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarypositioning.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarypositioning.code.tex
new file mode 100644
index 0000000000..b410975c32
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarypositioning.code.tex
@@ -0,0 +1,118 @@
+% Copyright 2018 by Till Tantau
+%
+% 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{tikzlibrarypositioning.code.tex}
+
+
+\tikzset{above/.code=\tikz@lib@place@handle@{#1}{south}{0}{1}{north}{1}}%
+\tikzset{above left/.code=\tikz@lib@place@handle@{#1}{south east}{-1}{1}{north west}{0.707106781}}%
+\tikzset{above right/.code=\tikz@lib@place@handle@{#1}{south west}{1}{1}{north east}{0.707106781}}%
+\tikzset{base left/.code =\tikz@lib@place@handle@{#1}{base east}{-1}{0}{base west}{1}}%
+\tikzset{base right/.code=\tikz@lib@place@handle@{#1}{base west}{1}{0}{base east}{1}}%
+\tikzset{below/.code=\tikz@lib@place@handle@{#1}{north}{0}{-1}{south}{1}}%
+\tikzset{below left/.code=\tikz@lib@place@handle@{#1}{north east}{-1}{-1}{south west}{0.707106781}}%
+\tikzset{below right/.code=\tikz@lib@place@handle@{#1}{north west}{1}{-1}{south east}{0.707106781}}%
+\tikzset{left/.code =\tikz@lib@place@handle@{#1}{east}{-1}{0}{west}{1}}%
+\tikzset{mid left/.code =\tikz@lib@place@handle@{#1}{mid east}{-1}{0}{mid west}{1}}%
+\tikzset{mid right/.code=\tikz@lib@place@handle@{#1}{mid west}{1}{0}{mid east}{1}}%
+\tikzset{right/.code=\tikz@lib@place@handle@{#1}{west}{1}{0}{east}{1}}%
+
+\newif\iftikz@lib@ignore@size
+
+% Hook into resets:
+\pgfutil@g@addto@macro\tikz@node@reset@hook{\tikz@addtransform{\tikz@lib@pos@call}\let\tikz@lib@pos@call=\relax}%
+
+\tikzset{on grid/.is if=tikz@lib@ignore@size}%
+
+\tikzset{node distance=1cm and 1cm}%
+
+\def\tikz@lib@place@handle@#1#2#3#4#5#6{%
+ \def\tikz@anchor{#2}%
+ \let\tikz@do@auto@anchor=\relax%
+ \edef\tikz@temp{#1}%
+ \def\tikz@lib@place@single@factor{#6}%
+ \expandafter\tikz@lib@place@handle@@\expandafter{\tikz@temp}{#3}{#4}{#5}%
+}%
+\def\tikz@lib@place@handle@@#1#2#3#4{%
+ \pgfutil@in@{of }{#1}%
+ \ifpgfutil@in@%
+ \tikz@lib@place@of#1\tikz@stop{#4}%
+ \else%
+ \edef\tikz@lib@place@nums{#1}%
+ \fi%
+ \ifx\tikz@lib@place@nums\pgfutil@empty%
+ % Ok, nothing to do, we have set the anchor and we are happy...
+ \else%
+ \expandafter\tikz@lib@place@parse@nums\expandafter{\tikz@lib@place@nums}%
+ \pgf@x=#2\pgf@x%
+ \pgf@y=#3\pgf@y%
+ \edef\tikz@lib@pos@call{\noexpand\pgftransformshift{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}}%
+ \fi%
+}%
+
+\def\tikz@lib@place@parse@nums#1{%
+ \pgfutil@in@{and}{#1}%
+ \ifpgfutil@in@%
+ \tikz@lib@place@parse@nums@#1\tikz@stop%
+ \else%
+ \tikz@lib@place@parse@nums@#1and#1\tikz@stop%
+ \pgf@x=\tikz@lib@place@single@factor\pgf@x%
+ \pgf@y=\tikz@lib@place@single@factor\pgf@y%
+ \fi
+}%
+\def\tikz@lib@place@parse@nums@#1and#2\tikz@stop{%
+ \pgfmathparse{#2}%
+ \ifpgfmathunitsdeclared%
+ \pgf@xa=\pgfmathresult pt%
+ \pgf@ya=0pt%
+ \else%
+ \let\tikz@lib@temp=\pgfmathresult%
+ \pgf@process{\pgfpointxy{\tikz@lib@temp}{0}}%
+ \pgf@xa=\pgf@x%
+ \pgf@ya=\pgf@y%
+ \fi%
+ \pgfmathparse{#1}%
+ \ifpgfmathunitsdeclared%
+ \advance\pgf@ya by\pgfmathresult pt%
+ \else%
+ \let\tikz@lib@temp=\pgfmathresult%
+ \pgf@process{\pgfpointxy{0}{\tikz@lib@temp}}%
+ \advance\pgf@xa by\pgf@x%
+ \advance\pgf@ya by\pgf@y%
+ \fi%
+ \pgf@x=\pgf@xa%
+ \pgf@y=\pgf@ya%
+}%
+
+\def\tikz@lib@place@of#1of #2\tikz@stop#3{%
+ \def\tikz@temp{#1}%
+ \ifx\tikz@temp\pgfutil@empty%
+ \tikz@lib@place@of@{\tikz@node@distance}{#2}{#3}%
+ \else%
+ \tikz@lib@place@of@{#1}{#2}{#3}%
+ \fi%
+}%
+\def\tikz@lib@place@of@#1#2#3{%
+ \tikz@scan@one@point\tikz@lib@place@remember(#2)%
+ \iftikz@shapeborder%
+ % Ok, this is relative to a border.
+ \iftikz@lib@ignore@size%
+ \edef\tikz@node@at{\noexpand\pgfpointanchor{\tikz@shapeborder@name}{center}}%
+ \def\tikz@anchor{center}%
+ \else%
+ \edef\tikz@node@at{\noexpand\pgfpointanchor{\tikz@shapeborder@name}{#3}}%
+ \fi%
+ \fi%
+ \edef\tikz@lib@place@nums{#1}%
+}%
+\def\tikz@lib@place@remember#1{\def\tikz@node@at{#1}}%
+
+
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryquotes.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryquotes.code.tex
new file mode 100644
index 0000000000..41ce3faaf5
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryquotes.code.tex
@@ -0,0 +1,90 @@
+% Copyright 2018 by Till Tantau
+%
+% 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{tikzlibraryquotes.code.tex}
+
+\def\tikz@quote@parser#1{\tikz@quote@@parser#1\pgf@stop}%
+\def\tikz@quote@@parser"#1"{%
+ \pgfutil@ifnextchar\bgroup{%
+ \tikz@quote@@parser@group{#1}}{%
+ \pgfutil@ifnextchar'{%
+ \tikz@quote@@parser@apo{#1}}{%
+ \tikz@quote@@parser@normal{#1}}}}%
+\def\tikz@quote@@parser@apo#1'{%
+ \pgfutil@ifnextchar\bgroup{\tikz@quote@@parser@apo@group{#1}}{\tikz@quote@@parser@apo@normal{#1}}}%
+\def\tikz@quote@@parser@group#1#2#3\pgf@stop{%
+ \expandafter\def\expandafter\tikz@temp\expandafter{\tikz@quotes@as{#1}{#2}}%
+ \expandafter\pgfkeysalso\expandafter{\tikz@temp}%
+}%
+\def\tikz@quote@@parser@normal#1#2\pgf@stop{%
+ \expandafter\def\expandafter\tikz@temp\expandafter{\tikz@quotes@as{#1}{#2}}%
+ \expandafter\pgfkeysalso\expandafter{\tikz@temp}%
+}%
+\def\tikz@quote@@parser@apo@group#1#2#3\pgf@stop{%
+ \expandafter\def\expandafter\tikz@temp\expandafter{\tikz@quotes@as{#1}{',#2}}%
+ \expandafter\pgfkeysalso\expandafter{\tikz@temp}%
+}%
+\def\tikz@quote@@parser@apo@normal#1#2\pgf@stop{%
+ \expandafter\def\expandafter\tikz@temp\expandafter{\tikz@quotes@as{#1}{',#2}}%
+ \expandafter\pgfkeysalso\expandafter{\tikz@temp}%
+}%
+
+\pgfkeys{/handlers/first char syntax=true}%
+
+\def\tikz@enable@node@quotes{%
+ \pgfkeyssetvalue{/handlers/first char syntax/\expandafter\meaning\string"}{\tikz@quote@parser}%
+ \let\tikz@quotes@as\tikz@node@quotes@as%
+}%
+\def\tikz@enable@edge@quotes{%
+ \pgfkeyssetvalue{/handlers/first char syntax/\expandafter\meaning\string"}{\tikz@quote@parser}%
+ \let\tikz@quotes@as\tikz@edge@quotes@as%
+}%
+\def\tikz@enable@pic@quotes{%
+ \pgfkeyssetvalue{/handlers/first char syntax/\expandafter\meaning\string"}{\tikz@quote@parser}%
+ \let\tikz@quotes@as\tikz@pic@quotes@as%
+}%
+
+\tikzset{
+ node quotes mean/.code={\def\tikz@node@quotes@as##1##2{#1}},
+ edge quotes mean/.code={\def\tikz@edge@quotes@as##1##2{#1}},
+ pic quotes mean/.code={\def\tikz@pic@quotes@as##1##2{#1}},
+ quotes mean pin/.style={node quotes mean={
+ pin={[direction shorthands,every pin quotes/.try,##2]##1}}},
+ quotes mean label/.style={node quotes mean={
+ label={[direction shorthands,every label quotes/.try,##2]##1}}},
+ quotes mean label,
+ edge quotes mean={edge node={node [every edge quotes,#2]{#1}}},
+ pic quotes mean={pic text={#1},pic text options={every pic quotes/.try,#2}},
+ every edge quotes/.style={auto},
+ direction shorthands/.code={%
+ \pgfkeyslet{/tikz/centered/.@cmd}\tikz@label@@centered
+ \pgfkeyslet{/tikz/above/.@cmd}\tikz@label@@above
+ \pgfkeyslet{/tikz/below/.@cmd}\tikz@label@@below
+ \pgfkeyslet{/tikz/left/.@cmd}\tikz@label@@left
+ \pgfkeyslet{/tikz/right/.@cmd}\tikz@label@@right
+ \pgfkeyslet{/tikz/above left/.@cmd}\tikz@label@@above@left
+ \pgfkeyslet{/tikz/above right/.@cmd}\tikz@label@@above@right
+ \pgfkeyslet{/tikz/below left/.@cmd}\tikz@label@@below@left
+ \pgfkeyslet{/tikz/below right/.@cmd}\tikz@label@@below@right
+ }
+}%
+
+\def\tikz@label@@centered#1\pgfeov{\pgfkeysalso{label position=center,pin position=center}}%
+\def\tikz@label@@above#1\pgfeov{\pgfkeysalso{label position=90,pin position=90}}%
+\def\tikz@label@@below#1\pgfeov{\pgfkeysalso{label position=-90,pin position=-90}}%
+\def\tikz@label@@left#1\pgfeov{\pgfkeysalso{label position=180,pin position=180}}%
+\def\tikz@label@@right#1\pgfeov{\pgfkeysalso{label position=0,pin position=0}}%
+\def\tikz@label@@above@left#1\pgfeov{\pgfkeysalso{label position=135,pin position=135}}%
+\def\tikz@label@@below@left#1\pgfeov{\pgfkeysalso{label position=-135,pin position=-135}}%
+\def\tikz@label@@above@right#1\pgfeov{\pgfkeysalso{label position=45,pin position=45}}%
+\def\tikz@label@@below@right#1\pgfeov{\pgfkeysalso{label position=-45,pin position=-45}}%
+
+
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryrdf.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryrdf.code.tex
new file mode 100644
index 0000000000..74e77ac3e2
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryrdf.code.tex
@@ -0,0 +1,291 @@
+% Copyright 2018 by Till Tantau
+%
+% 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{tikzlibraryrdf.code.tex}
+
+
+
+\def\tikz@add@rdf@pre@option#1{\expandafter\def\expandafter\tikz@rdf@pre@options\expandafter{\tikz@rdf@pre@options#1}}%
+\def\tikz@add@rdf@post@option#1{\expandafter\def\expandafter\tikz@rdf@post@options\expandafter{\tikz@rdf@post@options#1}}%
+
+\let\tikz@rdf@pre@options\pgfutil@empty
+\let\tikz@rdf@post@options\pgfutil@empty
+
+\tikzset{
+ %
+ % Switching on the engine
+ %
+ rdf engine on/.code={%
+ \def\tikz@clear@rdf@options{\let\tikz@rdf@pre@options\pgfutil@empty\let\tikz@rdf@post@options\pgfutil@empty}%
+ \def\tikz@do@rdf@pre@options{\tikz@rdf@pre@options\let\tikz@rdf@pre@options\pgfutil@empty}%
+ \def\tikz@do@rdf@post@options{\tikz@rdf@post@options\let\tikz@rdf@post@options\pgfutil@empty}%
+ \pgfkeys{/tikz/rdf engine/.code=\tikz@add@rdf@pre@option{\pgfqkeys{/tikz/rdf engine}{##1}}}%
+ },
+ rdf engine/.cd,
+ %
+ every statement/.style=,
+ %
+ % Namespaces
+ %
+ prefix/.code=\pgfrdfprefix{#1},
+ %
+ % Core commands
+ %
+ statement/.code={%
+ {%
+ \pgfkeys{/tikz/rdf engine/every statement}%
+ \pgfqkeys{/tikz/rdf engine/statements}{#1}%
+ \iftikz@rdf@is@a@container\tikz@rdf@init@container\fi%
+ \iftikz@rdf@is@a@member\tikz@rdf@make@member\fi%
+ \tikz@rdf@make@triple%
+ \expandafter}\tikz@rdf@action%
+ },
+ get scope curie/.code={%
+ \ifx\tikz@id@name\pgfutil@empty%
+ \def\tikz@id@name{@rdf}%
+ \fi%
+ \pgfidrefnextuse\tikz@temp{\tikz@id@name}%
+ \edef#1{\tikzrdfhashmark\tikz@temp}%
+ },
+ get new resource curie/.code={%
+ \pgfsys@new@id\tikz@temp%
+ \edef#1{\tikzrdfhashmark\tikz@temp}%
+ },
+ scope is new context/.style={get scope curie=\tikzrdfcontext}
+}%
+
+\def\tikzrdfcontext{\tikzrdfhashmark}%empty by default
+
+\tikzset{
+ rdf engine/statements/.cd,
+ %
+ % Core properties of statements
+ %
+ subject/.code={%
+ \def\tikz@rdf@target{\tikz@rdf@subject}%
+ \tikz@rdf@parse{#1}%
+ },
+ predicate/.code={%
+ \def\tikz@rdf@target{\tikz@rdf@predicate}%
+ \tikz@rdf@parse{#1}%
+ },
+ object/.code={%
+ \let\tikz@rdf@object@literal\relax%
+ \let\tikz@rdf@object\relax%
+ \def\tikz@temp{#1}%
+ \ifx\tikz@temp\tikz@rdf@current@scope@text%
+ \tikz@rdf@object@scope@contenttrue%
+ \else%
+ \tikz@rdf@object@scope@contentfalse%
+ \def\tikz@rdf@target{\tikz@rdf@object}%
+ \tikz@rdf@parse{#1}%
+ \fi%
+ },
+ %
+ % Shorthands
+ %
+ has type/.style={predicate=rdf:type,object={#1}},
+ %
+ % Containers
+ %
+ is a bag/.style={has type=rdf:Bag, is a container},
+ is a sequence/.style={has type=rdf:Seq, is a container},
+ is an alternative/.style={has type=rdf:Alt, is a container},
+ %
+ is a container/.code={\tikz@rdf@is@a@containertrue},
+ %
+ has as member/.code={\tikz@rdf@is@a@membertrue},%
+}%
+
+\def\tikz@rdf@current@scope@text{scope content}%
+
+\let\tikz@rdf@subject\relax
+\let\tikz@rdf@predicate\pgfutil@empty
+\let\tikz@rdf@object\relax
+\let\tikz@rdf@object@literal\relax
+\let\tikz@rdf@container\relax
+
+\newif\iftikz@rdf@object@scope@content
+\newif\iftikz@rdf@is@a@container
+\newif\iftikz@rdf@is@a@member
+
+
+\def\tikz@rdf@parse#1{%
+ \edef\tikz@temp{#1}%
+ \expandafter\tikz@rdf@parse@#1\relax%
+}%
+
+\def\tikz@rdf@parse@{%
+ \pgfutil@ifnextchar({\tikz@rdf@parse@name}{%)
+ \pgfutil@ifnextchar"{\tikz@rdf@parse@literals}{%
+ \tikz@rdf@parse@curie%
+ }%
+ }%
+}%
+
+\def\tikz@rdf@parse@name(#1)\relax{%
+ \pgfidrefprevuse\tikz@rdf@the@id{#1}\expandafter\edef\tikz@rdf@target{\tikzrdfhashmark\tikz@rdf@the@id}%
+}%
+\def\tikz@rdf@parse@literals"#1"{%
+ \ifx\tikz@rdf@target\tikz@rdf@object@name%
+ \def\tikz@rdf@object@literal{#1}%
+ \else%
+ \tikzerror{Only RDF objects can be literals}%
+ \fi%
+ \pgfutil@ifnextchar\relax\pgfutil@gobble\tikz@rdf@parse@literals@rest%
+}%
+\def\tikz@rdf@parse@literals@rest and scope content\relax{%
+ \tikz@rdf@object@scope@contenttrue%
+}%
+
+\def\tikz@rdf@object@name{\tikz@rdf@object}%
+\def\tikz@rdf@parse@curie#1\relax{%
+ \expandafter\def\tikz@rdf@target{#1}%
+}%
+
+{%
+ \catcode`\#=11
+ \gdef\tikzrdfhashmark{#}%
+}%
+
+
+\def\tikz@rdf@make@triple{%
+ % First, ensure that subject, predicate and object are set:
+ \ifx\tikz@rdf@subject\relax%
+ \tikzerror{RDF statement misses subject}%
+ \else%
+ \ifx\tikz@rdf@predicate\relax%
+ \tikzerror{RDF statement misses predicate}%
+ \else%
+ \iftikz@rdf@object@scope@content%
+ \edef\tikz@marshal{\noexpand\tikz@rdf@make@content@triple{\tikz@rdf@subject}{\tikz@rdf@predicate}{\tikz@rdf@object@literal}}%
+ \tikz@marshal%
+ \else%
+ \ifx\tikz@rdf@object\relax%
+ \ifx\tikz@rdf@object@literal\relax%
+ \tikzerror{RDF statement misses object}%
+ \else%
+ \edef\tikz@marshal{\noexpand\tikz@rdf@make@literal@triple{\tikz@rdf@subject}{\tikz@rdf@predicate}{\tikz@rdf@object@literal}}%
+ \tikz@marshal%
+ \fi%
+ \else%
+ \edef\tikz@marshal{\noexpand\tikz@rdf@make@normal@triple{\tikz@rdf@subject}{\tikz@rdf@predicate}{\tikz@rdf@object}}%
+ \tikz@marshal%
+ \fi%
+ \fi%
+ \fi%
+ \fi%
+}%
+
+\def\tikz@rdf@make@content@triple#1#2#3{%
+ \def\tikz@rdf@action{%
+ \def\tikz@rdf@invoke@code{%
+ \def\tikz@temp{#3}%
+ \ifx\tikz@temp\tikz@rdf@object@literal@text\else%
+ \pgfrdfcontent{#3}%
+ \fi%
+ \pgfrdfabout{#1}%
+ \pgfrdfdatatype{rdf:XMLLiteral}%
+ \foreach \tikz@rdf@pred in {#2}{%
+ \ifx\tikz@rdf@pred\pgfutil@empty\else%
+ \expandafter\pgfrdfproperty\expandafter{\tikz@rdf@pred}%
+ \fi%
+ }%
+ }%
+ }%
+}%
+
+\def\tikz@rdf@make@literal@triple#1#2#3{%
+ \def\tikz@rdf@action{%
+ \tikz@add@rdf@post@option{%
+ {%
+ \pgfrdfabout{#1}%
+ \foreach \tikz@rdf@pred in {#2}{%
+ \ifx\tikz@rdf@pred\pgfutil@empty\else%
+ \expandafter\pgfrdfproperty\expandafter{\tikz@rdf@pred}%
+ \fi%
+ }%
+ \pgfrdfcontent{#3}%
+ \pgfidscope%
+ \endpgfidscope%
+ }%
+ }%
+ }%
+}%
+
+\def\tikz@rdf@make@normal@triple#1#2#3{%
+ \def\tikz@rdf@action{%
+ \tikz@add@rdf@post@option{%
+ {%
+ \pgfrdfabout{#1}%
+ \foreach \tikz@rdf@pred in {#2}{%
+ \ifx\tikz@rdf@pred\pgfutil@empty\else%
+ \expandafter\pgfrdfproperty\expandafter{\tikz@rdf@pred}%
+ \fi%
+ }%
+ \pgfrdfresource{#3}%
+ \pgfidscope%
+ \endpgfidscope%
+ }%
+ }%
+ }%
+}%
+
+\def\tikz@rdf@object@literal@text{\tikz@rdf@object@literal}%
+
+
+
+
+% Containers
+
+\def\tikz@rdf@init@container{%
+ \ifx\tikz@rdf@subject\relax%
+ \tikzerror{RDF statement misses subject}%
+ \else%
+ \expandafter\gdef\csname tikz@rdf@c@\tikz@rdf@subject\endcsname{0}%
+ \fi%
+}%
+
+
+\def\tikz@rdf@make@member{%
+ \ifx\tikz@rdf@subject\relax%
+ \tikzerror{RDF statement misses subject}%
+ \else%
+ % Get number:
+ \expandafter\let\expandafter\tikz@temp\csname tikz@rdf@c@\tikz@rdf@subject\endcsname%
+ \ifx\tikz@temp\relax%
+ \tikzerror{RDF subject is not a container}%
+ \else%
+ \c@pgf@counta\tikz@temp%
+ \advance\c@pgf@counta by1\relax%
+ \expandafter\xdef\csname tikz@rdf@c@\tikz@rdf@subject\endcsname{\the\c@pgf@counta}%
+ \edef\tikz@rdf@predicate{rdf:_\the\c@pgf@counta}%
+ \fi%
+ \fi%
+}%
+
+
+
+
+
+% Hooks:
+
+\let\tikz@rdf@invoke@code\relax
+
+\def\tikz@rdf@id@hook{%
+ \tikz@rdf@invoke@code%
+ \let\tikz@rdf@invoke@code\relax%
+}%
+
+% Add hook:
+\expandafter\def\expandafter\tikz@id@hook\expandafter{\tikz@id@hook\tikz@rdf@id@hook}%
+
+
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryscopes.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryscopes.code.tex
new file mode 100644
index 0000000000..68856d591e
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryscopes.code.tex
@@ -0,0 +1,42 @@
+% Copyright 2018 by Till Tantau
+%
+% 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{tikzlibraryscopes.code.tex}
+
+% Redefine the after command hook...
+
+\def\tikz@lib@scope@check{%
+ \pgfutil@ifnextchar\tikz@intersect@finish{%
+ \tikz@intersect@finish\afterassignment\tikz@lib@scope@check\let\tikz@next%
+ }{%
+ \pgfutil@ifnextchar\par{%
+ \afterassignment\tikz@lib@scope@check\let\tikz@next%
+ }%
+ {\pgfutil@ifnextchar\bgroup{%gotcha
+ \afterassignment\tikz@lib@scope@gotcha\let\tikz@next%
+ }%
+ {}%
+ }%
+ }%
+}%
+
+\def\tikz@lib@scope@gotcha{%
+ \pgfutil@ifnextchar[{%]
+ \tikz@lib@scope@action%
+ }{%
+ % false alarm
+ \bgroup%
+ }%
+}%
+\def\tikz@lib@scope@action[#1]{%
+ \scope[#1]\bgroup\aftergroup\endscope%
+ \tikz@lib@scope@check%
+}%
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryshadings.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryshadings.code.tex
new file mode 100644
index 0000000000..2cf08776f3
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryshadings.code.tex
@@ -0,0 +1,21 @@
+% Copyright 2018 by Till Tantau
+%
+% 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{tikzlibraryshadings.code.tex}
+
+\usepgflibrary{shadings}%
+
+\tikzset{
+ lower left/.style={shading=bilinear interpolation,/utils/exec=\colorlet{lower left}{#1}},
+ upper left/.style={shading=bilinear interpolation,/utils/exec=\colorlet{upper left}{#1}},
+ lower right/.style={shading=bilinear interpolation,/utils/exec=\colorlet{lower right}{#1}},
+ upper right/.style={shading=bilinear interpolation,/utils/exec=\colorlet{upper right}{#1}}
+}%
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryshadows.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryshadows.code.tex
new file mode 100644
index 0000000000..3bd60e99fa
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryshadows.code.tex
@@ -0,0 +1,146 @@
+% Copyright 2018 by Till Tantau
+%
+% 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{tikzlibraryshadows.code.tex}
+
+\usetikzlibrary{fadings}%
+
+
+% General options
+\tikzset{
+ /tikz/shadow scale/.initial=1,
+ /tikz/shadow xshift/.initial=0pt,
+ /tikz/shadow yshift/.initial=0pt,
+}%
+
+% Basic shadow style
+\tikzset{
+ general shadow/.style={
+ preaction={
+ #1,
+ transform canvas={
+ scale around=\pgfkeysvalueof{/tikz/shadow scale}:(current path bounding box.center),
+ shift={(\pgfkeysvalueof{/tikz/shadow xshift},\pgfkeysvalueof{/tikz/shadow yshift})}
+ },
+ }
+ },
+ every shadow/.style={}
+}%
+
+
+
+%
+% Adds a simple drop shadow to a path
+%
+
+\tikzset{
+ /tikz/drop shadow/.style={
+ general shadow={%
+ shadow scale=1,
+ shadow xshift=.5ex,
+ shadow yshift=-.5ex,
+ opacity=.5,
+ fill=black!50,
+ every shadow,
+ #1
+ }
+ }
+}%
+
+
+%
+% Adds a circular drop shadow to a path
+%
+
+\tikzset{
+ /tikz/circular drop shadow/.style={
+ general shadow={%
+ shadow scale=1.1,
+ shadow xshift=.3ex,
+ shadow yshift=-.3ex,
+ fill=black!50,
+ path fading={circle with fuzzy edge 15 percent},
+ every shadow,
+ #1
+ }
+ }
+}%
+
+
+
+%
+% Adds a circular glow to a path
+%
+
+\tikzset{
+ /tikz/circular glow/.style={
+ general shadow={%
+ shadow scale=1.25,
+ shadow xshift=0pt,
+ shadow yshift=0pt,
+ fill=black!50,
+ path fading={circle with fuzzy edge 15 percent},
+ every shadow,
+ #1,
+ }
+ }
+}%
+
+
+
+
+
+%
+% Adds a "copy" version of the path behind it.
+%
+
+\tikzset{
+ /tikz/copy shadow/.style={
+ general shadow={%
+ /utils/exec={\let\tikz@lib@shadow@fill=\tikz@fillcolor\let\tikz@lib@shadow@draw=\tikz@strokecolor},
+ shadow scale=1,
+ shadow xshift=.5ex,
+ shadow yshift=.5ex,
+ fill=\tikz@lib@shadow@fill,
+ draw=\tikz@lib@shadow@draw,
+ every shadow,
+ #1
+ }
+ }
+}%
+
+
+%
+% Adds two "copies" of the path behind it.
+%
+
+\tikzset{
+ /tikz/double copy shadow/.style={
+ general shadow={%
+ /utils/exec={\let\tikz@lib@shadow@fill=\tikz@fillcolor\let\tikz@lib@shadow@draw=\tikz@strokecolor},
+ shadow scale=1,
+ shadow xshift=.5ex,
+ shadow yshift=.5ex,
+ fill=\tikz@lib@shadow@fill,
+ draw=\tikz@lib@shadow@draw,
+ #1,
+ shadow xshift/.expanded=2*\pgfkeysvalueof{/tikz/shadow xshift},
+ shadow yshift/.expanded=2*\pgfkeysvalueof{/tikz/shadow yshift},
+ },
+ general shadow={%
+ /utils/exec={\let\tikz@lib@shadow@fill=\tikz@fillcolor\let\tikz@lib@shadow@draw=\tikz@strokecolor},
+ shadow scale=1,
+ shadow xshift=.5ex,
+ shadow yshift=.5ex,
+ fill=\tikz@lib@shadow@fill,
+ draw=\tikz@lib@shadow@draw,
+ #1,
+ },
+ }
+}%
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryshapes.arrows.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryshapes.arrows.code.tex
new file mode 100644
index 0000000000..c20e6a73cc
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryshapes.arrows.code.tex
@@ -0,0 +1,16 @@
+% Copyright 2018 by Till Tantau
+%
+% 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{tikzlibraryshapes.arrows.code.tex}
+
+\usepgflibrary{shapes.arrows}%
+
+\pgfkeys{/tikz/arrow box arrows/.code={\pgf@lib@arrowbox@parsearrows{#1}}}%
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryshapes.callouts.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryshapes.callouts.code.tex
new file mode 100644
index 0000000000..2a3de5548a
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryshapes.callouts.code.tex
@@ -0,0 +1,35 @@
+% Copyright 2018 by 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.
+
+\usepgflibrary{shapes.callouts}%
+
+\pgfkeys{/tikz/callout absolute pointer/.code={%
+ \tikz@scan@one@point\tikz@lib@callout@checkforplus#1\relax%
+ }%
+}%
+
+\def\tikz@lib@callout@checkforplus#1{%
+ \pgfutil@ifnextchar+{\def\tikz@lib@callout@originalpoint{#1}\tikz@lib@callout@scan@relative}%
+ {\pgf@lib@callout@makeabsolutepointer{#1}}}%
+
+\def\tikz@lib@callout@scan@relative+{%
+ \pgfutil@ifnextchar+{\tikz@lib@callout@scan@plusplus}{\tikz@lib@callout@scan@plus}}%
+\def\tikz@lib@callout@scan@plusplus+{\tikz@scan@one@point\tikz@lib@callout@add}%
+\def\tikz@lib@callout@scan@plus{\tikz@scan@one@point\tikz@lib@callout@add}%
+\def\tikz@lib@callout@add#1{%
+ \expandafter\pgf@lib@callout@makeabsolutepointer\expandafter{%
+ \expandafter\pgfpointadd\expandafter{\tikz@lib@callout@originalpoint}{#1}}%
+}%
+
+\pgfkeys{/tikz/callout relative pointer/.code={%
+ \tikz@scan@one@point\pgf@lib@callout@makerelativepointer#1\relax%
+ }%
+}%
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryshapes.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryshapes.code.tex
new file mode 100644
index 0000000000..2efb5c3308
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryshapes.code.tex
@@ -0,0 +1,19 @@
+% Copyright 2018 by Till Tantau
+%
+% 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{tikzlibraryshapes.code.tex}
+
+\usetikzlibrary{shapes.geometric}%
+\usetikzlibrary{shapes.misc}%
+\usetikzlibrary{shapes.symbols}%
+\usetikzlibrary{shapes.arrows}%
+\usetikzlibrary{shapes.callouts}%
+\usetikzlibrary{shapes.multipart}%
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryshapes.gates.logic.IEC.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryshapes.gates.logic.IEC.code.tex
new file mode 100644
index 0000000000..c34229b137
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryshapes.gates.logic.IEC.code.tex
@@ -0,0 +1,38 @@
+% Copyright 2018 by 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{tikzlibraryshapes.gates.logic.IEC.code.tex}
+
+\usepgflibrary{shapes.gates.logic.IEC}%
+
+\tikzset{%
+ use IEC style logic gates/.code={%
+ \tikzset{%
+ and gate/.style={shape=and gate IEC},
+ nand gate/.style={shape=nand gate IEC},
+ or gate/.style={shape=or gate IEC},
+ nor gate/.style={shape=nor gate IEC},
+ xor gate/.style={shape=xor gate IEC},
+ xnor gate/.style={shape=xnor gate IEC},
+ not gate/.style={shape=not gate IEC},
+ buffer gate/.style={shape=buffer gate IEC},
+ and gate symbol/.style={and gate IEC symbol={##1}},
+ nand gate symbol/.style={nand gate IEC symbol={##1}},
+ or gate symbol/.style={or gate IEC symbol={##1}},
+ nor gate symbol/.style={nor gate IEC symbol={##1}},
+ xor gate symbol/.style={xor gate IEC symbol={##1}},
+ xnor gate symbol/.style={xnor gate IEC symbol={##1}},
+ not gate symbol/.style={not gate IEC symbol={##1}},
+ buffer gate symbol/.style={buffer gate IEC symbol={##1}},
+ logic gate symbol align/.style={/pgf/logic gate IEC symbol align={##1}},
+ logic gate symbol color/.style={/pgf/logic gate IEC symbol color={##1}}
+ }%
+ }%
+}%
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryshapes.gates.logic.US.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryshapes.gates.logic.US.code.tex
new file mode 100644
index 0000000000..66503414a0
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryshapes.gates.logic.US.code.tex
@@ -0,0 +1,40 @@
+% Copyright 2018 by 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{tikzlibraryshapes.gates.logic.US.code.tex}
+
+\usepgflibrary{shapes.gates.logic.US}%
+
+\tikzset{%
+ use US style logic gates/.code={%
+ \tikzset{%
+ and gate/.style={shape=and gate US},
+ nand gate/.style={shape=nand gate US},
+ or gate/.style={shape=or gate US},
+ nor gate/.style={shape=nor gate US},
+ xor gate/.style={shape=xor gate US},
+ xnor gate/.style={shape=xnor gate US},
+ not gate/.style={shape=not gate US},
+ buffer gate/.style={shape=buffer gate US}
+ }%
+ },
+ use CDH style logic gates/.code={%
+ \tikzset{%
+ and gate/.style={shape=and gate CDH},
+ nand gate/.style={shape=nand gate CDH},
+ or gate/.style={shape=or gate US},
+ nor gate/.style={shape=nor gate US},
+ xor gate/.style={shape=xor gate US},
+ xnor gate/.style={shape=xnor gate US},
+ not gate/.style={shape=not gate US},
+ buffer gate/.style={shape=buffer gate US}
+ }
+ }
+}%
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryshapes.geometric.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryshapes.geometric.code.tex
new file mode 100644
index 0000000000..3e923b940f
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryshapes.geometric.code.tex
@@ -0,0 +1,14 @@
+% Copyright 2018 by Till Tantau
+%
+% 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{tikzlibraryshapes.geometric.code.tex}
+
+\usepgflibrary{shapes.geometric}%
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryshapes.misc.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryshapes.misc.code.tex
new file mode 100644
index 0000000000..617c5f4034
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryshapes.misc.code.tex
@@ -0,0 +1,14 @@
+% Copyright 2018 by Till Tantau
+%
+% 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{tikzlibraryshapes.misc.code.tex}
+
+\usepgflibrary{shapes.misc}%
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryshapes.multipart.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryshapes.multipart.code.tex
new file mode 100644
index 0000000000..91183aaf78
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryshapes.multipart.code.tex
@@ -0,0 +1,36 @@
+% 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{tikzlibraryshapes.multipart.code.tex}
+
+\usepgflibrary{shapes.multipart}%
+
+\pgfkeys{/tikz/rectangle split/parts/.code={%
+ \pgfkeys{/pgf/rectangle split parts={#1}}%
+ }%
+}%
+
+\pgfkeys{/tikz/rectangle split use custom fill/.code={%
+ \pgfkeys{/pgf/rectangle split use custom fill={#1}}%
+ \pgfkeys{/tikz/fill=none}}%
+}%
+
+\pgfkeys{/tikz/rectangle split draw splits/.is if=pgfrectanglesplitdrawsplits}%
+
+\pgfkeys{/tikz/rectangle split part align/.code={%
+ \pgfkeys{/pgf/rectangle split part align={#1}}%
+ }%
+}%
+
+\pgfkeys{/tikz/rectangle split part fill/.code={%
+ \pgfkeys{/pgf/rectangle split part fill={#1}}%
+ }%
+}%
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryshapes.symbols.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryshapes.symbols.code.tex
new file mode 100644
index 0000000000..b616b54c88
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryshapes.symbols.code.tex
@@ -0,0 +1,17 @@
+% Copyright 2018 by Till Tantau
+%
+% 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{tikzlibraryshapes.symbols.code.tex}
+
+\pgfkeysifdefined{/tikz/shape border uses incircle}{}{%
+ \pgfkeys{/tikz/shape border uses incircle/.is if=pgfshapeborderusesincircle}}%
+
+\usepgflibrary{shapes.symbols}%
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarysnakes.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarysnakes.code.tex
new file mode 100644
index 0000000000..9acb6de915
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarysnakes.code.tex
@@ -0,0 +1,77 @@
+% Copyright 2018 by Till Tantau
+%
+% 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{tikzlibrarysnakes.code.tex}
+
+\pgfwarning{Snakes have been superseded by
+decorations. Please use the decoration libraries instead of the snakes
+library}%
+
+\usetikzlibrary{decorations.pathmorphing,decorations.pathreplacing,decorations.shapes}%
+
+
+% Old snakes stuff:
+
+\tikzoption{snake}[]{%
+ \def\tikz@@snake{#1}%
+ \ifx\tikz@@snake\pgfutil@empty%
+ \tikz@snakedtrue%
+ \else%
+ \ifx\tikz@@snake\tikz@nonetext%
+ \tikz@snakedfalse%
+ \else%
+ \tikz@snakedtrue%
+ \let\tikz@snake=\tikz@@snake%
+ \fi%
+ \fi}%
+
+\tikzoption{raise snake}{\def\pgf@snake@raise{\pgftransformyshift{#1}}}%
+\tikzoption{mirror snake}[true]{%
+ \csname if#1\endcsname
+ \def\pgf@snake@mirror{\pgftransformyscale{-1}}%
+ \else%
+ \let\pgf@snake@mirror=\pgfutil@empty%
+ \fi
+}%
+
+\tikzoption{gap before snake}{\def\tikz@presnake{{moveto}{#1}{\noexpand\tikz@snake@install@trans}{}}}%
+\tikzoption{line before snake}{\def\tikz@presnake{{lineto}{#1}{\noexpand\tikz@snake@install@trans}{}}}%
+
+\tikzoption{gap after snake}{\def\tikz@postsnake{{moveto}{#1}{\noexpand\tikz@snake@install@trans}{}}\def\tikz@mainsnakelength{\pgfsnakeremainingdistance-#1}}%
+\tikzoption{line after snake}{\def\tikz@postsnake{{lineto}{#1}{\noexpand\tikz@snake@install@trans}{}}\def\tikz@mainsnakelength{\pgfsnakeremainingdistance-#1}}%
+
+\tikzoption{gap around snake}{%
+ \def\tikz@presnake{{moveto}{#1}{\noexpand\tikz@snake@install@trans}{}}%
+ \def\tikz@postsnake{{moveto}{#1}{\noexpand\tikz@snake@install@trans}{}}%
+ \def\tikz@mainsnakelength{\pgfsnakeremainingdistance-#1}%
+}%
+\tikzoption{line around snake}{%
+ \def\tikz@presnake{{lineto}{#1}{\noexpand\tikz@snake@install@trans}{}}%
+ \def\tikz@postsnake{{lineto}{#1}{\noexpand\tikz@snake@install@trans}{}}%
+ \def\tikz@mainsnakelength{\pgfsnakeremainingdistance-#1}%
+}%
+\let\pgf@snake@mirror=\pgfutil@empty
+\let\pgf@snake@raise=\pgfutil@empty
+
+\def\tikz@snake@install@trans{\pgfsetsnakesegmenttransformation{\pgf@snake@mirror\pgf@snake@raise}}%
+
+\def\tikz@snake{zigzag}%
+
+\let\tikz@presnake=\pgfutil@empty
+\let\tikz@postsnake=\pgfutil@empty
+\def\tikz@mainsnakelength{\pgfsnakeremainingdistance}%
+
+
+\tikzset{snake triangles 45/.style= {snake=triangles,segment object length=2.41421356\pgfsnakesegmentamplitude}}%
+\tikzset{snake triangles 60/.style= {snake=triangles,segment object length=1.73205081\pgfsnakesegmentamplitude}}%
+\tikzset{snake triangles 90/.style= {snake=triangles,segment object length=\pgfsnakesegmentamplitude}}%
+
+
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryspy.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryspy.code.tex
new file mode 100644
index 0000000000..a5fea2a79b
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryspy.code.tex
@@ -0,0 +1,134 @@
+% Copyright 2019 by Till Tantau
+%
+% 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{tikzlibraryspy.code.tex}
+
+
+
+% Spy styles
+
+\tikzset{
+ spy using outlines/.style={
+ spy scope={
+ every spy on node/.style={very thin,draw},
+ every spy in node/.style={thick,draw},
+ #1
+ }
+ },
+ spy using overlays/.style={
+ spy scope={
+ every spy on node/.style={fill,fill opacity=0.2,text opacity=1},
+ every spy in node/.style={fill,fill opacity=0.2,text opacity=1},
+ #1
+ }
+ },
+ connect spies/.style={
+ spy connection path={\draw[thin] (tikzspyonnode) -- (tikzspyinnode);}
+ }
+}%
+
+\newbox\tikz@lib@spybox
+
+\let\tikz@lib@spy@collection=\pgfutil@empty%
+
+\tikzset{spy scope/.style={
+ size/.style={minimum size={##1}},
+ height/.style={minimum height={##1}},
+ width/.style={minimum width={##1}},
+ execute at begin scope={%
+ \let\tikz@lib@spy@save=\tikz@lib@spy@collection%
+ \setbox\tikz@lib@spybox=\hbox\bgroup\bgroup%
+ \let\spy=\tikz@lib@spy@parse},
+ execute at end scope={%
+ \egroup\egroup%
+ {%
+ \copy\tikz@lib@spybox%
+ \tikz@lib@spy@collection%
+ }%
+ \global\let\tikz@lib@spy@collection=\tikz@lib@spy@save%
+ },%
+ tikz@lib@spy@style/.style={#1},
+ tikz@lib@reset@gs
+ },
+ lens/.store in=\tikz@lib@spy@lens,
+ lens=,
+ magnification/.style={lens={scale={#1}}},
+ spy connection path/.store in=\tikz@lib@spy@path,
+ spy connection path=
+}%
+
+\tikzset{
+ tikz@lib@reset@gs/.style={black,thin,solid,opaque,line cap=butt,line join=miter}
+}%
+
+\def\tikz@lib@spy@parse{%
+ \pgfutil@ifnextchar[{\tikz@lib@spy@parse@opt}{\tikz@lib@spy@parse@opt[]}%]
+}%
+\def\tikz@lib@spy@parse@opt[#1]{
+ \pgfutil@ifnextchar x{\tikz@lib@spy@parse@opta[#1]}{\tikz@lib@spy@parse@opta[#1]}%]
+}%
+\def\tikz@lib@spy@parse@opta[#1]on#2in node#3;{%
+ \pgfutil@g@addto@macro\tikz@lib@spy@collection{\tikz@lib@spy@do{#1}{#2}{#3}}%
+}%
+
+\def\tikz@lib@spy@do#1#2#3{%
+ \scope[tikz@lib@spy@style,#1]
+ \node [alias=tikzspyonnode,inner sep=0pt,outer sep=0pt,every spy on node/.try,
+ /utils/exec={
+ {%
+ \let\tikz@transform=\relax
+ \pgftransformreset%
+ \expandafter\tikzset\expandafter{\tikz@lib@spy@lens}
+ \pgftransforminvert%
+ \pgfgettransformentries\a\b\c\d\e\f%
+ \global\let\pgf@lib@svg@a=\a%
+ \global\let\pgf@lib@svg@b=\b%
+ \global\let\pgf@lib@svg@c=\c%
+ \global\let\pgf@lib@svg@d=\d%
+ }%
+ \tikz@addtransform{%
+ \tikz@scan@one@point\pgftransformshift#2%
+ \pgftransformcm{\pgf@lib@svg@a}{\pgf@lib@svg@b}{\pgf@lib@svg@c}{\pgf@lib@svg@d}{\pgfpointorigin}%
+ }
+ }]{};
+ \expandafter\pgfutil@switch\expandafter\pgfutil@ifstrequal\expandafter{\tikz@anchor}{%
+ {north} {\def\tikz@spy@anchor{south}}%
+ {north east}{\def\tikz@spy@anchor{south west}}%
+ {east} {\def\tikz@spy@anchor{west}}%
+ {south east}{\def\tikz@spy@anchor{north west}}%
+ {south} {\def\tikz@spy@anchor{north}}%
+ {south west}{\def\tikz@spy@anchor{north east}}%
+ {west} {\def\tikz@spy@anchor{east}}%
+ {north west}{\def\tikz@spy@anchor{south east}}%
+ }{}{\def\tikz@spy@anchor{center}}%
+ \node [alias=tikzspyinnode,inner sep=0pt,outer sep=0pt,at={#2},every spy in node/.try,
+ path picture={\node[anchor=\tikz@spy@anchor,tikz@lib@reset@gs]{\nullfont%
+ \pgfpicture\relax\pgfsetbaseline{default}\pgfsettrimleft{default}\pgfsettrimright{default}%
+ \pgftransformreset%
+ \let\tikz@transform=\relax%
+ \expandafter\tikzset\expandafter{\tikz@lib@spy@lens}%
+ \pgflowlevelsynccm%
+ \tikz@scan@one@point\tikz@lib@spy@shift#2%
+ \pgflowlevelsynccm%
+ \copy\tikz@lib@spybox%
+ \endpgfpicture};}]#3{};
+ \tikz@lib@spy@path
+ \endscope
+}%
+
+\def\tikz@lib@spy@shift#1{%
+ \pgf@process{#1}%
+ \pgf@x=-\pgf@x%
+ \pgf@y=-\pgf@y%
+ \pgftransformshift{}%
+}%
+
+
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarysvg.path.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarysvg.path.code.tex
new file mode 100644
index 0000000000..521bf96b60
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarysvg.path.code.tex
@@ -0,0 +1,33 @@
+% Copyright 2018 by Till Tantau
+%
+% 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{tikzlibrarysvg.path.code.tex}
+
+\usepgflibrary{svg.path}%
+
+\def\tikz@svg@path vg{\pgfutil@ifnextchar[\tikz@svg@@path{\tikz@svg@@path[]}}%}%
+
+\def\tikz@svg@@path[#1]{\pgfutil@ifnextchar"{\tikz@svg@@path@old{#1}}{\tikz@svg@@path@new{#1}}}%
+\def\tikz@svg@@path@new#1#2{\tikz@svg@@path@old{#1}"#2"}%
+\def\tikz@svg@@path@old#1"#2"{
+ {%
+ \tikzset{#1}%
+ \pgfpathsvg{#2}%
+ }%
+ {
+ \pgftransforminvert
+ \pgf@process{\pgfpointtransformed{\pgfqpoint{\pgf@path@lastx}{\pgf@path@lasty}}}
+ }
+ \tikz@lastx=\pgf@x%
+ \tikz@lasty=\pgf@y%
+ \tikz@lastxsaved=\tikz@lastx%
+ \tikz@lastysaved=\tikz@lasty%
+ \tikz@updatecurrenttrue%
+ \tikz@scan@next@command
+}%
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarythrough.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarythrough.code.tex
new file mode 100644
index 0000000000..986235b75b
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarythrough.code.tex
@@ -0,0 +1,36 @@
+% Copyright 2018 by Till Tantau
+%
+% 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{tikzlibrarythrough.code.tex}
+
+
+
+\tikzset{circle through/.code={%
+ \pgfkeysalso{shape=circle,inner sep=0pt,outer sep=0pt}%
+ % Save transformations (correct?)
+ \pgfgettransform{\tikz@lib@saved@transform}%
+ \tikz@scan@one@point\tikz@lib@circle@through#1%
+ }}%
+
+\def\tikz@lib@circle@through#1{%
+ \tikz@addoption{%
+ {%
+ \pgfsettransform{\tikz@lib@saved@transform}%
+ \pgf@process{\pgfpointtransformed{#1}}%
+ \pgf@xa=\pgf@x%
+ \pgf@ya=\pgf@y%
+ \pgf@process{\pgfpointtransformed{\tikz@node@at}}%
+ \advance\pgf@xa by-\pgf@x%
+ \advance\pgf@ya by-\pgf@y%
+ \pgfmathparse{2*veclen(\the\pgf@xa,\the\pgf@ya)}%
+ \global\let\tikz@lib@circle@size=\pgfmathresult%
+ }%
+ \pgfset{/pgf/minimum size/.expanded=\tikz@lib@circle@size}%
+ }%
+}%
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarytopaths.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarytopaths.code.tex
new file mode 100644
index 0000000000..ecf850ab40
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarytopaths.code.tex
@@ -0,0 +1,381 @@
+% Copyright 2020 by Till Tantau
+%
+% 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{tikzlibrarytopaths.code.tex}
+
+
+% Move to
+
+\tikzset{move to/.style= {to path={(\tikztotarget) \tikztonodes}}}
+
+
+% Straight to
+
+\tikzset{line to/.style= {to path={-- (\tikztotarget) \tikztonodes}}}
+
+
+% Curved to
+
+\tikzset{every curve to/.style= {}}
+\tikzset{curve to/.style= {to path=\tikz@to@curve@path}}
+
+\tikzoption{bend angle}{\pgfmathsetmacro\tikz@to@bend{#1}}
+
+\tikzoption{bend left}[]{%
+ \def\pgf@temp{#1}%
+ \ifx\pgf@temp\pgfutil@empty%
+ \else%
+ \pgfmathsetmacro\tikz@to@bend{#1}%
+ \fi%
+ \let\tikz@to@out=\tikz@to@bend%
+ \pgfmathsetmacro\tikz@to@in{180-(\tikz@to@out)}%
+ \tikz@to@switch@on%
+ \tikz@to@relativetrue%
+}
+
+\tikzoption{bend right}[]{%
+ \def\pgf@temp{#1}%
+ \ifx\pgf@temp\pgfutil@empty%
+ \else%
+ \pgfmathsetmacro\tikz@to@bend{#1}%
+ \fi%
+ % Now, negate
+ \pgfmathsetmacro\tikz@to@out{-(\tikz@to@bend)}
+ \pgfmathsetmacro\tikz@to@in{180-(\tikz@to@out)}
+ \tikz@to@switch@on%
+ \tikz@to@relativetrue%
+}
+
+\tikzoption{relative}[true]{\csname tikz@to@relative#1\endcsname}
+\newif\iftikz@to@relative
+\tikz@to@relativefalse
+
+\tikzoption{in}{\def\tikz@to@in{#1}\tikz@to@switch@on}
+\tikzoption{out}{\def\tikz@to@out{#1}\tikz@to@switch@on}
+
+\tikzoption{in looseness}{\tikz@to@set@in@looseness{#1}}
+\tikzoption{out looseness}{\tikz@to@set@out@looseness{#1}}
+\tikzoption{looseness}{\tikz@to@set@in@looseness{#1}\tikz@to@set@out@looseness{#1}}
+
+\tikzoption{in control}{\tikz@to@set@in@control{#1}}
+\tikzoption{out control}{\tikz@to@set@out@control{#1}}
+\tikzoption{controls}{\tikz@to@parse@controls#1\pgf@stop}
+
+\tikzoption{in min distance}{\tikz@to@set@distances{#1}{}{}{}}
+\tikzoption{in max distance}{\tikz@to@set@distances{}{#1}{}{}}
+\tikzoption{in distance}{\tikz@to@set@distances{#1}{#1}{}{}}
+\tikzoption{out min distance}{\tikz@to@set@distances{}{}{#1}{}}
+\tikzoption{out max distance}{\tikz@to@set@distances{}{}{}{#1}}
+\tikzoption{out distance}{\tikz@to@set@distances{}{}{#1}{#1}}
+\tikzoption{min distance}{\tikz@to@set@distances{#1}{}{#1}{}}
+\tikzoption{max distance}{\tikz@to@set@distances{}{#1}{}{#1}}
+\tikzoption{distance}{\tikz@to@set@distances{#1}{#1}{#1}{#1}}
+
+\def\tikz@to@set@distances#1#2#3#4{%
+ \tikz@to@setifnotempy{#1}{\tikz@to@in@min}{\let\tikz@to@end@compute=\tikz@to@end@compute@looseness}%
+ \tikz@to@setifnotempy{#2}{\tikz@to@in@max}{\let\tikz@to@end@compute=\tikz@to@end@compute@looseness}%
+ \tikz@to@setifnotempy{#3}{\tikz@to@out@min}{\let\tikz@to@start@compute=\tikz@to@start@compute@looseness}%
+ \tikz@to@setifnotempy{#4}{\tikz@to@out@max}{\let\tikz@to@start@compute=\tikz@to@start@compute@looseness}%
+ \tikz@to@switch@on%
+}
+
+\def\tikz@to@setifnotempy#1#2#3{%
+ \def\pgf@temp{#1}%
+ \ifx\pgf@temp\pgfutil@empty\else\def#2{#1}#3\fi%
+}
+
+
+\def\tikz@to@set@in@looseness#1{%
+ \pgfmathsetmacro\tikz@to@in@looseness{#1}%
+ \let\tikz@to@end@compute=\tikz@to@end@compute@looseness%
+ \tikz@to@switch@on%
+}
+\def\tikz@to@set@out@looseness#1{%
+ \pgfmathsetmacro\tikz@to@out@looseness{#1}%
+ \let\tikz@to@start@compute=\tikz@to@start@compute@looseness%
+ \tikz@to@switch@on%
+}
+
+\def\tikz@to@parse@controls#1and#2\pgf@stop{\tikz@to@set@in@control{#2}\tikz@to@set@out@control{#1}}
+
+\def\tikz@to@set@in@control#1{%
+ \def\tikz@to@in@control{#1}%
+ \let\tikz@to@end@compute=\tikz@to@end@compute@control%
+ \tikz@to@switch@on%
+}
+\def\tikz@to@set@out@control#1{%
+ \def\tikz@to@out@control{#1}%
+ \let\tikz@to@start@compute=\tikz@to@start@compute@control%
+ \tikz@to@switch@on%
+}
+
+
+\def\tikz@to@bend{30}
+
+\def\tikz@to@out{45}
+\def\tikz@to@in{135}
+
+\def\tikz@to@out@looseness{1}
+\def\tikz@to@in@looseness{1}
+
+\def\tikz@to@in@min{0pt}
+\def\tikz@to@in@max{10000pt}
+\def\tikz@to@out@min{0pt}
+\def\tikz@to@out@max{10000pt}
+
+\def\tikz@to@switch@on{\let\tikz@to@path=\tikz@to@curve@path}
+
+\def\tikz@to@curve@path{%
+ [every curve to]
+ \pgfextra{\iftikz@to@relative\tikz@to@compute@relative\else\tikz@to@compute\fi}
+ \tikz@computed@path
+ \pgfextra{\tikz@updatenexttrue\tikz@updatecurrenttrue}%
+ \tikztonodes%
+}
+
+\def\tikz@to@modify#1#2{%
+ \pgfutil@ifundefined{pgf@sh@ns@#1}
+ {}%
+ {\edef#1{#1.#2}}
+}%
+
+\def\tikz@to@compute{%
+ \let\tikz@tofrom=\tikztostart%
+ \let\tikz@toto=\tikztotarget%
+ \tikz@to@modify\tikz@tofrom\tikz@to@out%
+ \tikz@to@modify\tikz@toto\tikz@to@in%
+ \ifx\tikz@to@start@compute\tikz@to@start@compute@looseness%
+ \tikz@to@compute@distance%
+ \else%
+ \ifx\tikz@from@start@compute\tikz@to@start@compute@looseness%
+ \tikz@to@compute@distance%
+ \fi%
+ \fi%
+ \tikz@to@start@compute%
+ \tikz@to@end@compute%
+ \edef\tikz@computed@path{.. controls \tikz@computed@start and \tikz@computed@end .. (\tikztotarget)}
+}
+
+\def\tikz@to@compute@distance{\tikz@scan@one@point\tikz@@to@compute@distance(\tikz@tofrom)}
+\def\tikz@@to@compute@distance#1{%
+ \def\tikz@first@point{#1}%
+ \tikz@scan@one@point\tikz@@@to@compute@distance(\tikz@toto)}
+\def\tikz@@@to@compute@distance#1{%
+ \iftikz@updatecurrent\else
+ \tikz@updatenextfalse
+ \fi
+ \def\tikz@second@point{#1}%
+ \tikz@to@compute@distance@main%
+}
+\def\tikz@to@compute@distance@main{%
+ \pgf@process{\pgfpointdiff{\tikz@first@point}{\tikz@second@point}}%
+ \ifdim\pgf@x<0pt\pgf@xa=-\pgf@x\else\pgf@xa=\pgf@x\fi%
+ \ifdim\pgf@y<0pt\pgf@ya=-\pgf@y\else\pgf@ya=\pgf@y\fi%
+ %
+ % Calculate length of second to first 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=0.3915\pgf@xa%
+ \pgf@xa=\tikz@to@out@looseness\pgf@x%
+ \pgf@xb=\tikz@to@in@looseness\pgf@x%
+ % Adjust as necessary
+ \pgfmathsetlength{\pgf@ya}{\tikz@to@out@min}
+ \ifdim\pgf@xa<\pgf@ya%
+ \pgf@xa=\pgf@ya%
+ \fi%
+ \pgfmathsetlength{\pgf@ya}{\tikz@to@out@max}
+ \ifdim\pgf@xa>\pgf@ya%
+ \pgf@xa=\pgf@ya%
+ \fi%
+ \pgfmathsetlength{\pgf@ya}{\tikz@to@in@min}
+ \ifdim\pgf@xb<\pgf@ya%
+ \pgf@xb=\pgf@ya%
+ \fi%
+ \pgfmathsetlength{\pgf@ya}{\tikz@to@in@max}
+ \ifdim\pgf@xb>\pgf@ya%
+ \pgf@xb=\pgf@ya%
+ \fi%
+}
+
+\def\tikz@to@start@compute@looseness{%
+ \edef\tikz@computed@start{([shift=({\tikz@to@out}:\the\pgf@xa)]\tikz@tofrom)}%
+}
+\def\tikz@to@end@compute@looseness{%
+ \edef\tikz@computed@end{([shift=({\tikz@to@in}:\the\pgf@xb)]\tikz@toto)}%
+}
+\def\tikz@to@start@compute@control{%
+ \let\tikz@computed@start=\tikz@to@out@control%
+}
+\def\tikz@to@end@compute@control{%
+ \let\tikz@computed@end=\tikz@to@in@control%
+}
+
+\let\tikz@to@start@compute=\tikz@to@start@compute@looseness%
+\let\tikz@to@end@compute=\tikz@to@end@compute@looseness%
+
+
+
+
+% Relative curves
+
+\def\tikz@to@compute@relative{%
+ \tikz@scan@one@point\tikz@@to@compute@relative(\tikztostart)%
+}
+\def\tikz@@to@compute@relative#1{%
+ \def\tikz@tofrom{#1}%
+ \tikz@scan@one@point\tikz@@@to@compute@relative(\tikztotarget)%
+}
+\def\tikz@@@to@compute@relative#1{%
+ \def\tikz@toto{#1}%
+ \begingroup
+ %
+ % Adjust start and target so that they lie on the border in the
+ % rotated coordinate system.
+ %
+ \pgfutil@ifundefined{pgf@sh@ns@\tikztostart}
+ {%
+ \let\tikz@first@point=\tikz@tofrom%
+ \let\tikz@tostart@tikz=\pgfutil@empty
+ }%
+ {%
+ % Start computation of new start.
+ {%
+ \tikz@tofrom%
+ \pgf@xc=\pgf@x%
+ \pgf@yc=\pgf@y%
+ {%
+ \pgftransformreset%
+ \pgftransformshift{\pgfqpoint{\pgf@xc}{\pgf@yc}}%
+ \pgftransformrotate{\tikz@to@out}%
+ \pgftransformshift{\pgfqpoint{-\pgf@xc}{-\pgf@yc}}%
+ \pgf@process{\pgfpointtransformed{\tikz@toto}}%
+ }%
+ \pgf@xc=\pgf@x%
+ \pgf@yc=\pgf@y%
+ \pgfpointshapeborder{\tikztostart}{\pgfqpoint{\pgf@xc}{\pgf@yc}}%
+ \xdef\tikz@tofrom@smuggle{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}
+ }%
+ \let\tikz@first@point=\tikz@tofrom@smuggle%
+ \tikz@first@point%
+ \edef\tikz@tostart@tikz{(\the\pgf@x,\the\pgf@y)}%
+ }%
+ \pgfutil@ifundefined{pgf@sh@ns@\tikztotarget}
+ {%
+ \let\tikz@second@point=\tikz@toto%
+ }%
+ {%
+ % Start computation of new target.
+ {%
+ \tikz@toto%
+ \pgf@xc=\pgf@x%
+ \pgf@yc=\pgf@y%
+ {%
+ \pgftransformreset%
+ \pgftransformshift{\pgfqpoint{\pgf@xc}{\pgf@yc}}%
+ \pgftransformrotate{180}%
+ \pgftransformrotate{\tikz@to@in}%
+ \pgftransformshift{\pgfqpoint{-\pgf@xc}{-\pgf@yc}}%
+ \pgf@process{\pgfpointtransformed{\tikz@tofrom}}%
+ }%
+ \pgf@xc=\pgf@x%
+ \pgf@yc=\pgf@y%
+ \pgfpointshapeborder{\tikztotarget}{\pgfqpoint{\pgf@xc}{\pgf@yc}}%
+ \xdef\tikz@toto@smuggle{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}
+ }%
+ \let\tikz@second@point=\tikz@toto@smuggle%
+ }%
+ \tikz@second@point%
+ \edef\tikz@totarget@tikz{(\the\pgf@x,\the\pgf@y)}%
+ %
+ % Compute distances
+ %
+ \tikz@to@compute@distance@main%
+ \edef\tikz@to@first@distance{\the\pgf@xa}%
+ \edef\tikz@to@second@distance{\the\pgf@xb}%
+ %
+ % Next step: Establish a transformed coordinate system so that the (modified)
+ % start is at the origin and the (modified) target is at (1,0)
+ %
+ \pgftransformreset%
+ \pgf@process{\tikz@first@point}%
+ \pgf@xa=\pgf@x%
+ \pgf@ya=\pgf@y%
+ \pgf@process{\tikz@second@point}%
+ \advance\pgf@x by-\pgf@xa%
+ \advance\pgf@y by-\pgf@ya%
+ \pgfpointnormalised{}%
+ \pgf@xc=\pgf@x%
+ \pgf@yc=\pgf@y%
+ \pgf@xb=-\pgf@x%
+ \pgf@yb=-\pgf@y%
+ %
+ % Now compute the control points.
+ %
+ {%
+ \pgftransformshift{\tikz@first@point}%
+ \pgftransformcm{\pgf@sys@tonumber\pgf@xc}{\pgf@sys@tonumber\pgf@yc}{\pgf@sys@tonumber\pgf@yb}{\pgf@sys@tonumber\pgf@xc}%
+ {\pgfpointorigin}%
+ \pgf@process{\pgfpointtransformed{\pgfpointpolar{\tikz@to@out}{\tikz@to@first@distance}}}%
+ \xdef\tikz@computed@start{(\the\pgf@x,\the\pgf@y)}%
+ }
+ {%
+ \pgftransformshift{\tikz@second@point}%
+ \pgftransformcm{\pgf@sys@tonumber\pgf@xc}{\pgf@sys@tonumber\pgf@yc}{\pgf@sys@tonumber\pgf@yb}{\pgf@sys@tonumber\pgf@xc}%
+ {\pgfpointorigin}%
+ \pgf@process{\pgfpointtransformed{\pgfpointpolar{\tikz@to@in}{\tikz@to@second@distance}}}%
+ \xdef\tikz@computed@end{(\the\pgf@x,\the\pgf@y)}%
+ }
+ \xdef\tikz@computed@path{
+ \tikz@tostart@tikz
+ .. controls \tikz@computed@start and \tikz@computed@end ..
+ \tikz@totarget@tikz}%
+ \endgroup
+}
+
+
+
+% Loops
+
+\tikzset{loop/.style= {to path={
+ \pgfextra{\let\tikztotarget=\tikztostart}
+ [looseness=8,min distance=5mm,every loop]
+ \tikz@to@curve@path
+ }}}
+
+\tikzset{every loop/.style= {->,shorten >=1pt}}
+
+\tikzset{loop right/.style= {right,out=15,in=-15,loop}}
+\tikzset{loop above/.style= {above,out=105,in=75,loop}}
+\tikzset{loop left/.style= {left,out=195,in=165,loop}}
+\tikzset{loop below/.style= {below,out=285,in=255,loop}}
+
+
+
+
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarytrees.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarytrees.code.tex
new file mode 100644
index 0000000000..d457f979b9
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibrarytrees.code.tex
@@ -0,0 +1,109 @@
+% Copyright 2019 by Till Tantau
+%
+% 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{tikzlibrarytrees.code.tex}
+
+
+
+%
+% Three point growth
+%
+
+\tikzoption{grow via three points}{\let\tikz@grow=\tikz@grow@three\tikz@parse@three#1}%
+
+\def\tikz@parse@three one child at#1(#2)#3and two children at#4(#5)#6and#7(#8){%
+ \def\tikz@tree@one@child{\tikz@scan@one@point\pgf@process(#2)}
+ \def\tikz@tree@left@child{\tikz@scan@one@point\pgf@process(#5)}
+ \def\tikz@tree@right@child{\tikz@scan@one@point\pgf@process(#8)}
+}%
+
+\def\tikz@grow@three{%
+ \pgf@process{\tikz@tree@one@child}%
+ \pgf@xa=\pgf@x%
+ \pgf@ya=\pgf@y%
+ \pgf@process{\tikz@tree@left@child}%
+ \pgf@xb=\pgf@x%
+ \pgf@yb=\pgf@y%
+ \advance\pgf@xb by-\pgf@xa%
+ \advance\pgf@yb by-\pgf@ya%
+ \pgf@process{\tikz@tree@right@child}%
+ \pgf@xc=\pgf@x%
+ \pgf@yc=\pgf@y%
+ \advance\pgf@xc by-\pgf@xa%
+ \advance\pgf@yc by-\pgf@ya%
+ \advance\pgf@xc by-\pgf@xb%
+ \advance\pgf@yc by-\pgf@yb%
+ \advance\tikznumberofchildren by-1\relax%
+ \pgf@xb=\tikznumberofchildren\pgf@xb\relax%
+ \pgf@yb=\tikznumberofchildren\pgf@yb\relax%
+ \advance\tikznumberofcurrentchild by-1\relax%
+ \pgf@xc=\tikznumberofcurrentchild\pgf@xc\relax%
+ \pgf@yc=\tikznumberofcurrentchild\pgf@yc\relax%
+ \advance\pgf@xa by\pgf@xb%
+ \advance\pgf@xa by\pgf@xc%
+ \advance\pgf@ya by\pgf@yb%
+ \advance\pgf@ya by\pgf@yc%
+ \edef\pgf@temp{\noexpand\pgftransformshift{\noexpand\pgfqpoint{\the\pgf@xa}{\the\pgf@ya}}}%
+ \pgf@temp%
+}%
+
+
+
+%
+% Circle grow
+%
+
+\tikzset{
+ grow cyclic/.style={
+ edge from parent/.append style={reset cm},
+ growth function=\tikz@grow@circle,
+ }
+}%
+
+\tikzset{sibling angle/.initial=20}%
+
+\def\tikz@grow@circle{%
+ \pgftransformrotate{%
+ (\pgfkeysvalueof{/tikz/sibling angle})*(-.5-.5*\tikznumberofchildren+\tikznumberofcurrentchild)}%
+ \pgftransformxshift{\the\tikzleveldistance}%
+}%
+
+\tikzoption{counterclockwise from}{\let\tikz@grow=\tikz@grow@circle@from\def\tikz@grow@circle@from@start{#1}}%
+
+\def\tikz@grow@circle@from{%
+ \pgftransformshift{\pgfpointpolar{\tikz@grow@circle@from@start+(\pgfkeysvalueof{/tikz/sibling angle})*(\tikznumberofcurrentchild-1)}{\the\tikzleveldistance}}%
+}%
+
+\tikzoption{clockwise from}{\let\tikz@grow=\tikz@grow@circle@from@\def\tikz@grow@circle@from@start{#1}}%
+
+\def\tikz@grow@circle@from@{%
+ \pgftransformshift{\pgfpointpolar{\tikz@grow@circle@from@start-(\pgfkeysvalueof{/tikz/sibling angle})*(\tikznumberofcurrentchild-1)}{\the\tikzleveldistance}}%
+}%
+
+
+
+%
+% Connections
+%
+
+\tikzset{edge from parent fork down/.style=
+ {edge from parent path={(\tikzparentnode\tikzparentanchor) -- +(0pt,-.5\tikzleveldistance) -| (\tikzchildnode\tikzchildanchor)}}}%
+
+\tikzset{edge from parent fork up/.style=
+ {edge from parent path={(\tikzparentnode\tikzparentanchor) -- +(0pt,.5\tikzleveldistance) -| (\tikzchildnode\tikzchildanchor)}}}%
+
+\tikzset{edge from parent fork left/.style=
+ {edge from parent path={(\tikzparentnode\tikzparentanchor) -- +(-.5\tikzleveldistance,0pt) |- (\tikzchildnode\tikzchildanchor)}}}%
+
+\tikzset{edge from parent fork right/.style=
+ {edge from parent path={(\tikzparentnode\tikzparentanchor) -- +(.5\tikzleveldistance,0pt) |- (\tikzchildnode\tikzchildanchor)}}}%
+
+
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryturtle.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryturtle.code.tex
new file mode 100644
index 0000000000..889806f8d5
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryturtle.code.tex
@@ -0,0 +1,84 @@
+% Copyright 2019 by Till Tantau
+%
+% 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{tikzlibraryturtle.code.tex}
+
+
+\tikzset{turtle/.style={/tikz/turtle/.cd,#1}}%
+
+% The current angle is stored in this key.
+\tikzset{turtle/direction/.code=\gdef\tikz@lib@turtle@dir{#1},turtle/direction=90}%
+
+% The current angle is stored in this key.
+\tikzset{turtle/distance/.initial=1cm}%
+
+% The to path options that are used to move the turtle
+\tikzset{turtle/how/.style=}%
+
+% Let the turtle jump home
+\tikzset{turtle/home/.style={/tikz/insert path={(0,0) [turtle/direction=90]}}}%
+
+% Moves the turtle forward by the given distance or, if no distance is
+% given, by turtle distance
+\tikzset{
+ turtle/forward/.default=\pgfkeysvalueof{/tikz/turtle/distance},
+ turtle/forward/.style={/tikz/insert path={to[/tikz/turtle/how]++({\tikz@lib@turtle@dir}:{#1})}}
+}%
+
+
+
+% Moves the turtle backward by the given distance or, if no distance is
+% given, by turtle distance
+\tikzset{
+ turtle/back/.default=\pgfkeysvalueof{/tikz/turtle/distance},
+ turtle/back/.style={turtle forward={-(#1)}}
+}%
+
+
+
+% Turns the turtle left by the given number of degrees
+\tikzset{
+ turtle/left/.default=90,
+ turtle/left/.code={%
+ \pgfmathparse{(#1)+(\tikz@lib@turtle@dir)}%
+ \ifdim\pgfmathresult pt>360pt\relax%
+ \pgfmathparse{\pgfmathresult-360}%
+ \fi%
+ \global\let\tikz@lib@turtle@dir\pgfmathresult
+ }
+}%
+
+
+% Turns the turtle left by the given number of degrees
+\tikzset{
+ turtle/right/.default=90,
+ turtle/right/.code={%
+ \pgfmathparse{#1}
+ \pgfmathparse{(\tikz@lib@turtle@dir)-\pgfmathresult}%
+ \ifdim\pgfmathresult pt<0pt\relax%
+ \pgfmathparse{\pgfmathresult+360}%
+ \fi%
+ \global\let\tikz@lib@turtle@dir\pgfmathresult
+ }
+}%
+
+
+% Shortcuts:
+\tikzset{turtle/.cd,
+ fd/.style={forward={#1}},
+ fd/.default=\pgfkeysvalueof{/tikz/turtle/distance},
+ bk/.style={back={#1}},
+ bk/.default=\pgfkeysvalueof{/tikz/turtle/distance},
+ lt/.style={left={#1}},
+ lt/.default=90,
+ rt/.style={right={#1}},
+ rt/.default=90}%
+
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryviews.code.tex b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryviews.code.tex
new file mode 100644
index 0000000000..8ced1b64f3
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/frontendlayer/tikz/libraries/tikzlibraryviews.code.tex
@@ -0,0 +1,45 @@
+% Copyright 2018 by Till Tantau
+%
+% 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{tikzlibraryviews.code.tex}
+
+
+\tikzset{
+ meet/.style={execute at begin scope={\tikz@lib@view@parse{meet}#1\pgf@stop},execute at end scope={\endpgfviewboxscope}},
+ view/.style={meet = {#1}},
+ slice/.style={execute at begin scope={\tikz@lib@view@parse{slice}#1\pgf@stop},execute at end scope={\endpgfviewboxscope}},
+}%
+
+\def\tikz@lib@view@parse#1#2\pgf@stop{%
+ \tikz@scan@one@point\tikz@lib@view@a#2\pgf@stop%
+ \pgfviewboxscope{\tikz@lib@view@stored@a}{\tikz@lib@view@stored@b}{\tikz@lib@view@stored@c}{\tikz@lib@view@stored@d}{#1}%
+}%
+\def\tikz@lib@view@a#1{%
+ \def\tikz@lib@view@stored@a{#1}%
+ \pgfutil@ifnextchar r{\tikz@lib@view@a@rec}{\tikz@scan@one@point\tikz@lib@view@b}%
+}%
+\def\tikz@lib@view@a@rec rectangle{\tikz@scan@one@point\tikz@lib@view@b}%
+\def\tikz@lib@view@b#1{%
+ \def\tikz@lib@view@stored@b{#1}%
+ \pgfutil@ifnextchar\pgf@stop{%
+ \let\tikz@lib@view@stored@c\tikz@lib@view@stored@a%
+ \let\tikz@lib@view@stored@d\tikz@lib@view@stored@b%
+ \pgfutil@gobble%
+ }{\tikz@lib@view@b@at}%
+}%
+\def\tikz@lib@view@b@at at{\tikz@scan@one@point\tikz@lib@view@c}%
+\def\tikz@lib@view@c#1{%
+ \def\tikz@lib@view@stored@c{#1}%
+ \pgfutil@ifnextchar r{\tikz@lib@view@c@rec}{\tikz@scan@one@point\tikz@lib@view@d}%
+}%
+\def\tikz@lib@view@c@rec rectangle{\tikz@scan@one@point\tikz@lib@view@d}%
+\def\tikz@lib@view@d#1{\def\tikz@lib@view@stored@d{#1}\pgfutil@ifnextchar\pgf@stop\pgfutil@gobble{\tikzerror{Wrong syntax for meet or slice key}}}%
+
+
+\endinput