summaryrefslogtreecommitdiff
path: root/graphics/pgf/base/tex/generic/systemlayer
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2023-01-16 03:03:27 +0000
committerNorbert Preining <norbert@preining.info>2023-01-16 03:03:27 +0000
commit6f9e1680085e7bb4d258f6f8116369d122e196e1 (patch)
tree9ac0ecb239240d1d672b188f29c1479de215074b /graphics/pgf/base/tex/generic/systemlayer
parentb8345f39630408bb198e7636381ce4240154ca9b (diff)
CTAN sync 202301160303
Diffstat (limited to 'graphics/pgf/base/tex/generic/systemlayer')
-rw-r--r--graphics/pgf/base/tex/generic/systemlayer/pgf.cfg33
-rw-r--r--graphics/pgf/base/tex/generic/systemlayer/pgfsys-common-pdf-via-dvi.def172
-rw-r--r--graphics/pgf/base/tex/generic/systemlayer/pgfsys-common-pdf.def119
-rw-r--r--graphics/pgf/base/tex/generic/systemlayer/pgfsys-common-postscript.def600
-rw-r--r--graphics/pgf/base/tex/generic/systemlayer/pgfsys-common-svg.def1613
-rw-r--r--graphics/pgf/base/tex/generic/systemlayer/pgfsys-dvi.def394
-rw-r--r--graphics/pgf/base/tex/generic/systemlayer/pgfsys-dvipdfm.def110
-rw-r--r--graphics/pgf/base/tex/generic/systemlayer/pgfsys-dvipdfmx.def504
-rw-r--r--graphics/pgf/base/tex/generic/systemlayer/pgfsys-dvips.def644
-rw-r--r--graphics/pgf/base/tex/generic/systemlayer/pgfsys-dvisvgm.def217
-rw-r--r--graphics/pgf/base/tex/generic/systemlayer/pgfsys-dvisvgm4ht.def86
-rw-r--r--graphics/pgf/base/tex/generic/systemlayer/pgfsys-luatex.def401
-rw-r--r--graphics/pgf/base/tex/generic/systemlayer/pgfsys-pdftex.def398
-rw-r--r--graphics/pgf/base/tex/generic/systemlayer/pgfsys-tex4ht.def487
-rw-r--r--graphics/pgf/base/tex/generic/systemlayer/pgfsys-textures.def95
-rw-r--r--graphics/pgf/base/tex/generic/systemlayer/pgfsys-vtex.def110
-rw-r--r--graphics/pgf/base/tex/generic/systemlayer/pgfsys-xetex.def79
-rw-r--r--graphics/pgf/base/tex/generic/systemlayer/pgfsys.code.tex1775
-rw-r--r--graphics/pgf/base/tex/generic/systemlayer/pgfsysanimations.code.tex2010
-rw-r--r--graphics/pgf/base/tex/generic/systemlayer/pgfsysprotocol.code.tex70
-rw-r--r--graphics/pgf/base/tex/generic/systemlayer/pgfsyssoftpath.code.tex204
21 files changed, 10121 insertions, 0 deletions
diff --git a/graphics/pgf/base/tex/generic/systemlayer/pgf.cfg b/graphics/pgf/base/tex/generic/systemlayer/pgf.cfg
new file mode 100644
index 0000000000..2580bad9d1
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/systemlayer/pgf.cfg
@@ -0,0 +1,33 @@
+% 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{pgf.cfg}
+
+% Copy this file to somewhere local and uncomment one of the following
+% if you do not trust/use/like the automatic driver selection
+% algorithms:
+
+% \def\pgfsysdriver{pgfsys-dvi.def}
+% \def\pgfsysdriver{pgfsys-dvipdfm.def}
+% \def\pgfsysdriver{pgfsys-dvipdfmx.def}
+% \def\pgfsysdriver{pgfsys-dvips.def}
+% \def\pgfsysdriver{pgfsys-pdftex.def}
+% \def\pgfsysdriver{pgfsys-luatex.def}
+% \def\pgfsysdriver{pgfsys-tex4ht.def}
+% \def\pgfsysdriver{pgfsys-textures.def}
+% \def\pgfsysdriver{pgfsys-vtex.def}
+% \def\pgfsysdriver{pgfsys-xetex.def}
+
+% Alternatively, use one of the above commands in your own files.
+
+\endinput
+
+%%% Local Variables:
+%%% mode: latex
+%%% End:
diff --git a/graphics/pgf/base/tex/generic/systemlayer/pgfsys-common-pdf-via-dvi.def b/graphics/pgf/base/tex/generic/systemlayer/pgfsys-common-pdf-via-dvi.def
new file mode 100644
index 0000000000..0678b18820
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/systemlayer/pgfsys-common-pdf-via-dvi.def
@@ -0,0 +1,172 @@
+% Copyright 2019 by Till Tantau
+% CMYK and grayscale shadings adaptation copyright 2019 by David Purton
+%
+% 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{pgfsys-common-pdf-via-dvi.def}
+
+% Common driver commands for all drivers that produce pdf via the
+% detour of a dvi file
+
+% For unique object name:
+\newcount\pgfsys@objnum\pgfsys@objnum\@ne
+
+% Hboxes
+
+\def\pgfsys@beginpurepicture{\special{pdf: content q}}
+
+
+\def\pgfsys@imagesuffixlist{.pdf:.jpg:.jpeg:.png:}
+\def\pgfsys@horishading#1#2#3{%
+ {%
+ \pgf@parsefunc{#3}%
+ \pgf@process{\pgfpoint{\pgf@max}{#2}}%
+ \edef\@temp{\noexpand\pgfutil@insertatbegincurrentpage{\special{pdf: beginxobj @pgfshade\the\pgfsys@objnum\space width \the\pgf@max\space height \the\pgf@y}}}\@temp%
+ \edef\@temp{\noexpand\pgfutil@insertatbegincurrentpage{\special{pdf: put @resources <<
+ /Shading << /Sh << /ShadingType 2
+ /ColorSpace \pgf@shading@device\space
+ /Domain [\pgf@pdfparseddomain]
+ /Coords [\pgf@doma\space0 \pgf@domb\space0]
+ /Function \pgf@pdfparsedfunction
+ /Extend [false false] >> >> >>}}}\@temp% <<
+ \pgfutil@insertatbegincurrentpage{\special{pdf: content /Sh sh}%
+ \special{pdf: endxobj}}%
+ \xdef\pgfutil@tempa{%
+ \hbox to\the\pgf@max{\vbox to#2{\vfil\special{pdf: usexobj @pgfshade\the\pgfsys@objnum}}\hfil}}%
+ }%
+ \global\expandafter\let\csname @pgfshading#1!\endcsname=\pgfutil@tempa
+ \global\advance\pgfsys@objnum\@ne
+}
+\def\pgfsys@vertshading#1#2#3{%
+ {%
+ \pgf@parsefunc{#3}%
+ \pgf@process{\pgfpoint{\pgf@max}{#2}}%
+ \edef\@temp{\noexpand\pgfutil@insertatbegincurrentpage{\special{pdf: beginxobj @pgfshade\the\pgfsys@objnum\space width \the\pgf@y\space height \the\pgf@max\space}}}\@temp%
+ \edef\@temp{\noexpand\pgfutil@insertatbegincurrentpage{\special{pdf: put @resources <<
+ /Shading << /Sh << /ShadingType 2
+ /ColorSpace \pgf@shading@device\space
+ /Domain [\pgf@pdfparseddomain]
+ /Coords [0 \pgf@doma\space0 \pgf@domb]
+ /Function \pgf@pdfparsedfunction
+ /Extend [false false] >> >> >>}}}\@temp% <<
+ \pgfutil@insertatbegincurrentpage{\special{pdf: content /Sh sh}%
+ \special{pdf: endxobj}}%
+ \xdef\pgfutil@tempa{%
+ \hbox to#2{\vbox to\the\pgf@max{\vfil\special{pdf: usexobj @pgfshade\the\pgfsys@objnum}}\hfil}}%
+ }%
+ \global\expandafter\let\csname @pgfshading#1!\endcsname=\pgfutil@tempa
+ \global\advance\pgfsys@objnum\@ne
+}
+\def\pgfsys@radialshading#1#2#3{%
+ {%
+ \pgf@parsefunc{#3}%
+ \pgf@process{#2}%
+ \pgf@xa=\pgf@x%
+ \pgf@ya=\pgf@y%
+ \pgf@process{\pgfpoint{\pgf@max}{\pgf@max}}%
+ \advance\pgf@xa by \pgf@x\relax%
+ \advance\pgf@ya by \pgf@y\relax%
+ \pgf@sys@bp@correct{\pgf@x}%
+ \pgf@sys@bp@correct{\pgf@y}%
+ \pgf@sys@bp@correct{\pgf@xa}%
+ \pgf@sys@bp@correct{\pgf@ya}%
+ \pgfutil@tempdima=2\pgf@max\relax%
+ \edef\@temp{\noexpand\pgfutil@insertatbegincurrentpage{\special{pdf: beginxobj @pgfshade\the\pgfsys@objnum\space width \the\pgfutil@tempdima\space height \the\pgfutil@tempdima}}}\@temp%
+ \edef\@temp{\noexpand\pgfutil@insertatbegincurrentpage{\special{pdf: put @resources <<
+ /Shading << /Sh << /ShadingType 3
+ /ColorSpace \pgf@shading@device\space
+ /Domain [\pgf@pdfparseddomain]
+ /Coords [\pgf@sys@tonumber{\pgf@xa} \pgf@sys@tonumber{\pgf@ya} \pgf@doma\space \pgf@sys@tonumber{\pgf@x} \pgf@sys@tonumber{\pgf@y} \pgf@domb]
+ /Function \pgf@pdfparsedfunction
+ /Extend [true false] >> >> >>}}}\@temp% <<
+ \pgfutil@insertatbegincurrentpage{\special{pdf: content /Sh sh}%
+ \special{pdf: endxobj}}%
+ \xdef\pgfutil@tempa{%
+ \hbox to\the\pgfutil@tempdima{\vbox to\the\pgfutil@tempdima{\vfil\special{pdf: usexobj @pgfshade\the\pgfsys@objnum}}\hfil}}%
+ }%
+ \global\expandafter\let\csname @pgfshading#1!\endcsname=\pgfutil@tempa
+ \global\advance\pgfsys@objnum\@ne
+}%
+
+\def\pgf@sys@pdf@dvi@tracker{
+ \def\pgfsys@markposition##1{%
+ \pdfsavepos%
+ \edef\pgf@temp{##1}%
+ \expandafter\write\expandafter\pgfutil@auxout\expandafter{%
+ \expandafter\noexpand\expandafter\pgfsyspdfmark\expandafter{\pgf@temp}{\the\pdflastxpos}{\the\pdflastypos}}%
+ }
+ \def\pgfsyspdfmark##1##2##3{%
+ \expandafter\gdef\csname pgf@sys@pdf@mark@pos@##1\endcsname{\pgfqpoint{##2sp}{##3sp}}%
+ }
+ \def\pgfsys@getposition##1##2{%
+ \edef\pgf@marshal{\let\noexpand##2=\expandafter\noexpand\csname pgf@sys@pdf@mark@pos@##1\endcsname}%
+ \pgf@marshal%
+ }
+ \def\pgf@sys@pdf@mark@pos@pgfpageorigin{\pgfpointorigin}
+}
+
+
+
+%
+% Resource management
+%
+
+\newif\ifpgf@sys@pdf@colorspaces@exists
+\newif\ifpgf@sys@pdf@patterns@exists
+\newif\ifpgf@sys@pdf@extgs@exists
+\newif\ifpgf@sys@pdf@colorspaces@created
+\newif\ifpgf@sys@pdf@patterns@created
+\newif\ifpgf@sys@pdf@extgs@created
+\newif\ifpgf@sys@pdf@any@resources
+
+\def\pgf@sys@setuppdfresources@plain{%
+ % This command will setup pdf resource in plain and in latex
+ % mode. ConTeXt has its own handler
+ \pgfutil@insertatbegineverypage{%
+ \pgf@sys@pdf@any@resourcesfalse%
+ \ifpgf@sys@pdf@extgs@exists%
+ \pgf@sys@pdf@any@resourcestrue%
+ \ifpgf@sys@pdf@extgs@created \else \special{pdf: obj @pgfextgs <<>>} \global\pgf@sys@pdf@extgs@createdtrue \fi% <<
+ \fi%
+ \ifpgf@sys@pdf@colorspaces@exists%
+ \pgf@sys@pdf@any@resourcestrue%
+ \ifpgf@sys@pdf@colorspaces@created \else \special{pdf: obj @pgfcolorspaces <<>>} \global\pgf@sys@pdf@colorspaces@createdtrue \fi% <<
+ \fi%
+ \ifpgf@sys@pdf@patterns@exists%
+ \pgf@sys@pdf@any@resourcestrue%
+ \ifpgf@sys@pdf@patterns@created \else \special{pdf: obj @pgfpatterns <<>>} \global\pgf@sys@pdf@patterns@createdtrue \fi% <<
+ \fi%
+ \ifpgf@sys@pdf@any@resources%
+ \special{pdf: put @resources <<
+ \ifpgf@sys@pdf@extgs@exists /ExtGState @pgfextgs \fi
+ \ifpgf@sys@pdf@patterns@exists /Pattern @pgfpattern \fi
+ \ifpgf@sys@pdf@colorspaces@exists /ColorSpace @pgfcolorspaces \fi
+ >>}% <<
+ \fi%
+ }
+ \def\pgf@sys@addpdfresource@extgs@plain##1{%
+ \global\pgf@sys@pdf@extgs@existstrue%
+ \pgfutil@insertatbegincurrentpage{\special{pdf: put @pgfextgs << ##1 >>}}% <<
+ }
+ \def\pgf@sys@addpdfresource@colorspaces@plain##1{%
+ \global\pgf@sys@pdf@colorspaces@existstrue%
+ \pgfutil@insertatbegincurrentpage{\special{pdf: put @pgfcolorspaces << ##1 >>}}% <<
+ }
+ \def\pgf@sys@addpdfresource@patterns@plain##1{%
+ \global\pgf@sys@pdf@patterns@existstrue%
+ \pgfutil@insertatbegincurrentpage{\special{pdf: put @pgfpatterns << ##1 >>}}% <<
+ }
+}
+\pgfutil@setuppdfresources % possibly call the above
+
+
+\endinput
+
+%%% Local Variables:
+%%% mode: latex
+%%% End:
diff --git a/graphics/pgf/base/tex/generic/systemlayer/pgfsys-common-pdf.def b/graphics/pgf/base/tex/generic/systemlayer/pgfsys-common-pdf.def
new file mode 100644
index 0000000000..e1ad4e7021
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/systemlayer/pgfsys-common-pdf.def
@@ -0,0 +1,119 @@
+% 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{pgfsys-common-pdf.def}
+
+
+% Common driver commands for all drivers that produce pdf
+
+
+% Path construction:
+\def\pgfsys@lineto#1#2{\pgf@sys@bp{#1}\pgf@sys@bp{#2}\pgfsysprotocol@literal{l}}
+\def\pgfsys@moveto#1#2{\pgf@sys@bp{#1}\pgf@sys@bp{#2}\pgfsysprotocol@literal{m}}
+\def\pgfsys@curveto#1#2#3#4#5#6{%
+ \pgf@sys@bp{#1}\pgf@sys@bp{#2}\pgf@sys@bp{#3}\pgf@sys@bp{#4}\pgf@sys@bp{#5}\pgf@sys@bp{#6}\pgfsysprotocol@literal{c}}
+\def\pgfsys@rect#1#2#3#4{\pgf@sys@bp{#1}\pgf@sys@bp{#2}\pgf@sys@bp{#3}\pgf@sys@bp{#4}\pgfsysprotocol@literal{re}}
+\def\pgfsys@closepath{\pgfsysprotocol@literal{h}}
+
+% Path usage:
+\def\pgfsys@stroke{\pgfsysprotocol@literal{S}}
+\def\pgfsys@closestroke{\pgfsysprotocol@literal{s}}
+\def\pgfsys@fill{\ifpgfsys@eorule\pgfsysprotocol@literal{f*}\else\pgfsysprotocol@literal{f}\fi}
+\def\pgfsys@fillstroke{\ifpgfsys@eorule\pgfsysprotocol@literal{B*}\else\pgfsysprotocol@literal{B}\fi}
+\def\pgfsys@clipnext{\ifpgfsys@eorule\pgfsysprotocol@literal{W*}\else\pgfsysprotocol@literal{W}\fi}
+\def\pgfsys@discardpath{\pgfsysprotocol@literal{n}}
+
+% Transformation:
+\def\pgfsys@transformcm#1#2#3#4#5#6{%
+ \pgfsysprotocol@literalbuffered{#1 #2 #3 #4}\pgf@sys@bp{#5}\pgf@sys@bp{#6}\pgfsysprotocol@literal{cm}}
+
+% Scopes
+\def\pgfsys@beginscope{\pgfsysprotocol@literal{q}}
+\def\pgfsys@endscope{\pgfsysprotocol@literal{Q}}
+
+% Graphics state
+\def\pgfsys@setdash#1#2{%
+ \pgfsysprotocol@literalbuffered{[}%
+ \pgfutil@for\pgf@sys@temp:={#1}\do{\pgf@sys@bp{\pgf@sys@temp}}%
+ \pgfsysprotocol@literalbuffered{]}%
+ \pgf@sys@bp{#2}\pgfsysprotocol@literal{d}}
+\def\pgfsys@setlinewidth#1{\pgf@sys@bp{#1}\pgfsysprotocol@literal{w}}
+\def\pgfsys@setmiterlimit#1{\pgfsysprotocol@literal{#1 M}}
+\def\pgfsys@buttcap{\pgfsysprotocol@literal{0 J}}
+\def\pgfsys@roundcap{\pgfsysprotocol@literal{1 J}}
+\def\pgfsys@rectcap{\pgfsysprotocol@literal{2 J}}
+\def\pgfsys@miterjoin{\pgfsysprotocol@literal{0 j}}
+\def\pgfsys@roundjoin{\pgfsysprotocol@literal{1 j}}
+\def\pgfsys@beveljoin{\pgfsysprotocol@literal{2 j}}
+\def\pgfsys@color@rgb@stroke#1#2#3{\pgfsysprotocol@literal{#1 #2 #3 RG}}
+\def\pgfsys@color@rgb@fill#1#2#3{\pgfsysprotocol@literal{#1 #2 #3 rg}}
+\def\pgfsys@color@cmyk@stroke#1#2#3#4{\pgfsysprotocol@literal{#1 #2 #3 #4 K}}
+\def\pgfsys@color@cmyk@fill#1#2#3#4{\pgfsysprotocol@literal{#1 #2 #3 #4 k}}
+\def\pgfsys@color@cmy@stroke#1#2#3{\pgfsysprotocol@literal{#1 #2 #3 0 K}}
+\def\pgfsys@color@cmy@fill#1#2#3{\pgfsysprotocol@literal{#1 #2 #3 0 k}}
+\def\pgfsys@color@gray@stroke#1{\pgfsysprotocol@literal{#1 G}}
+\def\pgfsys@color@gray@fill#1{\pgfsysprotocol@literal{#1 g}}
+
+% Visibility
+\def\pgfsys@begininvisiblescope{\pgfsys@beginscope{\pgfsys@discardpath\pgfsys@clipnext\pgfsys@moveto{0pt}{0pt}\pgfsys@discardpath}}
+\def\pgfsys@endinvisiblescope{\pgfsys@endscope}
+
+% Opacity
+\def\pgfsys@stroke@opacity#1{%
+ \expandafter\ifx\csname pgf@sys@pdf@so@#1\endcsname\relax%
+ \expandafter\gdef\csname pgf@sys@pdf@so@#1\endcsname{/pgf@CA#1}%
+ \pgfutil@addpdfresource@extgs{/pgf@CA#1 << /CA #1 >>}%<<
+ \fi%
+ \pgfsysprotocol@literal{\csname pgf@sys@pdf@so@#1\endcsname\space gs}%
+}
+\def\pgfsys@fill@opacity#1{%
+ \expandafter\ifx\csname pgf@sys@pdf@fo@#1\endcsname\relax%
+ \expandafter\gdef\csname pgf@sys@pdf@fo@#1\endcsname{/pgf@ca#1}%
+ \pgfutil@addpdfresource@extgs{/pgf@ca#1 << /ca #1 >>}%<<
+ \fi%
+ \pgfsysprotocol@literal{\csname pgf@sys@pdf@fo@#1\endcsname\space gs}%
+}
+
+% Blending
+\def\pgfsys@blend@mode#1{%
+ \expandafter\ifx\csname pgf@sys@pdf@bm@#1\endcsname\relax%
+ \expandafter\let\expandafter\pgf@temp\csname pgf@sys@pdf@blend@mode@map@#1\endcsname%
+ \expandafter\xdef\csname pgf@sys@pdf@bm@#1\endcsname{/pgf@bm\pgf@temp}%
+ \ifx\pgf@temp\relax%
+ \pgferror{Unknown blend mode '#1'}%
+ \def\pgf@temp{Normal}%
+ \fi%
+ \edef\pgf@temp{/pgf@bm\pgf@temp << /BM /\pgf@temp >>}%<<
+ \expandafter\pgfutil@addpdfresource@extgs\expandafter{\pgf@temp}%
+ \fi%
+ \pgfsysprotocol@literal{\csname pgf@sys@pdf@bm@#1\endcsname\space gs}%
+}
+\expandafter\def\csname pgf@sys@pdf@blend@mode@map@normal\endcsname{Normal}
+\expandafter\def\csname pgf@sys@pdf@blend@mode@map@multiply\endcsname{Multiply}
+\expandafter\def\csname pgf@sys@pdf@blend@mode@map@screen\endcsname{Screen}
+\expandafter\def\csname pgf@sys@pdf@blend@mode@map@overlay\endcsname{Overlay}
+\expandafter\def\csname pgf@sys@pdf@blend@mode@map@darken\endcsname{Darken}
+\expandafter\def\csname pgf@sys@pdf@blend@mode@map@lighten\endcsname{Lighten}
+\expandafter\def\csname pgf@sys@pdf@blend@mode@map@color dodge\endcsname{ColorDodge}
+\expandafter\def\csname pgf@sys@pdf@blend@mode@map@color burn\endcsname{ColorBurn}
+\expandafter\def\csname pgf@sys@pdf@blend@mode@map@hard light\endcsname{HardLight}
+\expandafter\def\csname pgf@sys@pdf@blend@mode@map@soft light\endcsname{SoftLight}
+\expandafter\def\csname pgf@sys@pdf@blend@mode@map@difference\endcsname{Difference}
+\expandafter\def\csname pgf@sys@pdf@blend@mode@map@exclusion\endcsname{Exclusion}
+\expandafter\def\csname pgf@sys@pdf@blend@mode@map@saturation\endcsname{Saturation}
+\expandafter\def\csname pgf@sys@pdf@blend@mode@map@color\endcsname{Color}
+\expandafter\def\csname pgf@sys@pdf@blend@mode@map@hue\endcsname{Hue}
+\expandafter\def\csname pgf@sys@pdf@blend@mode@map@luminosity\endcsname{Luminosity}
+
+\endinput
+
+
+%%% Local Variables:
+%%% mode: latex
+%%% End:
diff --git a/graphics/pgf/base/tex/generic/systemlayer/pgfsys-common-postscript.def b/graphics/pgf/base/tex/generic/systemlayer/pgfsys-common-postscript.def
new file mode 100644
index 0000000000..004b8e38f4
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/systemlayer/pgfsys-common-postscript.def
@@ -0,0 +1,600 @@
+% Copyright 2019 by Till Tantau
+% CMYK and grayscale shadings adaptation copyright 2019 by David Purton
+%
+% 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{pgfsys-common-postscript.def}
+
+
+% Driver commands for postscript
+
+\newif\ifpgf@fillcolor
+\newif\ifpgf@strokecolor
+\newif\ifpgfsys@@clipnext
+
+% Path construction:
+\def\pgfsys@lineto#1#2{\pgf@sys@bp{#1}\pgf@sys@bp{#2}\pgfsysprotocol@literal{lineto}}
+\def\pgfsys@moveto#1#2{\pgf@sys@bp{#1}\pgf@sys@bp{#2}\pgfsysprotocol@literal{moveto}}
+\def\pgfsys@curveto#1#2#3#4#5#6{%
+ \pgf@sys@bp{#1}\pgf@sys@bp{#2}\pgf@sys@bp{#3}\pgf@sys@bp{#4}\pgf@sys@bp{#5}\pgf@sys@bp{#6}\pgfsysprotocol@literal{curveto}}
+\def\pgfsys@rect#1#2#3#4{\pgf@sys@bp{#4}\pgf@sys@bp{#3}\pgf@sys@bp{#1}\pgf@sys@bp{#2}\pgfsysprotocol@literal{pgfe}}
+\def\pgfsys@closepath{\pgfsysprotocol@literal{closepath}}
+
+% Path usage:
+\def\pgfsys@stroke{%
+ \ifpgfsys@@clipnext%
+ \ifpgfsys@eorule%
+ \pgfsysprotocol@literal{gsave pgfsc pgfstr grestore eoclip newpath}%
+ \else%
+ \pgfsysprotocol@literal{gsave pgfsc pgfstr grestore clip newpath}%
+ \fi%
+ \pgfsys@@clipnextfalse%
+ \else%
+ \ifpgf@strokecolor%
+ \pgfsysprotocol@literal{gsave pgfsc pgfstr grestore newpath}%
+ \else%
+ \pgfsysprotocol@literal{pgfstr}%
+ \fi%
+ \fi}
+\def\pgfsys@fill{%
+ \ifpgfsys@@clipnext%
+ \ifpgfsys@eorule%
+ \pgfsysprotocol@literal{gsave pgffc pgfeofill grestore eoclip newpath}%
+ \else%
+ \pgfsysprotocol@literal{gsave pgffc pgffill grestore clip newpath}%
+ \fi%
+ \pgfsys@@clipnextfalse%
+ \else%
+ \ifpgf@fillcolor%
+ \ifpgfsys@eorule%
+ \pgfsysprotocol@literal{gsave pgffc pgfeofill grestore newpath}%
+ \else%
+ \pgfsysprotocol@literal{gsave pgffc pgffill grestore newpath}%
+ \fi%
+ \else%
+ \ifpgfsys@eorule%
+ \pgfsysprotocol@literal{pgfeofill}%
+ \else%
+ \pgfsysprotocol@literal{pgffill}%
+ \fi%
+ \fi%
+ \fi}
+\def\pgfsys@fillstroke{%
+ \ifpgfsys@eorule%
+ \pgfsysprotocol@literal{gsave pgffc pgfeofill grestore gsave pgfsc pgfstr grestore}%
+ \else%
+ \pgfsysprotocol@literal{gsave pgffc pgffill grestore gsave pgfsc pgfstr grestore}%
+ \fi%
+ \ifpgfsys@@clipnext%
+ \ifpgfsys@eorule%
+ \pgfsysprotocol@literal{eoclip}%
+ \else%
+ \pgfsysprotocol@literal{clip}%
+ \fi%
+ \pgfsys@@clipnextfalse%
+ \fi%
+ \pgfsysprotocol@literal{newpath}}
+\def\pgfsys@clipnext{\pgfsys@@clipnexttrue}
+\def\pgfsys@discardpath{%
+ \ifpgfsys@@clipnext%
+ \ifpgfsys@eorule%
+ \pgfsysprotocol@literal{eoclip}%
+ \else%
+ \pgfsysprotocol@literal{clip}%
+ \fi%
+ \pgfsys@@clipnextfalse%
+ \fi%
+ \pgfsysprotocol@literal{newpath}}
+
+% Transformation:
+\def\pgfsys@transformshift#1#2{\pgf@sys@bp{#1}\pgf@sys@bp{#2}\pgfsysprotocol@literal{translate}}
+\def\pgfsys@transformxyscale#1#2{\pgfsysprotocol@literal{#1 #2 scale}}
+\def\pgfsys@transformcm#1#2#3#4#5#6{%
+ \pgfsysprotocol@literalbuffered{[#1 #2 #3 #4}\pgf@sys@bp{#5}\pgf@sys@bp{#6}\pgfsysprotocol@literal{] concat}}
+
+% Scopes
+\def\pgfsys@beginscope{\pgfsysprotocol@literal{save}}
+\def\pgfsys@endscope{\pgfsysprotocol@literal{restore}}
+
+\newif\ifpgfsys@ps@boxmode
+\def\pgfsys@begin@text{\pgfsys@ps@boxmodetrue}
+\def\pgfsys@end@text{}
+
+
+% Graphics state
+\def\pgfsys@setdash#1#2{%
+ \pgfsysprotocol@literalbuffered{[}%
+ \pgfutil@for\pgf@sys@temp:={#1}\do{\pgf@sys@bp{\pgf@sys@temp}}%
+ \pgfsysprotocol@literalbuffered{]}%
+ \pgf@sys@bp{#2}\pgfsysprotocol@literal{setdash}}
+\def\pgfsys@setlinewidth#1{\pgf@sys@bp{#1}\pgfsysprotocol@literal{pgfw}}
+\def\pgfsys@setmiterlimit#1{\pgfsysprotocol@literal{#1 setmiterlimit}}
+\def\pgfsys@buttcap{\pgfsysprotocol@literal{0 setlinecap}}
+\def\pgfsys@roundcap{\pgfsysprotocol@literal{1 setlinecap}}
+\def\pgfsys@rectcap{\pgfsysprotocol@literal{2 setlinecap}}
+\def\pgfsys@miterjoin{\pgfsysprotocol@literal{0 setlinejoin}}
+\def\pgfsys@roundjoin{\pgfsysprotocol@literal{1 setlinejoin}}
+\def\pgfsys@beveljoin{\pgfsysprotocol@literal{2 setlinejoin}}
+\def\pgfsys@color@rgb@stroke#1#2#3{\pgfsysprotocol@literal{/pgfsc{#1 #2 #3 setrgbcolor}def}\pgf@strokecolortrue}
+\def\pgfsys@color@rgb@fill#1#2#3{\pgfsysprotocol@literal{/pgffc{#1 #2 #3 setrgbcolor}def}\pgf@fillcolortrue}
+\def\pgfsys@color@rgb#1#2#3{\pgfsys@color@reset\pgfsysprotocol@literal{#1 #2 #3 setrgbcolor}}
+\def\pgfsys@color@cmyk@stroke#1#2#3#4{\pgfsysprotocol@literal{/pgfsc{#1 #2 #3 #4 setcmykcolor}def}\pgf@strokecolortrue}
+\def\pgfsys@color@cmyk@fill#1#2#3#4{\pgfsysprotocol@literal{/pgffc{#1 #2 #3 #4 setcmykcolor}def}\pgf@fillcolortrue}
+\def\pgfsys@color@cmyk#1#2#3#4{\pgfsys@color@reset\pgfsysprotocol@literal{#1 #2 #3 #4 setcmykcolor}}
+\def\pgfsys@color@cmy@stroke#1#2#3{\pgfsysprotocol@literal{/pgfsc{#1 #2 #3 0 setcmykcolor}def}\pgf@strokecolortrue}
+\def\pgfsys@color@cmy@fill#1#2#3{\pgfsysprotocol@literal{/pgffc{#1 #2 #3 0 setcmykcolor}def}\pgf@fillcolortrue}
+\def\pgfsys@color@cmy#1#2#3{\pgfsys@color@reset\pgfsysprotocol@literal{#1 #2 #3 0 setcmykcolor}}
+\def\pgfsys@color@gray@stroke#1{\pgfsysprotocol@literal{/pgfsc{#1 setgray}def}\pgf@strokecolortrue}
+\def\pgfsys@color@gray@fill#1{\pgfsysprotocol@literal{/pgffc{#1 setgray}def}\pgf@fillcolortrue}
+\def\pgfsys@color@gray#1{\pgfsys@color@reset\pgfsysprotocol@literal{#1 setgray}}
+\def\pgfsysps@color@resetnow{\pgfsysprotocol@literal{/pgfsc{}def/pgffc{}def}\pgf@strokecolorfalse\pgf@fillcolorfalse}%
+\def\pgfsys@color@reset{%
+ \ifpgfsys@color@reset@inorder%
+ \ifpgf@strokecolor%
+ \pgfsysps@color@resetnow%
+ \else%
+ \ifpgf@fillcolor%
+ \pgfsysps@color@resetnow%
+ \fi%
+ \fi%
+ \else%
+ \pgfsysps@color@resetnow%
+ \fi}
+
+
+% Opacity
+
+\def\pgfsys@fill@opacity#1{%
+ \pgfsysprotocol@literal{#1 .pgfsetfillopacityalpha}%
+}
+\def\pgfsys@stroke@opacity#1{%
+ \pgfsysprotocol@literal{#1 .pgfsetstrokeopacityalpha}%
+}
+
+% Objects
+\newcount\pgf@objectcount
+\def\pgfsys@defobject#1#2#3#4{%
+ \global\advance\pgf@objectcount by 1%
+ \expandafter\xdef\csname#1\endcsname{\the\pgf@objectcount}%
+ \pgfsysprotocol@getcurrentprotocol\pgfsys@temp%
+ {%
+ \pgfsysprotocol@setcurrentprotocol\pgfutil@empty%
+ \pgfsysprotocol@bufferedtrue%
+ #4%
+ \pgfsysprotocol@getcurrentprotocol\pgfsys@@temp%
+ \pgf@sys@postscript@object{/pgf\csname#1\endcsname{gsave exec \pgfsys@@temp\space grestore} bind def}%
+ }%
+ \pgfsysprotocol@setcurrentprotocol\pgfsys@temp%
+}
+\def\pgfsys@useobject#1#2{%
+ \pgfsysprotocol@getcurrentprotocol\pgfsys@temp%
+ {%
+ \pgfsysprotocol@setcurrentprotocol\pgfutil@empty%
+ \pgfsysprotocol@bufferedfalse%
+ #2%
+ \pgfsysprotocol@invokecurrentprotocol%
+ \pgfsys@invoke{pgf\csname#1\endcsname}%
+ }%
+ \pgfsysprotocol@setcurrentprotocol\pgfsys@temp}
+
+% Shadings
+
+\def\pgfsys@horishading#1#2#3{%
+ {%
+ \pgf@parsefunc{#3}%
+ \pgfmathsetlength\pgf@x{#2}%
+ \pgf@xa=\pgf@x%
+ \pgf@sys@bp@correct{\pgf@x}%
+ \pgf@y=\pgf@max%
+ \pgf@sys@bp@correct{\pgf@y}%
+ \xdef\pgfutil@tempa{\hbox to \the\pgf@max{%
+ \noexpand\vrule width0pt height\the\pgf@xa%
+ \noexpand\pgfsys@beginpurepicture%
+ \noexpand\pgfsys@rect{0pt}{0pt}{\the\pgf@max}{\the\pgf@xa}%
+ \noexpand\pgfsys@clipnext%
+ \noexpand\pgfsys@discardpath%
+ \noexpand\pgfsys@invoke{\pgf@domb\space \pgf@sys@tonumber{\pgf@x} pgfH\pgf@shading@model\space \pgf@psfuncs\space pop}%
+ \hss%
+ \noexpand\pgfsys@endpurepicture}}%
+ }%
+ \global\expandafter\let\csname @pgfshading#1!\endcsname=\pgfutil@tempa
+}
+\def\pgfsys@vertshading#1#2#3{%
+ {%
+ \pgf@parsefunc{#3}%
+ \pgfmathsetlength\pgf@x{#2}%
+ \pgf@xa=\pgf@x%
+ \pgf@sys@bp@correct{\pgf@x}%
+ \pgf@y=\pgf@max%
+ \pgf@sys@bp@correct{\pgf@y}%
+ \xdef\pgfutil@tempa{\hbox to \the\pgf@xa{%
+ \noexpand\vrule width0pt height\the\pgf@max%
+ \noexpand\pgfsys@beginpurepicture%
+ \noexpand\pgfsys@rect{0pt}{0pt}{\the\pgf@xa}{\the\pgf@max}%
+ \noexpand\pgfsys@clipnext%
+ \noexpand\pgfsys@discardpath%
+ \noexpand\pgfsys@invoke{\pgf@domb\space \pgf@sys@tonumber{\pgf@x} pgfV\pgf@shading@model\space \pgf@psfuncs\space pop}%
+ \hss%
+ \noexpand\pgfsys@endpurepicture}}%
+ }%
+ \global\expandafter\let\csname @pgfshading#1!\endcsname=\pgfutil@tempa
+}
+\def\pgfsys@radialshading#1#2#3{%
+ {%
+ \pgf@parsefunc{#3}%
+ \pgf@process{#2}%
+ \pgf@sys@bp@correct{\pgf@x}%
+ \pgf@sys@bp@correct{\pgf@y}%
+ \pgf@xa=2\pgf@max%
+ \pgf@sys@bp@correct{\pgf@max}%
+ \advance\pgf@x by \pgf@max%
+ \advance\pgf@y by \pgf@max%
+ \xdef\pgfutil@tempa{\hbox to \the\pgf@xa{%
+ \noexpand\vrule width0pt height\the\pgf@xa%
+ \noexpand\pgfsys@beginpurepicture%
+ \noexpand\pgfsys@invoke{%
+ \pgf@domb\space \pgf@sys@tonumber{\pgf@y} \pgf@sys@tonumber{\pgf@x} \pgf@sys@tonumber{\pgf@max} pgfR1\pgf@shading@model\space
+ \pgf@psfuncs\space \pgf@firstcolor\space \pgf@doma\space pgfR2\pgf@shading@model}%
+ \hss%
+ \noexpand\pgfsys@endpurepicture}}%
+ }%
+ \global\expandafter\let\csname @pgfshading#1!\endcsname=\pgfutil@tempa
+}
+\def\pgfsys@functionalshading#1#2#3#4{%
+ {%
+ \pgf@process{#2}%
+ \pgf@xa=\pgf@x%
+ \pgf@ya=\pgf@y%
+ \pgf@process{#3}%
+ \pgf@xb=\pgf@x%
+ \pgf@yb=\pgf@y%
+ \advance\pgf@x by-\pgf@xa%
+ \advance\pgf@y by-\pgf@ya%
+ \pgf@sys@bp@correct{\pgf@xa}%
+ \pgf@sys@bp@correct{\pgf@ya}%
+ \pgf@sys@bp@correct{\pgf@xb}%
+ \pgf@sys@bp@correct{\pgf@yb}%
+ \pgf@xc=-\pgf@xa%
+ \pgf@yc=-\pgf@ya%
+ \xdef\pgfutil@tempa{%
+ \hbox to\the\pgf@x{\vbox to\the\pgf@y{\vfil
+ \noexpand\pgfsys@beginpurepicture%
+ \noexpand\pgfsys@invoke{%
+ \pgf@sys@tonumber{\pgf@xc} \pgf@sys@tonumber{\pgf@yc} translate
+ 1.1 setlinewidth [] 0 setdash 0 setlinecap
+ /pgfproc {#4} bind def
+ \pgf@sys@tonumber{\pgf@ya} 1 \pgf@sys@tonumber{\pgf@yb}
+ {
+ \pgf@sys@tonumber{\pgf@xa} 1 \pgf@sys@tonumber{\pgf@xb}
+ { 1 index 2 copy pgfproc \pgf@shading@ps@device\space moveto 1.1 0 rlineto stroke }
+ for
+ pop
+ }
+ for
+ }%
+ \noexpand\pgfsys@endpurepicture
+ }\hfil}%
+ }%
+ }%
+ \global\expandafter\let\csname @pgfshading#1!\endcsname=\pgfutil@tempa
+}
+
+%
+% Patterns
+%
+
+
+\def\pgfsys@declarepattern#1#2#3#4#5#6#7{%
+ % Start building the pattern dictionary:
+ \pgf@xa=#2\relax%
+ \pgf@ya=#3\relax%
+ \pgf@xb=#4\relax%
+ \pgf@yb=#5\relax%
+ \pgf@xc=#6\relax%
+ \pgf@yc=#7\relax%
+ \pgf@sys@bp@correct\pgf@xa%
+ \pgf@sys@bp@correct\pgf@ya%
+ \pgf@sys@bp@correct\pgf@xb%
+ \pgf@sys@bp@correct\pgf@yb%
+ \pgf@sys@bp@correct\pgf@xc%
+ \pgf@sys@bp@correct\pgf@yc%
+ \pgfsys@@declarepattern{#1}%
+}
+
+\def\pgfsys@@declarepattern#1#2#3#4#5#6#7#8#9{%
+ \pgfutil@tempdima=#6\relax%
+ \pgfutil@tempdimb=#7\relax%
+ \pgf@sys@bp@correct\pgfutil@tempdima%
+ \pgf@sys@bp@correct\pgfutil@tempdimb%
+ \edef\pgf@sys@marshal{%
+ \noexpand\pgfutil@insertatbegincurrentpage{\noexpand\pgfsys@outerinvoke{
+ save true setglobal globaldict begin /pgfpat#1
+ {
+ \ifnum#9=0 [/Pattern /DeviceRGB] \else /Pattern \fi\space
+ setcolorspace
+ gsave
+ initgraphics
+ <<
+ /Type /Pattern
+ /PatternType 1
+ /PaintType \ifnum#9=0 2 \else 1 \fi
+ /TilingType 1
+ /BBox [\pgf@sys@tonumber\pgf@xa\space\pgf@sys@tonumber\pgf@ya\space\pgf@sys@tonumber\pgf@xb\space\pgf@sys@tonumber\pgf@yb]
+ /XStep \pgf@sys@tonumber\pgf@xc\space
+ /YStep \pgf@sys@tonumber\pgf@yc\space
+ /Matrix [#2\space#3\space#4\space#5\space\pgf@sys@tonumber\pgfutil@tempdima\space\pgf@sys@tonumber\pgfutil@tempdimb]
+ /PaintProc
+ { begin 2 dict begin #8\space end end } bind
+ >>
+ matrix
+ makepattern
+ %/pgfpat#1\space exch def
+ grestore
+ setcolor
+ } bind def end restore
+ }}% <<
+ }%
+ \pgf@sys@marshal%
+}
+
+\def\pgfsys@setpatternuncolored#1#2#3#4{%
+ \pgfsysprotocol@literal{/pgffc{#2 #3 #4 pgfpat#1}def}%
+% [/Pattern /DeviceRGB] setcolorspace
+% #2 #3 #4 pgfpat#1\space setcolor
+% }def}%
+ \pgf@fillcolortrue%
+}
+
+\def\pgfsys@setpatterncolored#1{%
+ \pgfsysprotocol@literal{/pgffc{pgfpat#1}def}%/Pattern setcolorspace
+% pgfpat#1\space setcolor}def}%
+ \pgf@fillcolortrue%
+}
+
+
+
+\def\pgfsys@atbegindocument{%
+ % Parameters to horizontal pre axishade: \pgf@domb x
+ \pgf@sys@postscript@header{/pgfHrgb{%
+ /pgfheight exch def 0.75 setlinewidth [] 0 setdash
+ /pgfshade {pgfArgb} def /pgfdir { dup 0 moveto
+ dup 5 index lineto } bind def} bind def}%
+
+ % Parameters to vertical pre axishade: \pgf@domb x
+ \pgf@sys@postscript@header{/pgfVrgb{%
+ /pgfheight exch def 0.75 setlinewidth [] 0 setdash
+ /pgfshade {pgfArgb} def /pgfdir { dup 0 exch moveto dup 5 index
+ exch lineto } bind def} bind def}%
+
+ % Parameters to axishade: end x, start x, r-, g-, b- of first color, r-, g-, b- of second color
+ % Stack afterwards: end x
+ \pgf@sys@postscript@header{/pgfArgb{
+ /pgfdiff 8 index round cvi 8 index round cvi sub 2 mul 1 add def
+ 2 index 6 index sub pgfdiff div % put red-step on stack
+ 2 index 6 index sub pgfdiff div % put green-step on stack
+ 2 index 6 index sub pgfdiff div % put blue-step on stack
+ pgfheight 9 index 9 index 9 index 14 index
+ pgfdiff {
+ 3 index 3 index 3 index setrgbcolor % Set color
+ pgfdir
+ stroke
+ 4 -1 roll 7 index add % red += incred
+ 4 -1 roll 6 index add % green += incgreen
+ 4 -1 roll 5 index add % blue += incblue
+ 4 -1 roll .5 sub % x += 0.5
+ } repeat
+ mark 15 1 roll cleartomark exch pop % leave only start x on stack
+ }bind def }
+
+ % Parameters to radialshade pre: \pgf@domb y x max
+ \pgf@sys@postscript@header{/pgfR1rgb{
+ newpath dup dup dup 0 360 arc clip newpath
+ dup /pgfendx exch def
+ /pgfendy exch def
+ 0.875 setlinewidth
+ [] 0 setdash
+ /pgfshade {pgfRrgb} def
+ /pgfstartx exch def
+ /pgfstarty exch def
+ /pgfdiffx pgfendx pgfstartx sub def
+ /pgfdiffy pgfendy pgfstarty sub def
+ dup /pgfdomb exch def
+ }bind def }
+
+ % Parameters to radialshade post: \pgf@firstcolor \pgf@doma
+ \pgf@sys@postscript@header{/pgfR2rgb{
+ newpath 0.5 add pgfcircx pgfcircy 3 2 roll 0 360 arc
+ setrgbcolor fill pop}bind def }%
+
+ % Parameters to radialshade: end x, start x, r-, g-, b- of first color, r-, g-, b- of second color
+ % Stack afterwards: end x
+ \pgf@sys@postscript@header{/pgfRrgb{
+ /pgfdiff 8 index round cvi 8 index round cvi sub 4 mul 1 add def
+ /pgfcircx pgfstartx 9 index pgfdiffx pgfdomb div mul add def
+ /pgfcircy pgfstarty 9 index pgfdiffy pgfdomb div mul add def
+ /pgfcircxe pgfstartx 8 index pgfdiffx pgfdomb div mul add def
+ /pgfcircye pgfstarty 8 index pgfdiffy pgfdomb div mul add def
+ /pgfxstep pgfcircxe pgfcircx sub pgfdiff div def
+ /pgfystep pgfcircye pgfcircy sub pgfdiff div def
+ 2 index 6 index sub pgfdiff div % put red-step on stack
+ 2 index 6 index sub pgfdiff div % put green-step on stack
+ 2 index 6 index sub pgfdiff div % put green-step on stack
+ 8 index 8 index 8 index 13 index
+ pgfdiff {
+ 3 index 3 index 3 index setrgbcolor % Set color
+ pgfcircx pgfcircy 2 index 0 360 arc closepath
+ stroke
+ 4 -1 roll 6 index add % red += incred
+ 4 -1 roll 5 index add % green += incgreen
+ 4 -1 roll 4 index add % blue += incblue
+ 4 -1 roll .25 sub % x += 0.25
+ /pgfcircx pgfcircx pgfxstep add def
+ /pgfcircy pgfcircy pgfystep add def
+ } repeat
+ mark 14 1 roll cleartomark exch pop % leave only start x on stack
+ }bind def}
+
+ % Parameters to horizontal pre axishade: \pgf@domb x
+ \pgf@sys@postscript@header{/pgfHcmyk{
+ /pgfheight exch def 0.75 setlinewidth [] 0 setdash
+ /pgfshade {pgfAcmyk} def /pgfdir { dup 0 moveto
+ dup 6 index lineto } bind def} bind def}%
+
+ % Parameters to vertical pre axishade: \pgf@domb x
+ \pgf@sys@postscript@header{/pgfVcmyk{
+ /pgfheight exch def 0.75 setlinewidth [] 0 setdash
+ /pgfshade {pgfAcmyk} def /pgfdir { dup 0 exch moveto dup 6 index
+ exch lineto } bind def} bind def}%
+
+ % Parameters to axishade: end x, start x, c-, m-, y-, k- of first color, c-, m-, y-, k- of second color
+ \pgf@sys@postscript@header{/pgfAcmyk{
+ /pgfdiff 10 index round cvi 10 index round cvi sub 2 mul 1 add def
+ 3 index 8 index sub pgfdiff div % put cyan-step on stack
+ 3 index 8 index sub pgfdiff div % put magenta-step on stack
+ 3 index 8 index sub pgfdiff div % put yellow-step on stack
+ 3 index 8 index sub pgfdiff div % put black-step on stack
+ pgfheight 12 index 12 index 12 index 12 index 18 index
+ pgfdiff {
+ 4 index 4 index 4 index 4 index setcmykcolor % Set color
+ pgfdir
+ stroke
+ 5 -1 roll 9 index add % cyan += inccyan
+ 5 -1 roll 8 index add % magenta += incmagenta
+ 5 -1 roll 7 index add % yellow += incyellow
+ 5 -1 roll 6 index add % black += incblack
+ 5 -1 roll .5 sub % x += 0.5
+ } repeat
+ mark 19 1 roll cleartomark exch pop % leave only start x on stack
+ }bind def }%
+
+ % Parameters to radialshade pre: \pgf@domb y x max
+ \pgf@sys@postscript@header{/pgfR1cmyk{
+ newpath dup dup dup 0 360 arc clip newpath
+ dup /pgfendx exch def
+ /pgfendy exch def
+ 0.875 setlinewidth
+ [] 0 setdash
+ /pgfshade {pgfRcmyk} def
+ /pgfstartx exch def
+ /pgfstarty exch def
+ /pgfdiffx pgfendx pgfstartx sub def
+ /pgfdiffy pgfendy pgfstarty sub def
+ dup /pgfdomb exch def
+ }bind def }%
+
+ % Parameters to radialshade post: \pgf@firstcolor \pgf@doma
+ \pgf@sys@postscript@header{/pgfR2cmyk{
+ newpath 0.5 add pgfcircx pgfcircy 3 2 roll 0 360 arc
+ setcmykcolor fill pop}bind def }%
+
+ % Parameters to radialshade: end x, start x, c-, m-, y-, k- of first color, c-, m-, y-, k- of second color
+ \pgf@sys@postscript@header{/pgfRcmyk{
+ /pgfdiff 10 index round cvi 10 index round cvi sub 4 mul 1 add def
+ /pgfcircx pgfstartx 11 index pgfdiffx pgfdomb div mul add def
+ /pgfcircy pgfstarty 11 index pgfdiffy pgfdomb div mul add def
+ /pgfcircxe pgfstartx 10 index pgfdiffx pgfdomb div mul add def
+ /pgfcircye pgfstarty 10 index pgfdiffy pgfdomb div mul add def
+ /pgfxstep pgfcircxe pgfcircx sub pgfdiff div def
+ /pgfystep pgfcircye pgfcircy sub pgfdiff div def
+ 3 index 8 index sub pgfdiff div % put cyan-step on stack
+ 3 index 8 index sub pgfdiff div % put magenta-step on stack
+ 3 index 8 index sub pgfdiff div % put yellow-step on stack
+ 3 index 8 index sub pgfdiff div % put black-step on stack
+ 11 index 11 index 11 index 11 index 17 index
+ pgfdiff {
+ 4 index 4 index 4 index 4 index setcmykcolor % Set color
+ pgfcircx pgfcircy 2 index 0 360 arc closepath
+ stroke
+ 5 -1 roll 8 index add % cyan += inccyan
+ 5 -1 roll 7 index add % magenta += incmagenta
+ 5 -1 roll 6 index add % yellow += incyellow
+ 5 -1 roll 5 index add % black += incblack
+ 5 -1 roll .25 sub % x += 0.25
+ /pgfcircx pgfcircx pgfxstep add def
+ /pgfcircy pgfcircy pgfystep add def
+ } repeat
+ mark 18 1 roll cleartomark exch pop % leave only start x on stack
+ }bind def}%
+
+ % Parameters to horizontal pre axishade: \pgf@domb x
+ \pgf@sys@postscript@header{/pgfHgray{
+ /pgfheight exch def 0.75 setlinewidth [] 0 setdash
+ /pgfshade {pgfAgray} def /pgfdir { dup 0 moveto
+ dup 3 index lineto } bind def} bind def}%
+
+ % Parameters to vertical pre axishade: \pgf@domb x
+ \pgf@sys@postscript@header{/pgfVgray{
+ /pgfheight exch def 0.75 setlinewidth [] 0 setdash
+ /pgfshade {pgfAgray} def /pgfdir { dup 0 exch moveto dup 3 index
+ exch lineto } bind def} bind def}%
+
+ % Parameters to axishade: end x, start x, g of first color, g of second color
+ \pgf@sys@postscript@header{/pgfAgray{
+ /pgfdiff 4 index round cvi 4 index round cvi sub 2 mul 1 add def
+ dup 2 index sub pgfdiff div % put gray-step on stack
+ pgfheight 3 index 6 index
+ pgfdiff {
+ 1 index setgray % Set color
+ pgfdir
+ stroke
+ exch 3 index add % gray += incgray
+ exch .5 sub % x += 0.5
+ } repeat
+ mark 7 1 roll cleartomark exch pop % leave only start x on stack
+ }bind def }%
+
+ % Parameters to radialshade pre: \pgf@domb y x max
+ \pgf@sys@postscript@header{/pgfR1gray{
+ newpath dup dup dup 0 360 arc clip newpath
+ dup /pgfendx exch def
+ /pgfendy exch def
+ 0.875 setlinewidth
+ [] 0 setdash
+ /pgfshade {pgfRgray} def
+ /pgfstartx exch def
+ /pgfstarty exch def
+ /pgfdiffx pgfendx pgfstartx sub def
+ /pgfdiffy pgfendy pgfstarty sub def
+ dup /pgfdomb exch def
+ }bind def }%
+
+ % Parameters to radialshade post: \pgf@firstcolor \pgf@doma
+ \pgf@sys@postscript@header{/pgfR2gray{
+ newpath 0.5 add pgfcircx pgfcircy 3 2 roll 0 360 arc
+ setgray fill pop}bind def }%
+
+ % Parameters to radialshade: end x, start x, g of first color, g of second color
+ \pgf@sys@postscript@header{/pgfRgray{
+ /pgfdiff 4 index round cvi 4 index round cvi sub 4 mul 1 add def
+ /pgfcircx pgfstartx 5 index pgfdiffx pgfdomb div mul add def
+ /pgfcircy pgfstarty 5 index pgfdiffy pgfdomb div mul add def
+ /pgfcircxe pgfstartx 4 index pgfdiffx pgfdomb div mul add def
+ /pgfcircye pgfstarty 4 index pgfdiffy pgfdomb div mul add def
+ /pgfxstep pgfcircxe pgfcircx sub pgfdiff div def
+ /pgfystep pgfcircye pgfcircy sub pgfdiff div def
+ dup 2 index sub pgfdiff div % put gray-step on stack
+ 2 index 5 index
+ pgfdiff {
+ 1 index setgray % Set color
+ pgfcircx pgfcircy 2 index 0 360 arc closepath
+ stroke
+ exch 2 index add % gray += incgray
+ exch .25 sub % x += 0.25
+ /pgfcircx pgfcircx pgfxstep add def
+ /pgfcircy pgfcircy pgfystep add def
+ } repeat
+ mark 6 1 roll cleartomark exch pop % leave only start x on stack
+ }bind def}%
+}
+
+
+\endinput
+
+%%% Local Variables:
+%%% mode: latex
+%%% End:
diff --git a/graphics/pgf/base/tex/generic/systemlayer/pgfsys-common-svg.def b/graphics/pgf/base/tex/generic/systemlayer/pgfsys-common-svg.def
new file mode 100644
index 0000000000..f1d2729023
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/systemlayer/pgfsys-common-svg.def
@@ -0,0 +1,1613 @@
+% 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{pgfsys-common-svg.def}
+
+
+% Driver commands for svg
+
+
+
+% Helping functions:
+\def\pgf@sys@svg@make@defs#1{\pgf@sys@fail{svg defs}}
+\def\pgf@sys@svg@ref@defs#1{\pgf@sys@fail{svg defs}}
+\let\pgf@sys@svgpath=\pgfutil@empty
+\def\pgf@sys@svgnum#1{%
+ {%
+ \pgf@x=#1\relax%
+ \edef\temp{\expandafter\Pgf@geT\the\pgf@x\space}%
+ \pgfutil@toks@\expandafter\expandafter\expandafter{\expandafter\pgf@sys@svgpath\temp}%
+ \xdef\pgf@sys@svgpath{\the\pgfutil@toks@}%
+ }%
+}
+\def\pgf@sys@addtosvgpath#1{\pgfutil@g@addto@macro\pgf@sys@svgpath{#1\space}}
+\def\pgf@sys@flushsvgpath{\pgfsysprotocol@literal{\pgf@sys@svgpath}\global\let\pgf@sys@svgpath=\pgfutil@empty}
+\def\pgf@sys@svg@gs#1{%
+ {%
+ \pgfsysprotocol@literal{<g #1>\pgfsys@svg@newline}%
+ }%
+ \global\advance\pgf@sys@svg@scopecount by1\relax%
+}
+\newcount\pgf@sys@svg@objectcount
+
+{\catcode`\%=12
+\gdef\pgf@sys@svg@percentchar{%}
+}
+{\catcode`\#=11
+\gdef\pgf@sys@svg@hash{#}
+}
+
+% Path construction:
+\def\pgfsys@lineto#1#2{\pgf@sys@addtosvgpath{L}\pgf@sys@svgnum{#1}\pgf@sys@svgnum{#2}}
+\def\pgfsys@moveto#1#2{\pgf@sys@addtosvgpath{M}\pgf@sys@svgnum{#1}\pgf@sys@svgnum{#2}}
+\def\pgfsys@curveto#1#2#3#4#5#6{%
+ \pgf@sys@addtosvgpath{C}%
+ \pgf@sys@svgnum{#1}\pgf@sys@svgnum{#2}%
+ \pgf@sys@svgnum{#3}\pgf@sys@svgnum{#4}%
+ \pgf@sys@svgnum{#5}\pgf@sys@svgnum{#6}}
+\def\pgfsys@rect#1#2#3#4{%
+ \pgfsys@moveto{#1}{#2}%
+ \pgf@sys@addtosvgpath{h}\pgf@sys@svgnum{#3}%
+ \pgf@sys@addtosvgpath{v}\pgf@sys@svgnum{#4}%
+ \pgf@sys@addtosvgpath{h}{\pgf@x=#3\pgf@x=-\pgf@x\pgf@sys@svgnum{\pgf@x}}%
+ \pgfsys@closepath}
+\def\pgfsys@closepath{\pgf@sys@addtosvgpath{Z}}
+
+% Path usage:
+\newif\ifpgf@sys@svg@clipnext
+\def\pgf@sys@svg@possiblyclippedpath#1{%
+ \edef\pgf@sys@cacheref{\pgfsys@id@refcurrent}%
+ \pgfsys@if@fresh@currentid{\csname pgf@sys@svg@path@\pgf@sys@cacheref\endcsname}{}%
+ \let\pgfsys@anim@ba@d\pgfutil@empty
+ \csname pgfsys@anim@ba@\pgf@sys@cacheref\endcsname%
+ \ifpgf@sys@svg@clipnext%
+ \global\advance\pgf@sys@svg@objectcount by1\relax%
+ \pgfsysprotocol@literal{%
+ <clipPath id="\pgfsys@if@fresh@currentid{\pgf@sys@cacheref}{pgfcp\the\pgf@sys@svg@objectcount}clip">
+ <path id="\pgfsys@if@fresh@currentid{\pgf@sys@cacheref}{pgfcp\the\pgf@sys@svg@objectcount}" d="}%
+ \ifx\pgfsys@anim@ba@d\pgfutil@empty\pgf@sys@flushsvgpath\else\pgfsysprotocol@literal{\pgfsys@anim@ba@d}\fi%
+ \pgfsysprotocol@literal{"/> </clipPath>\pgfsys@svg@newline }
+ \pgfsysprotocol@literal{<use xlink:href="\#\pgfsys@if@fresh@currentid{\pgf@sys@cacheref}{pgfcp\the\pgf@sys@svg@objectcount}" %
+ \ifx\pgfsys@anim@ba@d\pgfutil@empty\else%
+ \ifx\pgfsys@anim@ba@markerstart\pgfutil@empty\else%
+ marker-start="url(\#\pgfsys@anim@ba@markerstart)" %
+ \fi%
+ \ifx\pgfsys@anim@ba@markerend\pgfutil@empty\else%
+ marker-end="url(\#\pgfsys@anim@ba@markerend)" %
+ \fi%
+ \fi%
+ #1/>\pgfsys@svg@newline }%
+ \pgf@sys@svg@gs{clip-path="url(\#\pgfsys@if@fresh@currentid{\pgfsys@id@refcurrent}{pgfcp\the\pgf@sys@svg@objectcount}clip)"}
+ \pgf@sys@svg@clipnextfalse%
+ \else%
+ \pgfsysprotocol@literal{<path\pgfsys@if@fresh@currentid{ id="\pgfsys@id@refcurrent"}{} d="}%
+ \ifx\pgfsys@anim@ba@d\pgfutil@empty\pgf@sys@flushsvgpath\else\pgfsysprotocol@literal{\pgfsys@anim@ba@d}\fi%
+ \pgfsysprotocol@literal{" %
+ \ifx\pgfsys@anim@ba@d\pgfutil@empty\else%
+ \ifx\pgfsys@anim@ba@markerstart\pgfutil@empty\else%
+ marker-start="url(\#\pgfsys@anim@ba@markerstart)" %
+ \fi%
+ \ifx\pgfsys@anim@ba@markerend\pgfutil@empty\else%
+ marker-end="url(\#\pgfsys@anim@ba@markerend)" %
+ \fi%
+ \fi%
+ #1/>\pgfsys@svg@newline }%
+ \fi%
+ \pgfsys@invalidate@currentid%
+}
+\def\pgfsys@stroke{\pgf@sys@svg@possiblyclippedpath{fill="none"}}
+\def\pgfsys@fill{\pgf@sys@svg@possiblyclippedpath{stroke="none"}}
+\def\pgfsys@fillstroke{\pgf@sys@svg@possiblyclippedpath{}}
+\def\pgfsys@clipnext{\pgf@sys@svg@clipnexttrue}
+\def\pgfsys@discardpath{%
+ \ifpgf@sys@svg@clipnext%
+ \edef\pgf@sys@cacheref{\pgfsys@id@refcurrent}%
+ \let\pgfsys@anim@ba@d\pgfutil@empty
+ \csname pgfsys@anim@ba@\pgf@sys@cacheref\endcsname%
+ \global\advance\pgf@sys@svg@objectcount by1\relax%
+ \pgfsysprotocol@literal{%
+ <clipPath id="pgfcp\the\pgf@sys@svg@objectcount">%
+ <path\pgfsys@if@fresh@currentid{ id="\pgfsys@id@refcurrent"}{} d="}%
+ \ifx\pgfsys@anim@ba@d\pgfutil@empty\pgf@sys@flushsvgpath\else\pgfsysprotocol@literal{\pgfsys@anim@ba@d}\fi%
+ \pgfsysprotocol@literal{"/> </clipPath>\pgfsys@svg@newline }
+ \pgf@sys@svg@gs{clip-path="url(\#pgfcp\the\pgf@sys@svg@objectcount)"}
+ \pgf@sys@svg@clipnextfalse%
+ \else%
+ \global\let\pgf@sys@svgpath=\pgfutil@empty
+ \fi%
+ \pgfsys@invalidate@currentid%
+}
+
+% Fill rules:
+\def\pgfsys@eoruletrue{\pgf@sys@svg@gs{fill-rule="evenodd"}}
+\def\pgfsys@eorulefalse{\pgf@sys@svg@gs{fill-rule="nonzero"}}
+
+% Transparency:
+\def\pgfsys@opacity#1{\pgf@sys@svg@gs{opacity="#1"}}
+\def\pgfsys@stroke@opacity#1{\pgf@sys@svg@gs{stroke-opacity="#1"}}
+\def\pgfsys@fill@opacity#1{\pgf@sys@svg@gs{fill-opacity="#1"}\def\pgf@sys@svg@opacity{#1}}
+\def\pgf@sys@svg@opacity{1}
+\def\pgfsys@transparencygroupfrombox#1{%
+ \setbox#1=\hbox{%
+ \pgfsys@invoke{<g opacity="\pgf@sys@svg@opacity" stroke-opacity="1" fill-opacity="1">\pgfsys@svg@newline }%
+ \box#1%
+ \pgfsys@invoke{</g>\pgfsys@svg@newline }%
+ }%
+}
+
+% Transformation:
+\def\pgfsys@transformcm#1#2#3#4#5#6{%
+ {\pgf@x=#5\pgf@y=#6%
+ \edef\pgf@temp{#1,#2,#3,#4}%
+ \ifx\pgf@temp\pgf@sys@svg@idtrans@text%
+ \ifdim\pgf@x=0pt\relax%
+ \ifdim\pgf@y=0pt%
+ \else%
+ \pgf@sys@svg@gs{transform="translate(\pgf@sys@tonumber{\pgf@x},\pgf@sys@tonumber{\pgf@y})"}%
+ \fi%
+ \else%
+ \pgf@sys@svg@gs{transform="translate(\pgf@sys@tonumber{\pgf@x},\pgf@sys@tonumber{\pgf@y})"}%
+ \fi%
+ \else%
+ \pgf@sys@svg@gs{transform="matrix(#1,#2,#3,#4,\pgf@sys@tonumber{\pgf@x},\pgf@sys@tonumber{\pgf@y})"}%
+ \fi}}
+\def\pgfsys@transformshift#1#2{%
+ {\pgf@x=#1\pgf@y=#2%
+ \ifdim\pgf@x=0pt\relax%
+ \ifdim\pgf@y=0pt%
+ \else%
+ \pgf@sys@svg@gs{transform="translate(\pgf@sys@tonumber{\pgf@x},\pgf@sys@tonumber{\pgf@y})"}%
+ \fi%
+ \else%
+ \pgf@sys@svg@gs{transform="translate(\pgf@sys@tonumber{\pgf@x},\pgf@sys@tonumber{\pgf@y})"}%
+ \fi}}
+\def\pgfsys@transformxyscale#1#2{%
+ {\pgf@x=#1pt\pgf@y=#2pt%
+ \pgf@sys@svg@gs{transform="scale(\pgf@sys@tonumber{\pgf@x},\pgf@sys@tonumber{\pgf@y})"}}}
+\def\pgfsys@viewboxmeet{\pgf@sys@svg@viewbox{meet}}
+\def\pgfsys@viewboxslice{\pgf@sys@svg@viewbox{slice}}
+\def\pgf@sys@svg@viewbox#1#2#3#4#5#6#7#8#9{%
+ {%
+ \edef\pgf@sys@cacheref{\pgfsys@id@refcurrent}%
+ \csname pgfsys@anim@ba@\pgf@sys@cacheref\endcsname%
+ \pgf@x#2%
+ \pgf@y#3%
+ \pgf@xa#4%
+ \pgf@ya#5%
+ \advance\pgf@xa by-\pgf@x%
+ \advance\pgf@ya by-\pgf@y%
+ \pgf@xb#6%
+ \pgf@yb#7%
+ \pgf@xc#8%
+ \pgf@yc#9%
+ \advance\pgf@xc by-\pgf@xb%
+ \advance\pgf@yc by-\pgf@yb%
+ \pgfsysprotocol@literal{<svg
+ overflow="visible"
+ preserveAspectRatio="xMidYMid #1"
+ \pgfsys@if@fresh@currentid{ id="\pgf@sys@cacheref"}{}
+ x="\pgf@sys@tonumber{\pgf@x}"
+ y="\pgf@sys@tonumber{\pgf@y}"
+ width="\pgf@sys@tonumber{\pgf@xa}"
+ height="\pgf@sys@tonumber{\pgf@ya}"
+ viewBox="%
+ \ifx\pgfsys@anim@ba@viewBox\pgfutil@empty%
+ \pgf@sys@tonumber{\pgf@xb} \pgf@sys@tonumber{\pgf@yb} \pgf@sys@tonumber{\pgf@xc} \pgf@sys@tonumber{\pgf@yc}%
+ \else%
+ \pgfsys@anim@ba@viewBox%
+ \fi%
+ ">}%
+ \pgfsys@invalidate@currentid%
+ }%
+}
+\def\pgfsys@endviewbox{\pgfsysprotocol@literal{</svg>}}
+
+
+% Scopes
+\newcount\pgf@sys@svg@scopecount
+
+\newif\ifpgfsys@svg@boxmode
+\def\pgfsys@begin@text{\pgfsys@beginscope\pgfsys@svg@boxmodetrue}
+\def\pgfsys@end@text{\pgfsys@endscope}
+
+\def\pgfsys@beginscope{%
+ \edef\pgf@sys@svg@thescopecount{\the\pgf@sys@svg@scopecount}%
+ \begingroup%
+ \pgf@sys@svg@scopecount=0\relax%
+}
+\def\pgfsys@beginscope@#1{%
+ \edef\pgf@sys@svg@thescopecount{\the\pgf@sys@svg@scopecount}%
+ \begingroup%
+ \pgf@sys@svg@scopecount=1\relax%
+ \pgfsysprotocol@literal{<g#1>\pgfsys@svg@newline }%
+}
+\def\pgfsys@endscope{%
+ \loop%
+ \ifnum\pgf@sys@svg@scopecount>0\relax%
+ \pgfsysprotocol@literal{</g>\pgfsys@svg@newline }%
+ \advance\pgf@sys@svg@scopecount by-1\relax%
+ \repeat%
+ \endgroup%
+ \global\pgf@sys@svg@scopecount=\pgf@sys@svg@thescopecount\relax%
+}
+\newif\ifpgfsys@svg@close@strokenone
+\def\pgfsys@begin@idscope{%
+ \begingroup%
+ \pgfsys@if@fresh@currentid{%
+ \edef\pgf@sys@cacheref{\pgfsys@id@refcurrent}%
+ \let\pgf@sys@svg@ba@gs\pgfutil@empty%
+ \csname pgfsys@anim@ba@\pgf@sys@cacheref\endcsname%
+ \pgfsys@beginscope@{ id="\pgf@sys@cacheref" \pgf@sys@svg@ba@gs\pgfsys@svg@rdf}%
+ \expandafter\let\expandafter\pgf@sys@svg@end@id@scope@code\csname pgf@sys@att@end@\pgfsys@id@refcurrent\endcsname%
+ \let\pgf@sys@svg@end@id@scope\pgfsys@endscope%
+ \csname pgf@sys@att@beg@\pgfsys@id@refcurrent\endcsname%
+ }{%
+ \ifx\pgfsys@svg@rdf\pgfutil@empty%
+ \let\pgf@sys@svg@end@id@scope@code\relax%
+ \let\pgf@sys@svg@end@id@scope\relax%
+ \else%
+ \pgfsys@beginscope@{\pgfsys@svg@rdf}%
+ \let\pgf@sys@svg@end@id@scope@code\relax%
+ \let\pgf@sys@svg@end@id@scope\pgfsys@endscope%
+ \fi%
+ }%
+ \expandafter\global\expandafter\let\csname pgf@sys@att@beg@\pgfsys@id@refcurrent\endcsname\relax%
+ \expandafter\global\expandafter\let\csname pgf@sys@att@end@\pgfsys@id@refcurrent\endcsname\relax%
+ \ifpgfsys@svg@boxmode\pgfsysprotocol@literal{<g stroke="none">}\pgfsys@svg@close@strokenonetrue\fi%
+ \pgfsys@invalidate@currentid%
+ \begingroup%
+ \global\let\pgfsys@svg@rdf\pgfutil@empty%
+}
+\def\pgfsys@end@idscope{%
+ \endgroup%
+ \ifpgfsys@svg@close@strokenone\pgfsysprotocol@literal{</g>}\fi%
+ \pgf@sys@svg@end@id@scope@code%
+ \pgf@sys@svg@end@id@scope%
+ \endgroup%
+}
+\let\pgfsys@svg@rdf\pgfutil@empty%
+
+% IDs
+
+\newcount\pgf@sys@svg@type@count
+
+\def\pgfsys@clean@type#1#2{%
+ \expandafter\let\expandafter#1\csname pgf@sys@svg@lookup@#2\endcsname%
+ \if#1\relax%
+ \global\advance\pgf@sys@svg@type@count by1\relax%
+ \expandafter\xdef\csname pgf@sys@svg@lookup@#2\endcsname{t\the\pgf@sys@svg@type@count}%
+ \expandafter\let\expandafter#1\csname pgf@sys@svg@lookup@#2\endcsname%
+ \fi%
+}
+
+
+
+% Graphics state
+\def\pgfsys@setdash#1#2{%
+ {%
+ \pgf@xa#2\relax%
+ \edef\pgf@test@dashpattern{#1}%
+ \ifx\pgf@test@dashpattern\pgfutil@empty%
+ \pgf@sys@svg@gs{stroke-dasharray="none" stroke-dashoffset="\pgf@sys@tonumber\pgf@xa"}%
+ \else%
+ \let\pgf@sys@svg@parsed@dash\pgfutil@empty%
+ \expandafter\pgf@sys@svg@parse@dash\pgf@test@dashpattern,\relax%
+ \pgf@sys@svg@gs{stroke-dasharray="\pgf@sys@svg@parsed@dash" stroke-dashoffset="\pgf@sys@tonumber\pgf@xa"}%
+ \fi%
+ }%
+}
+\def\pgf@sys@svg@parse@dash#1,{%
+ \pgf@x#1\relax%
+ \pgfutil@ifnextchar\relax{%
+ \edef\pgf@sys@svg@parsed@dash{\pgf@sys@svg@parsed@dash\pgf@sys@tonumber\pgf@x}%
+ }{%
+ \edef\pgf@sys@svg@parsed@dash{\pgf@sys@svg@parsed@dash\pgf@sys@tonumber\pgf@x,}%
+ \pgf@sys@svg@parse@dash%
+ }%
+}
+\def\pgfsys@setlinewidth#1{{\pgf@x=#1\pgf@sys@svg@gs{stroke-width="\pgf@sys@tonumber{\pgf@x}"}}}
+\def\pgfsys@setmiterlimit#1{\pgf@sys@svg@gs{stroke-miterlimit="#1"}}
+\def\pgfsys@buttcap{\pgf@sys@svg@gs{stroke-linecap="butt"}}
+\def\pgfsys@roundcap{\pgf@sys@svg@gs{stroke-linecap="round"}}
+\def\pgfsys@rectcap{\pgf@sys@svg@gs{stroke-linecap="square"}}
+\def\pgfsys@miterjoin{\pgf@sys@svg@gs{stroke-linejoin="miter"}}
+\def\pgfsys@roundjoin{\pgf@sys@svg@gs{stroke-linejoin="round"}}
+\def\pgfsys@beveljoin{\pgf@sys@svg@gs{stroke-linejoin="bevel"}}
+
+% Invisibility
+\def\pgfsys@begininvisible{\pgfsysprotocol@literal{<g visibility="hidden">\pgfsys@svg@newline }}
+\def\pgfsys@endinvisible{\pgfsysprotocol@literal{</g>}}
+\def\pgfsys@begininvisiblescope{\pgfsys@beginscope@{ visibility="hidden"}}
+\def\pgfsys@endinvisiblescope{\pgfsys@endscope}
+
+
+%
+% Color management
+%
+
+\def\pgf@sys@svg@rgb@to@hash#1#2#3{%
+ {%
+ \pgf@sys@svg@do@color{#1}%
+ \let\pgf@sys@svg@ra\pgf@sys@svg@hex@first%
+ \let\pgf@sys@svg@rb\pgf@sys@svg@hex@second%
+ \pgf@sys@svg@do@color{#2}%
+ \let\pgf@sys@svg@ga\pgf@sys@svg@hex@first%
+ \let\pgf@sys@svg@gb\pgf@sys@svg@hex@second%
+ \pgf@sys@svg@do@color{#3}%
+ \let\pgf@sys@svg@ba\pgf@sys@svg@hex@first%
+ \let\pgf@sys@svg@bb\pgf@sys@svg@hex@second%
+ \xdef\pgf@sys@svg@prepared{\pgf@sys@svg@hash\pgf@sys@svg@ra\pgf@sys@svg@rb\pgf@sys@svg@ga\pgf@sys@svg@gb\pgf@sys@svg@ba\pgf@sys@svg@bb}%
+ \ifx\pgf@sys@svg@ra\pgf@sys@svg@rb%
+ \ifx\pgf@sys@svg@ga\pgf@sys@svg@gb%
+ \ifx\pgf@sys@svg@ba\pgf@sys@svg@bb%
+ \xdef\pgf@sys@svg@prepared{\pgf@sys@svg@hash\pgf@sys@svg@ra\pgf@sys@svg@ga\pgf@sys@svg@ba}%
+ \fi%
+ \fi%
+ \fi%
+ }%
+}
+
+\expandafter\def\csname pgf@svg@0\endcsname{0}
+\expandafter\def\csname pgf@svg@1\endcsname{1}
+\expandafter\def\csname pgf@svg@2\endcsname{2}
+\expandafter\def\csname pgf@svg@3\endcsname{3}
+\expandafter\def\csname pgf@svg@4\endcsname{4}
+\expandafter\def\csname pgf@svg@5\endcsname{5}
+\expandafter\def\csname pgf@svg@6\endcsname{6}
+\expandafter\def\csname pgf@svg@7\endcsname{7}
+\expandafter\def\csname pgf@svg@8\endcsname{8}
+\expandafter\def\csname pgf@svg@9\endcsname{9}
+\expandafter\def\csname pgf@svg@10\endcsname{a}
+\expandafter\def\csname pgf@svg@11\endcsname{b}
+\expandafter\def\csname pgf@svg@12\endcsname{c}
+\expandafter\def\csname pgf@svg@13\endcsname{d}
+\expandafter\def\csname pgf@svg@14\endcsname{e}
+\expandafter\def\csname pgf@svg@15\endcsname{f}
+
+\def\pgf@sys@svg@do@color#1{%
+ \pgf@x#1\relax%
+ \c@pgf@counta\pgf@x%
+ \divide\c@pgf@counta by256\relax%
+ \ifnum\c@pgf@counta>255\relax%
+ \c@pgf@counta=255\relax%
+ \fi%
+ \ifnum\c@pgf@counta<0\relax%
+ \c@pgf@counta=0\relax%
+ \fi%
+ \c@pgf@countb\c@pgf@counta\relax%
+ \divide\c@pgf@countb by16\relax%
+ \expandafter\let\expandafter\pgf@sys@svg@hex@first\csname pgf@svg@\the\c@pgf@countb\endcsname%
+ \multiply\c@pgf@countb by16\relax%
+ \advance\c@pgf@counta by-\c@pgf@countb\relax%
+ \expandafter\let\expandafter\pgf@sys@svg@hex@second\csname pgf@svg@\the\c@pgf@counta\endcsname%
+}
+
+\def\pgf@sys@svg@color@rgb#1,#2,#3\relax{%
+ {%
+ \pgf@sys@svg@rgb@to@hash{#1pt}{#2pt}{#3pt}%
+ }%
+}
+\def\pgf@sys@svg@color@cmy#1,#2,#3\relax{%
+ {%
+ \pgf@xa=1pt%
+ \advance\pgf@xa by-#1pt%
+ \pgf@xb=1pt%
+ \advance\pgf@xb by-#2pt%
+ \pgf@xc=1pt%
+ \advance\pgf@xc by-#3pt%
+ \pgf@sys@svg@rgb@to@hash{\pgf@xa}{\pgf@xb}{\pgf@xc}%
+ }%
+}
+\def\pgf@sys@svg@color@cmyk#1,#2,#3,#4\relax{%
+ {%
+ \pgf@xa=1pt%
+ \advance\pgf@xa by-#4pt%
+ \pgf@xa=#1\pgf@xa%
+ \advance\pgf@xa by#4pt%
+ \advance\pgf@xa by-1pt%
+ \pgf@xa=-\pgf@xa%
+ \pgf@xb=1pt%
+ \advance\pgf@xb by-#4pt%
+ \pgf@xb=#2\pgf@xb%
+ \advance\pgf@xb by#4pt%
+ \advance\pgf@xb by-1pt%
+ \pgf@xb=-\pgf@xb%
+ \pgf@xc=1pt%
+ \advance\pgf@xc by-#4pt%
+ \pgf@xc=#3\pgf@xc%
+ \advance\pgf@xc by#4pt%
+ \advance\pgf@xc by-1pt%
+ \pgf@xc=-\pgf@xc%
+ \pgf@sys@svg@rgb@to@hash{\pgf@xa}{\pgf@xb}{\pgf@xc}%
+ }%
+}
+\def\pgf@sys@svg@color@gray#1\relax{%
+ {%
+ \pgf@xa=#1pt%
+ \pgf@sys@svg@rgb@to@hash{\pgf@xa}{\pgf@xa}{\pgf@xa}%
+ }%
+}
+
+\def\pgf@sys@svg@gs@color#1{%
+ \ifpgfpicture\pgf@sys@svg@gs{#1}\fi%
+}
+
+\def\pgf@sys@svg@colorpop{\special{color pop}}
+
+
+% RGB
+\def\pgfsys@color@rgb@stroke#1#2#3{%
+ \pgf@sys@svg@color@rgb#1,#2,#3\relax%
+ \let\pgf@sys@svg@last@stroke\pgf@sys@svg@prepared%
+ \pgf@sys@svg@gs@color{stroke="\pgf@sys@svg@prepared"}}
+\def\pgfsys@color@rgb@fill#1#2#3{%
+ \ifpgfpicture%
+ \pgf@sys@svg@color@rgb#1,#2,#3\relax%
+ \pgf@sys@svg@gs@color{fill="\pgf@sys@svg@prepared"}%
+ \else%
+ \special{color push rgb #1 #2 #3}%
+ \aftergroup\pgf@sys@svg@colorpop%
+ \fi}
+\def\pgfsys@color@rgb#1#2#3{%
+ \ifpgfpicture%
+ \pgf@sys@svg@color@rgb#1,#2,#3\relax%
+ \let\pgf@sys@svg@last@stroke\pgf@sys@svg@prepared%
+ \pgf@sys@svg@gs@color{\ifpgfsys@svg@boxmode\else stroke="\pgf@sys@svg@prepared" \fi fill="\pgf@sys@svg@prepared"}%
+ \else%
+ \special{color push rgb #1 #2 #3}%
+ \aftergroup\pgf@sys@svg@colorpop%
+ \fi}
+
+%CMYK
+\def\pgfsys@color@cmyk@stroke#1#2#3#4{%
+ \pgf@sys@svg@color@cmyk#1,#2,#3,#4\relax%
+ \let\pgf@sys@svg@last@stroke\pgf@sys@svg@prepared%
+ \pgf@sys@svg@gs@color{stroke="\pgf@sys@svg@prepared"}}
+\def\pgfsys@color@cmyk@fill#1#2#3#4{%
+ \ifpgfpicture%
+ \pgf@sys@svg@color@cmyk#1,#2,#3,#4\relax%
+ \pgf@sys@svg@gs@color{fill="\pgf@sys@svg@prepared"}%
+ \else%
+ \special{color push cmyk #1 #2 #3 #4}%
+ \aftergroup\pgf@sys@svg@colorpop%
+ \fi}
+\def\pgfsys@color@cmyk#1#2#3#4{%
+ \ifpgfpicture%
+ \pgf@sys@svg@color@cmyk#1,#2,#3,#4\relax%
+ \let\pgf@sys@svg@last@stroke\pgf@sys@svg@prepared%
+ \pgf@sys@svg@gs@color{\ifpgfsys@svg@boxmode\else stroke="\pgf@sys@svg@prepared" \fi fill="\pgf@sys@svg@prepared"}%
+ \else%
+ \special{color push cmyk #1 #2 #3 #4}%
+ \aftergroup\pgf@sys@svg@colorpop%
+ \fi}
+
+% CMY
+\def\pgfsys@color@cmy@stroke#1#2#3{%
+ \pgf@sys@svg@color@cmy#1,#2,#3\relax%
+ \let\pgf@sys@svg@last@stroke\pgf@sys@svg@prepared%
+ \pgf@sys@svg@gs@color{stroke="\pgf@sys@svg@prepared"}}
+\def\pgfsys@color@cmy@fill#1#2#3{%
+ \ifpgfpicture%
+ \pgf@sys@svg@color@cmy#1,#2,#3\relax%
+ \pgf@sys@svg@gs@color{fill="\pgf@sys@svg@prepared"}
+ \else%
+ \special{color push cmyk #1 #2 #3 0}%
+ \aftergroup\pgf@sys@svg@colorpop%
+ \fi}
+\def\pgfsys@color@cmy#1#2#3{%
+ \ifpgfpicture%
+ \pgf@sys@svg@color@cmy#1,#2,#3\relax%
+ \let\pgf@sys@svg@last@stroke\pgf@sys@svg@prepared%
+ \pgf@sys@svg@gs@color{\ifpgfsys@svg@boxmode\else stroke="\pgf@sys@svg@prepared" \fi fill="\pgf@sys@svg@prepared"}%
+ \else%
+ \special{color push cmyk #1 #2 #3 0}%
+ \aftergroup\pgf@sys@svg@colorpop%
+ \fi}
+
+% gray
+\def\pgfsys@color@gray@stroke#1{%
+ \pgf@sys@svg@color@gray#1\relax%
+ \let\pgf@sys@svg@last@stroke\pgf@sys@svg@prepared%
+ \pgf@sys@svg@gs@color{stroke="\pgf@sys@svg@prepared"}}
+\def\pgfsys@color@gray@fill#1{%
+ \ifpgfpicture%
+ \pgf@sys@svg@color@gray#1\relax%
+ \pgf@sys@svg@gs@color{fill="\pgf@sys@svg@prepared"}%
+ \else%
+ \special{color push gray #1}%
+ \aftergroup\pgf@sys@svg@colorpop%
+ \fi}
+\def\pgfsys@color@gray#1{%
+ \ifpgfpicture%
+ \pgf@sys@svg@color@gray#1\relax%
+ \let\pgf@sys@svg@last@stroke\pgf@sys@svg@prepared%
+ \pgf@sys@svg@gs@color{\ifpgfsys@svg@boxmode\else stroke="\pgf@sys@svg@prepared" \fi fill="\pgf@sys@svg@prepared"}%
+ \else%
+ \special{color push gray #1}%
+ \aftergroup\pgf@sys@svg@colorpop%
+ \fi}
+
+
+% Shadings:
+\def\pgf@sys@svg@shading@stops{%
+ % Step 1: Compute 1/\pgf@sys@shading@end@pos
+ \pgf@x=\pgf@sys@shading@end@pos\relax%
+ \c@pgf@counta=\pgf@x\relax%
+ \divide\c@pgf@counta by4096\relax%
+ % Step 2: Insert stops.
+ \expandafter\pgf@sys@svg@shading@dostops\pgf@sys@shading@ranges%
+ % dummy for end:
+ {{\pgf@sys@shading@end@pos}{\pgf@sys@shading@end@pos}{\pgf@sys@shading@end@rgb}{\pgf@sys@shading@end@rgb}}%
+ {}% end
+}
+\def\pgf@sys@svg@shading@dostops#1{%
+ \edef\pgf@test{#1}%
+ \ifx\pgf@test\pgfutil@empty%
+ \else%
+ \expandafter\pgf@sys@svg@shading@dostop\pgf@test%
+ \expandafter\pgf@sys@svg@shading@dostops%
+ \fi%
+}
+\def\pgf@sys@svg@shading@dostop#1#2#3#4{%
+ % #1 start pos
+ % #2 end pos
+ % #3 start rgb
+ % #4 end rgb
+ \pgf@x=#1%
+ \pgf@x=16\pgf@x%
+ \divide\pgf@x by \c@pgf@counta\relax%
+ \pgf@sys@svg@addtostops{<stop offset="\pgf@sys@tonumber\pgf@x" stop-color="}%
+ \pgf@sys@svg@shading@dorgb#3%
+ \pgf@sys@svg@addtostops{"/>\noexpand\pgfsys@svg@newline}%
+}
+\def\pgf@sys@svg@shading@dorgb#1#2#3{%
+ \pgf@sys@svg@color@rgb#1,#2,#3\relax%
+ \pgf@sys@svg@addtostops{\pgf@sys@svg@prepared}%
+}
+
+\let\pgf@sys@svg@thestops=\pgfutil@empty
+\def\pgf@sys@svg@addtostops#1{%
+ \edef\pgf@temp{#1}%
+ \expandafter\expandafter\expandafter\def
+ \expandafter\expandafter\expandafter\pgf@sys@svg@thestops
+ \expandafter\expandafter\expandafter{\expandafter\pgf@sys@svg@thestops\expandafter\space\pgf@temp}%
+}
+
+
+\def\pgfsys@horishading#1#2#3{%
+ {%
+ \pgf@parsefunc{#3}%
+ \global\advance\pgf@sys@svg@objectcount by1\relax%
+ \pgf@sys@svg@addtostops{<linearGradient id="pgfsh\the\pgf@sys@svg@objectcount">\noexpand\pgfsys@svg@newline}%
+ \pgf@sys@svg@shading@stops%
+ \pgf@sys@svg@addtostops{</linearGradient>\noexpand\pgfsys@svg@newline}%
+ \pgf@process{\pgfpoint{\pgf@sys@shading@end@pos}{#2}}%
+ \xdef\pgfutil@tempa{%
+ \def\noexpand\pgf@sys@svg@sh@defs{\noexpand\pgfsysprotocol@literal{\pgf@sys@svg@thestops}}%
+ \def\noexpand\pgf@sys@svg@sh{\noexpand\pgfsysprotocol@literal{<rect
+ width="\pgf@sys@tonumber{\pgf@x}"
+ height="\pgf@sys@tonumber{\pgf@y}"
+ style="fill:url(\noexpand\#pgfsh\the\pgf@sys@svg@objectcount);
+ stroke:none"/>\noexpand\pgfsys@svg@newline}}%
+ \def\noexpand\pgf@sys@svg@pos{\noexpand\pgfpoint{\the\pgf@x}{\the\pgf@y}}%
+ }%
+ }%
+ \global\expandafter\let\csname @pgfshading#1!\endcsname=\pgfutil@tempa
+}
+
+\def\pgfsys@functionalshading#1#2#3#4{%
+ \pgf@sys@fail{functional shadings}%
+ \expandafter\gdef\csname @pgfshading#1!\endcsname{%
+ \let\pgf@sys@svg@sh@defs\relax%
+ \let\pgf@sys@svg@sh\relax%
+ \let\pgf@sys@svg@pos\pgfpointorigin%
+ }%
+}
+
+\def\pgfsys@vertshading#1#2#3{%
+ {%
+ \pgf@parsefunc{#3}%
+ \global\advance\pgf@sys@svg@objectcount by1\relax%
+ \pgf@sys@svg@addtostops{<linearGradient
+ id="pgfsh\the\pgf@sys@svg@objectcount"
+ gradientTransform="rotate(90)">\noexpand\pgfsys@svg@newline}%
+ \pgf@sys@svg@shading@stops%
+ \pgf@sys@svg@addtostops{</linearGradient>\noexpand\pgfsys@svg@newline}%
+ \pgf@process{\pgfpoint{\pgf@sys@shading@end@pos}{#2}}%
+ \xdef\pgfutil@tempa{%
+ \def\noexpand\pgf@sys@svg@sh@defs{\noexpand\pgfsysprotocol@literal{\pgf@sys@svg@thestops}}%
+ \def\noexpand\pgf@sys@svg@sh{\noexpand\pgfsysprotocol@literal{<rect
+ width="\pgf@sys@tonumber{\pgf@y}"
+ height="\pgf@sys@tonumber{\pgf@x}"
+ style="fill:url(\noexpand\#pgfsh\the\pgf@sys@svg@objectcount);
+ stroke:none"/>\noexpand\pgfsys@svg@newline}}%
+ \def\noexpand\pgf@sys@svg@pos{\noexpand\pgfpoint{\the\pgf@y}{\the\pgf@x}}%
+ }%
+ }%
+ \global\expandafter\let\csname @pgfshading#1!\endcsname=\pgfutil@tempa
+}
+
+\def\pgfsys@radialshading#1#2#3{%
+ {%
+ \pgf@parsefunc{#3}%
+ \pgf@x=\pgf@sys@shading@end@pos\relax%
+ \c@pgf@counta=\pgf@x\relax%
+ \divide\c@pgf@counta by4096\relax%
+ \global\advance\pgf@sys@svg@objectcount by1\relax%
+ \pgf@process{#2}%
+ % Divide by 2\pgf@sys@shading@end@pos%
+ \pgf@x=8\pgf@x%
+ \divide\pgf@x by \c@pgf@counta\relax%
+ \pgf@y=8\pgf@y%
+ \divide\pgf@y by \c@pgf@counta\relax%
+ \advance\pgf@x by.5pt%
+ \advance\pgf@y by.5pt%
+ \pgf@sys@svg@addtostops{<radialGradient
+ id="pgfsh\the\pgf@sys@svg@objectcount"
+ fx="\pgf@sys@tonumber\pgf@x"
+ fy="\pgf@sys@tonumber\pgf@y"
+ >\noexpand\pgfsys@svg@newline}%
+ \pgf@sys@svg@shading@stops%
+ \pgf@sys@svg@addtostops{</radialGradient>\noexpand\pgfsys@svg@newline}%
+ \pgf@xa=\pgf@sys@shading@end@pos%
+ \pgf@xb=2\pgf@xa%
+ \xdef\pgfutil@tempa{%
+ \def\noexpand\pgf@sys@svg@sh@defs{\noexpand\pgfsysprotocol@literal{\pgf@sys@svg@thestops}}%
+ \def\noexpand\pgf@sys@svg@sh{\noexpand\pgfsysprotocol@literal{<circle
+ cx="\pgf@sys@tonumber{\pgf@xa}"
+ cy="\pgf@sys@tonumber{\pgf@xa}"
+ r="\pgf@sys@tonumber{\pgf@xa}"
+ style="fill:url(\noexpand\#pgfsh\the\pgf@sys@svg@objectcount);
+ stroke:none"/>\noexpand\pgfsys@svg@newline}}%
+ \def\noexpand\pgf@sys@svg@pos{\noexpand\pgfpoint{\the\pgf@xb}{\the\pgf@xb}}%
+ }%
+ }%
+ \global\expandafter\let\csname @pgfshading#1!\endcsname=\pgfutil@tempa
+}
+
+
+% Patterns
+
+\def\pgfsys@declarepattern#1#2#3#4#5#6#7{%
+ % Start building the pattern dictionary:
+ \pgf@xa=#2\relax%
+ \pgf@ya=#3\relax%
+ \pgf@xb=#4\relax%
+ \pgf@yb=#5\relax%
+ \pgf@xc=#6\relax%
+ \pgf@yc=#7\relax%
+ \pgfsys@@declarepattern{#1}%
+}
+
+\def\pgfsys@@declarepattern#1#2#3#4#5#6#7#8#9{%
+ \pgfutil@tempdima=#6\relax%
+ \pgfutil@tempdimb=#7\relax%
+ \ifnum#9=1\relax%
+ % Colored. That's easy:
+ \pgf@sys@svg@make@defs{#1}{
+ <pattern
+ id="pgfpat#1"
+ patternUnits="userSpaceOnUse"
+ width="\pgf@sys@tonumber\pgf@xc"
+ height="\pgf@sys@tonumber\pgf@yc"
+ patternTransform="matrix(#2\space#3\space#4\space#5\space\pgf@sys@tonumber\pgfutil@tempdima\space\pgf@sys@tonumber\pgfutil@tempdimb)">
+ #8
+ </pattern>}%
+ \else%
+ % Uncolored. Yikes!
+ \pgf@sys@svg@make@defs{#1}{
+ <pattern
+ id="pgfpat#1"
+ patternUnits="userSpaceOnUse"
+ width="\pgf@sys@tonumber\pgf@xc"
+ height="\pgf@sys@tonumber\pgf@yc"
+ patternTransform="matrix(#2\space#3\space#4\space#5\space\pgf@sys@tonumber\pgfutil@tempdima\space\pgf@sys@tonumber\pgfutil@tempdimb)"/>
+ <symbol id="pgfsym#1">
+ #8
+ </symbol>}%
+ \fi%
+}
+
+\def\pgfsys@setpatternuncolored#1#2#3#4{%
+ \global\advance\pgf@sys@svg@objectcount by1\relax%
+ \pgf@sys@svg@color@rgb#2,#3,#4\relax%
+ \pgfsysprotocol@literal{
+ <pattern id="pgfupat\the\pgf@sys@svg@objectcount" xlink:href="\#pgfpat#1">
+ <g stroke="\pgf@sys@svg@prepared" fill="\pgf@sys@svg@prepared"> <use xlink:href="\#pgfsym#1"/> </g>
+ </pattern>}%
+ \pgf@sys@svg@ref@defs{#1}%
+ \pgf@sys@svg@gs@color{fill="url(\#pgfupat\the\pgf@sys@svg@objectcount)"}%
+}
+
+\def\pgfsys@setpatterncolored#1{%
+ \pgf@sys@svg@ref@defs{#1}%
+ \pgf@sys@svg@gs@color{fill="url(\#pgfpat#1)"}%
+}
+
+
+
+
+
+
+% Animation
+
+\pgfsysanimationsupportedtrue
+
+\let\pgfsys@anim@val@dur\pgfutil@empty
+\let\pgfsys@anim@val@restart\pgfutil@empty
+\let\pgfsys@anim@val@repeatCount\pgfutil@empty
+\let\pgfsys@anim@val@repeatDur\pgfutil@empty
+\let\pgfsys@anim@val@fill\pgfutil@empty
+\let\pgfsys@anim@val@keyTimes\pgfutil@empty
+\let\pgfsys@anim@val@keyPoints\pgfutil@empty
+\let\pgfsys@anim@val@keySplines\pgfutil@empty
+\let\pgfsys@anim@val@begin\pgfutil@empty
+\let\pgfsys@anim@val@end\pgfutil@empty
+\let\pgfsys@anim@val@additive\pgfutil@empty
+\let\pgfsys@anim@val@accumulate\pgfutil@empty
+\def\pgfsys@anim@val@calcMode{spline}
+\let\pgfsys@anim@val@from\pgfutil@empty
+\let\pgfsys@anim@val@to\pgfutil@empty
+\let\pgfsys@anim@val@path\pgfutil@empty
+\let\pgfsys@anim@val@rotate\pgfutil@empty
+\let\pgfsys@anim@val@values\pgfutil@empty
+\def\pgfsys@anim@val@canvas@trans{{}{}}
+\let\pgfsys@anim@val@@id\pgfutil@empty
+\let\pgfsys@anim@val@@type\pgfutil@empty
+\let\pgfsys@anim@val@base\pgfutil@empty
+\let\pgfsys@anim@val@idref\pgfutil@empty
+\expandafter\let\csname pgfsys@anim@val@xlink:href\endcsname\pgfutil@empty
+
+\def\pgf@sys@svg@key#1{%
+ \expandafter\ifx\csname pgfsys@anim@val@#1\endcsname\pgfutil@empty\else%
+ \space#1="\csname pgfsys@anim@val@#1\endcsname"%
+ \fi%
+}
+
+\def\pgf@svg@anim@keys{
+ \pgf@sys@svg@key{dur}%
+ \pgf@sys@svg@key{restart}%
+ \pgf@sys@svg@key{repeatCount}%
+ \pgf@sys@svg@key{repeatDur}%
+ \pgf@sys@svg@key{fill}%
+ \pgf@sys@svg@key{keyTimes}%
+ \pgf@sys@svg@key{keyPoints}%
+ \pgf@sys@svg@key{keySplines}%
+ \pgf@sys@svg@key{begin}%
+ \pgf@sys@svg@key{end}%
+ \pgf@sys@svg@key{additive}%
+ \pgf@sys@svg@key{accumulate}%
+ \pgf@sys@svg@key{calcMode}%
+ \pgf@sys@svg@key{values}%
+ \pgf@sys@svg@key{from}%
+ \pgf@sys@svg@key{to}%
+ \pgf@sys@svg@key{path}%
+ \pgf@sys@svg@key{rotate}%
+ \pgf@sys@svg@key{xlink:href}%
+}
+
+\newif\ifpgf@sys@at@least@one@event
+\def\pgf@sys@svg@do@events#1{%
+ \pgf@sys@at@least@one@eventfalse%
+ \def\pgf@sys@event@target{#1}%
+ \expandafter\expandafter\expandafter\pgf@sys@svg@do@events@now\csname pgf@sys@event@list@#1\endcsname\relax%
+}
+\def\pgf@sys@svg@do@events@now{%
+ \pgfutil@ifnextchar\relax{}{\pgf@sys@svg@do@event}%
+}
+\def\pgf@sys@svg@do@event#1#2#3#4{%
+ \pgf@sys@at@least@one@eventtrue%
+ %
+ {%
+ \edef\pgf@temp{#1}%
+ \ifx\pgf@temp\pgfutil@empty%
+ \else%
+ \pgfsys@register@type{#2}%
+ \def\pgf@temp{\pgfsys@id@ref{#1}{#2}.}%
+ \fi%
+ \edef\pgf@@temp{#4}%
+ \ifx\pgf@@temp\pgfutil@empty%
+ \pgf@x0pt%
+ \else%
+ \pgf@x#4pt%
+ \fi%
+ \ifx\pgf@sys@event@target\pgf@sys@begin@text%
+ \advance\pgf@x by\pgf@xa\relax%
+ \fi\relax%
+ \ifdim\pgf@x<0pt%
+ \edef\pgf@@temp{ \pgf@sys@tonumber\pgf@x s}%
+ \else
+ \edef\pgf@@temp{ +\pgf@sys@tonumber\pgf@x s}%
+ \fi%
+ \xdef\pgf@svg@anim@temp{\pgf@temp#3\pgf@@temp}%
+ }%
+ \pgf@sys@svg@append{\pgf@sys@event@target}{\pgf@svg@anim@temp}%
+ \global\let\pgf@svg@anim@temp\relax%
+ \pgf@sys@svg@do@events@now%
+}
+
+
+\newif\ifpgf@sys@svg@is@sync@base
+\def\pgf@sys@svg@anim#1#2#3{%
+ \ifx\pgfsys@anim@val@@id\pgfutil@empty%
+ \pgferror{Animation misses ``whom''}%
+ \else%
+ {%
+ \ifx\pgfsys@anim@val@base\pgfutil@empty%
+ \else%
+ % Hook into id:
+ \expandafter\let\expandafter\pgf@sys@temp\csname pgfsys@anim@ba@\pgfsys@anim@val@idref\endcsname%
+ \ifx\pgf@sys@temp\relax%
+ \edef\pgf@sys@temp{\global\let\expandafter\noexpand\csname pgfsys@anim@ba@\pgfsys@anim@val@idref\endcsname\relax\noexpand\pgfsys@anim@ba@setup}%
+ \fi%
+ \expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter\pgf@sys@temp\expandafter\expandafter\expandafter{\expandafter\pgf@sys@temp\expandafter\def\expandafter#3\expandafter{\pgfsys@anim@val@base}}%
+ \expandafter\global\expandafter\let\csname pgfsys@anim@ba@\pgfsys@anim@val@idref\endcsname\pgf@sys@temp%
+ \fi%
+ \pgf@sys@svg@tl@eval%
+ \pgf@sys@svg@do@events{begin}%
+ \ifpgf@sys@at@least@one@event%
+ \else%
+ \pgf@sys@svg@append{begin}{\ifdim\pgf@xa>0pt+\fi\pgf@sys@tonumber\pgf@xa s}%
+ \fi%
+ \pgf@sys@svg@do@events{end}%
+ #2%
+ % Suppress empty, superfluous animations:
+ \pgfutil@tempswatrue%
+ \pgfsys@if@fresh@currentid{}{%
+ \ifx\pgfsys@anim@val@values\pgfutil@empty%
+ \ifx\pgfsys@anim@val@to\pgfutil@empty%
+ \ifx\pgfsys@anim@val@dur\pgfutil@empty%
+ \pgfutil@tempswafalse%
+ \fi%
+ \fi%
+ \fi}
+ \ifpgfutil@tempswa%
+ \edef\pgf@temp{{<animate #1\pgfsys@if@fresh@currentid{ id="\pgfsys@id@refcurrent"}{}\pgf@svg@anim@keys/>\pgfsys@svg@newline}}%
+ \expandafter\pgfsysprotocol@literal\pgf@temp%
+ \fi%
+ \pgfsys@invalidate@currentid%
+ }%
+ \fi%
+}
+
+\def\pgf@sys@svg@anim@path{%
+ % animate a path...
+ \ifx\pgfsys@anim@val@@id\pgfutil@empty%
+ \pgferror{Animation misses ``whom''}%
+ \else%
+ {%
+ \let\pgf@sys@svg@add@code\pgfutil@empty%
+ %
+ % Setup markers:
+ %
+ % Setup start
+ \ifx\pgf@svg@anim@marker@start\pgfutil@empty%
+ \let\pgf@sys@svg@marker@id@start\pgfutil@empty%
+ \else%
+ \global\advance\pgf@sys@svg@objectcount by1\relax%
+ \edef\pgf@sys@svg@marker@id{pgf\the\pgf@sys@svg@objectcount m}%
+ \edef\pgf@sys@svg@add@code{%
+ \noexpand\pgf@sys@svg@ref@defs{pgfs\pgf@svg@anim@marker@start}%
+ \noexpand\pgfsysprotocol@literal{<marker id="\pgf@sys@svg@marker@id" markerUnits="userSpaceOnUse" orient="auto" overflow="visible">
+ <use xlink:href="\#pgfs\pgf@svg@anim@marker@start" transform="scale(-1,-1)"/> </marker>\pgfsys@svg@newline}%
+ }%
+ \let\pgf@sys@svg@marker@id@start\pgf@sys@svg@marker@id%
+ \fi%
+ % Setup end
+ \ifx\pgf@svg@anim@marker@end\pgfutil@empty%
+ \let\pgf@sys@svg@marker@id@end\pgfutil@empty%
+ \else%
+ \global\advance\pgf@sys@svg@objectcount by1\relax%
+ \edef\pgf@sys@svg@marker@id{pgf\the\pgf@sys@svg@objectcount m}%
+ \edef\pgf@sys@svg@add@code@{%
+ \noexpand\pgf@sys@svg@ref@defs{pgfs\pgf@svg@anim@marker@end}%
+ \noexpand\pgfsysprotocol@literal{<marker id="\pgf@sys@svg@marker@id" markerUnits="userSpaceOnUse" orient="auto" overflow="visible">
+ <use xlink:href="\#pgfs\pgf@svg@anim@marker@end"/> </marker>\pgfsys@svg@newline}%
+ }%
+ \expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter\pgf@sys@svg@add@code\expandafter\expandafter\expandafter{\expandafter\pgf@sys@svg@add@code\pgf@sys@svg@add@code@}%
+ \let\pgf@sys@svg@marker@id@end\pgf@sys@svg@marker@id%
+ \fi%
+ \ifx\pgfsys@anim@val@base\pgfutil@empty%
+ \else%
+ % Hook into id of path:
+ \expandafter\let\expandafter\pgf@sys@temp\csname pgfsys@anim@ba@\pgfsys@anim@val@idref\endcsname%
+ \ifx\pgf@sys@temp\relax%
+ \edef\pgf@sys@temp{\global\let\expandafter\noexpand\csname pgfsys@anim@ba@\pgfsys@anim@val@idref\endcsname\relax\noexpand\pgfsys@anim@ba@setup}%
+ \fi%
+ \expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter\pgf@sys@temp\expandafter\expandafter\expandafter{\expandafter\pgf@sys@temp\expandafter\def\expandafter\pgfsys@anim@ba@d\expandafter{\pgfsys@anim@val@base}}%
+ \expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter\pgf@sys@temp\expandafter\expandafter\expandafter{\expandafter\pgf@sys@temp\expandafter\def\expandafter\pgfsys@anim@ba@markerstart\expandafter{\pgf@sys@svg@marker@id@start}}%
+ \expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter\pgf@sys@temp\expandafter\expandafter\expandafter{\expandafter\pgf@sys@temp\expandafter\def\expandafter\pgfsys@anim@ba@markerend\expandafter{\pgf@sys@svg@marker@id@end}}%
+ \expandafter\global\expandafter\let\csname pgfsys@anim@ba@\pgfsys@anim@val@idref\endcsname\pgf@sys@temp%
+ \fi%
+ \pgf@sys@svg@tl@eval%
+ \pgf@sys@svg@do@events{begin}%
+ \ifpgf@sys@at@least@one@event%
+ \else%
+ \pgf@sys@svg@append{begin}{\ifdim\pgf@xa>0pt+\fi\pgf@sys@tonumber\pgf@xa s}%
+ \fi%
+ \pgf@sys@svg@do@events{end}%
+ % Suppress empty, superfluous animations:
+ \pgfutil@tempswatrue%
+ \pgfsys@if@fresh@currentid{}{%
+ \ifx\pgfsys@anim@val@values\pgfutil@empty%
+ \ifx\pgfsys@anim@val@to\pgfutil@empty%
+ \ifx\pgfsys@anim@val@dur\pgfutil@empty%
+ \pgfutil@tempswafalse%
+ \fi%
+ \fi%
+ \fi}
+ \ifpgfutil@tempswa%
+ % Ok, first, animate the path:
+ \edef\pgf@temp{%
+ {%
+ <animate attributeName="d"\pgfsys@if@fresh@currentid{ id="\pgfsys@id@refcurrent"}{}\pgf@svg@anim@keys/>\pgfsys@svg@newline
+ <animate attributeName="marker-start"\pgfsys@if@fresh@currentid{ id="\pgfsys@id@refcurrent-ms"}{}%
+ \pgf@sys@svg@key{dur}%
+ \pgf@sys@svg@key{restart}%
+ \pgf@sys@svg@key{repeatCount}%
+ \pgf@sys@svg@key{repeatDur}%
+ \pgf@sys@svg@key{fill}%
+ \pgf@sys@svg@key{begin}%
+ \pgf@sys@svg@key{end}%
+ \pgf@sys@svg@key{xlink:href}
+ from="\ifx\pgf@svg@anim@marker@start\pgfutil@empty none\else url(\#\pgf@sys@svg@marker@id@start)\fi"
+ to="\ifx\pgf@svg@anim@marker@start\pgfutil@empty none\else url(\#\pgf@sys@svg@marker@id@start)\fi"
+ />\pgfsys@svg@newline%
+ <animate attributeName="marker-end"\pgfsys@if@fresh@currentid{ id="\pgfsys@id@refcurrent-me"}{}%
+ \pgf@sys@svg@key{dur}%
+ \pgf@sys@svg@key{restart}%
+ \pgf@sys@svg@key{repeatCount}%
+ \pgf@sys@svg@key{repeatDur}%
+ \pgf@sys@svg@key{fill}%
+ \pgf@sys@svg@key{begin}%
+ \pgf@sys@svg@key{end}%
+ \pgf@sys@svg@key{xlink:href}
+ from="\ifx\pgf@svg@anim@marker@end\pgfutil@empty none\else url(\#\pgf@sys@svg@marker@id@end)\fi"
+ to="\ifx\pgf@svg@anim@marker@end\pgfutil@empty none\else url(\#\pgf@sys@svg@marker@id@end)\fi"
+ />\pgfsys@svg@newline%
+ }}%
+ \expandafter\pgfsysprotocol@literal\pgf@temp%
+ \fi%
+ \ifx\pgf@sys@svg@add@code\pgfutil@empty%
+ \else%
+ \expandafter\let\expandafter\pgf@sys@svg@add@code@\csname pgf@sys@svg@path@\pgfsys@id@ref{\pgfsys@anim@val@@id}{\pgfsys@anim@val@@type}\endcsname%
+ \ifx\pgf@sys@svg@add@code@\relax%
+ \else%
+ \expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter\pgf@sys@svg@add@code\expandafter\expandafter\expandafter{\expandafter\pgf@sys@svg@add@code\pgf@sys@svg@add@code@}%
+ \fi%
+ \expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter\pgf@sys@svg@add@code%
+ \expandafter\expandafter\expandafter{\expandafter\pgf@sys@svg@add@code\expandafter\global\expandafter\let\csname pgf@sys@svg@path@\pgfsys@id@ref{\pgfsys@anim@val@@id}{\pgfsys@anim@val@@type}\endcsname\relax}%
+ \expandafter\global\expandafter\let\csname pgf@sys@svg@path@\pgfsys@id@ref{\pgfsys@anim@val@@id}{\pgfsys@anim@val@@type}\endcsname\pgf@sys@svg@add@code%
+ \fi%
+ \pgfsys@invalidate@currentid%
+ }%
+ \fi%
+}
+
+\def\pgfsys@anim@ba@setup{%
+ \let\pgfsys@anim@ba@opacity\pgfutil@empty%
+ \let\pgfsys@anim@ba@fillopacity\pgfutil@empty%
+ \let\pgfsys@anim@ba@strokeopacity\pgfutil@empty%
+ \let\pgfsys@anim@ba@visibility\pgfutil@empty%
+ \let\pgfsys@anim@ba@strokewidth\pgfutil@empty%
+ \let\pgfsys@anim@ba@fill\pgfutil@empty%
+ \let\pgfsys@anim@ba@stroke\pgfutil@empty%
+ \let\pgfsys@anim@ba@strokedasharray\pgfutil@empty%
+ \let\pgfsys@anim@ba@strokedashoffset\pgfutil@empty%
+ \let\pgf@sys@svg@ba@gs\pgf@sys@svg@ba@gs@do@now%
+}
+\let\pgfsys@anim@ba@opacity\pgfutil@empty%
+\let\pgfsys@anim@ba@fillopacity\pgfutil@empty%
+\let\pgfsys@anim@ba@strokeopacity\pgfutil@empty%
+\let\pgfsys@anim@ba@visibility\pgfutil@empty%
+\let\pgfsys@anim@ba@strokewidth\pgfutil@empty%
+\let\pgfsys@anim@ba@fill\pgfutil@empty%
+\let\pgfsys@anim@ba@stroke\pgfutil@empty%
+\let\pgfsys@anim@ba@viewBox\pgfutil@empty%
+\let\pgfsys@anim@ba@d\pgfutil@empty%
+\let\pgfsys@anim@ba@strokedasharray\pgfutil@empty%
+\let\pgfsys@anim@ba@strokedashoffset\pgfutil@empty%
+\let\pgfsys@anim@ba@markerstart\pgfutil@empty%
+\let\pgfsys@anim@ba@markerendd\pgfutil@empty%
+
+\def\pgf@sys@svg@ba@gs@do@now{%
+ \ifx\pgfsys@anim@ba@fill\pgfutil@empty\else fill="\pgfsys@anim@ba@fill" \fi%
+ \ifx\pgfsys@anim@ba@stroke\pgfutil@empty\else stroke="\pgfsys@anim@ba@stroke" \fi%
+ \ifx\pgfsys@anim@ba@opacity\pgfutil@empty\else opacity="\pgfsys@anim@ba@opacity" \fi%
+ \ifx\pgfsys@anim@ba@fillopacity\pgfutil@empty\else fill-opacity="\pgfsys@anim@ba@fillopacity" \fi%
+ \ifx\pgfsys@anim@ba@strokeopacity\pgfutil@empty\else stroke-opacity="\pgfsys@anim@ba@strokeopacity" \fi%
+ \ifx\pgfsys@anim@ba@visibility\pgfutil@empty\else visibility="\pgfsys@anim@ba@visibility" \fi%
+ \ifx\pgfsys@anim@ba@strokewidth\pgfutil@empty\else stroke-width="\pgfsys@anim@ba@strokewidth" \fi%
+ \ifx\pgfsys@anim@ba@strokedasharray\pgfutil@empty\else stroke-dasharray="\pgfsys@anim@ba@strokedasharray" \fi%
+ \ifx\pgfsys@anim@ba@strokedashoffset\pgfutil@empty\else stroke-dashoffset="\pgfsys@anim@ba@strokedashoffset" \fi%
+}
+
+
+
+\newcount\pgf@sys@svg@canvascount
+\def\pgf@sys@svg@anim@trans#1#2#3{%
+ \ifx\pgfsys@anim@val@@id\pgfutil@empty%
+ \pgferror{Animation misses ``whom''}%
+ \else%
+ {%
+ %
+ \global\advance\pgf@sys@svg@canvascount by1\relax%
+ \pgf@sys@svg@tl@eval%
+ \pgf@sys@svg@do@events{begin}%
+ \ifpgf@sys@at@least@one@event%
+ \else%
+ \pgf@sys@svg@append{begin}{\ifdim\pgf@xa>0pt+\fi\pgf@sys@tonumber\pgf@xa s}%
+ \fi%
+ \pgf@sys@svg@do@events{end}%
+ #2%
+ \pgfsys@register@type{\pgfsys@anim@val@@type}%
+ \pgf@sys@svg@replace{xlink:href}{\#\pgfsys@id@ref{\pgfsys@anim@val@@id canvas\the\pgf@sys@svg@canvascount}{\pgfsys@anim@val@@type}}%
+ \ifx\pgfsys@anim@val@base\pgfutil@empty%
+ \let\pgf@sys@svg@base@trans\pgfutil@empty%
+ \else%
+ \edef\pgf@sys@svg@base@trans{ transform="#3(\pgfsys@anim@val@base)"}%
+ \fi%
+ \pgfsysprotocol@literal{<#1\pgfsys@if@fresh@currentid{ id="\pgfsys@id@refcurrent"}{}\pgf@svg@anim@keys/>\pgfsys@svg@newline}%
+ \pgfsys@invalidate@currentid%
+ \edef\pgf@temp{{\pgfsys@id@ref{\pgfsys@anim@val@@id
+ canvas\the\pgf@sys@svg@canvascount}{\pgfsys@anim@val@@type}}}%
+ \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\pgf@sys@svg@attacher%
+ \expandafter\expandafter\expandafter\pgf@temp\expandafter\pgfsys@anim@val@canvas@trans\expandafter{\pgf@sys@svg@base@trans}%
+ }%
+ \fi%
+}
+
+\newif\ifpgf@sys@svg@called
+\def\pgf@sys@svg@attacher#1#2#3#4{%
+ \toks0{%
+ {%
+ \let\pgfsys@transformcm\pgfsys@anim@transformcm%
+ \global\pgf@sys@svg@calledfalse%
+ #2%
+ \ifpgf@sys@svg@called\else\pgfsysprotocol@literal{<g>}\fi%
+ \pgfsysprotocol@literal{<g id="#1"#4>}
+ {%
+ \global\pgf@sys@svg@calledfalse%
+ #3%
+ \ifpgf@sys@svg@called\else\pgfsysprotocol@literal{<g>}\fi%
+ }%
+ }%
+ }%
+ \edef\pgf@sys@svg@beg{\the\toks0}%
+ \def\pgf@sys@svg@end{\pgfsysprotocol@literal{</g></g></g>\noexpand\pgfsys@svg@newline}}%
+ \expandafter\expandafter\expandafter\pgfsys@attach@to@id%
+ \expandafter\expandafter\expandafter\pgfsys@anim@val@@id%
+ \expandafter\expandafter\expandafter\pgfsys@anim@val@@type%
+ \expandafter\expandafter\expandafter{\expandafter\pgf@sys@svg@beg\expandafter}\expandafter{\pgf@sys@svg@end}%
+}
+
+
+\def\pgfsys@anim@transformcm#1#2#3#4#5#6{%
+ \ifpgf@sys@svg@called%
+ \pgferror{Double transformation calls in animation}%
+ \else%
+ {%
+ \pgf@x=#5\pgf@y=#6%
+ \edef\pgf@temp{ transform="matrix(#1,#2,#3,#4,\pgf@sys@tonumber{\pgf@x},\pgf@sys@tonumber{\pgf@y})"}%
+ \ifx\pgf@temp\pgf@sys@svg@idmat@stext%
+ \let\pgf@temp\pgfutil@empty%
+ \fi%
+ \pgfsysprotocol@literal{<g\pgf@temp>}%
+ }%
+ \global\pgf@sys@svg@calledtrue%
+ \fi%
+}
+\def\pgf@sys@svg@idtrans@text{1.0,0.0,0.0,1.0}
+\def\pgf@sys@svg@idmat@text{transform="matrix(1.0,0.0,0.0,1.0,0.0,0.0)"}
+\def\pgf@sys@svg@idmat@stext{ transform="matrix(1.0,0.0,0.0,1.0,0.0,0.0)"}
+
+\def\pgf@sys@svg@replace#1#2{%
+ \expandafter\edef\csname pgfsys@anim@val@#1\endcsname{#2}%
+}
+
+\def\pgf@sys@svg@append#1#2{%
+ \expandafter\let\expandafter\pgf@svg@anim@temp@\csname pgfsys@anim@val@#1\endcsname%
+ \ifx\pgf@svg@anim@temp@\pgfutil@empty%
+ \expandafter\edef\csname pgfsys@anim@val@#1\endcsname{#2}%
+ \else\ifx\pgf@svg@anim@temp@\relax%
+ \pgfutil@packageerror{pgfsys}{Unknown animation key '#1'}{}
+ \else%
+ \edef\pgf@svg@anim@temp@{\pgf@svg@anim@temp@;#2}%
+ \expandafter\let\csname pgfsys@anim@val@#1\endcsname\pgf@svg@anim@temp@%
+ \fi\fi%
+}
+
+% The actual animate command
+\def\pgfsys@animate#1{%
+ \expandafter\let\expandafter\pgf@sys@temp\csname pgfsys@svg@animate#1\endcsname\relax%
+ \ifx\pgf@sys@temp\relax%
+ \pgf@sys@fail{animation attribute #1}%
+ \else%
+ \pgf@sys@temp%
+ \fi%
+}
+
+
+% The non-transforming animations
+\def\pgfsys@svg@animatenone{}
+\def\pgfsys@svg@animateopacity{\pgf@sys@svg@anim{attributeName="opacity"}{}{\pgfsys@anim@ba@opacity}}
+\def\pgfsys@svg@animatefillopacity{\pgf@sys@svg@anim{attributeName="fill-opacity"}{}{\pgfsys@anim@ba@fillopacity}}
+\def\pgfsys@svg@animatestrokeopacity{\pgf@sys@svg@anim{attributeName="stroke-opacity"}{}{\pgfsys@anim@ba@strokeopacity}}
+\def\pgfsys@svg@animatevisibility{\pgf@sys@svg@anim{attributeName="visibility"}{}{\pgfsys@anim@ba@visibility}}
+\def\pgfsys@svg@animatelinewidth{\pgf@sys@svg@anim{attributeName="stroke-width"}{}{\pgfsys@anim@ba@strokewidth}}
+\def\pgfsys@svg@animatecolor{\pgf@sys@svg@anim{attributeName="fill"}{}{\pgfsys@anim@ba@fill}\pgf@sys@svg@anim{attributeName="stroke"}{}{\pgfsys@anim@ba@stroke}}
+\def\pgfsys@svg@animatefillcolor{\pgf@sys@svg@anim{attributeName="fill"}{}{\pgfsys@anim@ba@fill}}
+\def\pgfsys@svg@animatestrokecolor{\pgf@sys@svg@anim{attributeName="stroke"}{}{\pgfsys@anim@ba@stroke}}
+\def\pgfsys@svg@animateviewbox{\pgf@sys@svg@anim{attributeName="viewBox"}{}{\pgfsys@anim@ba@viewBox}}
+\def\pgfsys@svg@animatepath{\pgf@sys@svg@anim@path}
+\def\pgfsys@svg@animatesyncbase{{\pgf@sys@svg@is@sync@basetrue\pgf@sys@svg@anim{}{}{}}}
+\def\pgfsys@svg@animatedash{%
+ \pgf@svg@anim@prep@dash{\pgfsys@anim@val@base}{\pgfsys@anim@val@base@array}{\pgfsys@anim@val@base@offset}%
+ \let\pgfsys@anim@val@base\pgfsys@anim@val@base@array%
+ \pgf@sys@svg@anim{attributeName="stroke-dasharray"}{%
+ \pgf@svg@anim@prep@dash{\pgfsys@anim@val@from}{\pgfsys@anim@val@from@array}{\pgfsys@anim@val@from@offset}%
+ \pgf@svg@anim@prep@dash{\pgfsys@anim@val@to}{\pgfsys@anim@val@to@array}{\pgfsys@anim@val@to@offset}%
+ \pgf@svg@anim@prep@dash{\pgfsys@anim@val@values}{\pgfsys@anim@val@values@array}{\pgfsys@anim@val@values@offset}%
+ \let\pgfsys@anim@val@from\pgfsys@anim@val@from@array%
+ \let\pgfsys@anim@val@to\pgfsys@anim@val@to@array%
+ \let\pgfsys@anim@val@values\pgfsys@anim@val@values@array%
+ }{\pgfsys@anim@ba@strokedasharray}%
+ \let\pgfsys@anim@val@base\pgfsys@anim@val@base@offset%
+ \pgf@sys@svg@anim{attributeName="stroke-dashoffset"}{%
+ \pgf@svg@anim@prep@dash{\pgfsys@anim@val@from}{\pgfsys@anim@val@from@array}{\pgfsys@anim@val@from@offset}%
+ \pgf@svg@anim@prep@dash{\pgfsys@anim@val@to}{\pgfsys@anim@val@to@array}{\pgfsys@anim@val@to@offset}%
+ \pgf@svg@anim@prep@dash{\pgfsys@anim@val@values}{\pgfsys@anim@val@values@array}{\pgfsys@anim@val@values@offset}%
+ \let\pgfsys@anim@val@from\pgfsys@anim@val@from@offset%
+ \let\pgfsys@anim@val@to\pgfsys@anim@val@to@offset%
+ \let\pgfsys@anim@val@values\pgfsys@anim@val@values@offset%
+ }{\pgfsys@anim@ba@strokedashoffset}%
+}
+
+% The transforming animations
+\def\pgfsys@svg@animatetranslate{\pgf@sys@svg@anim@trans{animateTransform attributeName="transform" type="translate"}{}{translate}}
+\def\pgfsys@svg@animatescale{\pgf@sys@svg@anim@trans{animateTransform attributeName="transform" type="scale"}{}{scale}}
+\def\pgfsys@svg@animaterotate{\pgf@sys@svg@anim@trans{animateTransform attributeName="transform" type="rotate"}{}{rotate}}
+\def\pgfsys@svg@animateskewx{\pgf@sys@svg@anim@trans{animateTransform attributeName="transform" type="skewX"}{}{skewX}}
+\def\pgfsys@svg@animateskewy{\pgf@sys@svg@anim@trans{animateTransform attributeName="transform" type="skewY"}{}{skewY}}
+\def\pgfsys@svg@animatemotion{\pgf@sys@svg@anim@trans{animateMotion}{%
+ \let\pgfsys@anim@val@base\pgfutil@empty%
+ \let\pgfsys@anim@val@keyPoints\pgfsys@anim@val@values%
+ \let\pgfsys@anim@val@values\pgfutil@empty%
+ \ifx\pgfsys@anim@val@keyTimes\pgfutil@empty%
+ \let\pgfsys@anim@val@keyPoints\pgfutil@empty%
+ \fi%
+ }{}}
+
+% The keys
+\def\pgfsys@animation@whom#1#2{%
+ % Animations must "look forward"...
+ \pgfsys@if@fresh@id{#1}{#2}{}{\pgferror{Animations must precede the to-be-animated objects (``whom'')}}%
+ \pgf@sys@svg@replace{@id}{#1}%
+ \pgf@sys@svg@replace{@type}{#2}%
+ \pgf@sys@svg@replace{xlink:href}{\#\pgfsys@id@ref{#1}{#2}}%
+ \pgf@sys@svg@replace{idref}{\pgfsys@id@ref{#1}{#2}}%
+}
+\def\pgfsys@animation@restart@always{\pgf@sys@svg@replace{restart}{always}}
+\def\pgfsys@animation@restart@never{\pgf@sys@svg@replace{restart}{never}}
+\def\pgfsys@animation@restart@whennotactive{\pgf@sys@svg@replace{restart}{whenNotActive}}
+\def\pgfsys@animation@repeat@indefinite{\pgf@sys@svg@replace{repeatCount}{indefinite}}
+\def\pgfsys@animation@repeat#1{\pgf@sys@svg@replace{repeatCount}{#1}}
+\def\pgfsys@animation@repeat@dur#1{\pgf@sys@svg@replace{repeatDur}{#1}}
+\def\pgfsys@animation@freezeatend{\pgf@sys@svg@replace{fill}{freeze}}
+\def\pgfsys@animation@removeatend{\pgf@sys@svg@replace{fill}{remove}}
+\def\pgfsys@animation@canvas@transform#1#2{\def\pgfsys@anim@val@canvas@trans{{#1}{#2}}}
+\def\pgfsys@animation@offset#1#2{\pgfsys@animation@event{}{}{}{#1}{#2}}
+\def\pgfsys@animation@event#1#2#3#4#5{%
+ \expandafter\edef\csname pgf@sys@event@list@#5\endcsname{\csname pgf@sys@event@list@#5\endcsname{#1}{#2}{#3}{#4}}%
+}%
+\def\pgf@sys@event@list@begin{}
+\def\pgf@sys@event@list@end{}
+\def\pgfsys@animation@syncbegin#1#2#3#4{\pgfsys@animation@event{#1}{#2}{begin}{#3}{#4}}
+\def\pgfsys@animation@syncend#1#2#3#4{\pgfsys@animation@event{#1}{#2}{end}{#3}{#4}}
+\def\pgfsys@animation@repeat@event#1#2#3#4#5{\pgfsys@animation@event{#1}{#2}{repeat(#3)}{#4}{#5}}
+\def\pgfsys@animation@accesskey#1#2#3{\pgfsys@animation@event{}{}{accessKey(#1)}{#2}{#3}}
+%\def\pgfsys@animation@sum{\pgf@sys@svg@replace{additive}{sum}}
+%\def\pgfsys@animation@replace{\pgf@sys@svg@replace{additive}{replace}}
+\def\pgfsys@animation@accumulate{\pgf@sys@svg@replace{accumulate}{sum}}
+\def\pgfsys@animation@noaccumulate{\pgf@sys@svg@replace{accumulate}{}}
+\def\pgfsys@animation@rotatealong{\pgf@sys@svg@replace{rotate}{auto}}
+\def\pgfsys@animation@norotatealong{\pgf@sys@svg@replace{rotate}{}}
+\def\pgfsys@animation@movealong#1{%
+ {%
+ \let\pgf@sys@save@svgpath=\pgf@sys@svgpath%
+ \global\let\pgf@sys@svgpath=\pgfutil@empty%
+ \pgfsyssoftpath@getcurrentpath\pgf@sys@save@path%
+ \pgfsyssoftpath@setcurrentpath\pgfutil@empty%
+ #1%
+ \pgfsyssoftpath@invokecurrentpath%
+ \pgfsyssoftpath@setcurrentpath\pgf@sys@save@path%
+ \global\let\pgf@svg@anim@temp\pgf@sys@svgpath%
+ \global\let\pgf@sys@svgpath\pgf@sys@save@svgpath%
+ }%
+ \pgf@sys@svg@replace{path}{\pgf@svg@anim@temp}%
+}
+\def\pgfsys@animation@tip@markers#1#2{%
+ \edef\pgf@svg@anim@marker@start{#1}%
+ \edef\pgf@svg@anim@marker@end{#2}%
+}
+\let\pgf@svg@anim@marker@start\pgfutil@empty
+\let\pgf@svg@anim@marker@end\pgfutil@empty
+
+
+
+% Timelines
+\let\pgf@sys@svg@tl@entries\pgfutil@empty
+\let\pgf@sys@svg@tl@start\pgfutil@empty
+\let\pgf@sys@svg@tl@end\pgfutil@empty
+
+
+\def\pgfsys@animation@time#1#2#3#4#5{%
+ \def\pgf@sys@svg@t{#1}%
+ \let\pgf@sys@last@out@spline\pgf@sys@svg@out@spline%
+ \def\pgf@sys@svg@in@spline{{#2}{#3}}%
+ \def\pgf@sys@svg@out@spline{{#4}{#5}}%
+}
+\def\pgfsys@animation@base{%
+ \let\pgf@sys@svg@t\pgf@sys@svg@base@text%
+}
+\def\pgf@sys@svg@base@text{base}
+
+\def\pgf@sys@svg@entry#1{%
+ \ifx\pgf@sys@svg@t\pgf@sys@svg@base@text%
+ % Ah, base. Save!
+ \edef\pgfsys@anim@val@base{#1}%
+ \else%
+ \ifx\pgf@sys@svg@tl@start\pgfutil@empty%
+ % Ah, first.
+ \let\pgf@sys@svg@tl@start\pgf@sys@svg@t%
+ \edef\pgf@sys@svg@tl@entries{%
+ \noexpand\pgf@sys@svg@add@time{\pgf@sys@svg@t}%
+ \noexpand\pgf@sys@svg@add@value{#1}%
+ }%
+ \else%
+ \ifx\pgf@sys@last@out@spline\pgfsys@stay@text%
+ \ifx\pgf@sys@svg@in@spline\pgfsys@jump@text%
+ {%
+ \pgf@x\pgf@sys@svg@t pt
+ \pgf@xa\pgf@sys@svg@tl@end pt%
+ \advance\pgf@x by\pgf@xa%
+ \pgf@x.5\pgf@x%
+ \edef\pgf@sys@temp{\pgf@sys@tonumber\pgf@x}
+ \expandafter}\expandafter\def\expandafter\pgf@sys@temp\expandafter{\pgf@sys@temp}%
+ \edef\pgf@sys@svg@temp{%
+ \noexpand\pgf@sys@svg@add@time{\pgf@sys@temp}%
+ \noexpand\pgf@sys@svg@add@spline{0}{0}{1}{1}%
+ \noexpand\pgf@sys@svg@add@value{\pgf@sys@svg@last@value}%
+ \noexpand\pgf@sys@svg@add@time{\pgf@sys@temp}%
+ \noexpand\pgf@sys@svg@add@spline{0}{0}{1}{1}%
+ \noexpand\pgf@sys@svg@add@value{#1}%
+ \noexpand\pgf@sys@svg@add@time{\pgf@sys@svg@t}%
+ \noexpand\pgf@sys@svg@add@spline{0}{0}{1}{1}%
+ \noexpand\pgf@sys@svg@add@value{#1}%
+ }%
+ \else
+ \edef\pgf@sys@svg@temp{%
+ \noexpand\pgf@sys@svg@add@time{\pgf@sys@svg@t}%
+ \noexpand\pgf@sys@svg@add@spline{0}{0}{1}{1}%
+ \noexpand\pgf@sys@svg@add@value{\pgf@sys@svg@last@value}%
+ \noexpand\pgf@sys@svg@add@time{\pgf@sys@svg@t}%
+ \noexpand\pgf@sys@svg@add@spline{0}{0}{1}{1}%
+ \noexpand\pgf@sys@svg@add@value{#1}%
+ }%
+ \fi%
+ \else%
+ \ifx\pgf@sys@svg@in@spline\pgfsys@jump@text%
+ \edef\pgf@sys@svg@temp{%
+ \noexpand\pgf@sys@svg@add@time{\pgf@sys@svg@tl@end}%
+ \noexpand\pgf@sys@svg@add@spline{0}{0}{1}{1}%
+ \noexpand\pgf@sys@svg@add@value{#1}%
+ \noexpand\pgf@sys@svg@add@time{\pgf@sys@svg@t}%
+ \noexpand\pgf@sys@svg@add@spline{0}{0}{1}{1}%
+ \noexpand\pgf@sys@svg@add@value{#1}%
+ }%
+ \else%
+ \edef\pgf@sys@svg@temp{%
+ \noexpand\pgf@sys@svg@add@time{\pgf@sys@svg@t}%
+ \noexpand\pgf@sys@svg@add@spline\pgf@sys@last@out@spline\pgf@sys@svg@in@spline%
+ \noexpand\pgf@sys@svg@add@value{#1}%
+ }%
+ \fi%
+ \fi%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\pgf@sys@svg@tl@entries%
+ \expandafter\expandafter\expandafter{\expandafter\pgf@sys@svg@tl@entries\pgf@sys@svg@temp}%
+ \fi%
+ \let\pgf@sys@svg@tl@end\pgf@sys@svg@t%
+ \edef\pgf@sys@svg@last@value{#1}%
+ \fi%
+}
+\newif\ifpgf@sys@svg@do@times
+\def\pgf@sys@svg@tl@eval{%
+ \pgf@xa=0pt%
+ % Overrulings
+ \pgf@sys@svg@do@timestrue%
+ % Ok, we need to compute the time interval
+ \ifx\pgf@sys@svg@tl@end\pgfutil@empty%
+ \else%
+ \ifx\pgf@sys@svg@tl@start\pgfutil@empty\else\pgf@xa=\pgf@sys@svg@tl@start pt\fi%
+ \pgf@xb=\pgf@sys@svg@tl@end pt%
+ \advance\pgf@xb by -\pgf@xa%
+ % Ok, \pgf@xb is now the duration.
+ \ifdim\pgf@xb>0pt\relax%
+ \pgf@sys@svg@replace{dur}{\pgf@sys@tonumber\pgf@xb}%
+ \else%
+ \pgf@sys@svg@replace{dur}{\pgf@sys@svg@indefinitetext}%
+ \fi%
+ % Now, prepare factors
+ \pgf@xc=8192pt%
+ \ifdim\pgf@xb<0.0001pt\relax
+ \pgf@xc=1pt%
+ \pgf@xb=1sp%
+ \else%
+ \divide\pgf@xc by\pgf@xb%
+ \multiply\pgf@xb by\pgf@xc%
+ \divide\pgf@xb by65536%
+ \fi%
+ % Now, run!
+ \pgf@sys@svg@tl@entries%
+ \ifx\pgfsys@anim@val@dur\pgf@sys@svg@indefinitetext%
+ \let\pgfsys@anim@val@from\pgfsys@anim@val@to%
+ \let\pgfsys@anim@val@keyTimes\pgfutil@empty%
+ \let\pgfsys@anim@val@calcMode\pgfutil@empty%
+ \fi%
+ \fi%
+}
+\def\pgf@sys@svg@indefinitetext{indefinite}
+\def\pgf@sys@svg@add@time#1{%
+ \ifpgf@sys@svg@do@times%
+ % Compute fraction:
+ \pgf@yb=#1pt%
+ \advance\pgf@yb by-\pgf@xa%
+ \multiply\pgf@yb by\pgf@xc%
+ \divide\pgf@yb by\pgf@xb%
+ \ifdim\pgf@yb<0pt\pgf@yb=0pt\fi%
+ \ifdim\pgf@yb>1pt\pgf@yb=1pt\fi%
+ \pgf@sys@svg@append{keyTimes}{\pgf@sys@tonumber\pgf@yb}%
+ \fi%
+}
+\def\pgf@sys@svg@add@spline#1#2#3#4{\ifpgf@sys@svg@do@times\pgf@sys@svg@append{keySplines}{#1 #2 #3 #4}\fi}
+\def\pgf@sys@svg@add@value#1{%
+ \ifx\pgfsys@anim@val@values\pgfutil@empty%
+ \ifx\pgfsys@anim@val@to\pgfutil@empty%
+ \pgf@sys@svg@replace{to}{#1}%
+ \else% move
+ \let\pgfsys@anim@val@values\pgfsys@anim@val@to%
+ \let\pgfsys@anim@val@to\pgfutil@empty%
+ \pgf@sys@svg@append{values}{#1}%
+ \fi%
+ \else%
+ \pgf@sys@svg@append{values}{#1}%
+ \fi%
+}
+\def\pgfsys@animation@val@current{\pgf@sys@svg@entry{}}
+\def\pgfsys@animation@val{\pgf@sys@svg@entry{nil}} % will be ignored anyway
+\def\pgfsys@animation@val@text#1{\pgf@sys@svg@entry{#1}}
+\def\pgfsys@animation@val@scalar#1{\pgf@sys@svg@entry{#1}}
+\def\pgfsys@animation@val@dimension#1{%
+ {%
+ \pgf@x=#1\relax%
+ \xdef\pgf@svg@anim@temp{\expandafter\Pgf@geT\the\pgf@x}%
+ }%
+ \pgf@sys@svg@entry{\pgf@svg@anim@temp}%
+}
+\def\pgfsys@animation@val@color@rgb#1#2#3{\pgf@sys@svg@color@rgb#1,#2,#3\relax\pgf@sys@svg@entry{\pgf@sys@svg@prepared}}
+\def\pgfsys@animation@val@color@cmyk#1#2#3#4{\pgf@sys@svg@color@cmyk#1,#2,#3,#4\relax\pgf@sys@svg@entry{\pgf@sys@svg@prepared}}
+\def\pgfsys@animation@val@color@cmy#1#2#3{\pgf@sys@svg@color@cmy#1,#2,#3\relax\pgf@sys@svg@entry{\pgf@sys@svg@prepared}}
+\def\pgfsys@animation@val@color@gray#1{\pgf@sys@svg@color@gray#1\relax\pgf@sys@svg@entry{\pgf@sys@svg@prepared}}
+\def\pgfsys@animation@val@path#1{%
+ {%
+ \let\pgf@sys@save@svgpath=\pgf@sys@svgpath%
+ \global\let\pgf@sys@svgpath=\pgfutil@empty%
+ \pgfsyssoftpath@getcurrentpath\pgf@sys@save@path%
+ \pgfsyssoftpath@setcurrentpath\pgfutil@empty%
+ #1%
+ \pgfsyssoftpath@invokecurrentpath%
+ \pgfsyssoftpath@setcurrentpath\pgf@sys@save@path%
+ \global\let\pgf@svg@anim@temp\pgf@sys@svgpath%
+ \global\let\pgf@sys@svgpath\pgf@sys@save@svgpath%
+ }%
+ \pgf@sys@svg@entry{\pgf@svg@anim@temp}%
+}
+\def\pgfsys@animation@val@translate#1#2{%
+ {%
+ \pgf@x=#1\relax%
+ \pgf@y=#2\relax%
+ \xdef\pgf@svg@anim@temp{\expandafter\Pgf@geT\the\pgf@x,\expandafter\Pgf@geT\the\pgf@y}%
+ }%
+ \pgf@sys@svg@entry{\pgf@svg@anim@temp}%
+}
+\def\pgfsys@animation@val@scale#1#2{\pgf@sys@svg@entry{#1,#2}}
+\def\pgfsys@animation@val@viewbox#1#2#3#4{%
+ {%
+ \pgf@x=#1\relax%
+ \pgf@y=#2\relax%
+ \pgf@xa=#3\relax%
+ \pgf@ya=#4\relax%
+ \advance\pgf@xa by-\pgf@x%
+ \advance\pgf@ya by-\pgf@y%
+ \xdef\pgf@svg@anim@temp{\expandafter\Pgf@geT\the\pgf@x\space\expandafter\Pgf@geT\the\pgf@y\space\expandafter\Pgf@geT\the\pgf@xa\space\expandafter\Pgf@geT\the\pgf@ya}%
+ }%
+ \pgf@sys@svg@entry{\pgf@svg@anim@temp}%
+}
+\def\pgfsys@animation@val@dash#1#2{%
+ \edef\pgf@test@dashpattern{#1}%
+ \let\pgf@sys@svg@parsed@dash\pgfutil@empty%
+ \ifx\pgf@test@dashpattern\pgfutil@empty%
+ \else%
+ \expandafter\pgf@sys@svg@parse@dash\pgf@test@dashpattern,\relax%
+ \fi%
+ {%
+ \pgf@x=#2\relax%
+ \xdef\pgf@svg@anim@temp{\expandafter\Pgf@geT\the\pgf@x}%
+ }%
+ \pgf@sys@svg@entry{{\pgf@sys@svg@parsed@dash}{\pgf@svg@anim@temp}}%
+}
+
+
+
+\def\pgf@svg@anim@prep@dash#1#2#3{%
+ \let\pgf@svg@anim@dash@array\pgfutil@empty%
+ \let\pgf@svg@anim@dash@offset\pgfutil@empty%
+ % #1 = \pgfsys@anim@val@from or \pgfsys@anim@val@to or \pgfsys@anim@val@values
+ \ifx#1\pgfutil@empty%
+ \else%
+ \expandafter\pgf@svg@anim@prep@dash@parse#1\pgf@stop%
+ \fi%
+ \let#2\pgf@svg@anim@dash@array%
+ \let#3\pgf@svg@anim@dash@offset%
+}
+
+\def\pgf@svg@anim@prep@dash@parse#1#2{%
+ \expandafter\def\expandafter\pgf@svg@anim@dash@array\expandafter{\pgf@svg@anim@dash@array#1}%
+ \expandafter\def\expandafter\pgf@svg@anim@dash@offset\expandafter{\pgf@svg@anim@dash@offset#2}%
+ \pgfutil@ifnextchar;{%
+ \expandafter\def\expandafter\pgf@svg@anim@dash@array\expandafter{\pgf@svg@anim@dash@array;}%
+ \expandafter\def\expandafter\pgf@svg@anim@dash@offset\expandafter{\pgf@svg@anim@dash@offset;}%
+ \expandafter\pgf@svg@anim@prep@dash@parse\pgfutil@gobble%
+ }{%
+ \pgfutil@gobble% done, gobble \pgf@stop
+ }%
+}
+
+
+%
+% Markers
+%
+
+\def\pgfsys@marker@declare@{%
+ \pgfsysprotocol@setcurrentprotocol\pgfutil@empty%
+ \pgfsys@beginscope@{ id="pgfs\the\pgf@sys@id@count"}%
+ \pgfsysprotocol@literal{\csname pgf@sys@marker@prot@\the\pgf@sys@id@count\endcsname}%
+ \pgfsys@endscope%
+ \pgfsysprotocol@getcurrentprotocol\pgfsys@temp%
+ \pgf@sys@svg@make@defs{pgfs\the\pgf@sys@id@count}{\pgfsys@temp}%
+}
+
+\def\pgfsys@marker@use#1{%
+ \pgf@sys@svg@ref@defs{pgfs#1}%
+ \pgfsysprotocol@literal{<use xlink:href="\#pgfs#1"/>}%
+}
+
+\def\pgfsys@marker@at@begin@usedpath#1{\def\pgf@sys@svg@marker@begin{#1}\let\pgf@sys@svg@marker@begin@use\pgfutil@empty}
+\def\pgfsys@marker@at@end@usedpath#1{\def\pgf@sys@svg@marker@end{#1}\let\pgf@sys@svg@marker@begin@use\pgfutil@empty}
+
+\let\pgf@sys@svg@marker@begin\relax
+\let\pgf@sys@svg@marker@end\relax
+
+\let\pgf@sys@svg@marker@begin@use\pgfutil@empty
+\let\pgf@sys@svg@marker@end@use\pgfutil@empty
+
+\def\pgf@sys@svg@prep@marker#1#2#3#4#5{%
+ \pgf@sys@svg@ref@defs{pgfs#1}%
+ \global\advance\pgf@sys@svg@objectcount by1\relax%
+ \edef\pgf@sys@svg@marker@id{pgf\the\pgf@sys@svg@objectcount}%
+ \pgfsysprotocol@literal{<marker id="\pgf@sys@svg@marker@id" markerUnits="userSpaceOnUse" orient="auto" overflow="visible">
+ <use xlink:href="\#pgfs#1"#2/> </marker>\pgfsys@svg@newline}%
+ \edef#3{marker-#4="url(\#\pgf@sys@svg@marker@id)" }%
+}
+
+
+%
+% RDF
+%
+
+\def\pgf@svg@rdf@init{%
+ \ifx\pgfsys@svg@rdf\pgfutil@empty%
+ % Ok, first, so init
+ \global\let\pgf@svg@rdf@vocab\relax%
+ \global\let\pgf@svg@rdf@about\relax%
+ \global\let\pgf@svg@rdf@content\relax%
+ \global\let\pgf@svg@rdf@datatype\relax%
+ \global\let\pgf@svg@rdf@href\relax%
+ \global\let\pgf@svg@rdf@inlist\relax%
+ \global\let\pgf@svg@rdf@prefix\relax%
+ \global\let\pgf@svg@rdf@property\relax%
+ \global\let\pgf@svg@rdf@rel\relax%
+ \global\let\pgf@svg@rdf@resource\relax%
+ \global\let\pgf@svg@rdf@rev\relax%
+ \global\let\pgf@svg@rdf@src\relax%
+ \global\let\pgf@svg@rdf@typeof\relax%
+ \global\let\pgfsys@svg@rdf\pgfsys@svg@rdf@initial%
+ \fi%
+}
+\def\pgfsys@svg@rdf@initial{%
+ \ifx\pgf@svg@rdf@vocab\relax\else\space vocab="\pgf@svg@rdf@vocab"\fi%
+ \ifx\pgf@svg@rdf@about\relax\else\space about="\pgf@svg@rdf@about"\fi%
+ \ifx\pgf@svg@rdf@datatype\relax\else\space datatype="\pgf@svg@rdf@datatype"\fi%
+ \ifx\pgf@svg@rdf@href\relax\else\space href="\pgf@svg@rdf@href"\fi%
+ \ifx\pgf@svg@rdf@inlist\relax\else\space inlist="\pgf@svg@rdf@inlist"\fi%
+ \ifx\pgf@svg@rdf@prefix\relax\else\space prefix="\pgf@svg@rdf@prefix"\fi%
+ \ifx\pgf@svg@rdf@property\relax\else\space property="\pgf@svg@rdf@property"\fi%
+ \ifx\pgf@svg@rdf@rel\relax\else\space rel="\pgf@svg@rdf@rel"\fi%
+ \ifx\pgf@svg@rdf@resource\relax\else\space resource="\pgf@svg@rdf@resource"\fi%
+ \ifx\pgf@svg@rdf@rev\relax\else\space rev="\pgf@svg@rdf@rev"\fi%
+ \ifx\pgf@svg@rdf@src\relax\else\space src="\pgf@svg@rdf@src"\fi%
+ \ifx\pgf@svg@rdf@typeof\relax\else\space typeof="\pgf@svg@rdf@typeof"\fi%
+ \ifx\pgf@svg@rdf@content\relax\else\space content="\pgf@svg@rdf@content"\fi%
+}
+
+\def\pgfsys@rdf@about#1{\pgf@svg@rdf@init\gdef\pgf@svg@rdf@about{#1}}
+\def\pgfsys@rdf@content#1{\pgf@svg@rdf@init\gdef\pgf@svg@rdf@content{#1}}
+\def\pgfsys@rdf@datatype#1{\pgf@svg@rdf@init\gdef\pgf@svg@rdf@datatype{#1}}
+\def\pgfsys@rdf@href#1{\pgf@svg@rdf@init\gdef\pgf@svg@rdf@href{#1}}
+\def\pgfsys@rdf@inlist{\pgf@svg@rdf@init\let\pgf@svg@rdf@inlist\pgfutil@empty}
+\def\pgfsys@rdf@prefix#1{\pgf@svg@rdf@init%
+ \ifx\pgf@svg@rdf@prefix\relax%
+ \gdef\pgf@svg@rdf@prefix{#1}
+ \else%
+ \expandafter\gdef\expandafter\pgf@svg@rdf@prefix\expandafter{\pgf@svg@rdf@prefix\space#1}%
+ \fi}
+\def\pgfsys@rdf@property#1{\pgf@svg@rdf@init%
+ \ifx\pgf@svg@rdf@property\relax%
+ \gdef\pgf@svg@rdf@property{#1}
+ \else%
+ \expandafter\gdef\expandafter\pgf@svg@rdf@property\expandafter{\pgf@svg@rdf@property\space#1}%
+ \fi}
+\def\pgfsys@rdf@rel#1{\pgf@svg@rdf@init%
+ \ifx\pgf@svg@rdf@rel\relax%
+ \gdef\pgf@svg@rdf@rel{#1}
+ \else%
+ \expandafter\gdef\expandafter\pgf@svg@rdf@rel\expandafter{\pgf@svg@rdf@rel\space#1}%
+ \fi}
+\def\pgfsys@rdf@rev#1{\pgf@svg@rdf@init%
+ \ifx\pgf@svg@rdf@rev\relax%
+ \gdef\pgf@svg@rdf@rev{#1}
+ \else%
+ \expandafter\gdef\expandafter\pgf@svg@rdf@rev\expandafter{\pgf@svg@rdf@rev\space#1}%
+ \fi}
+\def\pgfsys@rdf@typeof#1{\pgf@svg@rdf@init%
+ \ifx\pgf@svg@rdf@typeof\relax%
+ \gdef\pgf@svg@rdf@typeof{#1}
+ \else%
+ \expandafter\gdef\expandafter\pgf@svg@rdf@typeof\expandafter{\pgf@svg@rdf@typeof\space#1}%
+ \fi}
+\def\pgfsys@rdf@resource#1{\pgf@svg@rdf@init\gdef\pgf@svg@rdf@resource{#1}}
+\def\pgfsys@rdf@src#1{\pgf@svg@rdf@init\gdef\pgf@svg@rdf@src{#1}}
+\def\pgfsys@rdf@vocab#1{\pgf@svg@rdf@init\gdef\pgf@svg@rdf@vocab{#1}}
+
+
+
+
+
+
+%
+
+\def\pgfutil@color{\pgfsetcolor}
+
+\endinput
+
+
+%%% Local Variables:
+%%% mode: latex
+%%% End:
diff --git a/graphics/pgf/base/tex/generic/systemlayer/pgfsys-dvi.def b/graphics/pgf/base/tex/generic/systemlayer/pgfsys-dvi.def
new file mode 100644
index 0000000000..dbe6fb3130
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/systemlayer/pgfsys-dvi.def
@@ -0,0 +1,394 @@
+% 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{pgfsys-dvi.def}
+
+% Driver commands for pure, ultra-portable dvi, in the tradition of
+% old-style LaTeX pictures.
+%
+% Do not expect magic from this file
+
+
+\newtoks\pgf@sys@dvi@path
+\def\pgf@sys@dvi@addtopath#1{\pgf@sys@dvi@path\expandafter{\the\pgf@sys@dvi@path#1}}
+
+% Placing an object:
+\def\pgf@sys@dvi@put#1#2#3{%
+ {%
+ \setbox\pgf@hbox=\hbox{\raise#2\hbox to0pt{\kern#1\relax#3\hss}}%
+ \wd\pgf@hbox=0pt%
+ \ht\pgf@hbox=0pt%
+ \dp\pgf@hbox=0pt%
+ \box\pgf@hbox%
+ }%
+}
+
+\def\pgf@sys@dvi@drawrect#1#2#3#4{%
+ {%
+ \pgf@x=#1%
+ \pgf@y=#2%
+ \pgf@xa=#3%
+ \pgf@ya=#4%
+ \ifdim\pgf@xa<0pt%
+ \advance\pgf@x by\pgf@xa%
+ \pgf@xa=-\pgf@xa%
+ \fi%
+ \ifdim\pgf@ya<0pt%
+ \advance\pgf@y by\pgf@ya%
+ \pgf@ya=-\pgf@ya%
+ \fi%
+ \pgf@sys@dvi@put{\pgf@x}{\pgf@y}{\vrule width\pgf@xa height\pgf@ya}%
+ }%
+}
+
+\def\pgf@sys@dvi@bezier{%
+ {%
+ % First iteration:
+ \pgf@x=\pgf@time@t\pgf@x\advance\pgf@x by\pgf@time@s\pgf@xa%
+ \pgf@y=\pgf@time@t\pgf@y\advance\pgf@y by\pgf@time@s\pgf@ya%
+ \pgf@xa=\pgf@time@t\pgf@xa\advance\pgf@xa by\pgf@time@s\pgf@xb%
+ \pgf@ya=\pgf@time@t\pgf@ya\advance\pgf@ya by\pgf@time@s\pgf@yb%
+ \pgf@xb=\pgf@time@t\pgf@xb\advance\pgf@xb by\pgf@time@s\pgf@xc%
+ \pgf@yb=\pgf@time@t\pgf@yb\advance\pgf@yb by\pgf@time@s\pgf@yc%
+ % Second iteration:
+ \pgf@x=\pgf@time@t\pgf@x\advance\pgf@x by\pgf@time@s\pgf@xa%
+ \pgf@y=\pgf@time@t\pgf@y\advance\pgf@y by\pgf@time@s\pgf@ya%
+ \pgf@xa=\pgf@time@t\pgf@xa\advance\pgf@xa by\pgf@time@s\pgf@xb%
+ \pgf@ya=\pgf@time@t\pgf@ya\advance\pgf@ya by\pgf@time@s\pgf@yb%
+ % Third iteration:
+ \pgf@x=\pgf@time@t\pgf@x\advance\pgf@x by\pgf@time@s\pgf@xa%
+ \pgf@y=\pgf@time@t\pgf@y\advance\pgf@y by\pgf@time@s\pgf@ya%
+ %
+ \advance\pgf@x by-.5\pgf@sys@dvi@linewidth%
+ \advance\pgf@y by-.5\pgf@sys@dvi@linewidth%
+ \pgf@sys@dvi@drawrect{\pgf@x}{\pgf@y}{\pgf@sys@dvi@linewidth}{\pgf@sys@dvi@linewidth}%
+ }%
+}
+
+\def\pgf@sys@dvi@drawcurve#1#2#3#4#5#6#7#8{%
+ {%
+ \pgf@x=#1%
+ \pgf@y=#2%
+ \pgf@xa=#3%
+ \pgf@ya=#4%
+ \pgf@xb=#5%
+ \pgf@yb=#6%
+ \pgf@xc=#7%
+ \pgf@yc=#8%
+ % Compute number of steps:
+ \pgfutil@tempdima=\pgf@x%
+ \advance\pgfutil@tempdima by-\pgf@xa%
+ \ifdim\pgfutil@tempdima<0pt%
+ \pgfutil@tempdimb=-\pgfutil@tempdima%
+ \else%
+ \pgfutil@tempdimb=\pgfutil@tempdima%
+ \fi%
+ \pgfutil@tempdima=\pgf@y%
+ \advance\pgfutil@tempdima by-\pgf@ya%
+ \ifdim\pgfutil@tempdima<0pt%
+ \pgfutil@tempdima=-\pgfutil@tempdima%
+ \fi%
+ \ifdim\pgfutil@tempdima>\pgfutil@tempdimb%
+ \pgfutil@tempdimb=\pgfutil@tempdima%
+ \fi%
+ \pgfutil@tempdima=\pgf@xb%
+ \advance\pgfutil@tempdima by-\pgf@xc%
+ \ifdim\pgfutil@tempdima<0pt%
+ \pgfutil@tempdima=-\pgfutil@tempdima%
+ \fi%
+ \ifdim\pgfutil@tempdima>\pgfutil@tempdimb%
+ \pgfutil@tempdimb=\pgfutil@tempdima%
+ \fi%
+ \pgfutil@tempdima=\pgf@yb%
+ \advance\pgfutil@tempdima by-\pgf@yc%
+ \ifdim\pgfutil@tempdima<0pt%
+ \pgfutil@tempdima=-\pgfutil@tempdima%
+ \fi%
+ \ifdim\pgfutil@tempdima>\pgfutil@tempdimb%
+ \pgfutil@tempdimb=\pgfutil@tempdima%
+ \fi%
+ \pgfutil@tempdima=\pgf@x%
+ \advance\pgfutil@tempdima by-\pgf@xc%
+ \ifdim\pgfutil@tempdima<0pt%
+ \pgfutil@tempdima=-\pgfutil@tempdima%
+ \fi%
+ \ifdim\pgfutil@tempdima>\pgfutil@tempdimb%
+ \pgfutil@tempdimb=\pgfutil@tempdima%
+ \fi%
+ \pgfutil@tempdima=\pgf@y%
+ \advance\pgfutil@tempdima by-\pgf@yc%
+ \ifdim\pgfutil@tempdima<0pt%
+ \pgfutil@tempdima=-\pgfutil@tempdima%
+ \fi%
+ \ifdim\pgfutil@tempdima>\pgfutil@tempdimb%
+ \pgfutil@tempdimb=\pgfutil@tempdima%
+ \fi%
+ \pgfutil@tempcnta=\pgfutil@tempdimb%
+ \ifdim\pgf@sys@dvi@linewidth>0.3pt%
+ \pgfutil@tempdimb=0.15pt%
+ \else%
+ \ifdim\pgf@sys@dvi@linewidth<0.05pt%
+ \pgfutil@tempdimb=.025pt%
+ \else%
+ \pgfutil@tempdimb=.5\pgf@sys@dvi@linewidth%
+ \fi%
+ \fi%
+ \pgfutil@tempcntb=\pgfutil@tempdimb%
+ \divide\pgfutil@tempcnta by\pgfutil@tempcntb\relax%
+ \ifnum\pgfutil@tempcnta>0\relax%
+ \pgfutil@tempcntb=0\relax%
+ \loop%
+ {%
+ \pgfutil@tempdima=\the\pgfutil@tempcntb pt%
+ \pgfutil@tempdimb=\the\pgfutil@tempcnta pt%
+ \advance\pgfutil@tempdimb by-\pgfutil@tempdima\relax%
+ \divide\pgfutil@tempdima by\pgfutil@tempcnta\relax%
+ \divide\pgfutil@tempdimb by\pgfutil@tempcnta\relax%
+ \edef\pgf@time@t{\pgf@sys@tonumber{\pgfutil@tempdima}}%
+ \edef\pgf@time@s{\pgf@sys@tonumber{\pgfutil@tempdimb}}%
+ \pgf@sys@dvi@bezier%
+ }%
+ \advance\pgfutil@tempcntb by1\relax
+ \ifnum\pgfutil@tempcntb<\pgfutil@tempcnta%
+ {\def\pgf@time@t{1}\def\pgf@time@s{0}\pgf@sys@dvi@bezier}%
+ \repeat%
+ \fi%
+ }%
+}
+
+% Text:
+\def\pgfsys@hbox#1{%
+ \pgfsys@begin@idscope%
+ \wd#1=0pt%
+ \ht#1=0pt%
+ \dp#1=0pt%
+ \pgf@sys@dvi@put{\pgf@sys@dvi@pt@x}{\pgf@sys@dvi@pt@y}{\box#1}%
+ \pgfsys@end@idscope%
+}
+
+
+
+% Literals:
+
+\def\pgfsys@invoke#1{#1}
+
+
+% Buffered path construction:
+
+\def\pgfsys@moveto#1#2{\pgfsysprotocol@literal{\noexpand\pgf@sys@dvi@addtopath{\noexpand\pgf@sys@dvi@moveto{#1}{#2}}}}
+\def\pgfsys@lineto#1#2{\pgfsysprotocol@literal{\noexpand\pgf@sys@dvi@addtopath{\noexpand\pgf@sys@dvi@lineto{#1}{#2}}}}
+\def\pgfsys@curveto#1#2#3#4#5#6{\pgfsysprotocol@literal{\noexpand\pgf@sys@dvi@addtopath{\noexpand\pgf@sys@dvi@curveto{#1}{#2}{#3}{#4}{#5}{#6}}}}
+\def\pgfsys@rect#1#2#3#4{\pgfsysprotocol@literal{\noexpand\pgf@sys@dvi@addtopath{\noexpand\pgf@sys@dvi@rect{#1}{#2}{#3}{#4}}}}
+\def\pgfsys@closepath{\pgfsysprotocol@literal{\noexpand\pgf@sys@dvi@addtopath{\noexpand\pgf@sys@dvi@closepath}}}
+
+
+% Scoping
+\def\pgfsys@beginscope{\pgfsysprotocol@literal{\noexpand\pgf@sys@dvi@beginscope}}%
+\def\pgfsys@endscope{\pgfsysprotocol@literal{\noexpand\pgf@sys@dvi@endscope}}%
+
+\def\pgf@sys@dvi@beginscope{%
+ % Save current stuff...
+ \edef\pgf@sys@dvi@return{%
+ \global\pgf@sys@dvi@linewidth=\the\pgf@sys@dvi@linewidth%
+ \global\pgf@sys@dvi@pt@x=\the\pgf@sys@dvi@pt@x%
+ \global\pgf@sys@dvi@pt@y=\the\pgf@sys@dvi@pt@y%
+ \gdef\noexpand\pgf@sys@dvi@pt@aa{\pgf@sys@dvi@pt@aa}%
+ \gdef\noexpand\pgf@sys@dvi@pt@ab{\pgf@sys@dvi@pt@ab}%
+ \gdef\noexpand\pgf@sys@dvi@pt@ba{\pgf@sys@dvi@pt@ba}%
+ \gdef\noexpand\pgf@sys@dvi@pt@bb{\pgf@sys@dvi@pt@bb}%
+ }%
+ \begingroup%
+ \ignorespaces%
+}
+
+\def\pgf@sys@dvi@endscope{%
+ \endgroup%
+ \pgf@sys@dvi@return%
+}
+
+
+
+% Line width
+
+\newdimen\pgf@sys@dvi@linewidth
+\pgf@sys@dvi@linewidth=0.4pt
+
+\def\pgfsys@setlinewidth#1{\global\pgf@sys@dvi@linewidth=#1\relax}
+
+
+% Transformation matrix
+
+\newdimen\pgf@sys@dvi@pt@x
+\newdimen\pgf@sys@dvi@pt@y
+
+\def\pgf@sys@dvi@pt@aa{1.0} \def\pgf@sys@dvi@pt@ab{0.0}
+\def\pgf@sys@dvi@pt@ba{0.0} \def\pgf@sys@dvi@pt@bb{1.0}
+
+\def\pgf@sys@dvi@pos@transform#1#2{%
+ \pgf@pt@temp=#1%
+ #1=\pgf@sys@dvi@pt@aa#1%
+ \advance#1 by\pgf@sys@dvi@pt@ba#2%
+ #2=\pgf@sys@dvi@pt@bb#2%
+ \advance#2 by\pgf@sys@dvi@pt@ab\pgf@pt@temp%
+ \advance#1 by\pgf@sys@dvi@pt@x%
+ \advance#2 by\pgf@sys@dvi@pt@y%
+}
+
+\def\pgf@sys@dvi@transformcm#1#2#3#4#5#6{%
+ {%
+ \pgf@xc=#5%
+ \pgf@yc=#6%
+ %
+ \pgf@x=#1pt%
+ \pgf@y=#2pt%
+ %
+ \pgf@xa=\pgf@sys@dvi@pt@aa\pgf@x%
+ \advance\pgf@xa by \pgf@sys@dvi@pt@ba\pgf@y%
+ %
+ \pgf@ya=\pgf@sys@dvi@pt@ab\pgf@x%
+ \advance\pgf@ya by \pgf@sys@dvi@pt@bb\pgf@y%
+ %
+ \pgf@x=#3pt%
+ \pgf@y=#4pt%
+ %
+ \pgf@xb=\pgf@sys@dvi@pt@aa\pgf@x%
+ \advance\pgf@xb by \pgf@sys@dvi@pt@ba\pgf@y%
+ %
+ \pgf@yb=\pgf@sys@dvi@pt@ab\pgf@x%
+ \advance\pgf@yb by \pgf@sys@dvi@pt@bb\pgf@y%
+ %
+ \pgf@x=\pgf@sys@dvi@pt@aa\pgf@xc%
+ \advance\pgf@x by\pgf@sys@dvi@pt@ba\pgf@yc%
+ \advance\pgf@x by\pgf@sys@dvi@pt@x%
+ %
+ \pgf@y=\pgf@sys@dvi@pt@ab\pgf@xc%
+ \advance\pgf@y by\pgf@sys@dvi@pt@bb\pgf@yc%
+ \advance\pgf@y by\pgf@sys@dvi@pt@y%
+ %
+ \global\pgf@sys@dvi@pt@x=\pgf@x%
+ \global\pgf@sys@dvi@pt@y=\pgf@y%
+ \xdef\pgf@sys@dvi@pt@aa{\pgf@sys@tonumber{\pgf@xa}}%
+ \xdef\pgf@sys@dvi@pt@ab{\pgf@sys@tonumber{\pgf@ya}}%
+ \xdef\pgf@sys@dvi@pt@ba{\pgf@sys@tonumber{\pgf@xb}}%
+ \xdef\pgf@sys@dvi@pt@bb{\pgf@sys@tonumber{\pgf@yb}}%
+ }%
+}
+
+\def\pgfsys@transformcm#1#2#3#4#5#6{%
+ {%
+ \pgf@x=#5\relax%
+ \pgf@y=#6\relax%
+ \pgfsysprotocol@literal{\noexpand\pgf@sys@dvi@transformcm{#1}{#2}{#3}{#4}{\the\pgf@x}{\the\pgf@y}}%
+ }%
+}
+
+
+% Stroking
+
+\def\pgfsys@stroke{\pgfsysprotocol@literal{\noexpand\pgf@sys@dvi@stroke}}%
+
+
+\def\pgf@sys@dvi@stroke{%
+ \let\pgf@sys@dvi@moveto=\pgf@sys@dvi@moveto@stroke%
+ \let\pgf@sys@dvi@lineto=\pgf@sys@dvi@lineto@stroke%
+ \let\pgf@sys@dvi@curveto=\pgf@sys@dvi@curveto@stroke%
+ \let\pgf@sys@dvi@rect=\pgf@sys@dvi@rect@stroke%
+ \let\pgf@sys@dvi@closepath=\pgf@sys@dvi@closepath@stroke%
+ {\the\pgf@sys@dvi@path}%
+ \pgf@sys@dvi@path{}%
+}
+
+\def\pgf@sys@dvi@moveto@stroke#1#2{%
+ % These two store the current position:
+ \pgf@xc=#1\relax%
+ \pgf@yc=#2\relax%
+ % These two store the last moveto:
+ \pgf@xb=\pgf@xc%
+ \pgf@yb=\pgf@yc%
+}
+
+\def\pgf@sys@dvi@lineto@stroke#1#2{%
+ {%
+ \pgf@xa=#1\relax%
+ \pgf@ya=#2\relax%
+ \pgf@x=\pgf@xc%
+ \pgf@y=\pgf@yc%
+ \pgf@sys@dvi@pos@transform{\pgf@xa}{\pgf@ya}%
+ \pgf@sys@dvi@pos@transform{\pgf@x}{\pgf@y}%
+ % Now, we need to draw a line from (x/y) to (xa/ya)
+ %
+ % Horizontal?
+ \ifdim\pgf@y=\pgf@ya%
+ % Ok, that should be easy...
+ \pgf@xb=\pgf@xa%
+ \advance\pgf@xb by-\pgf@x%
+ \advance\pgf@y by-0.5\pgf@sys@dvi@linewidth%
+ \pgf@sys@dvi@drawrect{\pgf@x}{\pgf@y}{\pgf@xb}{\pgf@sys@dvi@linewidth}%
+ \else%
+ \ifdim\pgf@x=\pgf@xa%
+ % Ok, also easy...
+ \pgf@yb=\pgf@ya%
+ \advance\pgf@yb by-\pgf@y%
+ \advance\pgf@x by-0.5\pgf@sys@dvi@linewidth%
+ \pgf@sys@dvi@drawrect{\pgf@x}{\pgf@y}{\pgf@sys@dvi@linewidth}{\pgf@yb}%
+ \else%
+ \edef\pgf@marshal{\noexpand\pgf@sys@dvi@drawcurve{\the\pgf@x}{\the\pgf@y}{\the\pgf@x}{\the\pgf@y}{\the\pgf@xa}{\the\pgf@ya}{\the\pgf@xa}{\the\pgf@ya}}%
+ \pgf@marshal%
+ \fi%
+ \fi%
+ }%
+ % Remember:
+ \pgf@xc=#1\relax%
+ \pgf@yc=#2\relax%
+}
+
+
+\def\pgf@sys@dvi@curveto@stroke#1#2#3#4#5#6{%
+ \pgf@x=\pgf@xc%
+ \pgf@y=\pgf@yc%
+ \pgf@xa=#1%
+ \pgf@ya=#2%
+ \pgf@xb=#3%
+ \pgf@yb=#4%
+ \pgf@xc=#5%
+ \pgf@yc=#6%
+ {%
+ \pgf@sys@dvi@pos@transform{\pgf@x}{\pgf@y}%
+ \pgf@sys@dvi@pos@transform{\pgf@xa}{\pgf@ya}%
+ \pgf@sys@dvi@pos@transform{\pgf@xb}{\pgf@yb}%
+ \pgf@sys@dvi@pos@transform{\pgf@xc}{\pgf@yc}%
+ \pgf@sys@dvi@drawcurve{\pgf@x}{\pgf@y}{\pgf@xa}{\pgf@ya}{\pgf@xb}{\pgf@yb}{\pgf@xc}{\pgf@yc}%
+ }%
+}
+
+\def\pgf@sys@dvi@closepath@stroke{%
+ \pgf@sys@dvi@lineto@stroke{\pgf@xc}{\pgf@yc}%
+}
+
+\def\pgf@sys@dvi@rect@stroke#1#2#3#4{%
+ \pgf@x=#1\relax%
+ \pgf@y=#2\relax%
+ \pgf@xa=#3\relax%
+ \pgf@ya=#4\relax%
+ \advance\pgf@xa by\pgf@x%
+ \advance\pgf@ya by\pgf@y%
+ \pgf@sys@dvi@moveto@stroke{\pgf@x}{\pgf@y}%
+ \pgf@sys@dvi@lineto@stroke{\pgf@xa}{\pgf@y}%
+ \pgf@sys@dvi@lineto@stroke{\pgf@xa}{\pgf@ya}%
+ \pgf@sys@dvi@lineto@stroke{\pgf@x}{\pgf@ya}%
+ \pgf@sys@dvi@closepath@stroke%
+}
+
+
+
+\endinput
+
+%%% Local Variables:
+%%% mode: latex
+%%% End:
diff --git a/graphics/pgf/base/tex/generic/systemlayer/pgfsys-dvipdfm.def b/graphics/pgf/base/tex/generic/systemlayer/pgfsys-dvipdfm.def
new file mode 100644
index 0000000000..df1209aefb
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/systemlayer/pgfsys-dvipdfm.def
@@ -0,0 +1,110 @@
+% 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{pgfsys-dvipdfm.def}
+
+% Driver commands for dvipdfm
+
+%
+% Load common pdf and pdf in dvi commands:
+%
+\input pgfsys-common-pdf.def
+\input pgfsys-common-pdf-via-dvi.def
+
+%
+% dvipdfm-specific stuff:
+%
+
+\def\pgfsys@hbox#1{%
+ \pgfsys@begin@idscope%
+ \pgfsys@invoke{q -1 0 0 -1 0 0 cm}%
+ \special{pdf: content -1 0 0 -1 0 0 cm 3 Tr q}% translate to
+ % original coordinate system and do
+ % not show anything
+ {\hbox to 0pt{\pgfutil@font@normalfont\pgfutil@selectfont.\hss}}% enforce font change
+ \pgfsys@invoke{0 Tr}%
+ \pgfsys@invoke{0 J [] 0 d}% reset line cap and dash
+ \wd#1=0pt%
+ \ht#1=0pt%
+ \dp#1=0pt%
+ \box#1
+ \pgfsys@invoke{n Q Q}%
+ \pgfsys@end@idscope%
+}
+\def\pgfsys@hboxsynced#1{%
+ {%
+ \pgfsys@begin@idscope%
+ \pgfsys@beginscope%
+ \setbox\pgf@hbox=\hbox{%
+ \hskip\pgf@pt@x%
+ \raise\pgf@pt@y\hbox{%
+ \pgf@pt@x=0pt%
+ \pgf@pt@y=0pt%
+ \special{pdf: content q}%
+ \pgflowlevelsynccm%
+ \pgfsys@invoke{q -1 0 0 -1 0 0 cm}%
+ \special{pdf: content -1 0 0 -1 0 0 cm q}% translate to original coordinate system
+ \pgfsys@invoke{0 J [] 0 d}% reset line cap and dash
+ \wd#1=0pt%
+ \ht#1=0pt%
+ \dp#1=0pt%
+ \box#1%
+ \pgfsys@invoke{n Q Q Q}%
+ }%
+ \hss%
+ }%
+ \wd\pgf@hbox=0pt%
+ \ht\pgf@hbox=0pt%
+ \dp\pgf@hbox=0pt%
+ \pgfsys@hbox\pgf@hbox%
+ \pgfsys@endscope%
+ \pgfsys@end@idscope%
+ }%
+}
+
+\def\pgfsys@beginpicture{%
+ \pgfsys@invoke{3 Tr}%
+ \hbox to 0pt{\pgfutil@font@normalfont\pgfutil@selectfont.\hss}% enforce font change
+ \pgfsys@invoke{0 Tr}%
+ \special{pdf: content q}}
+\def\pgfsys@endpicture{%
+ \pgfsys@invoke{n Q}%
+}
+
+\def\pgfsys@invoke#1{\special{pdf: content Q #1 q}} % ugly, but necessary...
+
+\def\pgfsys@papersize#1#2{%
+% \expandafter\gdef\expandafter\pgfsys@atbegindocument%
+% \expandafter{\pgfsys@atbegindocument
+ \special{papersize=#1,#2}%
+% }
+}
+
+\def\pgfsys@prepare@papersize#1#2{%
+ \expandafter\gdef\expandafter\pgfsys@atbegindocument%
+ \expandafter{\pgfsys@atbegindocument
+ \special{papersize=#1,#2}%
+ }
+}
+
+%
+% Position tracking (needs pdftex >= 1.40.0-alpha-20051205 in dvi mode)
+%
+\ifx\pdftexversion\@undefined
+\else
+ \ifnum\pdftexversion>139
+ \pgf@sys@pdf@dvi@tracker
+ \fi
+\fi
+
+\endinput
+
+%%% Local Variables:
+%%% mode: latex
+%%% End:
diff --git a/graphics/pgf/base/tex/generic/systemlayer/pgfsys-dvipdfmx.def b/graphics/pgf/base/tex/generic/systemlayer/pgfsys-dvipdfmx.def
new file mode 100644
index 0000000000..7fc1a4e7ed
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/systemlayer/pgfsys-dvipdfmx.def
@@ -0,0 +1,504 @@
+% Copyright 2019 by Till Tantau
+% CMYK and grayscale shadings adaptation copyright 2019 by David Purton
+%
+% 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{pgfsys-dvipdfmx.def}
+
+% Driver commands for dvipdfmx
+%
+% Modified by Jin-Hwan Cho <chofchof@ktug.or.kr> on April 18, 2009.
+% This driver requires the version DVIPDFMX-20080605 that is contained
+% in texlive 2008 or later.
+
+%
+% Load common pdf and pdf in dvi commands:
+%
+\input pgfsys-common-pdf.def
+
+
+% For unique object name:
+\newcount\pgfsys@objnum\pgfsys@objnum\@ne
+
+% `pdf:code' is an abbreviation of `pdf:literal direct', the idea of which
+% came from pdfTeX's primitive \pdfliteral direct.
+\def\pgfsys@invoke#1{\special{pdf:code #1}}
+
+% If color is changed by \pgfsys@invoke explicitly, the color
+% optimization routine in dvipdfmx does not work correctly
+% because the routine checks color specials only. For example,
+%
+% \special{color push 0}\pgfsys@invoke{1 g 1 G}\special{color push 0}
+%
+% the last color special will be ignored the optimization routine
+% thinks that the color has changed to the same color.
+% To avoid this problem, we need to change the color temporarily to another.
+%
+% We assume that black is the default color when no color is specified.
+\def\pgfsys@dvipdfmx@start@force@reset@color{%
+ \special{pdf:bcolor [1]}%
+ \special{pdf:bcolor [0]}%
+}
+\def\pgfsys@dvipdfmx@stop@force@reset@color{%
+ \special{pdf:ecolor}%
+ \special{pdf:ecolor}%
+}
+
+
+\def\pgfsys@dvipdfmx@suspendcontent{%
+ \special{pdf:code q -1 0 0 -1 0 0 cm q}%
+ \special{pdf: econtent}%
+ \special{pdf: bcontent}%
+ \special{pdf:code -1 0 0 -1 0 0 cm}%
+ \special{pdf:code q}% translate to original system
+ \special{pdf: econtent}%
+}
+
+\def\pgfsys@dvipdfmx@unsuspendcontent{%
+ \special{pdf: bcontent}%
+ \special{pdf:code Q Q Q}%
+}
+
+\def\pgfsys@hbox#1{%
+ \pgfsys@begin@idscope%
+ \pgfsys@beginscope%
+ \setbox#1=\hbox{\box#1}%
+ \wd#1=0pt%
+ \ht#1=0pt%
+ \dp#1=0pt%
+ \pgfsys@dvipdfmx@suspendcontent%
+ \pgfsys@invoke{0 J [] 0 d}% reset line cap and dash
+ \pgfsys@dvipdfmx@start@force@reset@color%
+ \box#1%
+ \pgfsys@dvipdfmx@stop@force@reset@color%
+ \pgfsys@dvipdfmx@unsuspendcontent%
+ \pgfsys@endscope%
+ \pgfsys@end@idscope%
+}
+
+% We cannot use many codes in pgfsys-common-pdf-via-dvi.def.
+% So it is rewritten here (with some bugs fixed).
+\def\pgfsys@hboxsynced#1{%
+ \pgfsys@begin@idscope%
+ \pgfsys@beginscope%
+ \setbox#1=\hbox{\box#1}%
+ \wd#1=0pt%
+ \ht#1=0pt%
+ \dp#1=0pt%
+ \pgfsys@dvipdfmx@suspendcontent%
+ \pgfsys@invoke{0 J [] 0 d}% reset line cap and dash
+ \pgfsys@dvipdfmx@start@force@reset@color%
+ \pgf@sys@bp@correct\pgf@pt@x%
+ \pgf@sys@bp@correct\pgf@pt@y%
+ \special{pdf:btrans matrix \pgf@pt@aa\space \pgf@pt@ab\space \pgf@pt@ba\space \pgf@pt@bb\space
+ \pgf@sys@tonumber{\pgf@pt@x} \pgf@sys@tonumber{\pgf@pt@y}}%
+ \box#1%
+ \special{pdf:etrans}%
+ \pgfsys@dvipdfmx@stop@force@reset@color%
+ \pgfsys@dvipdfmx@unsuspendcontent%
+ \pgfsys@endscope%
+ \pgfsys@end@idscope%
+}
+
+% All text materials between `pdf:bcontent' and `pdf:econtent' are
+% treated in the relative coordinate.
+\def\pgfsys@beginpicture{\special{pdf:bcontent}}
+\def\pgfsys@endpicture{\special{pdf:econtent}}
+
+\def\pgfsys@imagesuffixlist{.pdf:.jpg:.jpeg:.png:.bmp:}
+
+% Shaidng came from pgfsys-pdftex.def
+\def\pgfsys@horishading#1#2#3{%
+ {%
+ \pgf@parsefunc{#3}%
+ \pgfmathparse{#2}%
+ \pgf@process{\pgfpoint{\pgf@max}{#2}}%
+ \edef\@tempa{\noexpand\pgfutil@insertatbegincurrentpagefrombox{%
+ \special{pdf:bxobj @pgfshade\the\pgfsys@objnum\space width \the\pgf@max\space height \pgfmathresult pt}%
+ \special{pdf:put @resources
+ <<
+ /Shading << /Sh << /ShadingType 2
+ /ColorSpace \pgf@shading@device\space
+ /Domain [\pgf@pdfparseddomain]
+ /Coords [\pgf@doma\space0 \pgf@domb\space0]
+ /Function \pgf@pdfparsedfunction
+ /Extend [false false] >> >>
+ >>}%
+ \pgfsys@invoke{/Sh sh}%
+ \special{pdf:exobj}}}\@tempa% <<
+ \xdef\pgfutil@tempa{%
+ \hbox to\the\pgf@max{\vbox to\pgfmathresult pt{\vfil\special{pdf:uxobj @pgfshade\the\pgfsys@objnum}}\hfil}}%
+ }%
+ \global\expandafter\let\csname @pgfshading#1!\endcsname=\pgfutil@tempa
+ \global\advance\pgfsys@objnum\@ne%
+}
+\def\pgfsys@vertshading#1#2#3{%
+ {%
+ \pgf@parsefunc{#3}%
+ \pgfmathparse{#2}%
+ \pgf@process{\pgfpoint{\pgf@max}{#2}}%
+ \edef\@tempa{\noexpand\pgfutil@insertatbegincurrentpagefrombox{%
+ \special{pdf:bxobj @pgfshade\the\pgfsys@objnum\space width \pgfmathresult pt\space height \the\pgf@max}%
+ \special{pdf:put @resources
+ <<
+ /Shading << /Sh << /ShadingType 2
+ /ColorSpace \pgf@shading@device\space
+ /Domain [\pgf@pdfparseddomain]
+ /Coords [0 \pgf@doma\space0 \pgf@domb]
+ /Function \pgf@pdfparsedfunction
+ /Extend [false false] >> >>
+ >>}%
+ \pgfsys@invoke{/Sh sh}%
+ \special{pdf:exobj}}}\@tempa% <<
+ \xdef\pgfutil@tempa{%
+ \hbox to\pgfmathresult pt{\vbox to\the\pgf@max{\vfil\special{pdf:uxobj @pgfshade\the\pgfsys@objnum}}\hfil}}%
+ }%
+ \global\expandafter\let\csname @pgfshading#1!\endcsname=\pgfutil@tempa
+ \global\advance\pgfsys@objnum\@ne%
+}
+\def\pgfsys@radialshading#1#2#3{%
+ {%
+ \pgf@parsefunc{#3}%
+ \pgf@process{#2}%
+ \pgf@xa=\pgf@x%
+ \pgf@ya=\pgf@y%
+ \pgf@process{\pgfpoint{\pgf@max}{\pgf@max}}%
+ \advance\pgf@xa by \pgf@x%
+ \advance\pgf@ya by \pgf@y%
+ \pgf@sys@bp@correct{\pgf@x}%
+ \pgf@sys@bp@correct{\pgf@y}%
+ \pgf@sys@bp@correct{\pgf@xa}%
+ \pgf@sys@bp@correct{\pgf@ya}%
+ \pgfutil@tempdima=2\pgf@max%
+ \edef\@tempa{\noexpand\pgfutil@insertatbegincurrentpagefrombox{%
+ \special{pdf:bxobj @pgfshade\the\pgfsys@objnum\space width \the\pgfutil@tempdima\space height \the\pgfutil@tempdima}%
+ \special{pdf:put @resources
+ <<
+ /Shading << /Sh << /ShadingType 3
+ /ColorSpace \pgf@shading@device\space
+ /Domain [\pgf@pdfparseddomain]
+ /Coords [\pgf@sys@tonumber{\pgf@xa} \pgf@sys@tonumber{\pgf@ya} \pgf@doma\space \pgf@sys@tonumber{\pgf@x} \pgf@sys@tonumber{\pgf@y} \pgf@domb]
+ /Function \pgf@pdfparsedfunction
+ /Extend [true false] >> >>
+ >>}%
+ \pgfsys@invoke{/Sh sh}%
+ \special{pdf:exobj}}}\@tempa% <<
+ \xdef\pgfutil@tempa{%
+ \hbox to\the\pgfutil@tempdima{\vbox to\the\pgfutil@tempdima{\vfil\special{pdf:uxobj @pgfshade\the\pgfsys@objnum}}\hfil}}%
+ }%
+ \global\expandafter\let\csname @pgfshading#1!\endcsname=\pgfutil@tempa
+ \global\advance\pgfsys@objnum\@ne%
+}
+\def\pgfsys@functionalshading#1#2#3#4{%
+ {%
+ \pgf@process{#2}%
+ \pgf@xa=\pgf@x%
+ \pgf@ya=\pgf@y%
+ \pgf@process{#3}%
+ \pgf@xb=\pgf@x%
+ \pgf@yb=\pgf@y%
+ \advance\pgf@x by-\pgf@xa%
+ \advance\pgf@y by-\pgf@ya%
+ \pgf@sys@bp@correct{\pgf@xa}%
+ \pgf@sys@bp@correct{\pgf@ya}%
+ \pgf@sys@bp@correct{\pgf@xb}%
+ \pgf@sys@bp@correct{\pgf@yb}%
+ \pgf@xc=-\pgf@xa%
+ \pgf@yc=-\pgf@ya%
+ % Now build the function
+ \edef\@tempa{\noexpand\pgfutil@insertatbegincurrentpagefrombox{%
+ \special{pdf:stream @pgfstream\the\pgfsys@objnum\space({#4}) <</FunctionType 4
+ /Domain [\pgf@sys@tonumber{\pgf@xa}\space\pgf@sys@tonumber{\pgf@xb}\space\pgf@sys@tonumber{\pgf@ya}\space\pgf@sys@tonumber{\pgf@yb}]
+ /Range [\pgf@shading@functional@range]>>}}}\@tempa%
+ \edef\@tempa{\noexpand\pgfutil@insertatbegincurrentpagefrombox{%
+ \special{pdf:bxobj @pgfshade\the\pgfsys@objnum\space width \the\pgf@x\space height \the\pgf@y}%
+ \special{pdf:put @resources <</Shading <</Sh <</ShadingType 1
+ /ColorSpace \pgf@shading@device\space
+ /Matrix [1 0 0 1 \pgf@sys@tonumber{\pgf@xc}\space\pgf@sys@tonumber{\pgf@yc}]
+ /Domain [\pgf@sys@tonumber{\pgf@xa}\space\pgf@sys@tonumber{\pgf@xb}\space\pgf@sys@tonumber{\pgf@ya}\space\pgf@sys@tonumber{\pgf@yb}]
+ /Function @pgfstream\the\pgfsys@objnum>> >> >>}%
+ \pgfsys@invoke{/Sh sh}%
+ \special{pdf:exobj}}}\@tempa% <<
+ \xdef\pgfutil@tempa{%
+ \hbox to\the\pgf@x{\vbox to\the\pgf@y{\vfil\special{pdf:uxobj @pgfshade\the\pgfsys@objnum}}\hfil}}%
+ }%
+ \global\expandafter\let\csname @pgfshading#1!\endcsname=\pgfutil@tempa
+ \global\advance\pgfsys@objnum\@ne%
+}
+
+% \pgf@sys@pdf@dvi@tracker was not touched!
+\def\pgf@sys@pdf@dvi@tracker{
+ \def\pgfsys@markposition##1{%
+ \pdfsavepos%
+ \edef\pgf@temp{##1}%
+ \expandafter\pgfutil@writetoaux\expandafter{%
+ \expandafter\noexpand\expandafter\pgfsyspdfmark\expandafter{\pgf@temp}{\the\pdflastxpos}{\the\pdflastypos}}%
+ }
+ \def\pgfsyspdfmark##1##2##3{%
+ \expandafter\gdef\csname pgf@sys@pdf@mark@pos@##1\endcsname{\pgfqpoint{##2sp}{##3sp}}%
+ \pgfutil@check@rerun{##1}{{##2}{##3}}%
+ }
+ \def\pgfsys@getposition##1##2{%
+ \edef\pgf@marshal{\let\noexpand##2=\expandafter\noexpand\csname pgf@sys@pdf@mark@pos@##1\endcsname}%
+ \pgf@marshal%
+ }
+ \def\pgf@sys@pdf@mark@pos@pgfpageorigin{\pgfpointorigin}
+}
+
+% Resource management: bugs were fixed.
+\newif\ifpgf@sys@pdf@colorspaces@exists
+\newif\ifpgf@sys@pdf@patterns@exists
+\newif\ifpgf@sys@pdf@extgs@exists
+\newif\ifpgf@sys@pdf@colorspaces@created
+\newif\ifpgf@sys@pdf@patterns@created
+\newif\ifpgf@sys@pdf@extgs@created
+\newif\ifpgf@sys@pdf@any@resources
+
+\def\pgf@sys@setuppdfresources@plain{%
+ % This command will setup pdf resource in plain and in latex
+ % mode. ConTeXt has its own handler
+ \pgfutil@insertatbegineverypage{%
+ \pgf@sys@pdf@any@resourcesfalse%
+ \ifpgf@sys@pdf@extgs@exists%
+ \pgf@sys@pdf@any@resourcestrue%
+ \ifpgf@sys@pdf@extgs@created\else\special{pdf:obj @pgfextgs <<>>}\global\pgf@sys@pdf@extgs@createdtrue\fi% <<
+ \fi%
+ \ifpgf@sys@pdf@colorspaces@exists%
+ \pgf@sys@pdf@any@resourcestrue%
+ \ifpgf@sys@pdf@colorspaces@created\else\special{pdf:obj @pgfcolorspaces <<>>}\global\pgf@sys@pdf@colorspaces@createdtrue\fi% <<
+ \fi%
+ \ifpgf@sys@pdf@patterns@exists%
+ \pgf@sys@pdf@any@resourcestrue%
+ \ifpgf@sys@pdf@patterns@created\else\special{pdf:obj @pgfpatterns <<>>}\global\pgf@sys@pdf@patterns@createdtrue\fi% <<
+ \fi%
+ \ifpgf@sys@pdf@any@resources%
+ \special{pdf:put @resources
+ <<
+ \ifpgf@sys@pdf@extgs@exists /ExtGState @pgfextgs \fi
+ \ifpgf@sys@pdf@patterns@exists /Pattern @pgfpatterns \fi
+ \ifpgf@sys@pdf@colorspaces@exists /ColorSpace @pgfcolorspaces \fi
+ >>}% <<
+ \fi%
+ }
+ \def\pgf@sys@addpdfresource@extgs@plain##1{%
+ \global\pgf@sys@pdf@extgs@existstrue%
+ \pgfutil@insertatbegincurrentpage{\special{pdf:put @pgfextgs << ##1 >>}}% <<
+ }
+ \def\pgf@sys@addpdfresource@colorspaces@plain##1{%
+ \global\pgf@sys@pdf@colorspaces@existstrue%
+ \pgfutil@insertatbegincurrentpage{\special{pdf:put @pgfcolorspaces << ##1 >>}}% <<
+ }
+ \def\pgf@sys@addpdfresource@patterns@plain##1{%
+ \global\pgf@sys@pdf@patterns@existstrue%
+ \pgfutil@insertatbegincurrentpage{\special{pdf:put @pgfpatterns << ##1 >>}}% <<
+ }
+}
+\pgfutil@setuppdfresources % possibly call the above
+
+% As pgfsys-pdftex.def, the following code is required
+% to give colors on pattern objects.
+\pgfutil@addpdfresource@colorspaces{ /pgfprgb [/Pattern /DeviceRGB] }
+
+% Image Mask came from pgfsys-pdftex.def
+% generic/pgf/basiclayer/pgfcoreimage.code.tex must be modified!
+\def\pgfsys@defineimage{% width, height, page number
+ \ifx\pgf@imagewidth\pgfutil@empty\edef\pgf@imagewidth{1bp}\fi% width?
+ \ifx\pgf@imageheight\pgfutil@empty\edef\pgf@imageheight{1bp}\fi% height?
+ \ifx\pgf@imagepage\pgfutil@empty\else\edef\pgf@imagepage{ page \pgf@imagepage}\fi%
+ \ifx\pgf@imageinterpolate\pgfutil@empty\else\edef\pgf@imageinterpolate{ /Interpolate\space\pgf@imageinterpolate}\fi%
+ \ifx\pgf@imagemask\pgfutil@empty\else\xdef\pgf@imagemask{ /SMask @\pgf@imagemask}\fi%
+ \edef\pgf@image{\noexpand\hbox to \pgf@imagewidth{\vbox to \pgf@imageheight{\vfil\special{pdf:image width \pgf@imagewidth\space height \pgf@imageheight\space\pgf@imagepage\space(\pgf@filename) <<\pgf@imageinterpolate\pgf@imagemask\space>>}}\hfil}}%
+}
+\def\pgfsys@definemask{%
+ \ifx\pgf@maskmatte\pgfutil@empty%
+ \else%
+ \edef\pgf@maskmatte{/Matte [\pgf@maskmatte]}%
+ \fi%
+ \edef\pgf@attr{\pgf@maskmatte\space /Decode [1 0]}%
+ \special{pdf:image @pgfmask\the\pgfsys@objnum\space hide (\pgf@filename) << \pgf@attr >>}%
+ \edef\pgf@mask{pgfmask\the\pgfsys@objnum}%
+ \global\advance\pgfsys@objnum\@ne%
+}
+
+% Patterns came from pgfsys-pdftex.def
+% dvipdfmx provides a new special `pdf:stream' for a stream object.
+\def\pgfsys@declarepattern#1#2#3#4#5#6#7{%
+ % Start building the pattern dictionary:
+ \pgf@xa=#2\relax%
+ \pgf@ya=#3\relax%
+ \pgf@xb=#4\relax%
+ \pgf@yb=#5\relax%
+ \pgf@xc=#6\relax%
+ \pgf@yc=#7\relax%
+ \pgf@sys@bp@correct\pgf@xa%
+ \pgf@sys@bp@correct\pgf@ya%
+ \pgf@sys@bp@correct\pgf@xb%
+ \pgf@sys@bp@correct\pgf@yb%
+ \pgf@sys@bp@correct\pgf@xc%
+ \pgf@sys@bp@correct\pgf@yc%
+ \pgfsys@@declarepattern{#1}%
+}
+
+\def\pgfsys@@declarepattern#1#2#3#4#5#6#7#8#9{%
+ \pgfutil@tempdima=#6\relax%
+ \pgfutil@tempdimb=#7\relax%
+ \pgf@sys@bp@correct\pgfutil@tempdima%
+ \pgf@sys@bp@correct\pgfutil@tempdimb%
+ % Now create the pattern object:
+ \pgfsys@dvipdfmx@patternobj{%
+ \pgfsys@dvipdfmx@stream{@pgfpatternobject#1}{#8}{%
+ /Type /Pattern
+ /PatternType 1
+ /PaintType \ifnum#9=0 2 \else 1 \fi
+ /TilingType 1
+ /BBox [\pgf@sys@tonumber\pgf@xa\space\pgf@sys@tonumber\pgf@ya\space\pgf@sys@tonumber\pgf@xb\space\pgf@sys@tonumber\pgf@yb]
+ /XStep \pgf@sys@tonumber\pgf@xc\space
+ /YStep \pgf@sys@tonumber\pgf@yc\space
+ /Matrix [#2\space#3\space#4\space#5\space\pgf@sys@tonumber\pgfutil@tempdima\space\pgf@sys@tonumber\pgfutil@tempdimb]
+ /Resources <</Pattern<<>>>> %<<
+ }%
+ }%
+ \pgfutil@addpdfresource@patterns{/pgfpat#1\space @pgfpatternobject#1}%
+}
+
+% hook for xdvipdfmx:
+\def\pgfsys@dvipdfmx@patternobj#1{%
+ \pgfutil@insertatbegincurrentpagefrombox{#1}%
+}%
+
+% hook for xdvipdfmx:
+\def\pgfsys@dvipdfmx@stream#1#2#3{%
+ \special{pdf:stream #1 (#2) << #3 >>}%
+}%
+
+
+\def\pgfsys@setpatternuncolored#1#2#3#4{%
+ \pgfsysprotocol@literal{/pgfprgb cs #2 #3 #4 /pgfpat#1\space scn}%
+}
+\def\pgfsys@setpatterncolored#1{%
+ \pgfsysprotocol@literal{/Pattern cs /pgfpat#1\space scn}%
+}
+
+% Opacity masks (fadings) came from pgfsys-pdftex.def
+%
+% One problem was that the second argument of \pgfsys@fadingfrombox
+% is a box so that \pgfutil@insertatbegincurrentpage cannot be used.
+% So, the new command \pgfutil@insertatbegincurrentpagefrombox is written
+% in generic/pgf/utilities/pgfutil-[context,latex,plain].def.
+\def\pgfsys@fadingfrombox#1#2{%
+ \expandafter\ifx\csname pgfsmaskxform@#1\endcsname\relax%
+ {%
+ \pgf@x=-.5\wd#2%
+ \pgf@y=-.5\ht#2%
+ \advance\pgf@y by.5\dp#2%
+ \expandafter\xdef\csname pgfsmasktrans@#1\endcsname{%
+ \noexpand\pgftransformcm{1}{0}{0}{1}{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}}%
+ \edef\@tempa{\noexpand\pgfutil@insertatbegincurrentpagefrombox{%
+ \special{pdf:bxobj @pgfsmask\the\pgfsys@objnum\space%
+ width \the\wd#2\space height \the\ht#2\space depth \the\dp#2}%
+ \wd#2=0pt%
+ \ht#2=0pt%
+ \dp#2=0pt%
+ \box#2%
+ \special{pdf:put @resources
+ <<
+ \ifpgf@sys@pdf@extgs@exists /ExtGState @pgfextgs \fi
+ \ifpgf@sys@pdf@patterns@exists /Pattern @pgfpatterns \fi
+ \ifpgf@sys@pdf@colorspaces@exists /ColorSpace @pgfcolorspaces \fi
+ >>}% <<
+ \special{pdf:exobj <</Group <</S/Transparency /CS/DeviceGray>> >>}}}\@tempa%
+ \expandafter\xdef\csname pgfsmaskxform@#1\endcsname{\the\pgfsys@objnum}%
+ }%
+ \global\advance\pgfsys@objnum\@ne%
+ \fi%
+}
+\def\pgfsys@usefading#1#2#3#4#5#6#7{%
+ \expandafter\ifx\csname pgfsmaskxform@#1\endcsname\relax%
+ \pgferror{Undefined fading '#1'}%
+ \else%
+ {%
+ \expandafter\ifx\csname pgfsmask@#1\endcsname\relax%
+ \pgf@sys@pdf@install@mask{#1}%
+ \fi%
+ \pgftransformreset%
+ \pgftransformcm{#2}{#3}{#4}{#5}{\pgfpoint{#6}{#7}}%
+ \csname pgfsmasktrans@#1\endcsname%
+ {%
+ \pgflowlevelsynccm%
+ \pgfsys@invoke{/pgfsmask\csname pgfsmaskxform@#1\endcsname\space gs}%
+ }%
+ \pgftransforminvert%
+ \pgflowlevelsynccm%
+ }%
+ \fi
+}
+\def\pgf@sys@pdf@install@mask#1{%
+ \pgfutil@addpdfresource@extgs{%
+ /pgfsmask\csname pgfsmaskxform@#1\endcsname\space <<
+ /SMask <<
+ /S /Luminosity
+ /G @pgfsmask\csname pgfsmaskxform@#1\endcsname
+ >> >>}%<<
+ \expandafter\let\csname pgfsmask@#1\expandafter\endcsname\csname pgfsmaskxform@#1\endcsname%
+}
+
+% Transparency groups came from pgfsys-pdftex.def
+\def\pgfsys@transparencygroupfrombox#1{%
+ {%
+ \pgfutil@tempdima=\pgf@picminx
+ \pgf@sys@bp@correct\pgf@picminx%
+ \pgf@sys@bp@correct\pgf@picmaxx%
+ \pgf@sys@bp@correct\pgf@picminy%
+ \pgf@sys@bp@correct\pgf@picmaxy%
+ \edef\@tempa{\noexpand\pgfutil@insertatbegincurrentpagefrombox{%
+ \special{pdf:bxobj @pgftransgroup\the\pgfsys@objnum\space bbox \pgf@sys@tonumber\pgf@picminx\space\pgf@sys@tonumber\pgf@picminy\space\pgf@sys@tonumber\pgf@picmaxx\space\pgf@sys@tonumber\pgf@picmaxy}%
+ \wd#1=0pt%
+ \ht#1=0pt%
+ \dp#1=0pt%
+ \hskip\pgfutil@tempdima\box#1\hskip-\pgfutil@tempdima%
+ \special{pdf:put @resources
+ <<
+ \ifpgf@sys@pdf@extgs@exists /ExtGState @pgfextgs \fi
+ \ifpgf@sys@pdf@patterns@exists /Pattern @pgfpatterns \fi
+ \ifpgf@sys@pdf@colorspaces@exists /ColorSpace @pgfcolorspaces \fi
+ >>}% <<
+ \special{pdf:exobj <</Group << /S /Transparency
+ /I \ifpgfsys@transparency@group@isolated true \else false \fi
+ /K \ifpgfsys@transparency@group@knockout true \else false \fi>> >>}%
+ }}\@tempa%
+ \special{pdf:uxobj @pgftransgroup\the\pgfsys@objnum}%
+ }%
+ \global\advance\pgfsys@objnum\@ne%
+}
+
+%
+% Position tracking (needs pdftex >= 1.40.0-alpha-20051205 in dvi mode)
+%
+\ifx\pdfsavepos\@undefined
+\else
+ \pgf@sys@pdf@dvi@tracker
+\fi
+
+\def\pgfsys@papersize#1#2{%
+% \expandafter\gdef\expandafter\pgfsys@atbegindocument%%
+% \expandafter{\pgfsys@atbegindocument
+ \special{papersize=#1,#2}%
+% }
+}
+\def\pgfsys@prepare@papersize#1#2{%
+ \expandafter\gdef\expandafter\pgfsys@atbegindocument%%
+ \expandafter{\pgfsys@atbegindocument
+ \special{papersize=#1,#2}%
+ }
+}
+
+\endinput
+
+%%% Local Variables:
+%%% mode: latex
+%%% End:
diff --git a/graphics/pgf/base/tex/generic/systemlayer/pgfsys-dvips.def b/graphics/pgf/base/tex/generic/systemlayer/pgfsys-dvips.def
new file mode 100644
index 0000000000..8a791ff5ad
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/systemlayer/pgfsys-dvips.def
@@ -0,0 +1,644 @@
+% Copyright 2019 by Till Tantau
+%
+% PS-3 shadings, image and opacity masks (fadings), transparency groups,
+% blend modes copyright 2020 by Alexander Grahn
+%
+% 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{pgfsys-dvips.def}
+
+% Driver commands for dvips
+
+\def\pgfsys@invoke#1{\special{ps\ifpgfsys@ps@boxmode\else:\fi: #1}}
+\def\pgfsys@outerinvoke#1{\special{ps: #1}}
+\def\pgf@sys@postscript@header#1{\pgfutil@insertatbegincurrentpage{\special{! #1}}}
+\def\pgf@sys@postscript@object#1{\special{! #1}}
+
+
+%
+% Load common postscript commands:
+%
+\input pgfsys-common-postscript.def
+
+
+%
+% dvips-specific stuff:
+%
+
+\def\pgfsys@beginpicture{\pgfsys@ps@boxmodefalse\special{ps: }\special{ps::[begin]}\pgfsys@invoke{pgfo}}
+\def\pgfsys@endpicture{\pgfsys@invoke{pgfc}\special{ps::[end]}}
+\def\pgfsys@hbox#1{%
+ \pgfsys@begin@idscope%
+ \pgfsys@invoke{pgfs}%
+ \special{ps::[end]}%
+ \wd#1=0pt
+ \ht#1=0pt
+ \dp#1=0pt
+ \box#1
+ \special{ps::[begin]}%
+ \pgfsys@invoke{pgfr}%
+ \pgfsys@end@idscope%
+}
+\def\pgfsys@begininvisible{%
+ \special{ps::[begin]}%
+ \pgfsys@invoke{gsave nulldevice}%
+ \special{ps::[end]}}
+\def\pgfsys@endinvisible{%
+ \special{ps::[begin]}%
+ \pgfsys@invoke{grestore}%
+ \special{ps::[end]}%
+}
+\def\pgfsys@color@unstacked#1{\special{ps: \XC@usecolor{#1}}}
+\def\pgfsys@imagesuffixlist{.epsi:.eps:.ps:}
+
+\def\pgfsys@papersize#1#2{%
+ \special{papersize=#1,#2}%
+ % \expandafter\gdef\expandafter\pgfsys@atbegindocument\expandafter{\pgfsys@atbegindocument\special{papersize=#1,#2}}%
+}
+\def\pgfsys@prepare@papersize#1#2{%
+ \expandafter\gdef\expandafter\pgfsys@atbegindocument\expandafter{\pgfsys@atbegindocument\special{papersize=#1,#2}}%
+}
+
+\expandafter\gdef\expandafter\pgfsys@atbegindocument\expandafter{\pgfsys@atbegindocument%
+ \pgf@sys@postscript@header{
+ /pgfsc{}bind def% stroke color is empty by default
+ /pgffc{}bind def% fill color is empty by default
+ /pgfstr{stroke}bind def%
+ /pgffill{fill}bind def%
+ /pgfeofill{eofill}bind def%
+ /pgfe{a dup 0 rlineto exch 0 exch rlineto neg 0 rlineto closepath}bind def% rectangle
+ /pgfw{setlinewidth}bind def% setlinewidth
+ /pgfs{save pgfpd 72 Resolution div 72 VResolution div neg scale
+ magscale{1 DVImag div dup scale}if
+ pgfx neg pgfy neg translate pgffoa .setopacityalpha}bind def% save
+ /pgfr{pgfsd restore}bind def %restore
+ userdict begin%
+ /pgfo{pgfsd /pgfx currentpoint /pgfy exch def def @beginspecial}bind def %open
+ /pgfc{newpath @endspecial pgfpd}bind def %close
+ /pgfsd{globaldict /pgfdelta /delta where {pop delta} {0} ifelse put}bind def% save delta
+ /pgfpd{/delta globaldict /pgfdelta get def}bind def % put delta
+ /.setblendmode where {pop} {/.setblendmode{pop}def} ifelse % install .setblendmode
+ /.setfillconstantalpha where {%
+ pop /.setopacityalpha {.setfillconstantalpha} def%
+ } {%
+ /.setopacityalpha where {pop} {/.setopacityalpha {pop} def} ifelse% install .setopacityalpha (fallback)
+ } ifelse
+ /.pgfsetfillopacityalpha{/pgffoa exch def
+ /.setfillconstantalpha where {pop pgffoa .setfillconstantalpha} {%
+ /pgffill{gsave pgffoa .setopacityalpha fill 1 .setopacityalpha newpath fill grestore newpath}bind def
+ /pgfeofill{gsave pgffoa .setopacityalpha eofill 1 .setopacityalpha newpath eofill grestore newpath}bind def%
+ } ifelse%
+ } bind def
+ /.pgfsetstrokeopacityalpha{/pgfsoa exch def
+ /.setstrokeconstantalpha where {pop pgfsoa .setstrokeconstantalpha} {%
+ /pgfstr{gsave pgfsoa .setopacityalpha stroke grestore newpath}bind def%
+ } ifelse%
+ }bind def
+ /pgffoa 1 def
+ /pgfsoa 1 def
+ % mandatory, transparency-related per-page operations, see
+ % https://www.ghostscript.com/doc/current/Language.htm#Transparency
+ % (bop-hook & eop-hook automatically executed if defined in userdict, see texdoc dvips)
+ /.pushpdf14devicefilter where {pop
+ [userdict /bop-hook known {userdict /bop-hook get aload pop} if
+ {0 .pushpdf14devicefilter} aload pop] cvx userdict exch /bop-hook exch put
+ [userdict /eop-hook known {userdict /eop-hook get aload pop} if
+ {.poppdf14devicefilter} aload pop] cvx userdict exch /eop-hook exch put%
+ } if
+ % keeps printers from choking on pdfmark operator
+ systemdict /pdfmark known not {userdict /pdfmark systemdict /cleartomark get put} if
+ end
+ }%
+}
+
+\AtBeginDocument{ % needed for plain TeX
+ \pgfsys@atbegindocument
+ \let\pgfsys@atbegindocument=\pgfutil@empty
+}
+
+
+
+%
+% Position tracking (needs pdftex or luatex in dvi mode)
+%
+\ifx\savepos\@undefined
+ \ifx\pdfsavepos\@undefined
+ \else
+ \let\pgf@savepos\pdfsavepos
+ \let\pgf@lastxpos\pdflastxpos
+ \let\pgf@lastypos\pdflastypos
+ \fi
+\else
+ \let\pgf@savepos\savepos
+ \let\pgf@lastxpos\lastxpos
+ \let\pgf@lastypos\lastypos
+\fi
+
+
+\ifx\pgf@savepos\@undefined
+\else
+
+\def\pgfsys@markposition#1{%
+ \pgf@savepos%
+ \edef\pgf@temp{#1}%
+ \expandafter\pgfutil@writetoaux\expandafter{%
+ \expandafter\noexpand\expandafter\pgfsyspdfmark\expandafter{\pgf@temp}{\the\pgf@lastxpos}{\the\pgf@lastypos}}%
+}
+
+\def\pgfsyspdfmark#1#2#3{%
+ \expandafter\gdef\csname pgf@sys@pdf@mark@pos@#1\endcsname{\pgfqpoint{#2sp}{#3sp}}%
+ \pgfutil@check@rerun{#1}{{#2}{#3}}%
+}
+
+\def\pgfsys@getposition#1#2{%
+ \edef\pgf@marshal{\let\noexpand#2=\expandafter\noexpand\csname pgf@sys@pdf@mark@pos@#1\endcsname}%
+ \pgf@marshal%
+}
+
+\def\pgf@sys@pdf@mark@pos@pgfpageorigin{\pgfpointorigin}
+
+\fi
+
+
+% Path usage:
+\def\pgfsys@discardpath{%
+ \ifpgfsys@@clipnext%
+ \ifpgfsys@eorule%
+ \pgfsysprotocol@literal{%
+ /pgfsmaskinplace dup where {exch get}{pop false} ifelse not {eoclip} if}%
+ \else%
+ \pgfsysprotocol@literal{%
+ /pgfsmaskinplace dup where {exch get}{pop false} ifelse not {clip} if}%
+ \fi%
+ \pgfsys@@clipnextfalse%
+ \fi%
+ \pgfsysprotocol@literal{newpath}}
+
+
+%
+% Blending
+%
+
+\def\pgfsys@blend@mode#1{%
+ \expandafter\ifx\csname pgf@sys@pdf@bm@#1\endcsname\relax%
+ \expandafter\let\expandafter\pgf@temp\csname pgf@sys@pdf@blend@mode@map@#1\endcsname%
+ \expandafter\xdef\csname pgf@sys@pdf@bm@#1\endcsname{/\pgf@temp}%
+ \ifx\pgf@temp\relax%
+ \pgferror{Unknown blend mode '#1'}%
+ \def\pgf@temp{Normal}%
+ \fi%
+ \fi%
+ \pgfsysprotocol@literal{\csname pgf@sys@pdf@bm@#1\endcsname\space .setblendmode}%
+}
+\expandafter\def\csname pgf@sys@pdf@blend@mode@map@normal\endcsname{Normal}
+\expandafter\def\csname pgf@sys@pdf@blend@mode@map@multiply\endcsname{Multiply}
+\expandafter\def\csname pgf@sys@pdf@blend@mode@map@screen\endcsname{Screen}
+\expandafter\def\csname pgf@sys@pdf@blend@mode@map@overlay\endcsname{Overlay}
+\expandafter\def\csname pgf@sys@pdf@blend@mode@map@darken\endcsname{Darken}
+\expandafter\def\csname pgf@sys@pdf@blend@mode@map@lighten\endcsname{Lighten}
+\expandafter\def\csname pgf@sys@pdf@blend@mode@map@color dodge\endcsname{ColorDodge}
+\expandafter\def\csname pgf@sys@pdf@blend@mode@map@color burn\endcsname{ColorBurn}
+\expandafter\def\csname pgf@sys@pdf@blend@mode@map@hard light\endcsname{HardLight}
+\expandafter\def\csname pgf@sys@pdf@blend@mode@map@soft light\endcsname{SoftLight}
+\expandafter\def\csname pgf@sys@pdf@blend@mode@map@difference\endcsname{Difference}
+\expandafter\def\csname pgf@sys@pdf@blend@mode@map@exclusion\endcsname{Exclusion}
+\expandafter\def\csname pgf@sys@pdf@blend@mode@map@saturation\endcsname{Saturation}
+\expandafter\def\csname pgf@sys@pdf@blend@mode@map@color\endcsname{Color}
+\expandafter\def\csname pgf@sys@pdf@blend@mode@map@hue\endcsname{Hue}
+\expandafter\def\csname pgf@sys@pdf@blend@mode@map@luminosity\endcsname{Luminosity}
+
+
+%
+% Shadings
+%
+
+\def\pgfsys@horishading#1#2#3{%
+ {%
+ \pgf@parsefunc{#3}%
+ \pgf@xb=\pgf@max
+ \pgfmathsetlength\pgf@y{#2}%
+ \pgf@yb=\pgf@y
+ \pgf@sys@bp@correct{\pgf@xb}%
+ \pgf@sys@bp@correct{\pgf@yb}%
+ \xdef\pgfutil@tempa{\hbox to \the\pgf@max{%
+ \noexpand\vrule width0pt height\the\pgf@y%
+ \noexpand\pgfsys@beginpurepicture%
+ \noexpand\pgfsys@outerinvoke{
+ \pgf@sys@tonumber{\pgf@yb} \pgf@sys@tonumber{\pgf@xb} 0 0 pgfe <<
+ /PatternType 2
+ /Shading <<
+ /ShadingType 2
+ /ColorSpace \pgf@shading@device\space
+ /Domain [\pgf@pdfparseddomain]
+ /Coords [\pgf@doma\space0 \pgf@domb\space0]
+ /Function \pgf@pdfparsedfunction
+ >>
+ >> matrix makepattern setpattern fill
+ }%
+ \hss%
+ \noexpand\pgfsys@endpurepicture%
+ }}%
+ }%
+ \global\expandafter\let\csname @pgfshading#1!\endcsname\pgfutil@tempa%
+}
+\def\pgfsys@vertshading#1#2#3{%
+ {%
+ \pgf@parsefunc{#3}%
+ \pgfmathsetlength\pgf@x{#2}%
+ \pgf@xb=\pgf@x
+ \pgf@yb=\pgf@max
+ \pgf@sys@bp@correct{\pgf@xb}%
+ \pgf@sys@bp@correct{\pgf@yb}%
+ \xdef\pgfutil@tempa{\hbox to \the\pgf@x{%
+ \noexpand\vrule width0pt height\the\pgf@max%
+ \noexpand\pgfsys@beginpurepicture%
+ \noexpand\pgfsys@outerinvoke{
+ \pgf@sys@tonumber{\pgf@yb} \pgf@sys@tonumber{\pgf@xb} 0 0 pgfe <<
+ /PatternType 2
+ /Shading <<
+ /ShadingType 2
+ /ColorSpace \pgf@shading@device\space
+ /Domain [\pgf@pdfparseddomain]
+ /Coords [0 \pgf@doma\space0 \pgf@domb]
+ /Function \pgf@pdfparsedfunction
+ >>
+ >> matrix makepattern setpattern fill
+ }%
+ \hss%
+ \noexpand\pgfsys@endpurepicture%
+ }}%
+ }%
+ \global\expandafter\let\csname @pgfshading#1!\endcsname\pgfutil@tempa%
+}
+\def\pgfsys@radialshading#1#2#3{%
+ {%
+ \pgf@parsefunc{#3}%
+ \pgf@process{#2}%
+ \pgf@xa=\pgf@x
+ \pgf@ya=\pgf@y
+ \pgf@process{\pgfpoint{\pgf@max}{\pgf@max}}%
+ \advance\pgf@xa by \pgf@x
+ \advance\pgf@ya by \pgf@y
+ \pgf@sys@bp@correct{\pgf@x}%
+ \pgf@sys@bp@correct{\pgf@y}%
+ \pgf@sys@bp@correct{\pgf@xa}%
+ \pgf@sys@bp@correct{\pgf@ya}%
+ \pgf@max=2\pgf@max
+ \xdef\pgfutil@tempa{\hbox to \the\pgf@max{%
+ \noexpand\vrule width0pt height\the\pgf@max%
+ \noexpand\pgfsys@beginpurepicture%
+ \noexpand\pgfsys@outerinvoke{
+ <<
+ /ShadingType 3
+ /ColorSpace \pgf@shading@device\space
+ /Domain [\pgf@pdfparseddomain]
+ /Coords [\pgf@sys@tonumber{\pgf@xa} \pgf@sys@tonumber{\pgf@ya} \pgf@doma\space
+ \pgf@sys@tonumber{\pgf@x} \pgf@sys@tonumber{\pgf@y} \pgf@domb]
+ /Function \pgf@pdfparsedfunction
+ /Extend [true false]
+ >> shfill
+ }%
+ \hss%
+ \noexpand\pgfsys@endpurepicture%
+ }}%
+ }%
+ \global\expandafter\let\csname @pgfshading#1!\endcsname\pgfutil@tempa%
+}
+\def\pgfsys@functionalshading#1#2#3#4{%
+ {%
+ \pgf@process{#2}%
+ \pgf@xa=\pgf@x
+ \pgf@ya=\pgf@y
+ \pgf@process{#3}%
+ \pgf@xb=\pgf@x
+ \pgf@yb=\pgf@y
+ \advance\pgf@x by-\pgf@xa
+ \advance\pgf@y by-\pgf@ya
+ \pgf@sys@bp@correct{\pgf@xa}%
+ \pgf@sys@bp@correct{\pgf@ya}%
+ \pgf@sys@bp@correct{\pgf@xb}%
+ \pgf@sys@bp@correct{\pgf@yb}%
+ \pgf@xc=-\pgf@xa
+ \pgf@yc=-\pgf@ya
+ \xdef\pgfutil@tempa{%
+ \hbox to\the\pgf@x{\vbox to\the\pgf@y{\vfil
+ \noexpand\pgfsys@beginpurepicture%
+ \noexpand\pgfsys@invoke{%
+ % patch coords
+ /pgfpatchllx \pgf@sys@tonumber{\pgf@xa} def
+ /pgfpatchlly \pgf@sys@tonumber{\pgf@ya} def
+ % shading patch width and height
+ /pgfpatchX \pgf@sys@tonumber{\pgf@xb} pgfpatchllx sub def
+ /pgfpatchY \pgf@sys@tonumber{\pgf@yb} pgfpatchlly sub def
+ % number of samples in each direction (with samples spaced by approx. 1bp)
+ /pgfsamplesx pgfpatchX round cvi 1 add def
+ /pgfsamplesy pgfpatchY round cvi 1 add def
+ % exact sample distance in each direction, in bp
+ /pgfpatchdx pgfpatchX pgfsamplesx 1 sub div def
+ /pgfpatchdy pgfpatchY pgfsamplesy 1 sub div def
+ %
+ pgfpatchllx neg pgfpatchlly neg translate
+ /pgfproc {#4} bind def
+ %
+ % sampling procedure; repeatedly called by /ReusableStreamDecode filter;
+ % on each call, /pgfsamplingproc puts one colour sample (rgb, cmyk or gray)
+ % on the operand stack which is then consumed by the filter
+ userdict /pgfsampleidx 0 put % internal index; updated on each call
+ /pgfsamplingproc {
+ pgfsampleidx pgfsamplesx pgfsamplesy mul eq {
+ () % push empty string on the stack to signal end-of-data
+ } {
+ pgfcolorsample\pgf@shading@model\space % -str-
+ pgfsampleidx pgfsamplesx mod pgfpatchdx mul pgfpatchllx add % -str- x
+ pgfsampleidx pgfsamplesx idiv pgfpatchdy mul pgfpatchlly add % -str- x y
+ pgfproc % -str- <colour>
+ pgfwritesample\pgf@shading@model\space % -str-
+ /pgfsampleidx pgfsampleidx 1 add store % (update index)
+ } ifelse
+ } bind def
+ %
+ pgfpatchY pgfpatchX pgfpatchllx pgfpatchlly pgfe <<
+ /PatternType 2
+ /Shading <<
+ /ShadingType 1
+ /Domain [0 1 0 1]
+ /Matrix [pgfpatchX 0 0 pgfpatchY pgfpatchllx pgfpatchlly]
+ /ColorSpace \pgf@shading@device\space
+ /Function <<
+ /FunctionType 0
+ /Order 1
+ /Domain [0 1 0 1]
+ /Range pgfrange\pgf@shading@model
+ /BitsPerSample pgfchanneldepth\pgf@shading@model % bits per channel, actually
+ /Size [pgfsamplesx pgfsamplesy]
+ /DataSource /pgfsamplingproc load /ReusableStreamDecode filter
+ >>
+ >>
+ >> matrix makepattern setpattern fill
+ }%
+ \noexpand\pgfsys@endpurepicture%
+ }\hss}%
+ }%
+ }%
+ \global\expandafter\let\csname @pgfshading#1!\endcsname\pgfutil@tempa%
+}
+
+% helpers for converting FunctionType-4 to FunctionType-0, i. e. sampled, functions;
+% FunctionType-4 functions are not defined in PostScript-3
+%
+% These are the different colour models we are going to use:
+% +-------+-------------------+-----------+------------------+
+% | model | channel depth/bit | max value | sample size/byte |
+% +-------+-------------------+-----------+------------------+
+% | cmyk | 8 | 255 | 4 |
+% | rgb | 8 | 255 | 3 |
+% | gray | 24 | 16777215 | 3 |
+% +-------+-------------------+-----------+------------------+
+\expandafter\gdef\expandafter\pgfsys@atbegindocument\expandafter{\pgfsys@atbegindocument%
+ \pgf@sys@postscript@header{
+ %
+ % -str- c m y k pgfwritesamplecmyk ==> -str-
+ % -str- r g b pgfwritesamplergb ==> -str-
+ % -str- gray pgfwritesamplegray ==> -str-
+ % writes a single colour sample into the /pgfcolorsample* string;
+ % colour components (c,m,y,k; r,g,b; gray) between 0.0 to 1.0
+ %
+ /pgfwritesamplecmyk {
+ 4 index 0 5 index pgfcheckcolorrange 255 mul round cvi put
+ 4 index 1 4 index pgfcheckcolorrange 255 mul round cvi put
+ 4 index 2 3 index pgfcheckcolorrange 255 mul round cvi put
+ 4 index 3 2 index pgfcheckcolorrange 255 mul round cvi put
+ pop pop pop pop
+ } bind def
+ %
+ /pgfwritesamplergb {
+ 3 index 0 4 index pgfcheckcolorrange 255 mul round cvi put
+ 3 index 1 3 index pgfcheckcolorrange 255 mul round cvi put
+ 3 index 2 2 index pgfcheckcolorrange 255 mul round cvi put
+ pop pop pop
+ } bind def
+ %
+ /pgfwritesamplegray {
+ % grayvalue between 0 and 16777215 (24 bit)
+ pgfcheckcolorrange 16777215 mul round cvi % -str- gray24
+ 1 index 0 2 index -16 bitshift put % high byte
+ 1 index 1 2 index 65535 and -8 bitshift put % middle byte
+ 1 index 2 2 index 255 and put % low byte
+ pop
+ } bind def
+ %
+ % <colour component> pgfcheckcolorrange ==> <something between 0.0 and 1.0>
+ % truncates value to the allowed range (user-defined Type-4 functions may
+ % happen to provide values outside this range)
+ /pgfcheckcolorrange {
+ dup 0.0 lt {pop 0.0} if
+ dup 1.0 gt {pop 1.0} if
+ } bind def
+ %
+ %colour depths per channel (bit)
+ /pgfchanneldepthcmyk 8 def
+ /pgfchanneldepthrgb 8 def
+ /pgfchanneldepthgray 24 def
+ %
+ % allocate strings as buffers for storing a single colour sample
+ /pgfcolorsamplecmyk 4 string def
+ /pgfcolorsamplergb 3 string def
+ /pgfcolorsamplegray 3 string def
+ %
+ %/Range array in the FunctionType 0 dictionary
+ /pgfrangecmyk [0 1 0 1 0 1 0 1] def
+ /pgfrangergb [0 1 0 1 0 1] def
+ /pgfrangegray [0 1] def
+ }%
+}
+
+
+%
+% Opacity masks
+%
+
+\def\pgfsys@fadingfrombox#1#2{%
+ \ifcsname pgfsmaskxform@#1\endcsname
+ \pgfwarning{Fading '#1' already defined.\MessageBreak Going to replace it with new definition}%
+ \fi%
+ \global\advance\pgf@objectcount\@ne%
+ {%
+ \pgf@x=-.5\wd#2%
+ \pgf@y=-.5\ht#2%
+ \advance\pgf@y by.5\dp#2%
+ \expandafter\xdef\csname pgfsmasktrans@#1\endcsname{%
+ \noexpand\pgftransformcm{1}{0}{0}{1}{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}}%
+ \edef\@tempa{\noexpand\pgfutil@insertatbegincurrentpagefrombox{%
+ % box coordinates (reference point and top) needed for ps2pdf
+ \pgfsys@outerinvoke{currentpoint /pgf@refy exch def /pgf@refx exch def}%
+ \hbox to 0pt {\hbox to \ifdim\ht#2>\ht\strutbox\ht#2\else\ht\strutbox\fi{\hss\pgfsys@outerinvoke{%
+ /pgf@top pgf@refy currentpoint pop pgf@refx sub VResolution Resolution div mul sub def%
+ }}\hss}%
+ % lower-right box corner coordinates for viewing
+ \hbox to 0pt {\hbox to \wd#2{\hss\pgfsys@outerinvoke{/pgf@right currentpoint pop def}}\hss}%
+ \hbox to 0pt {\hbox to \ifdim\dp#2>\dp\strutbox\dp#2\else\dp\strutbox\fi{\hss\pgfsys@outerinvoke{%
+ /pgf@bot pgf@refy currentpoint pop pgf@refx sub VResolution Resolution div mul add def%
+ }}\hss}%
+ \pgfsys@outerinvoke{gsave
+ clippath pathbbox newpath pop pop translate
+ systemdict /pdfmark known {%
+ % for ps2pdf, translate box to upper-left page corner, so we have the whole clipping
+ % path (i. e. page area) available, as outlying parts get clipped
+ pgf@refx neg pgf@top neg translate%
+ } {%
+ % for viewing, however, we want to hide the box by moving it off-page; we do so by aligning
+ % the lower-right box corner with the upper-left page corner
+ pgf@right neg pgf@bot neg translate%
+ } ifelse
+ % translate origin (0,0) to the reference point
+ gsave pgf@refx pgf@refy translate
+ mark /_objdef {pgfsmaskxform@\the\pgf@objectcount}
+ /BBox [clippath pathbbox newpath] /BP pdfmark grestore%
+ }%
+ \wd#2=0pt
+ \ht#2=0pt
+ \dp#2=0pt
+ \box#2%
+ \pgfsys@outerinvoke{mark /EP pdfmark grestore}%
+ }}\@tempa%
+ \expandafter\xdef\csname pgfsmaskxform@#1\endcsname{\the\pgf@objectcount}%
+ }%
+}
+\def\pgfsys@usefading#1#2#3#4#5#6#7{%
+ \ifcsname pgfsmaskxform@#1\endcsname%
+ {%
+ \pgftransformreset%
+ \pgftransformcm{#2}{#3}{#4}{#5}{\pgfpoint{#6}{#7}}%
+ \csname pgfsmasktrans@#1\endcsname%
+ {%
+ \pgflowlevelsynccm%
+ \pgfsys@outerinvoke{%
+ /.begintransparencymaskgroup where {pop
+ /pgf@sys@currentcolorspace currentcolorspace def
+ /pgf@sys@currentcolor [currentcolor] cvx def
+ /pgf@sys@OverrideICC currentuserparams /OverrideICC get def % Chr. Liddell
+ <</OverrideICC true>> setuserparams % of Artifex
+ /DeviceGray setcolorspace
+ true <</Subtype/Luminosity>> clippath pathbbox newpath .begintransparencymaskgroup
+ gsave
+ 72 Resolution div 72 VResolution div scale
+ 1 DVImag div 1 DVImag div neg scale
+ mark {pgfsmaskxform@\csname pgfsmaskxform@#1\endcsname} /SP pdfmark
+ grestore
+ 0 .endtransparencymask
+ <</OverrideICC pgf@sys@OverrideICC>> setuserparams % restore orig. settings
+ pgf@sys@currentcolorspace setcolorspace
+ pgf@sys@currentcolor setcolor
+ /pgfsmaskinplace true def
+ } if%
+ }%
+ }%
+ \pgftransforminvert%
+ \pgflowlevelsynccm%
+ }%
+ \else
+ \pgferror{Undefined fading '#1'}%
+ \fi%
+}
+\def\pgfsys@clipfading{%
+ \pgfsyssoftpath@invokecurrentpath%
+ \pgfsys@clipnext%
+ \pgfsys@discardpath%
+}
+
+
+%
+% Transparency groups
+%
+\def\pgfsys@transparencygroupfrombox#1{%
+ \global\advance\pgf@objectcount\@ne%
+ \pgfsys@outerinvoke{%
+ mark /_objdef {pgfxform@\the\pgf@objectcount} /BBox [clippath pathbbox newpath] /BP pdfmark
+ gsave
+ /pgf@sys@foa pgffoa def /pgf@sys@soa pgfsoa def
+ /.setstrokeconstantalpha where
+ {pop 1 .pgfsetfillopacityalpha 1 .pgfsetstrokeopacityalpha} if%
+ }%
+ \wd#1=0pt
+ \ht#1=0pt
+ \dp#1=0pt
+ \hskip\pgf@picminx\box#1\hskip-\pgf@picminx
+ \pgfsys@outerinvoke{%
+ /pgffoa pgf@sys@foa def /pgfsoa pgf@sys@soa def
+ grestore
+ mark /EP pdfmark
+ mark {pgfxform@\the\pgf@objectcount} << /Group << /S /Transparency
+ /I \ifpgfsys@transparency@group@isolated true \else false \fi
+ /K \ifpgfsys@transparency@group@knockout true \else false \fi >> >> /PUT pdfmark%
+ }%
+ \setbox#1=\hbox{\pgfsys@outerinvoke{mark {pgfxform@\the\pgf@objectcount} /SP pdfmark}}%
+}
+
+
+%
+% Image inclusion, adding SMask reference and image interpolation if mandated
+%
+
+\def\pgfsys@defineimage{%
+ \ifx\pgf@imagewidth\pgfutil@empty\else\edef\pgf@imagewidth{width=\pgf@imagewidth,}\fi%
+ \ifx\pgf@imageheight\pgfutil@empty\else\edef\pgf@imageheight{height=\pgf@imageheight,}\fi%
+ \begingroup%
+ \def\pgf@imageaddedkeys{}\def\@tempa{true}%
+ \ifx\pgf@imageinterpolate\@tempa\def\pgf@imageaddedkeys{/Interpolate true}\fi%
+ \ifx\pgf@imagemask\pgfutil@empty\else\edef\pgf@imageaddedkeys{\pgf@imageaddedkeys /SMask {\pgf@imagemask}}\fi%
+ \edef\@tempa{%
+ \ifx\pgf@imageaddedkeys\pgfutil@empty\else%
+ \noexpand\pgfsys@outerinvoke{%
+ save /pgfparent [(img) cvx cvn rand] cvx def %random name for current image
+ mark /_objdef /pgfparent load /NI pdfmark
+ % sometimes, image metadata contain embedded pdfmarks that prevent us from
+ % writing to the image dictionary ourselves, so we disable them temporarily
+ save /pdfmark /cleartomark load def
+ }%
+ \fi%
+ \noexpand\includegraphics[\pgf@imageheight\pgf@imagewidth]{\pgf@filename}%
+ \ifx\pgf@imageaddedkeys\pgfutil@empty\else%
+ \noexpand\pgfsys@outerinvoke{%
+ % empty image dummy, in case the provided file is not a valid raster image
+ 0 0 1 [1 0 0 1 0 0] {} image restore
+ mark /pgfparent load <<\pgf@imageaddedkeys>> /PUT pdfmark restore
+ }%
+ \fi%
+ }%
+ \expandafter\endgroup%
+ \expandafter\def\expandafter\pgf@image\expandafter{\@tempa}%
+}
+
+
+%
+% Image masks
+%
+
+\def\pgfsys@definemask{%
+ \global\advance\pgf@objectcount\@ne%
+ \ifx\pgf@maskmatte\pgfutil@empty%
+ \else%
+ \edef\pgf@maskmatte{/Matte [\pgf@maskmatte]}%
+ \fi%
+ \pgfsys@outerinvoke{%
+ mark /_objdef {pgfmask\the\pgf@objectcount} /NI pdfmark
+ 1 dict begin /pdfmark /cleartomark load def
+ }%
+ \special{psfile=\pgf@filename\space hsize=0 vsize=0}%
+ \pgfsys@outerinvoke{%
+ 0 0 1 [1 0 0 1 0 0] {} image
+ end mark {pgfmask\the\pgf@objectcount} <</Decode [1 0] \pgf@maskmatte>> /PUT pdfmark
+ }%
+ \edef\pgf@mask{pgfmask\the\pgf@objectcount}%
+}
+
+\endinput
+
+%%% Local Variables:
+%%% mode: latex
+%%% End:
diff --git a/graphics/pgf/base/tex/generic/systemlayer/pgfsys-dvisvgm.def b/graphics/pgf/base/tex/generic/systemlayer/pgfsys-dvisvgm.def
new file mode 100644
index 0000000000..a089601182
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/systemlayer/pgfsys-dvisvgm.def
@@ -0,0 +1,217 @@
+% 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{pgfsys-dvisvgm.def}
+
+
+% Driver commands for dvisvgm
+
+%
+% Load common pdf commands:
+%
+\input pgfsys-common-svg.def
+
+\newif\ifpgf@sys@svg@inpicture
+
+\def\pgf@sys@svg@make@defs#1#2{{\let\#\pgf@sys@svg@hash\special{dvisvgm:rawset #1}\special{dvisvgm:rawdef #2}\special{dvisvgm:endrawset}}}
+\def\pgf@sys@svg@ref@defs#1{\special{dvisvgm:rawput #1}}
+\def\pgfsys@invoke#1{{\let\#\pgf@sys@svg@hash\special{dvisvgm:raw #1}}}
+\def\pgfsys@beginpicture{%
+ \special{color push gray 0}% make dvisvgm *not* add anything to text
+ \pgf@sys@svg@inpicturetrue% in a picture
+ \pgfsys@svg@boxmodefalse%
+ \pgfsys@invoke{<g \ifx\pgf@sys@svg@last@stroke\relax\else
+ stroke="\pgf@sys@svg@last@stroke" \fi stroke-miterlimit="10" transform="translate({?x},{?y})scale(0.996264,-0.996264)">}}
+\def\pgfsys@endpicture{\pgfsys@invoke{</g>}\special{color pop}}
+
+\def\pgfsys@svg@newline{{?nl}}
+
+\let\pgf@sys@svg@last@stroke\relax%
+
+
+\def\pgfsys@hbox#1{%
+ {%
+ \setbox#1=\hbox{\box#1}%
+ \wd#1=0pt%
+ \ht#1=0pt%
+ \dp#1=0pt%
+ \pgfsys@begin@idscope%
+ \pgfsys@invoke{<g stroke="none" transform="scale(-1.00375,1.00375)translate({?x},{?y})scale(-1,-1)">}\box#1\pgfsys@invoke{</g>}%
+ \pgfsys@end@idscope%
+ }%
+}
+
+\def\pgfsys@hboxsynced#1{%
+ {%
+ \setbox#1=\hbox{\box#1}%
+ \wd#1=0pt%
+ \ht#1=0pt%
+ \dp#1=0pt%
+ \pgfsys@begin@idscope%
+ \pgfsys@beginscope%
+ \pgflowlevelsynccm%
+ \pgfsys@invoke{<g stroke="none" transform="scale(-1.00375,1.00375)translate({?x},{?y})scale(-1,-1)">}\box#1\pgfsys@invoke{</g>}%
+ \pgfsys@endscope%
+ \pgfsys@end@idscope%
+ }%
+}
+
+
+\def\pgfsys@shadingoutsidepgfpicture#1{%
+ \begingroup%
+ #1%
+ \setbox\pgfpic=\hbox to0pt{%
+ \pgfsys@beginpicture%
+ \pgfsys@beginscope%
+ \pgf@sys@svg@sh@defs%
+ \pgf@sys@svg@sh%
+ \pgfsys@endscope%
+ \pgfsys@endpicture%
+ \hss%
+ }%
+ \pgf@process{\pgf@sys@svg@pos}%
+ \pgf@picminx=0pt%
+ \pgf@picminy=0pt%
+ \pgf@picmaxx=\pgf@x%
+ \pgf@picmaxy=\pgf@y%
+ \def\pgf@trimleft@final{0pt}%
+ \def\pgf@trimright@final{0pt}%
+ \def\pgf@shift@baseline{0pt}%
+ \pgfsys@typesetpicturebox\pgfpic%
+ \endgroup%
+}
+
+\def\pgfsys@shadinginsidepgfpicture#1{%
+ #1%
+ \pgf@sys@svg@sh@defs% hmmm....
+ \pgf@process{\pgf@sys@svg@pos}
+ \pgf@xa=-.5\pgf@x%
+ \pgf@ya=-.5\pgf@y%
+ \pgfsysprotocol@literal{<g transform="translate(\pgf@sys@tonumber{\pgf@xa},\pgf@sys@tonumber{\pgf@ya})">}%
+ \pgf@sys@svg@sh%
+ \pgfsysprotocol@literal{</g>}%
+}
+
+
+
+\def\pgfsys@papersize#1#2{%
+ {%
+ \pgf@x#1\relax%
+ \pgf@y#2\relax%
+ \pgf@xa-1in\relax%
+ \special{dvisvgm:bbox fix \pgf@sys@tonumber\pgf@xa\space \pgf@sys@tonumber\pgf@xa\space \pgf@sys@tonumber\pgf@x\space \pgf@sys@tonumber\pgf@y}%
+ }%
+}
+\def\pgfsys@prepare@papersize#1#2{%
+ \expandafter\gdef\expandafter\pgfsys@atbegindocument\expandafter{\pgfsys@atbegindocument\pgfsys@papersize{#1}{#2}}%
+}
+
+
+
+\def\pgfsys@typesetpicturebox#1{%
+ \pgf@ya=\pgf@shift@baseline\relax%
+ \advance\pgf@ya by-\pgf@picminy\relax%
+ %
+ %
+ \advance\pgf@picmaxy by-\pgf@picminy\relax% maxy is now the height
+ \advance\pgf@picmaxx by-\pgf@picminx\relax% maxx is now the width
+ \setbox#1=\hbox{\hskip-\pgf@picminx\lower\pgf@picminy\box#1}%
+ \ht#1=\pgf@picmaxy%
+ \wd#1=\pgf@picmaxx%
+ \dp#1=0pt%
+ \leavevmode%
+ \pgf@xa=\pgf@trimleft@final\relax \ifdim\pgf@xa=0pt \else\kern\pgf@xa\fi%
+ \raise-\pgf@ya\hbox{\ifpgf@sys@svg@inpicture\else\special{dvisvgm:bbox \pgf@sys@tonumber\pgf@picmaxx\space\pgf@sys@tonumber\pgf@picmaxy}\fi\box#1}%
+ \pgf@xa=\pgf@trimright@final\relax \ifdim\pgf@xa=0pt \else\kern\pgf@xa\fi%
+}
+
+
+
+\def\pgfsys@text@to@black@hook{%
+ \let\pgfsys@svg@set@color@orig\set@color%
+ \let\pgfsys@svg@reset@color@orig\reset@color%
+ \def\set@color{\special{dvisvgm:raw <g fill="black">}\pgfsys@svg@set@color@orig}%
+ \def\reset@color{\special{dvisvgm:raw </g>}\pgfsys@svg@reset@color@orig}%
+}
+
+
+
+% Fadings
+
+% FIXME: Correct sizes!
+
+%
+% Opacity masks
+%
+% \def\pgfsys@fadingfrombox#1#2{%
+% \setbox#2=\hbox{%
+% \pgfsys@invoke{<mask id="pgfmask#1">}%
+% \box#2%
+% \pgfsys@invoke{</mask>}%
+% }%
+% \wd#2=0pt%
+% \ht#2=0pt%
+% \dp#2=0pt%
+% \unskip\box#2%
+% }
+% \def\pgfsys@usefading#1#2#3#4#5#6#7{%
+% \pgf@sys@svg@gs@color{mask="url(\#pgfmask#1)"}%
+% }
+
+
+
+
+%
+% Position tracking (needs pdftex or luatex in dvi mode)
+%
+\ifx\savepos\@undefined
+ \ifx\pdfsavepos\@undefined
+ \else
+ \let\pgf@savepos\pdfsavepos
+ \let\pgf@lastxpos\pdflastxpos
+ \let\pgf@lastypos\pdflastypos
+ \fi
+\else
+ \let\pgf@savepos\savepos
+ \let\pgf@lastxpos\lastxpos
+ \let\pgf@lastypos\lastypos
+\fi
+
+
+\ifx\pgf@savepos\@undefined
+\else
+
+\def\pgfsys@markposition#1{%
+ \pgf@savepos%
+ \edef\pgf@temp{#1}%
+ \expandafter\pgfutil@writetoaux\expandafter{%
+ \expandafter\noexpand\expandafter\pgfsyspdfmark\expandafter{\pgf@temp}{\the\pgf@lastxpos}{\the\pgf@lastypos}}%
+}
+
+\def\pgfsyspdfmark#1#2#3{%
+ \expandafter\gdef\csname pgf@sys@pdf@mark@pos@#1\endcsname{\pgfqpoint{#2sp}{#3sp}}%
+ \pgfutil@check@rerun{#1}{{#2}{#3}}%
+}
+
+\def\pgfsys@getposition#1#2{%
+ \edef\pgf@marshal{\let\noexpand#2=\expandafter\noexpand\csname pgf@sys@pdf@mark@pos@#1\endcsname}%
+ \pgf@marshal%
+}
+
+\def\pgf@sys@pdf@mark@pos@pgfpageorigin{\pgfpointorigin}
+
+\fi
+
+
+\endinput
+
+
+%%% Local Variables:
+%%% mode: latex
+%%% End:
diff --git a/graphics/pgf/base/tex/generic/systemlayer/pgfsys-dvisvgm4ht.def b/graphics/pgf/base/tex/generic/systemlayer/pgfsys-dvisvgm4ht.def
new file mode 100644
index 0000000000..77e7c9bb7a
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/systemlayer/pgfsys-dvisvgm4ht.def
@@ -0,0 +1,86 @@
+% Copyright 2021 by Michal Hoftich
+% Copyright 2006 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{pgfsys-dvisvgm4ht.def}
+
+% Driver commands for tex4ht
+
+%
+% Load common pdf commands:
+%
+
+% we load the dvips driver by default. it doesn't support patterns and some other stuff,
+% but it handles better nested images and some formatting. if you use patterns or if you
+% have other issues with the default method, pass the "tikz-dvisvgm" option to make4ht.
+\ifdefined\ifOption
+\ifOption{tikz+}{\input pgfsys-dvisvgm.def}{\input pgfsys-dvips.def}
+\else
+% load the dvips driver by default
+\input pgfsys-dvips.def
+\fi
+
+
+\def\texfourht@tikz@begin{%
+ \bgroup%
+ \def\run@pict@cmd{}% insert the \Picture hooks only in the top nesting level
+ \def\end@pict@cmd{}%
+ \ifdefined\EndPicture\else% We are already inside command that uses \Picture
+ \ifdefined\inside@pict@cmd\else% handle nested uses
+ \ifdefined\tikzexternalize\else% Support externalize library
+ \def\run@pict@cmd{\Picture*}%
+ \def\end@pict@cmd{\EndPicture}%
+ \fi\fi\fi%
+ % command used to detect nesting
+ \def\inside@pict@cmd{}%
+ \csname a:tikzpicture\endcsname%
+}
+
+\def\texfourht@tikz@end{%
+ \csname b:tikzpicture\endcsname%
+ \egroup%
+}
+
+\AtBeginDocument{%
+ \NewConfigure{tikzpicture}{2}%
+ \catcode`\:=11%
+ \Configure{tikzpicture}{%
+ \protect\csname nested:math\endcsname% support display math
+ \run@pict@cmd{}%
+ }{\end@pict@cmd}
+ % configure the output picture format to svg, as it will require dvisvgm
+ % post processing.
+ \Configure{Picture}{.svg}%
+ % insert tex4ht hooks around TikZ picture box
+ \def\pgfsys@typesetpicturebox#1{%
+ \texfourht@tikz@begin%
+ \orig@pgfsys@typesetpicturebox{#1}%
+ \texfourht@tikz@end%
+ }
+ %
+ \ConfigureEnv{tikzpicture}{\texfourht@tikz@begin}{\texfourht@tikz@end}{}{}%
+ \ConfigureEnv{pgfpicture}{\texfourht@tikz@begin}{\texfourht@tikz@end}{}{}%
+ \catcode`\:=12%
+}
+
+
+% Make the code inserted by tex4ht configurable
+%
+
+
+\let\orig@pgfsys@typesetpicturebox\pgfsys@typesetpicturebox
+%\def\pgf@sys@postscript@header#1{{\special{! #1}}}
+
+
+\endinput
+
+
+%%% Local Variables:
+%%% mode: latex
+%%% End:
diff --git a/graphics/pgf/base/tex/generic/systemlayer/pgfsys-luatex.def b/graphics/pgf/base/tex/generic/systemlayer/pgfsys-luatex.def
new file mode 100644
index 0000000000..e60b1913a3
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/systemlayer/pgfsys-luatex.def
@@ -0,0 +1,401 @@
+% Copyright 2019 by Till Tantau
+% CMYK and grayscale shadings adaptation copyright 2019 by David Purton
+%
+% 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{pgfsys-luatex.def}
+
+\ifnum\luatexversion<95
+ \immediate\write-1{luatex driver of PGF: detected lua version \the\luatexversion; falling back to old pdftex driver^^J}%
+ \input pgfsys-pdftex.def
+ \expandafter\endinput
+\fi
+
+% Driver commands for pdf
+
+%
+% Load common pdf commands:
+%
+\input pgfsys-common-pdf.def
+
+%
+% pdftex-specific stuff:
+%
+\def\pgfsys@invoke#1{\pdfextension literal{#1}}
+
+% Synced hboxes
+\def\pgfsys@hboxsynced#1{%
+ {%
+ \pgfsys@beginscope%
+ \setbox\pgf@hbox=\hbox{%
+ \hskip\pgf@pt@x%
+ \raise\pgf@pt@y\hbox{%
+ \pgf@pt@x=0pt%
+ \pgf@pt@y=0pt%
+ \pgflowlevelsynccm%
+ \pgfsys@hbox#1}%
+ \hss%
+ }%
+ \wd\pgf@hbox=0pt%
+ \ht\pgf@hbox=0pt%
+ \dp\pgf@hbox=0pt%
+ \box\pgf@hbox%
+ \pgfsys@endscope%
+ }%
+}
+
+
+
+\def\pgfsys@imagesuffixlist{.pdf:.jpg:.jpeg:.png:}
+\def\pgfsys@defineimage{% width, height, page number
+ \ifx\pgf@imagewidth\pgfutil@empty\else\edef\pgf@imagewidth{ width \pgf@imagewidth }\fi%
+ \ifx\pgf@imageheight\pgfutil@empty\else\edef\pgf@imageheight{ height \pgf@imageheight }\fi%
+ \ifx\pgf@imagepage\pgfutil@empty\else\edef\pgf@imagepage{ page \pgf@imagepage }\fi%
+ \ifx\saveimageresource\@undefined% old version of lualatex
+ \ifx\pgf@imagepage\pgfutil@empty\else%
+ \pgfwarning{Page selection not supported. Ignoring page selection}%
+ \fi%
+ \setbox\pgfutil@tempboxa=\hbox{%
+ \pdfimage \pgf@imageheight \pgf@imagewidth {\pgf@filename}}%
+ \pdfform\pgfutil@tempboxa%
+ \edef\pgf@image{\noexpand\pdfrefform\the\pdflastform}%
+ \else% new version
+ {\saveimageresource \pgf@imageheight \pgf@imagewidth attr
+ {/Interpolate \pgf@imageinterpolate\space\pgf@imagemask} \pgf@imagepage
+ {\pgf@filename}}%
+ \edef\pgf@image{\noexpand\useimageresource\the\lastsavedimageresourceindex}%
+ \fi
+}%
+\def\pgfsys@definemask{%
+ \ifx\pgf@maskmatte\pgfutil@empty%
+ \else%
+ \edef\pgf@maskmatte{/Matte [\pgf@maskmatte]}%
+ \fi%
+ \edef\pgf@attr{{\pgf@maskmatte\space /Decode [1 0]}}%
+ \immediate\saveimageresource attr \pgf@attr {\pgf@filename}%
+ \edef\pgf@mask{/SMask \the\lastsavedimageresourceindex\space 0 R}%
+}
+\def\pgfsys@horishading#1#2#3{%
+ {%
+ \pgf@parsefunc{#3}%
+ \pgfmathparse{#2}%
+ \setbox\pgfutil@tempboxa=\hbox dir TLT to\pgf@max{\vbox to\pgfmathresult pt{\vfil\pgfsys@invoke{/Sh sh}}\hfil}%
+ \pgf@process{\pgfpoint{\pgf@max}{#2}}%
+ \immediate\saveboxresource resources {%
+ /Shading << /Sh << /ShadingType 2
+ /ColorSpace \pgf@shading@device\space
+ /Domain [\pgf@pdfparseddomain]
+ /Coords [\pgf@doma\space0 \pgf@domb\space0]
+ /Function \pgf@pdfparsedfunction
+ /Extend [false false] >> >>}\pgfutil@tempboxa% <<
+ \xdef\pgfutil@tempa{\hbox{\noexpand\useboxresource\the\lastsavedboxresourceindex}}%
+ }%
+ \global\expandafter\let\csname @pgfshading#1!\endcsname=\pgfutil@tempa
+}
+\def\pgfsys@vertshading#1#2#3{%
+ {%
+ \pgf@parsefunc{#3}%
+ \pgfmathparse{#2}%
+ \setbox\pgfutil@tempboxa=\hbox dir TLT to\pgfmathresult pt{\vbox to\pgf@max{\vfil\pgfsys@invoke{/Sh sh}}\hfil}%
+ \pgf@process{\pgfpoint{#2}{\pgf@max}}%
+ \immediate\saveboxresource resources {%
+ /Shading << /Sh << /ShadingType 2
+ /ColorSpace \pgf@shading@device\space
+ /Domain [\pgf@pdfparseddomain]
+ /Coords [0 \pgf@doma\space0 \pgf@domb]
+ /Function \pgf@pdfparsedfunction
+ /Extend [false false] >> >>}\pgfutil@tempboxa% <<
+ \xdef\pgfutil@tempa{\hbox{\noexpand\useboxresource\the\lastsavedboxresourceindex}}%
+ }%
+ \global\expandafter\let\csname @pgfshading#1!\endcsname=\pgfutil@tempa
+}
+\def\pgfsys@radialshading#1#2#3{%
+ {%
+ \pgf@parsefunc{#3}%
+ \setbox\pgfutil@tempboxa=\hbox dir TLT to2\pgf@max{\vbox to2\pgf@max{\vfil\pgfsys@invoke{/Sh sh}}\hfil}%
+ \pgf@process{#2}%
+ \pgf@xa=\pgf@x%
+ \pgf@ya=\pgf@y%
+ \pgf@process{\pgfpoint{\pgf@max}{\pgf@max}}%
+ \advance\pgf@xa by \pgf@x%
+ \advance\pgf@ya by \pgf@y%
+ \pgf@sys@bp@correct{\pgf@x}%
+ \pgf@sys@bp@correct{\pgf@y}%
+ \pgf@sys@bp@correct{\pgf@xa}%
+ \pgf@sys@bp@correct{\pgf@ya}%
+ \immediate\saveboxresource resources {%
+ /Shading << /Sh << /ShadingType 3
+ /ColorSpace \pgf@shading@device\space
+ /Domain [\pgf@pdfparseddomain]
+ /Coords [\pgf@sys@tonumber{\pgf@xa} \pgf@sys@tonumber{\pgf@ya} \pgf@doma\space \pgf@sys@tonumber{\pgf@x} \pgf@sys@tonumber{\pgf@y} \pgf@domb]
+ /Function \pgf@pdfparsedfunction
+ /Extend [true false] >> >>}\pgfutil@tempboxa% <<
+ \xdef\pgfutil@tempa{\hbox{\noexpand\useboxresource\the\lastsavedboxresourceindex}}%
+ }%
+ \global\expandafter\let\csname @pgfshading#1!\endcsname=\pgfutil@tempa
+}%
+\def\pgfsys@functionalshading#1#2#3#4{%
+ {%
+ \pgf@process{#2}%
+ \pgf@xa=\pgf@x%
+ \pgf@ya=\pgf@y%
+ \pgf@process{#3}%
+ \pgf@xb=\pgf@x%
+ \pgf@yb=\pgf@y%
+ \advance\pgf@x by-\pgf@xa%
+ \advance\pgf@y by-\pgf@ya%
+ \setbox\pgfutil@tempboxa=\hbox dir TLT to\pgf@x{\vbox to\pgf@y{\vfil\pgfsys@invoke{/Sh sh}}\hfil}%
+ \pgf@sys@bp@correct{\pgf@xa}%
+ \pgf@sys@bp@correct{\pgf@ya}%
+ \pgf@sys@bp@correct{\pgf@xb}%
+ \pgf@sys@bp@correct{\pgf@yb}%
+ \pgf@xc=-\pgf@xa%
+ \pgf@yc=-\pgf@ya%
+ % Now build the function
+ \pdfextension obj
+ stream
+ attr
+ {
+ /FunctionType 4
+ /Domain [\pgf@sys@tonumber{\pgf@xa}\space\pgf@sys@tonumber{\pgf@xb}\space\pgf@sys@tonumber{\pgf@ya}\space\pgf@sys@tonumber{\pgf@yb}]
+ /Range [\pgf@shading@functional@range]
+ }
+ {{#4}}%
+ \edef\pgf@temp@num{\the\numexpr\pdffeedback lastobj\relax}%
+ \saveboxresource resources {%
+ /Shading << /Sh << /ShadingType 1
+ /ColorSpace \pgf@shading@device\space
+ /Matrix [1 0 0 1 \pgf@sys@tonumber{\pgf@xc}\space\pgf@sys@tonumber{\pgf@yc}]
+ /Domain [\pgf@sys@tonumber{\pgf@xa}\space\pgf@sys@tonumber{\pgf@xb}\space\pgf@sys@tonumber{\pgf@ya}\space\pgf@sys@tonumber{\pgf@yb}]
+ /Function \pgf@temp@num\space 0 R
+ >> >>}\pgfutil@tempboxa% <<
+ \xdef\pgfutil@tempa{\hbox{%
+ \noexpand\useboxresource\the\lastsavedboxresourceindex%
+ \noexpand\pdfextension refobj \pgf@temp@num%
+ }}%
+ }%
+ \global\expandafter\let\csname @pgfshading#1!\endcsname=\pgfutil@tempa
+}
+
+
+
+% Patterns
+
+\def\pgfsys@declarepattern#1#2#3#4#5#6#7{%
+ % Start building the pattern dictionary:
+ \pgf@xa=#2\relax%
+ \pgf@ya=#3\relax%
+ \pgf@xb=#4\relax%
+ \pgf@yb=#5\relax%
+ \pgf@xc=#6\relax%
+ \pgf@yc=#7\relax%
+ \pgf@sys@bp@correct\pgf@xa%
+ \pgf@sys@bp@correct\pgf@ya%
+ \pgf@sys@bp@correct\pgf@xb%
+ \pgf@sys@bp@correct\pgf@yb%
+ \pgf@sys@bp@correct\pgf@xc%
+ \pgf@sys@bp@correct\pgf@yc%
+ \pgfsys@@declarepattern{#1}%
+}
+
+\def\pgfsys@@declarepattern#1#2#3#4#5#6#7#8#9{%
+ \pgfutil@tempdima=#6\relax%
+ \pgfutil@tempdimb=#7\relax%
+ \pgf@sys@bp@correct\pgfutil@tempdima%
+ \pgf@sys@bp@correct\pgfutil@tempdimb%
+ % Now create the pattern object:
+ \immediate\pdfextension obj stream
+ attr
+ {
+ /Type /Pattern
+ /PatternType 1
+ /PaintType \ifnum#9=0 2 \else 1 \fi
+ /TilingType 1
+ /BBox [\pgf@sys@tonumber\pgf@xa\space\pgf@sys@tonumber\pgf@ya\space\pgf@sys@tonumber\pgf@xb\space\pgf@sys@tonumber\pgf@yb]
+ /XStep \pgf@sys@tonumber\pgf@xc\space
+ /YStep \pgf@sys@tonumber\pgf@yc\space
+ /Matrix [#2\space#3\space#4\space#5\space\pgf@sys@tonumber\pgfutil@tempdima\space\pgf@sys@tonumber\pgfutil@tempdimb]
+ /Resources <</Pattern<<>>>> %<<
+ }
+ {#8}%
+ \pgfutil@addpdfresource@patterns{/pgfpat#1\space \the\numexpr\pdffeedback lastobj\relax\space 0 R}%
+}
+
+\def\pgfsys@setpatternuncolored#1#2#3#4{%
+ \pgfsysprotocol@literal{/pgfprgb cs #2 #3 #4 /pgfpat#1\space scn}%
+}
+
+\def\pgfsys@setpatterncolored#1{%
+ \pgfsysprotocol@literal{/Pattern cs /pgfpat#1\space scn}%
+}
+
+
+
+\def\pgfsys@papersize#1#2{\pageheight#2\relax\pagewidth#1\relax}
+
+\def\pgfsys@global@papersize#1#2{\global\pageheight#2\relax\global\pagewidth#1\relax}
+
+\ifx\paperheight\@undefined
+ \def\pgfsys@thepageheight{\pageheight}
+ \def\pgfsys@thepagewidth{\pagewidth}
+\fi
+
+
+%
+% Position tracking
+%
+\def\pgfsys@markposition#1{%
+ \savepos%
+ \edef\pgf@temp{#1}%
+ \expandafter\pgfutil@writetoaux\expandafter{%
+ \expandafter\noexpand\expandafter\pgfsyspdfmark\expandafter{\pgf@temp}{\the\lastxpos}{\the\lastypos}}%
+}
+
+\def\pgfsyspdfmark#1#2#3{%
+ \expandafter\gdef\csname pgf@sys@pdf@mark@pos@#1\endcsname{\pgfqpoint{#2sp}{#3sp}}%
+ \pgfutil@check@rerun{#1}{{#2}{#3}}%
+}
+
+\def\pgfsys@getposition#1#2{%
+ \edef\pgf@marshal{\let\noexpand#2=\expandafter\noexpand\csname pgf@sys@pdf@mark@pos@#1\endcsname}%
+ \pgf@marshal%
+}
+
+\def\pgf@sys@pdf@mark@pos@pgfpageorigin{\pgfqpoint{\hoffset}{\voffset}}
+
+
+%
+% Opacity masks
+%
+\def\pgfsys@fadingfrombox#1#2{%
+ {%
+ \pgf@sys@pdf@check@resources%
+ \pgf@x=-.5\wd#2%
+ \pgf@y=-.5\ht#2%
+ \advance\pgf@y by.5\dp#2%
+ \expandafter\xdef\csname pgfsmasktrans@#1\endcsname{%
+ \noexpand\pgftransformcm{1}{0}{0}{1}{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}}%
+ \saveboxresource resources { \pgf@sys@pdf@possible@resources } #2%
+ \expandafter\xdef\csname pgfsmaskxform@#1\endcsname{\the\lastsavedboxresourceindex}%
+ }%
+}
+\def\pgfsys@usefading#1#2#3#4#5#6#7{%
+ \expandafter\ifx\csname pgfsmaskxform@#1\endcsname\relax%
+ \pgferror{Undefined fading '#1'}%
+ \else%
+ {%
+ \expandafter\ifx\csname pgfsmask@#1\endcsname\relax%
+ \pgf@sys@pdf@install@mask{#1}%
+ \fi%
+ \pgftransformreset%
+ \pgftransformcm{#2}{#3}{#4}{#5}{\pgfpoint{#6}{#7}}%
+ \csname pgfsmasktrans@#1\endcsname%
+ {%
+ \pgflowlevelsynccm%
+ \pgfsys@invoke{/pgfsmask\csname pgfsmask@#1\endcsname\space gs}%
+ }%
+ \pgftransforminvert%
+ \pgflowlevelsynccm%
+ }%
+ \fi
+}
+
+\def\pgf@sys@pdf@install@mask#1{%
+ \setbox\pgfutil@tempboxa=\hbox{\useboxresource\csname pgfsmaskxform@#1\endcsname}
+ \immediate\saveboxresource%
+ attr {
+ /Group
+ <<
+ /S /Transparency
+ /CS /DeviceGray
+ >>
+ }% <<
+ \pgfutil@tempboxa%
+ \pgfutil@addpdfresource@extgs{%
+ /pgfsmask\the\lastsavedboxresourceindex\space
+ <<
+ /SMask
+ <<
+ /S /Luminosity
+ /G \the\lastsavedboxresourceindex\space 0 R
+ >>
+ >> } %<<
+ \expandafter\xdef\csname pgfsmask@#1\endcsname{\the\lastsavedboxresourceindex}%
+}
+
+%
+% Transparency groups
+%
+\def\pgfsys@transparencygroupfrombox#1{%
+ \pgf@sys@pdf@check@resources%
+ \saveboxresource
+ attr { /Group << /S /Transparency
+ /I \ifpgfsys@transparency@group@isolated true \else false \fi
+ /K \ifpgfsys@transparency@group@knockout true \else false \fi >> } %<<
+ resources { \pgf@sys@pdf@possible@resources }
+ #1%
+ \setbox#1=\hbox{\useboxresource\lastsavedboxresourceindex}%
+}
+
+
+
+
+%
+% Resource management
+%
+
+\def\pgf@sys@setuppdfresources@plain{%
+ % This command will setup pdf resource in plain and in latex
+ % mode. ConTeXt has its own handler
+ % Page resources (they are kept in objects and only written at the
+ % very end)
+ \pdfextension obj reserveobjnum \edef\pgf@sys@pdf@extgs@objnum{\the\numexpr\pdffeedback lastobj\relax}
+ \pdfextension obj reserveobjnum \edef\pgf@sys@pdf@pattern@objnum{\the\numexpr\pdffeedback lastobj\relax}
+ \pdfextension obj reserveobjnum \edef\pgf@sys@pdf@colrospaces@objnum{\the\numexpr\pdffeedback lastobj\relax}
+ \def\pgf@sys@pdf@possible@resources{%
+ /ColorSpace \pgf@sys@pdf@colrospaces@objnum\space 0 R
+ /Pattern \pgf@sys@pdf@pattern@objnum\space 0 R
+ /ExtGState \pgf@sys@pdf@extgs@objnum\space 0 R
+ }
+ \let\pgf@sys@pdf@check@resources=\relax%
+ \def\pgf@sys@pdf@install@pageresources{
+ {
+ \edef\temp{
+ \pgf@sys@pdf@possible@resources
+ }
+ \expandafter\global\expandafter\pdfvariable pageresources\expandafter{\temp}
+ }
+ }
+ \pgf@sys@pdf@install@pageresources
+ \expandafter\pgfutil@everybye\expandafter{%
+ \the\pgfutil@everybye%
+ \immediate \pdfextension obj useobjnum \pgf@sys@pdf@extgs@objnum {<<\pgf@sys@pgf@resource@list@extgs>>}%<<
+ \immediate \pdfextension obj useobjnum \pgf@sys@pdf@pattern@objnum {<<\pgf@sys@pgf@resource@list@patterns>>}%<<
+ \immediate \pdfextension obj useobjnum \pgf@sys@pdf@colrospaces@objnum {<<\pgf@sys@pgf@resource@list@colorspaces>>}%<<
+ }
+ \let\pgf@sys@pgf@resource@list@extgs=\pgfutil@empty%
+ \let\pgf@sys@pgf@resource@list@patterns=\pgfutil@empty%
+ \let\pgf@sys@pgf@resource@list@colorspaces=\pgfutil@empty%
+ \def\pgf@sys@addpdfresource@extgs@plain##1{\xdef\pgf@sys@pgf@resource@list@extgs{\pgf@sys@pgf@resource@list@extgs\space##1}}
+ \def\pgf@sys@addpdfresource@patterns@plain##1{\xdef\pgf@sys@pgf@resource@list@patterns{\pgf@sys@pgf@resource@list@patterns\space##1}}
+ \def\pgf@sys@addpdfresource@colorspaces@plain##1{\xdef\pgf@sys@pgf@resource@list@colorspaces{\pgf@sys@pgf@resource@list@colorspaces\space##1}}
+}
+\pgfutil@setuppdfresources % possibly call the above
+
+\pgfutil@addpdfresource@colorspaces{ /pgfprgb [/Pattern /DeviceRGB] }
+
+\def\pgfsys@color@unstacked#1{%
+ \pdfextension literal{\csname\string\color@#1\endcsname}%
+}
+
+\endinput
+
+
+%%% Local Variables:
+%%% mode: latex
+%%% End:
diff --git a/graphics/pgf/base/tex/generic/systemlayer/pgfsys-pdftex.def b/graphics/pgf/base/tex/generic/systemlayer/pgfsys-pdftex.def
new file mode 100644
index 0000000000..3b9b33006a
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/systemlayer/pgfsys-pdftex.def
@@ -0,0 +1,398 @@
+% Copyright 2019 by Till Tantau
+% CMYK and grayscale shadings adaptation copyright 2019 by David Purton
+%
+% 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{pgfsys-pdftex.def}
+
+
+% Driver commands for pdf
+
+%
+% Load common pdf commands:
+%
+\input pgfsys-common-pdf.def
+
+%
+% pdftex-specific stuff:
+%
+\def\pgfsys@invoke#1{\pdfliteral{#1}}
+
+% Synced hboxes
+\def\pgfsys@hboxsynced#1{%
+ {%
+ \pgfsys@begin@idscope%
+ \pgfsys@beginscope%
+ \setbox\pgf@hbox=\hbox{%
+ \hskip\pgf@pt@x%
+ \raise\pgf@pt@y\hbox{%
+ \pgf@pt@x=0pt%
+ \pgf@pt@y=0pt%
+ \pgflowlevelsynccm%
+ \pgfsys@hbox#1}%
+ \hss%
+ }%
+ \wd\pgf@hbox=0pt%
+ \ht\pgf@hbox=0pt%
+ \dp\pgf@hbox=0pt%
+ \box\pgf@hbox%
+ \pgfsys@endscope%
+ \pgfsys@end@idscope%
+ }%
+}
+
+
+
+\def\pgfsys@imagesuffixlist{.pdf:.jpg:.jpeg:.png:}
+\def\pgfsys@defineimage{% width, height, page number
+ \ifx\pgf@imagewidth\pgfutil@empty\else\edef\pgf@imagewidth{ width \pgf@imagewidth }\fi%
+ \ifx\pgf@imageheight\pgfutil@empty\else\edef\pgf@imageheight{ height \pgf@imageheight }\fi%
+ \ifx\pgf@imagepage\pgfutil@empty\else\edef\pgf@imagepage{ page \pgf@imagepage }\fi%
+ \ifx\pdfximage\@undefined% old version of pdflatex
+ \ifx\pgf@imagepage\pgfutil@empty\else%
+ \pgfwarning{Page selection not supported. Ignoring page selection}%
+ \fi%
+ \setbox\pgfutil@tempboxa=\hbox{%
+ \pdfimage \pgf@imageheight \pgf@imagewidth {\pgf@filename}}%
+ \pdfform\pgfutil@tempboxa%
+ \edef\pgf@image{\noexpand\pdfrefform\the\pdflastform}%
+ \else% new version
+ {\pdfximage \pgf@imageheight \pgf@imagewidth attr
+ {/Interpolate \pgf@imageinterpolate\space\pgf@imagemask} \pgf@imagepage
+ {\pgf@filename}}%
+ \edef\pgf@image{\noexpand\pdfrefximage\the\pdflastximage}%
+ \fi
+}%
+\def\pgfsys@definemask{%
+ \ifx\pgf@maskmatte\pgfutil@empty%
+ \else%
+ \edef\pgf@maskmatte{/Matte [\pgf@maskmatte]}%
+ \fi%
+ \edef\pgf@attr{{\pgf@maskmatte\space /Decode [1 0]}}%
+ \immediate\pdfximage attr \pgf@attr {\pgf@filename}%
+ \edef\pgf@mask{/SMask \the\pdflastximage\space 0 R}%
+}
+\def\pgfsys@horishading#1#2#3{%
+ {%
+ \pgf@parsefunc{#3}%
+ \pgfmathparse{#2}%
+ \setbox\pgfutil@tempboxa=\hbox to\pgf@max{\vbox to\pgfmathresult pt{\vfil\pgfsys@invoke{/Sh sh}}\hfil}%
+ \pgf@process{\pgfpoint{\pgf@max}{#2}}%
+ \immediate\pdfxform resources {%
+ /Shading << /Sh << /ShadingType 2
+ /ColorSpace \pgf@shading@device\space
+ /Domain [\pgf@pdfparseddomain]
+ /Coords [\pgf@doma\space0 \pgf@domb\space0]
+ /Function \pgf@pdfparsedfunction
+ /Extend [false false] >> >>}\pgfutil@tempboxa% <<
+ \xdef\pgfutil@tempa{\hbox{\noexpand\pdfrefxform\the\pdflastxform}}%
+ }%
+ \global\expandafter\let\csname @pgfshading#1!\endcsname=\pgfutil@tempa
+}
+\def\pgfsys@vertshading#1#2#3{%
+ {%
+ \pgf@parsefunc{#3}%
+ \pgfmathparse{#2}%
+ \setbox\pgfutil@tempboxa=\hbox to\pgfmathresult pt{\vbox to\pgf@max{\vfil\pgfsys@invoke{/Sh sh}}\hfil}%
+ \pgf@process{\pgfpoint{#2}{\pgf@max}}%
+ \immediate\pdfxform resources {%
+ /Shading << /Sh << /ShadingType 2
+ /ColorSpace \pgf@shading@device\space
+ /Domain [\pgf@pdfparseddomain]
+ /Coords [0 \pgf@doma\space0 \pgf@domb]
+ /Function \pgf@pdfparsedfunction
+ /Extend [false false] >> >>}\pgfutil@tempboxa% <<
+ \xdef\pgfutil@tempa{\hbox{\noexpand\pdfrefxform\the\pdflastxform}}%
+ }%
+ \global\expandafter\let\csname @pgfshading#1!\endcsname=\pgfutil@tempa
+}
+\def\pgfsys@radialshading#1#2#3{%
+ {%
+ \pgf@parsefunc{#3}%
+ \setbox\pgfutil@tempboxa=\hbox to2\pgf@max{\vbox to2\pgf@max{\vfil\pgfsys@invoke{/Sh sh}}\hfil}%
+ \pgf@process{#2}%
+ \pgf@xa=\pgf@x%
+ \pgf@ya=\pgf@y%
+ \pgf@process{\pgfpoint{\pgf@max}{\pgf@max}}%
+ \advance\pgf@xa by \pgf@x%
+ \advance\pgf@ya by \pgf@y%
+ \pgf@sys@bp@correct{\pgf@x}%
+ \pgf@sys@bp@correct{\pgf@y}%
+ \pgf@sys@bp@correct{\pgf@xa}%
+ \pgf@sys@bp@correct{\pgf@ya}%
+ \immediate\pdfxform resources {%
+ /Shading << /Sh << /ShadingType 3
+ /ColorSpace \pgf@shading@device\space
+ /Domain [\pgf@pdfparseddomain]
+ /Coords [\pgf@sys@tonumber{\pgf@xa} \pgf@sys@tonumber{\pgf@ya} \pgf@doma\space \pgf@sys@tonumber{\pgf@x} \pgf@sys@tonumber{\pgf@y} \pgf@domb]
+ /Function \pgf@pdfparsedfunction
+ /Extend [true false] >> >>}\pgfutil@tempboxa% <<
+ \xdef\pgfutil@tempa{\hbox{\noexpand\pdfrefxform\the\pdflastxform}}%
+ }%
+ \global\expandafter\let\csname @pgfshading#1!\endcsname=\pgfutil@tempa
+}%
+\def\pgfsys@functionalshading#1#2#3#4{%
+ {%
+ \pgf@process{#2}%
+ \pgf@xa=\pgf@x%
+ \pgf@ya=\pgf@y%
+ \pgf@process{#3}%
+ \pgf@xb=\pgf@x%
+ \pgf@yb=\pgf@y%
+ \advance\pgf@x by-\pgf@xa%
+ \advance\pgf@y by-\pgf@ya%
+ \setbox\pgfutil@tempboxa=\hbox to\pgf@x{\vbox to\pgf@y{\vfil\pgfsys@invoke{/Sh sh}}\hfil}%
+ \pgf@sys@bp@correct{\pgf@xa}%
+ \pgf@sys@bp@correct{\pgf@ya}%
+ \pgf@sys@bp@correct{\pgf@xb}%
+ \pgf@sys@bp@correct{\pgf@yb}%
+ \pgf@xc=-\pgf@xa%
+ \pgf@yc=-\pgf@ya%
+ % Now build the function
+ \pdfobj
+ stream
+ attr
+ {
+ /FunctionType 4
+ /Domain [\pgf@sys@tonumber{\pgf@xa}\space\pgf@sys@tonumber{\pgf@xb}\space\pgf@sys@tonumber{\pgf@ya}\space\pgf@sys@tonumber{\pgf@yb}]
+ /Range [\pgf@shading@functional@range]
+ }
+ {{#4}}%
+ \edef\pgf@temp@num{\the\pdflastobj}%
+ \pdfxform resources {%
+ /Shading << /Sh << /ShadingType 1
+ /ColorSpace \pgf@shading@device\space
+ /Matrix [1 0 0 1 \pgf@sys@tonumber{\pgf@xc}\space\pgf@sys@tonumber{\pgf@yc}]
+ /Domain [\pgf@sys@tonumber{\pgf@xa}\space\pgf@sys@tonumber{\pgf@xb}\space\pgf@sys@tonumber{\pgf@ya}\space\pgf@sys@tonumber{\pgf@yb}]
+ /Function \pgf@temp@num\space 0 R
+ >> >>}\pgfutil@tempboxa% <<
+ \xdef\pgfutil@tempa{\hbox{%
+ \noexpand\pdfrefxform\the\pdflastxform%
+ \noexpand\pdfrefobj\pgf@temp@num%
+ }}%
+ }%
+ \global\expandafter\let\csname @pgfshading#1!\endcsname=\pgfutil@tempa
+}
+
+
+
+% Patterns
+
+\def\pgfsys@declarepattern#1#2#3#4#5#6#7{%
+ % Start building the pattern dictionary:
+ \pgf@xa=#2\relax%
+ \pgf@ya=#3\relax%
+ \pgf@xb=#4\relax%
+ \pgf@yb=#5\relax%
+ \pgf@xc=#6\relax%
+ \pgf@yc=#7\relax%
+ \pgf@sys@bp@correct\pgf@xa%
+ \pgf@sys@bp@correct\pgf@ya%
+ \pgf@sys@bp@correct\pgf@xb%
+ \pgf@sys@bp@correct\pgf@yb%
+ \pgf@sys@bp@correct\pgf@xc%
+ \pgf@sys@bp@correct\pgf@yc%
+ \pgfsys@@declarepattern{#1}%
+}
+
+\def\pgfsys@@declarepattern#1#2#3#4#5#6#7#8#9{%
+ \pgfutil@tempdima=#6\relax%
+ \pgfutil@tempdimb=#7\relax%
+ \pgf@sys@bp@correct\pgfutil@tempdima%
+ \pgf@sys@bp@correct\pgfutil@tempdimb%
+ % Now create the pattern object:
+ \immediate\pdfobj stream
+ attr
+ {
+ /Type /Pattern
+ /PatternType 1
+ /PaintType \ifnum#9=0 2 \else 1 \fi
+ /TilingType 1
+ /BBox [\pgf@sys@tonumber\pgf@xa\space\pgf@sys@tonumber\pgf@ya\space\pgf@sys@tonumber\pgf@xb\space\pgf@sys@tonumber\pgf@yb]
+ /XStep \pgf@sys@tonumber\pgf@xc\space
+ /YStep \pgf@sys@tonumber\pgf@yc\space
+ /Matrix [#2\space#3\space#4\space#5\space\pgf@sys@tonumber\pgfutil@tempdima\space\pgf@sys@tonumber\pgfutil@tempdimb]
+ /Resources <</Pattern<<>>>> %<<
+ }
+ {#8}%
+ \pgfutil@addpdfresource@patterns{/pgfpat#1\space \the\pdflastobj\space 0 R}%
+}
+
+\def\pgfsys@setpatternuncolored#1#2#3#4{%
+ \pgfsysprotocol@literal{/pgfprgb cs #2 #3 #4 /pgfpat#1\space scn}%
+}
+
+\def\pgfsys@setpatterncolored#1{%
+ \pgfsysprotocol@literal{/Pattern cs /pgfpat#1\space scn}%
+}
+
+
+
+\def\pgfsys@papersize#1#2{\pdfpageheight#2\relax\pdfpagewidth#1\relax}
+
+\def\pgfsys@global@papersize#1#2{\global\pdfpageheight#2\relax\global\pdfpagewidth#1\relax}
+
+\ifx\paperheight\@undefined
+ \def\pgfsys@thepageheight{\pdfpageheight}
+ \def\pgfsys@thepagewidth{\pdfpagewidth}
+\fi
+
+
+%
+% Position tracking
+%
+\def\pgfsys@markposition#1{%
+ \pdfsavepos%
+ \edef\pgf@temp{#1}%
+ \expandafter\pgfutil@writetoaux\expandafter{%
+ \expandafter\noexpand\expandafter\pgfsyspdfmark\expandafter{\pgf@temp}{\the\pdflastxpos}{\the\pdflastypos}}%
+}
+
+\def\pgfsyspdfmark#1#2#3{%
+ \expandafter\gdef\csname pgf@sys@pdf@mark@pos@#1\endcsname{\pgfqpoint{#2sp}{#3sp}}%
+ \pgfutil@check@rerun{#1}{{#2}{#3}}%
+}
+
+\def\pgfsys@getposition#1#2{%
+ \edef\pgf@marshal{\let\noexpand#2=\expandafter\noexpand\csname pgf@sys@pdf@mark@pos@#1\endcsname}%
+ \pgf@marshal%
+}
+
+\def\pgf@sys@pdf@mark@pos@pgfpageorigin{\pgfqpoint{\hoffset}{\voffset}}
+
+
+%
+% Opacity masks
+%
+\def\pgfsys@fadingfrombox#1#2{%
+ {%
+ \pgf@sys@pdf@check@resources%
+ \pgf@x=-.5\wd#2%
+ \pgf@y=-.5\ht#2%
+ \advance\pgf@y by.5\dp#2%
+ \expandafter\xdef\csname pgfsmasktrans@#1\endcsname{%
+ \noexpand\pgftransformcm{1}{0}{0}{1}{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}}%
+ \pdfxform resources { \pgf@sys@pdf@possible@resources } #2%
+ \expandafter\xdef\csname pgfsmaskxform@#1\endcsname{\the\pdflastxform}%
+ }%
+}
+\def\pgfsys@usefading#1#2#3#4#5#6#7{%
+ \expandafter\ifx\csname pgfsmaskxform@#1\endcsname\relax%
+ \pgferror{Undefined fading '#1'}%
+ \else%
+ {%
+ \expandafter\ifx\csname pgfsmask@#1\endcsname\relax%
+ \pgf@sys@pdf@install@mask{#1}%
+ \fi%
+ \pgftransformreset%
+ \pgftransformcm{#2}{#3}{#4}{#5}{\pgfpoint{#6}{#7}}%
+ \csname pgfsmasktrans@#1\endcsname%
+ {%
+ \pgflowlevelsynccm%
+ \pgfsys@invoke{/pgfsmask\csname pgfsmask@#1\endcsname\space gs}%
+ }%
+ \pgftransforminvert%
+ \pgflowlevelsynccm%
+ }%
+ \fi
+}
+
+\def\pgf@sys@pdf@install@mask#1{%
+ \setbox\pgfutil@tempboxa=\hbox{\pdfrefxform\csname pgfsmaskxform@#1\endcsname}
+ \immediate\pdfxform%
+ attr {
+ /Group
+ <<
+ /S /Transparency
+ /CS /DeviceGray
+ >>
+ }% <<
+ \pgfutil@tempboxa%
+ \pgfutil@addpdfresource@extgs{%
+ /pgfsmask\the\pdflastxform\space
+ <<
+ /SMask
+ <<
+ /S /Luminosity
+ /G \the\pdflastxform\space 0 R
+ >>
+ >> } %<<
+ \expandafter\xdef\csname pgfsmask@#1\endcsname{\the\pdflastxform}%
+}
+
+%
+% Transparency groups
+%
+\def\pgfsys@transparencygroupfrombox#1{%
+ \pgf@sys@pdf@check@resources%
+ \pdfxform
+ attr { /Group << /S /Transparency
+ /I \ifpgfsys@transparency@group@isolated true \else false \fi
+ /K \ifpgfsys@transparency@group@knockout true \else false \fi >> } %<<
+ resources { \pgf@sys@pdf@possible@resources }
+ #1%
+ \setbox#1=\hbox{\pdfrefxform\pdflastxform}%
+}
+
+
+
+
+%
+% Resource management
+%
+
+\def\pgf@sys@setuppdfresources@plain{%
+ % This command will setup pdf resource in plain and in latex
+ % mode. ConTeXt has its own handler
+ % Page resources (they are kept in objects and only written at the
+ % very end)
+ \pdfobj reserveobjnum \edef\pgf@sys@pdf@extgs@objnum{\the\pdflastobj}
+ \pdfobj reserveobjnum \edef\pgf@sys@pdf@pattern@objnum{\the\pdflastobj}
+ \pdfobj reserveobjnum \edef\pgf@sys@pdf@colrospaces@objnum{\the\pdflastobj}
+ \def\pgf@sys@pdf@possible@resources{%
+ /ColorSpace \pgf@sys@pdf@colrospaces@objnum\space 0 R
+ /Pattern \pgf@sys@pdf@pattern@objnum\space 0 R
+ /ExtGState \pgf@sys@pdf@extgs@objnum\space 0 R
+ }
+ \let\pgf@sys@pdf@check@resources=\relax%
+ \def\pgf@sys@pdf@install@pageresources{
+ {
+ \edef\temp{
+ \pgf@sys@pdf@possible@resources
+ }
+ \expandafter\global\expandafter\pdfpageresources\expandafter{\temp}
+ }
+ }
+ \pgf@sys@pdf@install@pageresources
+ \expandafter\pgfutil@everybye\expandafter{%
+ \the\pgfutil@everybye%
+ \immediate \pdfobj useobjnum \pgf@sys@pdf@extgs@objnum {<<\pgf@sys@pgf@resource@list@extgs>>}%<<
+ \immediate \pdfobj useobjnum \pgf@sys@pdf@pattern@objnum {<<\pgf@sys@pgf@resource@list@patterns>>}%<<
+ \immediate \pdfobj useobjnum \pgf@sys@pdf@colrospaces@objnum {<<\pgf@sys@pgf@resource@list@colorspaces>>}%<<
+ }
+ \let\pgf@sys@pgf@resource@list@extgs=\pgfutil@empty%
+ \let\pgf@sys@pgf@resource@list@patterns=\pgfutil@empty%
+ \let\pgf@sys@pgf@resource@list@colorspaces=\pgfutil@empty%
+ \def\pgf@sys@addpdfresource@extgs@plain##1{\xdef\pgf@sys@pgf@resource@list@extgs{\pgf@sys@pgf@resource@list@extgs\space##1}}
+ \def\pgf@sys@addpdfresource@patterns@plain##1{\xdef\pgf@sys@pgf@resource@list@patterns{\pgf@sys@pgf@resource@list@patterns\space##1}}
+ \def\pgf@sys@addpdfresource@colorspaces@plain##1{\xdef\pgf@sys@pgf@resource@list@colorspaces{\pgf@sys@pgf@resource@list@colorspaces\space##1}}
+}
+\pgfutil@setuppdfresources % possibly call the above
+
+\pgfutil@addpdfresource@colorspaces{ /pgfprgb [/Pattern /DeviceRGB] }
+
+\def\pgfsys@color@unstacked#1{%
+ \pdfliteral{\csname\string\color@#1\endcsname}%
+}
+
+\endinput
+
+
+%%% Local Variables:
+%%% mode: latex
+%%% End:
diff --git a/graphics/pgf/base/tex/generic/systemlayer/pgfsys-tex4ht.def b/graphics/pgf/base/tex/generic/systemlayer/pgfsys-tex4ht.def
new file mode 100644
index 0000000000..44dd1ae5b0
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/systemlayer/pgfsys-tex4ht.def
@@ -0,0 +1,487 @@
+% 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{pgfsys-tex4ht.def}
+
+
+
+% Driver commands for tex4ht
+
+%
+% Load common pdf commands:
+%
+\input pgfsys-common-svg.def
+
+%
+% tex4ht-specific stuff:
+%
+\def\pgfsys@invoke#1{\pgf@sys@fail{svg code in preamble}}
+\def\pgfsys@body@invoke#1{\HCode{#1}}
+
+\newcount\pgf@sys@svg@picnum
+
+\def\pgfsys@pictureboxsynced#1{%
+ \pgfsys@beginscope\pgflowlevelsynccm\box#1\pgfsys@endscope%
+}
+
+
+%%
+%% initial support of Mathml and xhtml inside svg through the svg:foreignelement tag
+%%
+%% it'll allow us to have complicated text nodes in the tex4ht driver
+%%
+
+
+%Example (to improve the display, you have to use css)
+%
+%\tikzpicture[svg text only=false]
+%\draw (0,0) node[inner sep=0pt,draw] {tight}
+%(0cm,2em) node[inner sep=5pt,draw] {loose}
+%(0cm,4em) node[fill=red!20] {default};
+%\draw (3,0) node[inner sep=0pt,draw] {TIGHT}
+%(3cm,2em) node[inner sep=5pt,draw] {LOOSE}
+%(3cm,4em) node[fill=red!20] {DEFAULT};
+%\draw (6,0) node[inner sep=0pt,draw] {$tight$}
+%(6cm,2em) node[inner sep=5pt,draw] {$loose$}
+%(6cm,4em) node[fill=red!20] {$default$};
+%\draw (9,0) node[inner sep=0pt,draw] {$TIGHT$}
+%(9cm,2em) node[inner sep=5pt,draw] {$LOOSE$}
+%(9cm,4em) node[fill=red!20] {$Default$};
+%\endtikzpicture
+%
+% you can use the options "svg text css=filename", "svg text id=idname", "svg text class=classname" to customize the display through the use of css
+%
+
+
+
+
+
+
+
+%\def\pgfsys@beginpicture{%
+% % \Configure{[]}{$}{$} these two lines aren't needed for tex4ht and moreother they produce errors with plain tex !
+% % \Configure{()}{$}{$}
+% \Configure{$$}{}{}{}%$$
+% \Configure{$}{}{}{}%$
+% \Configure{SUB}{\HCode{<tspan baseline-shift="sub">}}{\HCode{</tspan>}}
+% \Configure{SUP}{\HCode{<tspan baseline-shift="sub">}}{\HCode{</tspan>}}
+% \Configure{SUBSUP}{}{}{}
+% \Configure{htf}
+% {0}{+}{<tspan font-family="}
+% {\%s}{" font-size="\%s}{}{}
+% {">}{</tspan>}
+%}
+
+
+
+%\def\pgfsys@endpicture{%
+% % undo:
+% \Configure{htf}{0}{+}{<span\Hnewline
+% class="}{\%s}{-\%s}{x-x-\%d}{}{">}{</span>}
+%}
+
+\def\pgfsys@svg@newline{^^J}
+
+% we don't want tex4ht putting <p> and </p> tags automatically in our svg code and causing invalid xhtml in our svg pictures
+\newif\ifpgfsys@CssIncluded@\pgfsys@CssIncluded@false
+\def\pgfsys@beginpicture{%
+ \pgfsys@svg@boxmodefalse%
+ \EndP\HtmlParOff%
+ \pgfkeys{/pgf/tex4ht node/escape=false}%
+ % text only nodes are the default. Advantage : pure svg pictures are
+ % the default, nicer for text only nodes.
+ % Disadvantages : this rendering methods produce more invalid or degraded svg pictures than with the foreignelement tag
+ %% we use css to control the display of foreignelement rendered text nodes
+ \ifpgfsys@CssIncluded@
+ \else
+ \Css{
+ .foreignobject {%
+ line-height:100\%;
+ font-size:120\%; % this is the trick....a font of size 100% in
+ % a box scaled down to half size makes it a
+ % half size font.
+ % you'll have to double the size of things
+ % that you want to have a regular size in
+ % this half-scaled box though
+ font-family:STIXgeneral,Times,Symbol,cmr10,CMSY10,CMEX10;%
+ % can't wait for the stix font...the cmr10, etc font are
+ % available from the mozilla site, times and symbols should be
+ % okey
+ padding:0;
+ margin:0;
+ % background-color:\#12ff55; usefull for debugging positioning
+ text-align:center; % good for centered text nodes...will have to improve that later on...with more integration with pgf options for text nodes
+ }
+ }%
+ \Css{%
+ math {%, math[mode="inline"] {
+ vertical-align:baseline;
+ line-height:100\%;
+ font-size:100\%;
+ font-family:STIXGeneral,Times,Symbol, cmr10,cmsy10,cmex10,cmmi10;
+ font-style: normal;
+ margin:0;
+ % background-color:\#99ff99;
+ padding:0;
+ }%
+ }%
+ \pgfsys@CssIncluded@true
+ \fi
+}%
+
+\def\pgfsys@endpicture{%
+ \HtmlParOn
+ \par% FIXME : was '\Par' but that seems to be undefined!?
+}%
+
+% this is okay for both rendering methods for text nodes (mtext or foreignelement)...
+\def\pgfsys@typesetpicturebox#1{%
+ \global\advance\pgf@sys@svg@picnum by 1\relax%
+ % Ok, compute width/height
+ \pgf@xa=\pgf@picminx%
+ \pgf@ya=\pgf@picminy%
+ \pgf@xb=\pgf@picmaxx%
+ \pgf@yb=\pgf@picmaxy%
+ \pgf@x=\pgf@xb%
+ \advance\pgf@x by-\pgf@xa%
+ \pgf@y=\pgf@yb%
+ \advance\pgf@y by-\pgf@ya%
+ \ifdim\pgf@y<1pt%
+ \pgf@y=1pt%
+ \fi%
+ \pgf@xc=\pgf@x%
+ \pgf@yc=\pgf@y%
+ \pgfsysprotocol@flushcurrentprotocol%
+ \HCode{<object data="\jobname-\the\pgf@sys@svg@picnum.svg" width="}%
+ % Calculate pixel coordinates (this does not really make sense, but
+ % we have to do it anyway). Assume 96dpi.
+ \pgf@x=1.3333333\pgf@x%
+ \pgf@y=1.3333333\pgf@y%
+ % Add one pixel for security:
+ \advance\pgf@x by1pt%
+ \advance\pgf@y by1pt%
+ \pgf@sys@pt\pgf@x%
+ \pgfsysprotocol@flushcurrentprotocol%
+ \pgfsys@invoke{" height="}%
+ \pgf@sys@pt\pgf@y%
+ \pgfsysprotocol@flushcurrentprotocol%
+ \pgfsys@invoke{" type="image/svg+xml"><p>SVG-Viewer needed.</p></object>}%
+ \special{t4ht>\jobname-\the\pgf@sys@svg@picnum.svg}%
+ %%%%%%%% This is necessary to control the svg through css
+ \pgfkeys{%
+ /pgf/tex4ht node/css/.get=\pgfsys@foreignobject@css
+ }%
+ \pgfsys@invoke{<?xml version="1.0" encoding="iso-8859-1" standalone="no"?>\Hnewline% added that
+ <?xml-stylesheet href="\pgfsys@foreignobject@css.css" type="text/css"?>\Hnewline}% added that
+%%%%%%%%%%%%%%% maybee I should add an option to change the css, for the whole picture
+ \pgfsys@invoke{<svg xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink" width="\the\pgf@xc"
+ height="\the\pgf@yc" viewBox="}%
+ \pgf@sys@pt{\pgf@xa}\pgf@sys@pt{\pgf@ya}\pgf@sys@pt{\pgf@xc}\pgf@sys@pt{\pgf@yc}%
+ \pgfsysprotocol@flushcurrentprotocol%
+ \pgf@ya=-\pgf@ya%
+ \pgfsys@invoke{">\Hnewline <g transform="translate(0,}
+ \pgf@sys@pt\pgf@yb\pgfsysprotocol@flushcurrentprotocol%
+ \pgfsys@invoke{) scale(1,-1) translate(0,}%
+ \pgf@sys@pt\pgf@ya\pgfsysprotocol@flushcurrentprotocol%
+ \pgfsys@invoke{)">\Hnewline }%
+ %
+ \pgf@ya=\pgf@shift@baseline\relax%
+ \advance\pgf@ya by-\pgf@picminy\relax%
+ %
+ %
+ \advance\pgf@picmaxy by-\pgf@picminy\relax% maxy is now the height
+ \advance\pgf@picmaxx by-\pgf@picminx\relax% maxx is now the width
+ \setbox#1=\hbox{\hskip-\pgf@picminx\lower\pgf@picminy\box#1}%
+ \ht#1=\pgf@picmaxy%
+ \wd#1=\pgf@picmaxx%
+ \dp#1=0pt%
+ \leavevmode
+ \pgf@xa=\pgf@trimleft@final\relax \ifdim\pgf@xa=0pt \else\kern\pgf@xa\fi
+ \raise-\pgf@ya\box#1%
+ \pgf@xa=\pgf@trimright@final\relax \ifdim\pgf@xa=0pt \else\kern\pgf@xa\fi
+ \pgfsys@invoke{</g>\Hnewline </svg>\Hnewline }%
+ \special{t4ht<\jobname-\the\pgf@sys@svg@picnum.svg}%
+}%
+
+%% we'll use this hbox for the mtext rendering method (the "text only=true" option)
+\def\pgfsys@hbox#1{%
+ \pgf@x=.5\wd#1%
+ \ifx\tikz@textcolor\relax\else\ifx\tikz@textcolor\@undefined\else%
+ \ifx\tikz@textcolor\pgfutil@empty%
+ \pgfsetfillcolor{.}%
+ \else%
+ \pgfsetfillcolor{\tikz@textcolor}%
+ \fi%
+ \fi\fi% tweak for TikZ
+ \HCode{<text
+ style="stroke:none"
+ transform="scale(1,-1) translate(\pgf@sys@tonumber{\pgf@x},0)"
+ text-anchor="middle"
+ }%
+ \ifpgfutil@format@is@latex%
+ \ifx\f@size\pgfutil@empty%
+ \else%
+ \HCode{ font-size="\f@size"}%
+ \fi%
+ \fi%
+ \HCode{>\Hnewline }%
+ \wd#1=0pt%
+ \ht#1=0pt%
+ \dp#1=0pt%
+ \box#1
+ \HCode{</text>\Hnewline }%
+}%
+
+%% we save this definition
+\let\pgfsys@mtext@hbox\pgfsys@hbox
+
+%% we have to use some "evil" ^^ tex4ht hackery
+% tex4ht hackery
+{% grouping necessary cause we change the catcode of ":"
+ \catcode`:=11\relax
+ %%% this is necessary to calculate the size of text nodes with
+ %%% inline maths
+ % (it is an improvement of tex4ht, got to ask eitan gurary if he
+ % could put it in the tex4ht code)
+ \gdef\DviMathAlt{%
+ \a:DviMath\leavevmode \MathClass
+ \ht:special{t4ht@(}\hbox\bgroup{\expandafter\ifx\csname
+ ht:everypar\endcsname\relax\expandafter\everypar\else
+ \expandafter\ht:everypar\fi{}\leavevmode\ht:special{t4ht@)}}\DviSend
+ }%
+ % these are configures for the foreignelement rendering method of text nodes : we let tex4ht write xhtml and mathml in the svg picture
+ %
+ \gdef\pgfsys@foreignobject@configure{%
+ \Configure{$}{\Configure{@math}{%\a:mathml
+ display="inline" }\DviMathAlt}{\EndDviMath}{}%%% we REALLY need to use \DviMathAlt here instead of \DviMath see above remark
+ \Configure{$$}{\Configure{@math}{%\a:mathml
+ display="block" }\IgnorePar
+ \ifvmode\else \HCode{<!--tex4ht:inline-->}\fi\EndP
+ \DviMath}{\EndDviMath\ShowPar\pgfsys@foreignobject@par{\csname HCondtrue\endcsname\noindent}
+ }{\DisplayMathtrue}%
+ \Configure{SUB}{\Send{BACK}{<\a:mathml msub><\a:mathml mrow\Hnewline>}%
+ \Tg</\a:mathml mrow>\Tg<\a:mathml mrow\Hnewline>\trap:base}{\Tg</\a:mathml mrow>\TG</\a:mathml msub\Hnewline>}%
+ \Configure{SUP}{\Send{BACK}{<\a:mathml msup><\a:mathml mrow\Hnewline>}%
+ \Tg</\a:mathml mrow>\Tg<\a:mathml mrow\Hnewline>\trap:base}{\Tg</\a:mathml mrow>\TG</\a:mathml msup\Hnewline>}%
+ \Configure{SUBSUP}{\Send{BACK}{<\a:mathml msubsup><\a:mathml mrow\Hnewline>}%
+ \Tg</\a:mathml mrow>\Tg<\a:mathml mrow\Hnewline>\trap:base}{\Tg</\a:mathml mrow>\Tg<\a:mathml mrow\Hnewline>\trap:base}{\Tg</\a:mathml mrow>\TG</\a:mathml msubsup\Hnewline>}%
+ \Configure{htf}{0}{+}{<span\Hnewline
+ class="}{\%s}{-\%s}{x-x-\%d}{}{">}{</span>}%
+ }%
+ \global\let\pgfsys@foreignobject@par=\par % use this instead of \par
+ % -- \Configure is no \long macro (at
+ % least in one of the older
+ % versions).
+
+ % these are the configures for the mtext rendering method of text
+ % nodes : we turn everything into regular character (don't want math
+ % modes or subsup)
+ % and we hope it works (it doesn't if the text nodes aren't simple)
+ \gdef\pgfsys@mtext@configure{%
+ % no configures for \(\) and \[\] those might be needed for
+ % context or Latex. Let me know !
+ \Configure{$$}{}{}{}% no block maths
+ \Configure{$}{}{}{}%$ no inline maths
+ \Configure{SUB}{\HCode{<tspan baseline-shift="sub">}}{\HCode{</tspan>}}%
+ \Configure{SUP}{\HCode{<tspan baseline-shift="sub">}}{\HCode{</tspan>}}%
+ \Configure{SUBSUP}{}{}{}% not both sub and sup
+ \Configure{htf} {0}{+}{<tspan font-family="}{\%s}{" font-size="\%s}{}{}{">}{</tspan>}%
+ }%
+}%
+
+% a counter to produce unique ids for each text node rendered with foreign element
+\newcount\pgf@sys@svg@nodenum
+
+
+% pgfutil@minipage
+%
+% I had to change it to make it play nice with the way tex4ht puts <p> and <\p> tags
+%
+
+\newif\ifpgfsys@textonly
+\def\pgfutil@minipage[#1]#2{%
+ \hbox to#2\bgroup
+ \hsize=#2\relax
+ \vbox\bgroup
+% though it works, I'm desabling the above-mentioned hack to make tex4ht behave with <p> <\p>, because it blurps the positioning
+% (I''l try to fix that later, it's a css thing)
+%
+% \ifpgfsys@textonly\else\HtmlParOn\fi
+%
+% \noindent is better as it doesn't produce indentation AND it makes you leave vertical mode
+ \noindent%\leavevmode
+}%
+\def\pgfutil@endminipage{%
+% same thing here
+%
+% \ifpgfsys@textonly\else\EndP\HtmlParOff\fi
+ \egroup\egroup
+}%
+
+
+% I'll have to fix those names later
+\newbox\pgfsys@foreignobject@Box
+\newdimen\pgf@s
+\newdimen\pgf@t
+% this is the alternate hbox routine that renders text nodes through the foreignobject tag
+\def\pgfsys@foreignobject@hbox#1{%
+ % Compute box y translation (x translation is correct).
+ \pgf@y=-\ht#1\relax
+ \HCode{<g transform="scale(1,-1) translate(0,\pgf@sys@tonumber{\pgf@y}) % got to translate in y
+ scale(0.5,0.5)">\Hnewline}% scaling work around (damn dumb browsers !)
+ % Compute box size (scaled 2 times)
+ % this is necessary to make the browser scale the font down 50% (the STUPID browsers won't make font-size:50% happen,
+ % so we have to work around this by making svg scale the things down 50%, doubling the size of the text node frame (i.e. no changement there)
+ \pgf@x=2\wd#1\relax
+ \pgf@y=2\ht#1\relax
+ \advance\pgf@y by 2\dp#1\relax
+ % this is to adjust the y translation to compensate for the differences between the TeX and the Html models for lines
+ \setbox\pgfsys@foreignobject@Box=\hbox{abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
+ $abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZf_1^1\overline D)_1^1\vec i\vec j$}%
+ \pgf@t=\ht#1\relax
+ \advance\pgf@t by -\ht\pgfsys@foreignobject@Box\relax
+ \pgf@s=\pgf@t\relax
+ \advance\pgf@s by \dp#1\relax
+ \advance\pgf@s by -\dp\pgfsys@foreignobject@Box\relax
+ \ifnum\pgf@s>0\relax
+ \pgf@s=0pt
+ \pgf@t=0pt
+ \else
+ \advance \pgf@y by -2\pgf@s\relax
+ \pgf@t=2\pgf@t\relax
+ \fi
+ %
+ \HCode{<foreignObject x="0" y="\pgf@sys@tonumber{\pgf@t}"
+ width="\pgf@sys@tonumber{\pgf@x}" height="\pgf@sys@tonumber{\pgf@y}">}%
+ % this is to make use of the css, class and id options through which you can control the way things display
+ \pgfkeys{%
+ /pgf/tex4ht node/css/.get=\pgfsys@foreignobject@css,%
+ /pgf/tex4ht node/class/.get=\pgfsys@foreignobject@class,%
+ /pgf/tex4ht node/id/.get=\pgfsys@foreignobject@id
+ }%
+ \HCode{<head>\Hnewline
+ <link rel="stylesheet" type="text/css" href="\pgfsys@foreignobject@css.css" />\Hnewline
+ </head>\Hnewline
+ % I'll have to look into this, perhaps there are better
+ % doctype....&nbsp; aren't recognised and produces invalid svg
+ % pictures a workaround (not implemented yet) would be to make
+ % them into entities of the svg picture.
+ <body id="\pgfsys@foreignobject@id" class="\pgfsys@foreignobject@class" xmlns="http://www.w3.org/1999/xhtml" >\Hnewline
+ <div>\Hnewline
+ }%
+ \box#1%
+ \HCode{%
+ </div>\Hnewline
+ </body>\Hnewline
+ </foreignObject>\Hnewline
+ }%
+ % debug positioning not needed but it would be nice to let it there to control things later on
+ % \HCode{<rect x="0" y="0" width="\pgf@sys@tonumber{\pgf@x}" height="\pgf@sys@tonumber{\pgf@y}"
+ % style="fill:yellow;stroke:red; fill-opacity:0.5;stroke-opacity:0.5"/>}
+ \HCode{</g>\Hnewline}%
+ \global\advance\pgf@sys@svg@nodenum by 1\relax
+}%
+
+% the options and the code that controls it all (switches between \pgfsys@mtext@hbox and \pgfsys@foreignelement@hbox)
+
+\pgfkeys{%
+ /pgf/.cd,
+ tex4ht node/escape/.is choice,
+ tex4ht node/escape/false/.code={\let\pgfsys@hbox\pgfsys@mtext@hbox\pgfsys@mtext@configure\pgfsys@textonlytrue},
+ tex4ht node/escape/true/.code={\let\pgfsys@hbox\pgfsys@foreignobject@hbox\pgfsys@foreignobject@configure\pgfsys@textonlyfalse},
+ tex4ht node/css/.initial=\jobname,
+ tex4ht node/class/.initial=foreignobject,
+ tex4ht node/id/.initial=\jobname\the\pgf@sys@svg@picnum-\the\pgf@sys@svg@nodenum
+}%
+
+
+
+
+
+
+% this might be needed
+%\font\SvgText=cmr10\relax
+
+
+
+
+% There is something rellay wrong with the way "%" chars are used in here... you should code "}%" to avoid unnecessary spaces
+% and it is unnecessary to code \cs%
+% got to be carefull with numbers though, cf the texbook...2\relax and 2 % are okey
+
+\def\pgfsys@outerinvoke{\ifpgfpicture\expandafter\pgfsys@invoke\else\expandafter\pgfutil@gobble\fi}
+
+\def\pgfsys@shadingoutsidepgfpicture#1{\pgf@sys@fail{svg code in preamble}}
+\def\pgfsys@shadinginsidepgfpicture#1{\pgf@sys@fail{svg code in preamble}}
+
+\def\pgfsys@body@shadingoutsidepgfpicture#1{%
+ \begingroup%
+ #1%
+ \setbox\pgfpic=\hbox to0pt{%
+ \pgfsys@beginpicture%
+ \pgfsys@beginscope%
+ \pgf@sys@svg@sh@defs%
+ \pgf@sys@svg@sh%
+ \pgfsys@endscope%
+ \pgfsys@endpicture%
+ \hss%
+ }%
+ \pgf@process{\pgf@sys@svg@pos}%
+ \pgf@picminx=0pt%
+ \pgf@picminy=0pt%
+ \pgf@picmaxx=\pgf@x%
+ \pgf@picmaxy=\pgf@y%
+ \def\pgf@trimleft@final{0pt}%
+ \def\pgf@trimright@final{0pt}%
+ \def\pgf@shift@baseline{0pt}%
+ \pgfsys@typesetpicturebox\pgfpic%
+ \endgroup%
+}
+
+\def\pgfsys@body@shadinginsidepgfpicture#1{%
+ #1%
+ \pgf@sys@svg@sh@defs% hmmm....
+ \pgf@process{\pgf@sys@svg@pos}
+ \pgf@xa=-.5\pgf@x%
+ \pgf@ya=-.5\pgf@y%
+ \pgfsysprotocol@literal{<g transform="translate(\pgf@sys@tonumber{\pgf@xa},\pgf@sys@tonumber{\pgf@ya})">\Hnewline}%
+ \pgf@sys@svg@sh%
+ \pgfsysprotocol@literal{</g>\Hnewline}%
+}
+
+
+\ifpgfutil@format@is@latex
+ % Protect against color.4ht evil meddling with xcolor:
+ \RequirePackage{xcolor}
+ \let\pgf@xcolor@declaredcolor=\@declaredcolor
+ \let\pgf@xcolor@undeclaredcolor=\@undeclaredcolor
+\fi
+
+\AtBeginDocument{
+ \let\pgfsys@invoke=\pgfsys@body@invoke
+ \let\pgfsys@shadingoutsidepgfpicture=\pgfsys@body@shadingoutsidepgfpicture
+ \let\pgfsys@shadinginsidepgfpicture=\pgfsys@body@shadinginsidepgfpicture
+ \ifpgfutil@format@is@latex
+ \let\pgf@texht@declaredcolor=\@declaredcolor
+ \let\pgf@texht@undeclaredcolor=\@undeclaredcolor
+ \def\@declaredcolor{\ifpgfpicture\expandafter\pgf@xcolor@declaredcolor\else\expandafter\pgf@texht@declaredcolor\fi}
+ \def\@undeclaredcolor{\ifpgfpicture\expandafter\pgf@xcolor@undeclaredcolor\else\expandafter\pgf@texht@undeclaredcolor\fi}
+ \fi
+ \def\pgfutil@color{\pgfsetcolor}
+ % \ConfigureEnv{pgfpicture}{}{}{}{} there is no environment in plain TeX and this produces errors
+ % this might be needed for context or latex though....let me know !
+}%
+
+\endinput
+
+
+%%% Local Variables:
+%%% mode: latex
+%%% End:
diff --git a/graphics/pgf/base/tex/generic/systemlayer/pgfsys-textures.def b/graphics/pgf/base/tex/generic/systemlayer/pgfsys-textures.def
new file mode 100644
index 0000000000..6f6163593d
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/systemlayer/pgfsys-textures.def
@@ -0,0 +1,95 @@
+% 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{pgfsys-textures.def}
+
+\pgfutil@packagewarning
+ {pgfsys-textures.def}%
+ {This driver is deprecated and will be removed by the end of 2022.
+ Please switch to another TeX engine}
+
+% Driver commands for textures driver
+
+
+\def\pgfsys@invoke#1{\special{rawpostscript #1}}
+\def\pgf@sys@postscript@header#1{\special{prepostscript #1}}
+\def\pgf@sys@postscript@object#1{\special{rawpostscript #1}}
+
+
+%
+% Load common postscript commands:
+%
+\input pgfsys-common-postscript.def
+
+
+%
+% textures-specific stuff:
+%
+
+\def\pgfsys@beginpicture{%
+ \special{rawpostscript save}%
+ \special{rawpostscript save pgfgetcoords}%
+ \special{postscript}% here come the coordinates
+ \special{rawpostscript restore}%
+ \special{rawpostscript pgfbeginpicture}}
+\def\pgfsys@endpicture{\special{rawpostscript restore}}
+\def\pgfsys@hbox#1{%
+ \pgfsys@begin@idscope%
+ \pgfsys@invoke{save pgfbeginhbox}%
+ \wd#1=0pt%
+ \ht#1=0pt%
+ \dp#1=0pt%
+ \box#1%
+ \pgfsys@invoke{restore}%
+ \pgfsys@end@idscope%
+}
+\def\pgfsys@begininvisible{%
+ \special{rawpostscript gsave nulldevice}%
+}
+\def\pgfsys@endinvisible{%
+ \special{rawpostscript grestore}%
+}
+\def\pgfsys@color@unstacked#1{\special{rawpostscript \XC@usecolor{#1}}}
+
+\def\pgfsys@imagesuffixlist{.epsi:.eps:.ps:}
+
+\AtBeginDocument{
+ % Always present specials.
+ \special{prepostscript
+ /pgfsc{}bind def% stroke color is empty by default
+ /pgffc{}bind def% fill color is empty by default
+ /pgfe{moveto dup 0 rlineto exch 0 exch rlineto neg 0 rlineto closepath}bind def% rectangle
+ /pgfstr{stroke}bind def%
+ /pgffill{fill}bind def%
+ /pgfeofill{eofill}bind def%
+ /pgfw{setlinewidth}bind def% setlinewidth
+ /pgfgetcoords{/sps{globaldict begin /pgfgy exch def /pgfgx exch def
+ end pop pop}def/eps{}def userdict begin}bind def
+ /pgfbeginpicture{/pgfx pgfgx def /pgfy pgfgy def pgfx pgfy translate 1 1 72.27 72 div mul2 neg scale}bind def
+ /pgfbeginhbox{1 1 72 72.27 div mul2 neg scale
+ pgfx neg pgfy neg translate
+ pgffoa .setopacityalpha}bind def% save
+ /.setopacityalpha where {pop} {/.setopacityalpha{pop}def} ifelse % install .setopacityalpha
+ /.pgfsetfillopacityalpha{/pgffoa exch def
+ /pgffill{gsave pgffoa .setopacityalpha fill 1 .setopacityalpha
+ newpath fill grestore newpath}bind def
+ /pgfeofill{gsave pgffoa .setopacityalpha eofill1
+ .setopacityalpha newpath eofill grestore newpath}bind def}bind def
+ /.pgfsetstrokeopacityalpha{/pgfsoa exch def
+ /pgfstr{gsave pgfsoa .setopacityalpha stroke grestore newpath}bind def}bind def
+ /pgffoa 1 def
+ /pgfsoa 1 def
+ }
+}
+
+\endinput
+
+%%% Local Variables:
+%%% mode: latex
+%%% End:
diff --git a/graphics/pgf/base/tex/generic/systemlayer/pgfsys-vtex.def b/graphics/pgf/base/tex/generic/systemlayer/pgfsys-vtex.def
new file mode 100644
index 0000000000..a1b0bea98d
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/systemlayer/pgfsys-vtex.def
@@ -0,0 +1,110 @@
+% 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{pgfsys-vtex.def}
+
+\pgfutil@packagewarning
+ {pgfsys-vtex.def}%
+ {This driver is deprecated and will be removed by the end of 2022.
+ Please switch to another TeX engine}
+
+% Driver commands for vtex
+
+% Invoking things:
+\def\pgfsys@invoke#1{\special{pS: grestore #1 gsave}} % to protect against things happeing in between
+\def\pgfsys@outerinvoke#1{\special{pS: #1}}
+\def\pgf@sys@postscript@header#1{\immediate\special{pS: #1}}
+\def\pgf@sys@postscript@object#1{\immediate\special{pS: #1}}
+
+
+%
+% Load common postscript commands:
+%
+\input pgfsys-common-postscript.def
+
+
+%
+% vtex-specific stuff:
+%
+
+
+% Starting and ending a picture:
+\def\pgfsys@beginpicture{\special{pS:
+ save
+ /pgfx currentpoint /pgfy exch def def
+ currentpoint translate
+ gsave}%
+ \let\set@color=\pgf@sys@vtex@set@color%
+ \let\reset@color=\pgf@sys@vtex@reset@color%
+}
+\def\pgf@sys@vtex@setcolor#1{%
+ \pgfutil@colorlet{pgf@tempcolor}{#1}%
+ \pgfutil@ifundefined{applycolormixins}{}{\applycolormixins{pgf@tempcolor}}%
+ \expandafter\expandafter\expandafter\pgf@sys@vtex@@setcolor\csname\string\color@pgf@tempcolor\endcsname%
+}
+\def\pgf@sys@vtex@@setcolor#1#2#3#4#5{%
+ \pgfsysps@color@resetnow%
+ \expandafter\ifx\csname pgfsys@color@#4\endcsname\relax%
+ \pgferror{Unsupported color model `#4'. Sorry}%
+ \else%
+ \edef\pgf@colmarshal{\expandafter\noexpand\csname pgfsys@color@#4\endcsname}%
+ \pgf@uncomma#5,,%
+ \pgf@colmarshal%
+ \fi}
+\def\pgf@sys@vtex@set@color{\pgf@sys@vtex@setcolor{.}\aftergroup\reset@color}
+\def\pgf@sys@vtex@reset@color{\pgf@sys@vtex@setcolor{.}}
+\def\pgfsys@endpicture{\special{pS:
+ newpath
+ grestore
+ newpath
+ restore}}
+
+% Graphics:
+\def\pgfsys@imagesuffixlist{.epsi:.eps:.ps:.pdf:}
+
+% Starting and ending a box:
+\def\pgfsys@hbox#1{%
+ \pgfsys@invoke{save pgfx neg pgfy neg translate}%
+ \wd#1=0pt%
+ \ht#1=0pt%
+ \dp#1=0pt%
+ \box#1
+ \pgfsys@invoke{restore}%
+}
+
+\def\pgfsys@color@unstacked#1{\special{pS: \XC@usecolor{#1}}}
+
+\def\pgfsys@fill@opacity#1{\pgf@sys@fail{opacity}}
+\def\pgfsys@stroke@opacity#1{\pgf@sys@fail{opacity}}
+
+\AtBeginDocument{
+ % Always present specials.
+ \immediate\special{pS:
+ /pgfsc{} bind def% stroke color is empty by default
+ /pgffc{} bind def% fill color is empty by default
+ /pgfstr{stroke} bind def%
+ /pgffill{fill} bind def%
+ /pgfeofill{eofill} bind def%
+ /pgfe{moveto dup 0 rlineto exch 0 exch rlineto neg 0 rlineto closepath} bind def% rectangle
+ /pgfw{setlinewidth} bind def % setlinewidth
+ }
+}
+
+% vtex commands for changing the paper size
+\def\pgfsys@papersize#1#2{\mediawidth#1\mediaheight#2}
+
+
+
+
+
+\endinput
+
+%%% Local Variables:
+%%% mode: latex
+%%% End:
diff --git a/graphics/pgf/base/tex/generic/systemlayer/pgfsys-xetex.def b/graphics/pgf/base/tex/generic/systemlayer/pgfsys-xetex.def
new file mode 100644
index 0000000000..ce08194ce1
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/systemlayer/pgfsys-xetex.def
@@ -0,0 +1,79 @@
+% 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{pgfsys-xetex.def}
+
+\input pgfsys-dvipdfmx.def
+
+\def\pgfsys@dvipdfmx@patternobj#1{%
+ % I have NO idea why this is necessary for xdvipdfmx - but without
+ % it, it crashes.
+ \pgfutil@insertatbegincurrentpagefrombox{#1}%
+}%
+
+% XeTeX supports pdftex commands for paper size
+\def\pgfsys@papersize#1#2{%
+ \pdfpageheight#2\relax%
+ \pdfpagewidth#1\relax}
+
+\def\pgfsys@global@papersize#1#2{%
+ \global\pdfpageheight#2\relax%
+ \global\pdfpagewidth#1\relax}
+
+
+% Xetex does not support interpolate and not mask
+\def\pgfsys@defineimage{% width, height, page number
+ \ifx\includegraphics\undefined
+ \ifx\pgf@imagewidth\pgfutil@empty\edef\pgf@imagewidth{1bp}\fi% width?
+ \ifx\pgf@imageheight\pgfutil@empty\edef\pgf@imageheight{1bp}\fi% height?
+ \ifx\pgf@imagepage\pgfutil@empty\else\edef\pgf@imagepage{ page \pgf@imagepage}\fi%
+ \ifx\pgf@imageinterpolate\pgfutil@empty\else\edef\pgf@imageinterpolate{ /Interpolate\space\pgf@imageinterpolate}\fi%
+ \ifx\pgf@imagemask\pgfutil@empty\else\xdef\pgf@imagemask{ /SMask @\pgf@imagemask}\fi%
+ \edef\pgf@image{\noexpand\hbox to \pgf@imagewidth{\vbox to \pgf@imageheight{\vfil\special{pdf:image width \pgf@imagewidth\space height \pgf@imageheight\space\pgf@imagepage\space(\pgf@filename) <<\pgf@imageinterpolate\pgf@imagemask\space>>}}\hfil}}%
+ \else
+ \ifx\pgf@imagewidth\pgfutil@empty\else\edef\pgf@imagewidth{width=\pgf@imagewidth,}\fi%
+ \ifx\pgf@imageheight\pgfutil@empty\else\edef\pgf@imageheight{height=\pgf@imageheight,}\fi%
+ \ifx\pgf@imagepage\pgfutil@empty\else\edef\pgf@imagepage{page=\pgf@imagepage,}\fi%
+ \edef\pgf@image{\noexpand\includegraphics[\pgf@imageheight\pgf@imagewidth\pgf@imagepage]{\pgf@filename}}%
+ \fi%
+}
+
+% XeTeX supports position tracking, now
+\def\pgfsys@markposition#1{%
+ \pdfsavepos%
+ \edef\pgf@temp{#1}%
+ \expandafter\pgfutil@writetoaux\expandafter{%
+ \expandafter\noexpand\expandafter\pgfsyspdfmark\expandafter{\pgf@temp}{\the\pdflastxpos}{\the\pdflastypos}}%
+}
+
+\def\pgfsyspdfmark#1#2#3{%
+ \expandafter\gdef\csname pgf@sys@pdf@mark@pos@#1\endcsname{\pgfqpoint{#2sp}{#3sp}}%
+ \pgfutil@check@rerun{#1}{{#2}{#3}}%
+}
+
+\def\pgfsys@getposition#1#2{%
+ \edef\pgf@marshal{\let\noexpand#2=\expandafter\noexpand\csname pgf@sys@pdf@mark@pos@#1\endcsname}%
+ \pgf@marshal%
+}
+
+\ifnum\the\XeTeXversion\expandafter\pgfutil@gobble\XeTeXrevision>0999991\relax
+ \def\pgf@sys@pdf@mark@pos@pgfpageorigin{\pgfqpoint{\hoffset}{\voffset}}
+\else
+ \def\pgf@sys@pdf@mark@pos@pgfpageorigin{\pgfqpoint{2\hoffset}{0pt}}
+\fi
+
+\ifx\paperheight\@undefined
+\else
+ \pdfpagewidth\paperwidth
+ \pdfpageheight\paperheight % this is to work around a positioning problem in xetex.
+\fi
+
+
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/systemlayer/pgfsys.code.tex b/graphics/pgf/base/tex/generic/systemlayer/pgfsys.code.tex
new file mode 100644
index 0000000000..a673297299
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/systemlayer/pgfsys.code.tex
@@ -0,0 +1,1775 @@
+% 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.
+
+\ProvidesPackageRCS{pgfsys.code.tex}
+
+
+% Load key mechanism
+\ifdefined\pgfkeysloaded\else
+ \input pgfkeys.code.tex
+\fi
+
+% "pgf" is a family
+\pgfkeys{/pgf/.is family}
+\def\pgfset{\pgfqkeys{/pgf}}
+
+% This if is needed *very* early
+\newif\ifpgfpicture
+
+
+%
+% The following conversion functions are used to convert from TeX
+% dimensions to postscript/pdf points.
+%
+{\catcode`\p=12\catcode`\t=12\gdef\Pgf@geT#1pt{#1}}
+
+\def\pgf@sys@tonumber#1{\expandafter\Pgf@geT\the#1}
+
+\def\pgf@sys@bp@correct#1{#1=0.99627#1}
+
+\def\pgf@sys@bp#1{%
+ {%
+ \pgf@x=#1\relax%
+ \pgf@x=0.99627\pgf@x%
+ \edef\temp{\expandafter\Pgf@geT\the\pgf@x\space}%
+ \pgfutil@toks@\expandafter\expandafter\expandafter{\expandafter\pgfsysprotocol@currentprotocol\temp}%
+ \xdef\pgfsysprotocol@currentprotocol{\the\pgfutil@toks@}%
+ }%
+}
+\def\pgf@sys@pt#1{%
+ {%
+ \pgf@x=#1\relax%
+ \edef\temp{\expandafter\Pgf@geT\the\pgf@x\space}%
+ \pgfutil@toks@\expandafter\expandafter\expandafter{\expandafter\pgfsysprotocol@currentprotocol\temp}%
+ \xdef\pgfsysprotocol@currentprotocol{\the\pgfutil@toks@}%
+ }%
+}
+
+
+% internal dimensions that are always present when pgsys is loaded.
+\newdimen\pgf@x
+\newdimen\pgf@y
+\newdimen\pgf@xa
+\newdimen\pgf@ya
+\newdimen\pgf@xb
+\newdimen\pgf@yb
+\newdimen\pgf@xc
+\newdimen\pgf@yc
+\newdimen\pgf@xd
+\newdimen\pgf@yd
+
+\newwrite\w@pgf@writea
+\newread\r@pgf@reada
+\let\pgfutil@inputcheck=\r@pgf@reada
+
+% internal counters that are always present when pgfsys is loaded
+\newcount\c@pgf@counta
+\newcount\c@pgf@countb
+\newcount\c@pgf@countc
+\newcount\c@pgf@countd
+
+\newtoks\t@pgf@toka
+\newtoks\t@pgf@tokb
+\newtoks\t@pgf@tokc
+
+% Ensure that math registers are the same (math is broken in case it
+% is loaded first)
+\let\pgfmath@x\pgf@x
+\let\pgfmath@xa\pgf@xa
+\let\pgfmath@xb\pgf@xb
+\let\pgfmath@xc\pgf@xc
+
+\let\pgfmath@y\pgf@y
+\let\pgfmath@ya\pgf@ya
+\let\pgfmath@yb\pgf@yb
+\let\pgfmath@yc\pgf@yc
+
+\let\c@pgfmath@counta\c@pgf@counta
+\let\c@pgfmath@countb\c@pgf@countb
+\let\c@pgfmath@countc\c@pgf@countc
+\let\c@pgfmath@countd\c@pgf@countd
+
+
+
+
+
+% In the following dummy definitions of the pgf system commands are
+% given. The individual drivers must overwrite these definitions,
+% preferably all of them. If some system command is used that has not
+% been overwritten, the command fails with a warning.
+%
+% In some cases, some pgf system commands are just shorthands for a
+% series of more complicated commands. In this case, a default
+% implementation is given in this file, but a driver may choose to
+% overwrite this default implementation with a more efficient
+% version. For example, a closestroke is the same as a closepath
+% followed by a stroking, but in pdf there is a special shorthand for
+% this. So, the pdf driver overwrites \pgfsys@closestroke, while the
+% postscript driver does not.
+%
+% The commands for which default implementations are available are
+% given at the end.
+
+\def\pgf@sys@fail#1{%
+ \expandafter\ifx\csname pgf@sys@fail@#1\endcsname\pgfutil@empty%
+ \else%
+ \expandafter\global\expandafter\let\csname pgf@sys@fail@#1\endcsname=\pgfutil@empty%
+ \pgfwarning{Your graphic driver \pgfsysdriver\space does not support #1. This warning is given only once}%
+ \fi%
+}
+
+
+
+%
+% Invocation commands
+%
+
+\def\pgfsys@invoke{\pgf@sys@fail{invoking specials}}
+% This command is used whenever some literal text needs to be inserted
+% into the resulting .pdf, .ps, or .dvi file. Note that most
+% \pgfsys@xxxx commands will not directly call this command, but,
+% rather, use the protocolling mechanism to record their literal
+% text. It is then left to the discretion of the protocolling
+% mechanism to insert the literal text at some appropriate, later
+% time.
+%
+% This command should only be called when \pgfsys@beginpicture has
+% been called previously and when the picture has not been suspended
+% using \pgfsys@beginhbox.
+
+\def\pgfsys@outerinvoke{\pgfsys@invoke}
+% This command can be used to insert protocolled graphic commands
+% outside any picture. This is extremely dangerous, but sometimes
+% useful. By default, this command does the same as inside pictures.
+
+
+
+%
+%
+% Path construction commands
+%
+%
+
+\def\pgfsys@moveto#1#2{\pgf@sys@fail{path constructions}}
+% This command is used to start a path at a specific point (#1,#2)
+% or to move the current point of the current path to (#1,#2)
+% without drawing anything upon stroking (the current path is
+% `interrupted').
+%
+% The arguments must be dimensions (like |10pt|).
+%
+% Example:
+%
+% \pgfsys@moveto{10pt}{10pt}
+% \pgfsys@lineto{0pt}{0pt}
+% \pgfsys@stroke
+%
+% This will draw a line from (10pt,10pt) to the origin of the picture.
+
+\def\pgfsys@lineto#1#2{\pgf@sys@fail{path constructions}}
+% Continue the current path to (#1,#2) with a line.
+
+\def\pgfsys@curveto#1#2#3#4#5#6{\pgf@sys@fail{path constructions}}
+% Continue the current path with a bezier curve to (#5,#6). The
+% control points of the curve are at (#1,#2) and (#3,#4).
+
+\def\pgfsys@rect#1#2#3#4{\pgf@sys@fail{path constructions}}
+% Append a rectangle to the current path whose lower left corner is at
+% (#1,#2) and whose width/height is given by (#3,#4).
+%
+% This command can be `mapped back' to moveto and lineto commands, but
+% it is included since pdf has a special, quick version of this command.
+
+\def\pgfsys@closepath{\pgf@sys@fail{path constructions}}
+% Close the current path. This results in joining the current point of
+% the path with the point specified by the last moveto
+% operation. Typically, this is preferable over using lineto to the
+% last point specified by a moveto, since the line starting at this
+% point and the line ending at this point will be smoothly joined by
+% closepath.
+%
+% Example:
+%
+% \pgfsys@moveto{0}{0}
+% \pgfsys@lineto{10}{10}
+% \pgfsys@lineto{0}{10}
+% \pgfsys@closepath
+% \pgfsys@stroke
+%
+% versus
+%
+% \pgfsys@moveto{0}{0}
+% \pgfsys@lineto{10}{10}
+% \pgfsys@lineto{0}{10}
+% \pgfsys@lineto{0}{0}
+% \pgfsys@stroke
+%
+% The difference between the above will be that in the second triangle
+% the corner at the origin will be wrong; it will just be the overlay
+% of two lines going in different directions, not a sharp pointed
+% corner.
+
+
+
+
+
+
+%
+%
+% Stroking and filling commands
+%
+%
+
+\def\pgfsys@stroke{\pgf@sys@fail{path usage}}
+% Stroke the current path (as if it were drawn with a pen). A number
+% of so-called graphic state parameters influence this, which can be
+% set in different ways:
+%
+% - linewidth
+% The `thickness' of the line. A width of 0 is the thinnest width
+% renderable on the device. On a high-resolution printer this may
+% become invisible and should be avoided. A good choice is 0.4pt,
+% which is the default.
+%
+% - stroke color
+% This special color is used for stroking. If it is not set, the
+% current color is used.
+%
+% - cap
+% The cap describes how the endings of lines a drawn. A round cap
+% adds a little half circle to these endings. A butt cap ends the
+% lines exactly at the end (or start) point without anything
+% added. A rectangular cap ends the lines like the butt cap, but the
+% lines protrude over the endpoint by the line thickness. (See also
+% the pdf or postscript manual). If the path has been closed, no cap
+% is drawn.
+%
+% - join
+% This describes how a bend (a join) in a path is rendered. A round
+% join draws bends using small arcs. A bevel join just draws the two
+% lines and then fills the join minimally so that it becomes
+% convex. A miter join extends the lines so that they form a single
+% sharp corner, but only up to a certain miter limit. (See the pdf
+% or postscript manual once more).
+%
+% - dash
+% The line may be dashed according to a dashing pattern.
+%
+% - clipping area
+% If a clipping area is established, only those parts of the path
+% that are inside the clipping area will be drawn.
+%
+% In addition to stroking a path, the path may also be used for
+% clipping after it has been stroked. This will happen if the
+% \pgfsys@clipnext is used prior to this command, see there for
+% details.
+
+\def\pgfsys@fill{\pgf@sys@fail{path usage}}
+% This command fills the area surrounded by the current path. If the
+% path has not yet been closed, it is closed prior to filling. The
+% path itself is not stroked. For self-intersecting paths or paths
+% consisting of multiple parts, the nonzero winding number rule is
+% used to determine whether a point is inside or outside the
+% path, except if \ifpgfsys@eorule holds -- in which case the even-odd
+% rule should be used. (See the pdf or postscript manual for details.)
+%
+% The following graphic state parameters influence the filling:
+%
+% - fill color
+% If the fill color is not especially set, the current color is
+% used.
+%
+% - clipping area
+% If a clipping area is established, only those parts of the filling
+% area that are inside the clipping area will be drawn.
+%
+% In addition to filling the path, the path will also be used for
+% clipping if \pgfsys@clipnext is used prior to this command.
+
+\def\pgfsys@fillstroke{\pgf@sys@fail{path usage}}
+% First, the path is filled, then the path is stroked. If the fill and
+% stroke colors are the same (or if they are not specified and the
+% current color is used), this yields almost the same as a
+% \pgfsys@fill. However, due to the line thickness of the stroked
+% path, the fillstroked area will be slightly larger.
+%
+% In addition to stroking and filling the path, the path will also be
+% used for clipping if \pgfsys@clipnext is used prior to this command.
+
+\def\pgfsys@clipnext{\pgf@sys@fail{path usage}}
+% This command should be issued after a path has been constructed, but
+% before it has been stroked and/or filled or discarded. When the
+% command is used, the next stroking/filling/discarding command will
+% first be executed normally. Then, afterwards, the just-used path
+% will be used for subsequent clipping. If there has already been a
+% clipping region, this region is intersected with the new clipping
+% path (the clipping cannot get bigger). The nonzero winding number
+% rule is used to determine whether a point is inside or outside the
+% clipping area or the even-odd rule, depending on whether
+% \ifpgfsys@eorule holds.
+
+\def\pgfsys@discardpath{\pgf@sys@fail{path usage}}
+% Normally, this command should `throw away' the current path.
+% However, after \pgfsys@clipnext has been called, the current path
+% should subsequently be used for clipping. See \pgfsys@clipnext for
+% details.
+
+\def\pgfsys@closestroke{\pgfsys@closepath\pgfsys@stroke}
+% This command should have the same effect as first closing the path
+% and then stroking it.
+
+\newif\ifpgfsys@eorule
+% Decides, whether even-odd filling and clipping is
+% to be used or normal the non-zero winding number rule. See the
+% pdf-documentation for details on what these rules are.
+
+
+
+
+%
+%
+% Stroking options
+%
+%
+\def\pgfsys@setlinewidth#1{\pgf@sys@fail{setting the line width}}
+% Sets the width of lines, when stroked, to #1, which must be a TeX
+% dimension (as text).
+
+\def\pgfsys@buttcap{\pgf@sys@fail{setting the line cap}}
+% Sets the cap to a butt cap. See \pgfsys@stroke.
+
+\def\pgfsys@roundcap{\pgf@sys@fail{setting the line cap}}
+% Sets the cap to a round cap. See \pgfsys@stroke.
+
+\def\pgfsys@rectcap{\pgf@sys@fail{setting the line cap}}
+% Sets the cap to a rectangular cap. See \pgfsys@stroke.
+
+\def\pgfsys@miterjoin{\pgf@sys@fail{setting the line join}}
+% Sets the join to a miter join. See \pgfsys@stroke.
+
+\def\pgfsys@setmiterlimit#1{\pgf@sys@fail{setting the line cap}}
+% Sets the miter limit of lines to #1. See the pdf or postscript
+% documentation.
+
+\def\pgfsys@roundjoin{\pgf@sys@fail{setting the line cap}}
+% Sets the join to a round join. See \pgfsys@stroke.
+
+\def\pgfsys@beveljoin{\pgf@sys@fail{setting the line cap}}
+% Sets the join to a bevel join. See \pgfsys@stroke.
+
+\def\pgfsys@setdash#1#2{\pgf@sys@fail{setting the dashing pattern}}
+% Sets the dashing patter. #1 should be a list of lengths separated by
+% commas. #2 should be a single dimension.
+%
+% The list of values in #1 is used to determine the lengths of the
+% `on' phases of the dashing and of the `off' phases. For example, if
+% #1 is `3pt,4pt', then the dashing pattern is `3pt on followed by 4pt
+% off, followed by 3pt on, followed by 4pt off, and so on'. A pattern
+% of `.5pt,4pt,3pt,1.5pt' means `.5pt on, 4pt off, 3pt on, 1.5pt off, .5pt on,
+% ...'. If the number of entries is odd, the last one is used twice,
+% so `3pt' means `3pt on, 3pt off, 3pt on, 3pt off,...'. An empty list
+% means `always on'.
+%
+% The second argument determines the `phase' of the pattern. For
+% example, for a pattern of `3pt,4pt' and a phase of `1pt', the pattern
+% would start: `2pt on, 4pt off, 3pt on, 4pt off, 3pt on, 4pt off...'.
+
+
+
+
+
+%
+%
+% Color stuff
+%
+%
+
+\def\pgfsys@color@rgb@stroke#1#2#3{\pgf@sys@fail{color}}
+% Sets the color used for stroking operations to the given rgb tuple
+% (numbers between 0 and 1).
+%
+% Example: Make stroked text dark red: \pgfsys@color@rgb@stroke{0.5}{0}{0}
+%
+% The special stroking color is only used if the stroking color has
+% been set since the last \pgfutil@color command. Thus, each \pgfutil@color command
+% should reset both the stroking and filling colors.
+
+\def\pgfsys@color@rgb@fill#1#2#3{\pgf@sys@fail{color}}
+% Sets the color used for filling operations to the given rgb tuple
+% (numbers between 0 and 1). This color may be different from the
+% stroking color.
+
+\def\pgfsys@color@rgb#1#2#3{\pgfsys@color@rgb@stroke{#1}{#2}{#3}\pgfsys@color@rgb@fill{#1}{#2}{#3}}
+% Sets the color used for filling and stroking operations. This is a
+% ``low-level'' version of the \pgfutil@color command. It is currently only
+% used by the plain tex version to support colors.
+
+\def\pgfsys@color@cmyk@stroke#1#2#3#4{\pgf@sys@fail{color}}
+% Sets the color used for stroking operations to the given cymk tuple
+% (numbers between 0 and 1).
+
+\def\pgfsys@color@cmyk@fill#1#2#3#4{\pgf@sys@fail{color}}
+% Sets the color used for filling operations to the given cymk tuple
+% (numbers between 0 and 1).
+
+\def\pgfsys@color@cmyk#1#2#3#4{\pgfsys@color@cmyk@stroke{#1}{#2}{#3}{#4}\pgfsys@color@cmyk@fill{#1}{#2}{#3}{#4}}
+% Sets the color used for filling and stroking operations.
+
+\def\pgfsys@color@cmy@stroke#1#2#3{\pgf@sys@fail{color}}
+% Sets the color used for stroking operations to the given cym tuple
+% (numbers between 0 and 1).
+
+\def\pgfsys@color@cmy@fill#1#2#3{\pgf@sys@fail{color}}
+% Sets the color used for filling operations to the given cym tuple
+% (numbers between 0 and 1).
+
+\def\pgfsys@color@cmy#1#2#3{\pgfsys@color@cmy@stroke{#1}{#2}{#3}\pgfsys@color@cmy@fill{#1}{#2}{#3}}
+% Sets the color used for filling and stroking operations.
+
+\def\pgfsys@color@gray@stroke#1{\pgf@sys@fail{color}}
+% Sets the color used for stroking operations to the given gray level
+% (number between 0 and 1).
+
+\def\pgfsys@color@gray@fill#1{\pgf@sys@fail{color}}
+% Sets the color used for filling operations to the given gray level
+% (number between 0 and 1).
+
+\def\pgfsys@color@gray#1{\pgfsys@color@gray@stroke{#1}\pgfsys@color@gray@fill{#1}}
+% Sets the color used for filling and stroking operations.
+
+\newif\ifpgfsys@color@reset@inorder
+% This if decides whether the color resetting of the
+% \pgfsys@color@reset command may assume that all color commands are
+% given ``in order.'' This means that this command will not be called,
+% say, at the beginning of a box that is later inserted at a point
+% where a fill color was actively set. This may allow the command to
+% produce more compact code when it ``knows'' that no special fill or
+% stroke color has been set.
+\pgfsys@color@reset@inordertrue
+
+
+\def\pgfsys@color@reset{}
+% This command will be called when the \pgfutil@color command is used. It
+% should purge any internal settings of stroking and filling
+% color. After this call, till the next use of a command like
+% \pgfsys@color@rgb@fill, the current color installed by the \pgfutil@color
+% command should be used.
+
+\def\pgfsys@color@unstacked#1{}
+% This slightly obscure command causes the color stack to be
+% tricked. When called, this command should set the current color to
+% #1 without causing any change in the color stack.
+
+\def\pgfsys@text@to@black@hook{}
+% Another slightly obscure command that allows tikz to hack into
+% dvisvgm's color management inside text nodes. The problem is that
+% the color "black" is special for dvisvgm.
+
+
+
+%
+%
+% Coordinate system transformations
+%
+%
+
+\def\pgfsys@transformcm#1#2#3#4#5#6{\pgf@sys@fail{transformations}}
+% Perform a concatenation of the low-level current transformation
+% matrix with the matrix given by the values #1 to #6. The
+% transformation matrix is a transformation on a homogeneous
+% 2D-coordinate system. See the pdf or postscript manual for details.
+
+\def\pgfsys@transformshift#1#2{\pgfsys@transformcm{1}{0}{0}{1}{#1}{#2}}
+% This command will change the origin of the low-level coordinate
+% system to (#1,#2).
+
+\def\pgfsys@transformxyscale#1#2{\pgfsys@transformcm{#1}{0}{0}{#2}{0bp}{0bp}}
+% This command will scale the low-level coordinate system (and
+% everything that is drawn) by a factor of #1 in x-directed and #2 in
+% y-direction. Note that this applies to everything, including
+% lines. So a scaled line will have a different width and may even
+% have a different width when going along the x-axis and when going
+% along the y-axis, if the scaling is different in these directions.
+
+\def\pgfsys@viewboxmeet#1#2#3#4#5#6#7#8{\pgfsys@beginscope\pgf@sys@default@viewbox@impl{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}{<}}
+% Consider the two rectangles R with lower left corner
+% (#5,#6) and upper right (#7,#8) and S with lower left corner
+% (#1,#2) and upper right (#3,#4). Now, consider the transformation
+% that scales and translates R so that the result T has the same
+% center as S and has maximal size while still being inside S. This
+% transformation gets installed in a new graphics group, which must be
+% ended with a corresponding \pgfsys@endviewbox.
+
+\def\pgfsys@viewboxslice#1#2#3#4#5#6#7#8{\pgfsys@beginscope\pgf@sys@default@viewbox@impl{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}{>}}
+% Works like \pgfsys@viewboxmeet, but R3 will have minimal size so
+% that in contains all of R2.
+
+\def\pgfsys@endviewbox{\pgfsys@endscope}
+% Ends a viewbox scope started by either of the previous two commands.
+
+
+\def\pgf@sys@default@viewbox@impl#1#2#3#4#5#6#7#8#9{{%
+ \pgf@x#1%
+ \pgf@y#2%
+ \pgf@xa#3%
+ \pgf@ya#4%
+ \advance\pgf@xa by-\pgf@x%
+ \advance\pgf@ya by-\pgf@y%
+ \pgfmathdivide@{\pgf@sys@tonumber\pgf@xa}{\pgf@sys@tonumber\pgf@ya}%
+ \let\aspectr\pgfmathresult%
+ \pgf@xb#5%
+ \pgf@yb#6%
+ \pgf@xc#7%
+ \pgf@yc#8%
+ \advance\pgf@xc by-\pgf@xb%
+ \advance\pgf@yc by-\pgf@yb%
+ \pgfmathdivide@{\pgf@sys@tonumber\pgf@xc}{\pgf@sys@tonumber\pgf@yc}%
+ \let\aspects\pgfmathresult%
+ \ifdim\aspectr pt#9\aspects pt%
+ \pgfmathdivide@{\pgf@sys@tonumber\pgf@xa}{\pgf@sys@tonumber\pgf@xc}%
+ \else%
+ \pgfmathdivide@{\pgf@sys@tonumber\pgf@ya}{\pgf@sys@tonumber\pgf@yc}%
+ \fi%
+ \advance\pgf@x by.5\pgf@xa%
+ \advance\pgf@xb by.5\pgf@xc%
+ \advance\pgf@y by.5\pgf@ya%
+ \advance\pgf@yb by.5\pgf@yc%
+ \pgfsys@transformcm{\pgfmathresult}{0}{0}{\pgfmathresult}{\pgf@x}{\pgf@y}%
+ \pgfsys@transformcm{1}{0}{0}{1}{-\pgf@xb}{-\pgf@yb}%
+ }%
+}
+
+
+
+
+%
+%
+% Graphic state saving and restoring.
+%
+%
+
+\def\pgfsys@beginscope{\pgf@sys@fail{scoping}}
+% Saves the current graphic state on a graphic state stack. All
+% changes to the graphic state parameters mentioned for \pgfsys@stroke
+% and \pgfsys@fill will be local to the current graphic state and will
+% the old values will be restored after endscope is used.
+%
+% WARNING: pdf and postscript differ with respect to the question of
+% whether the current path is part of the graphic state or not. For
+% this reason, you should never use this command unless the path is
+% currently empty. For example, it might be a good idea to use
+% discardpath prior to calling this command.
+
+\def\pgfsys@endscope{\pgf@sys@fail{scoping}}
+% Restores the last saved graphic state.
+
+\def\pgfsys@begin@idscope{%
+ \begingroup%
+ \edef\pgf@sys@cacheref{\pgfsys@id@refcurrent}%
+ \expandafter\let\expandafter\pgfsys@beg@save\csname pgf@sys@att@beg@\pgf@sys@cacheref\endcsname%
+ \expandafter\let\expandafter\pgfsys@end@save\csname pgf@sys@att@end@\pgf@sys@cacheref\endcsname%
+ \ifx\pgfsys@beg@save\relax%
+ \ifx\pgfsys@end@save\relax%
+ \else%
+ \pgfsys@call@save%
+ \fi%
+ \else%
+ \pgfsys@call@save%
+ \fi%
+ \pgfsys@invalidate@currentid%
+ \begingroup%
+}
+% Starts an "id scope" where the current value of \pgfsys@use@id and
+% \pgfsys@use@type is used. If the combination has been used before,
+% nothing happens. Otherwise, depending of the driver, a graphic
+% scope may or may not be created. To ensure that a graphic scope is
+% created, use \pgfsys@beginscope additionally.
+
+\def\pgfsys@call@save{%
+ \pgfsys@beginscope%
+ \pgfsys@beg@save%
+ \expandafter\global\expandafter\let\csname pgf@sys@att@beg@\pgfsys@id@refcurrent\endcsname\relax%
+ \expandafter\global\expandafter\let\csname pgf@sys@att@end@\pgfsys@id@refcurrent\endcsname\relax%
+}
+
+\def\pgfsys@end@idscope{
+ \endgroup%
+ \ifx\pgfsys@beg@save\relax%
+ \ifx\pgfsys@end@save\relax%
+ \else%
+ \pgfsys@call@end%
+ \fi%
+ \else%
+ \pgfsys@call@end%
+ \fi%
+ \endgroup
+}
+% Ends an id scope.
+
+\def\pgfsys@call@end{%
+ \pgfsys@end@save%
+ \pgfsys@endscope%
+}
+
+
+\def\pgfsys@begin@text{}
+% Inside a text box you should not use graphics command. However, TikZ
+% needs to insert some color commands at the beginnings of text
+% boxes. For most drivers, this is not a problem; except for SVG,
+% where every change of the graphics state opens a scope and needs a
+% closing scope. This command should be used at the beginning of text
+% boxes containing such color commands and the matching
+% \pgfsys@end@text at the end. If the box does not contain commands
+% that change the graphics state, this command is not needed.
+
+\def\pgfsys@end@text{}
+% Closes a \pgfsys@begin@text.
+
+
+
+%
+%
+% Id management (all of these commands have a default implementation
+% any typically need not be redefined by a driver)
+%
+%
+
+% The id count
+\newcount\pgf@sys@id@count
+
+\def\pgfsys@new@id#1{%
+ \edef#1{pgf\the\pgf@sys@id@count}%
+ \global\advance\pgf@sys@id@count by1\relax%
+}
+% Creates a new id and stores it in the macro #1.
+
+\def\pgfsys@use@id#1{%
+ \edef\pgf@sys@id@current@id{#1}%
+ \let\pgfsys@current@type\pgfutil@empty%
+}
+\let\pgf@sys@id@current@id\pgfutil@empty
+% Sets the id to be used for the next graphic object (group, box, or
+% path). The type is reset to be empty. #1 must be a macro name that
+% has previously been set using \pgfsys@new@id.
+%
+% Each combination of id and type can be used only once, on a second
+% use nothing happens.
+
+\def\pgfsys@clear@id{%
+ \let\pgf@sys@id@current@id\pgfutil@empty%
+}
+% Clears the current id, so nothing can be referenced.
+
+\def\pgfsys@use@type#1{%
+ \edef\pgfsys@current@type{#1}%
+ \pgfsys@register@type\pgfsys@current@type%
+}
+\let\pgfsys@current@type\pgfutil@empty
+% Sets the type to be used for the next graphic object.
+
+\def\pgfsys@append@type#1{%
+ \ifx\pgfsys@current@type\pgfutil@empty%
+ \pgfsys@use@type{#1}%
+ \else%
+ \pgfsys@use@type{\pgfsys@current@type.#1}%
+ \fi%
+}
+% Appends something to the current type
+
+\def\pgfsys@register@type#1{%
+ \expandafter\let\expandafter\pgf@sys@temp\csname pgf@sys@reg@type@#1\endcsname%
+ \ifx\pgf@sys@temp\relax%
+ {%
+ \c@pgf@counta\pgf@sys@type@count\relax%
+ \global\advance\c@pgf@counta by1\relax%
+ \edef\pgf@sys@type@count{\the\c@pgf@counta}%
+ \expandafter\xdef\csname pgf@sys@reg@type@#1\endcsname{y\the\c@pgf@counta}%
+ }%
+ \fi%
+}
+% Registers a type with the system. Must be called before any use of
+% the type
+\def\pgf@sys@reg@type@{}
+\def\pgf@sys@reg@type@background{b}
+\def\pgf@sys@reg@type@path{p}
+\def\pgf@sys@reg@type@text{t}
+\expandafter\def\csname pgf@sys@reg@type@background.path\endcsname{bp}
+\def\pgf@sys@type@count{0}
+
+\def\pgfsys@push@type{%
+ \expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter\pgf@sys@typestack%
+ \expandafter\expandafter\expandafter{\expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter\pgfsys@current@type%
+ \expandafter\expandafter\expandafter{\expandafter\pgfsys@current@type\expandafter}%
+ \expandafter\def\expandafter\pgf@sys@typestack\expandafter{\pgf@sys@typestack}}%
+}
+\let\pgf@sys@typestack\pgfutil@empty
+% Pushes the current type onto a global stack. This is useful for
+% temporarily changing the type without creating \TeX scopes.
+
+\def\pgfsys@pop@type{\pgf@sys@typestack}
+% Pops the last id from the stack.
+
+\def\pgfsys@id@ref#1#2{#1\csname pgf@sys@reg@type@#2\endcsname}
+% Expands to a text that can be inserted as a reference. #1 must be a
+% reference created \pgfsys@new@id, #2 must be a type that has been
+% registered using \pgfsys@id@register@type.
+
+\def\pgfsys@id@refcurrent{\pgfsys@id@ref{\pgf@sys@id@current@id}{\pgfsys@current@type}}
+% Expands to a text that can be inserted as a reference to the current
+% id-type pair in use.
+
+\def\pgfsys@invalidate@currentid{%
+ \expandafter\global\expandafter\let\csname pgf@sys@id@keylist@\pgfsys@id@refcurrent\endcsname\pgfutil@empty%
+}
+% Mark the current id-type pair as used.
+
+\def\pgfsys@attach@to@id#1#2#3#4{%
+ \pgfsys@register@type{#2}%
+ \expandafter\def\expandafter\pgf@sys@tempbeg\expandafter{\csname pgf@sys@att@beg@\pgfsys@id@ref{#1}{#2}\endcsname}%
+ \expandafter\def\expandafter\pgf@sys@tempend\expandafter{\csname pgf@sys@att@end@\pgfsys@id@ref{#1}{#2}\endcsname}%
+ \expandafter\ifx\pgf@sys@tempbeg\relax%
+ \expandafter\let\pgf@sys@tempbeg\pgfutil@empty%
+ \fi%
+ \expandafter\ifx\pgf@sys@tempend\relax%
+ \expandafter\let\pgf@sys@tempend\pgfutil@empty%
+ \fi%
+ \expandafter\let\expandafter\pgf@sys@tempbeg@cont\pgf@sys@tempbeg%
+ \expandafter\let\expandafter\pgf@sys@tempend@cont\pgf@sys@tempend%
+ \expandafter\expandafter\expandafter\gdef\expandafter\pgf@sys@tempbeg\expandafter{\pgf@sys@tempbeg@cont#3}%
+ \def\pgf@sys@temp{#4}%
+ \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\gdef\expandafter\expandafter\expandafter\pgf@sys@tempend\expandafter\expandafter\expandafter{\expandafter\pgf@sys@temp\pgf@sys@tempend@cont}%
+}
+% Attaches some code to an id-type pair so that when the id's scope
+% gets created, #3 is added at the beginning and #4 is added at the
+% end.
+
+\def\pgfsys@if@fresh@id#1#2#3#4{%
+ \edef\pgf@sys@temp{#1}%
+ \ifx\pgf@sys@temp\pgfutil@empty% empty id always counts as "has been used"
+ #4%
+ \else%
+ \pgfsys@register@type{#2}%
+ \expandafter\ifx\csname pgf@sys@id@keylist@\pgfsys@id@ref{#1}{#2}\endcsname\pgfutil@empty%
+ % has already been used!
+ #4%
+ \else%
+ #3%
+ \fi%
+ \fi%
+}
+% Checks whether a given id-type pair #1-#2 has not been used, yet. If
+% so, #3 is executed, otherwise #4.
+
+\def\pgfsys@if@fresh@currentid#1#2{%
+ \ifx\pgf@sys@id@current@id\pgfutil@empty% empty id always counts as "has been used"
+ #2%
+ \else%
+ \expandafter\ifx\csname pgf@sys@id@keylist@\pgfsys@id@refcurrent\endcsname\pgfutil@empty%
+ % has already been used!
+ #2%
+ \else%
+ #1%
+ \fi%
+ \fi%
+}
+% Checks whether the current id-type pair in use has not been used,
+% yet. If so, #1 is executed, otherwise #2.
+
+
+
+
+%
+%
+% Special commands
+%
+%
+
+\def\pgfsys@imagesuffixlist{}
+% A list of suffixes, separated by `:', that will be tried when
+% searching for an image.
+
+
+
+%
+%
+% Transparency
+%
+%
+
+\def\pgfsys@opacity#1{\pgfsys@stroke@opacity{#1}\pgfsys@fill@opacity{#1}}
+% Ideally, this should sets the opacity of all operations, treating
+% the group as a transparency group with 1 meaning fully opaque, 0
+% meaning fully transparent. Since most drivers do not support this,
+% the fallback is to set the stroke and fill opacity at the same
+% time. This is not quite the same, however.
+
+\def\pgfsys@stroke@opacity#1{\pgf@sys@fail{opacity}}
+% Sets the opacity of stroking operations. 1 means fully opaque, 0
+% means fully transparent.
+
+\def\pgfsys@fill@opacity#1{\pgf@sys@fail{opacity}}
+% Sets the opacity of filling operations. 1 means fully opaque, 0
+% means fully transparent.
+
+\def\pgfsys@transparencygroupfrombox#1{\pgf@sys@fail{transparency groups}}
+% This takes a TeX box and converts it into a transparency
+% group. This means that any transparency settings apply to the box as
+% a whole. For instance, if a box contains two overlapping black
+% circles and you draw them normally with 50% transparency, then the
+% overlap will be darker than the rest. By comparison, if the circles
+% are part of a transparency group, the overlap will get the same
+% color as the rest.
+%
+% The following settings modify the behaviour of a transparency group:
+
+\newif\ifpgfsys@transparency@group@isolated
+\newif\ifpgfsys@transparency@group@knockout
+
+
+\def\pgfsys@blend@mode#1{\pgf@sys@fail{blend mode}}
+% Sets the current blend mode. See the PDF specification for details
+% on blend modes.
+
+
+\def\pgfsys@definemask{\pgf@sys@fail{image masks}}
+% This command declares a mask for usage with images. It works similar
+% to \pgfsys@defineimage: Certain macros are set when the command is
+% called. The result should be to set the macro \pgf@mask to a pdf
+% object count that can subsequently be used as a soft mask. The
+% following macros will be set when this command is invoked:
+%
+% - \pgf@filename
+% File name of the mask to be defined.
+%
+% - \pgf@maskmatte
+% The so-called matte of the mask (see the pdf documentation for
+% details). The matte is a color specification consisting of 1, 3 or
+% 4 numbers between 0 and 1. The number of numbers depends on the
+% number of color channels in the image (not in the mask!). It will
+% be assumed that the image has been preblended with this color.
+
+\def\pgfsys@fadingfrombox#1#2{\pgf@sys@fail{fadings}}
+% Declares an fading named #1. The parameter #2 must be a
+% box. Its contents luminosity determines the opacity of the resulting
+% mask.
+
+\def\pgfsys@usefading#1#2#3#4#5#6#7{\pgf@sys@fail{fadings}}
+% Installs a previously declared fading #1 in the current graphics
+% state. Parameters #2 to #7 specify a transformation cm that should
+% be applied to the mask before it is used.
+
+\def\pgfsys@clipfading{}
+% This default implementation is a no-op for all drivers except `dvips'
+% where we have to set the clipping path _before_ installing the fading (used in
+% \pgfsetfadingforcurrentpath, \pgfsetfadingforcurrentpathstroked commands of
+% the basic layer)
+
+
+%
+%
+% Shading commands
+%
+%
+
+\def\pgfsys@horishading#1#2#3{\pgf@sys@fail{shadings}\pgf@sys@noshading{#1}}
+% Declares a horizontal shading for later use. The effect of this
+% command should be the definition of a macro called `@pgfshading#1!'
+% (or \csname @pdfshading#1!\endcsname, to be precise). When invoked,
+% this new macro should insert a shading at the current position.
+%
+% #1 is the name of the shading, which is also used in the output
+% macro name. #2 is the height of the shading and must be given as a
+% TeX dimension like `2cm' or `10pt'. #3 is a shading color
+% specification as specified in the pgfuserguide. The shading
+% specification implicitly fixes the width of the shading.
+%
+% When `@pgfshading#1!' is invoked, it should insert a box of height
+% #2 and the width implicit in the shading declaration.
+
+\def\pgfsys@vertshading#1#2#3{\pgf@sys@fail{shadings}\pgf@sys@noshading{#1}}
+% Like horishading, only for vertical shadings. This time, the height
+% of the shading is implicit in #3 and the width is given as #2.
+
+\def\pgfsys@radialshading#1#2#3{\pgf@sys@fail{shadings}\pgf@sys@noshading{#1}}
+% Declares a radial shading. Like the previous macros, this command
+% should setup the macro `@pgfshading#1!', which upon invocation
+% should insert a radial shading whose size is implicit in #3.
+%
+% The parameter #2 is a pgf point specification if the starting point
+% of the shading. See the pgfuserguide for details.
+
+\def\pgfsys@functionalshading#1#2#3#4{\pgf@sys@fail{shadings (functional)}\pgf@sys@noshading{#1}}
+% Declares a shading using a PostScript-like function that provides a
+% color for each point. Like the previous macros, this command
+% should setup the macro `@pgfshading#1!' so that it will produce a
+% box containing the desired shading.
+%
+% Parameter #1 is the name of the shading. Parameter #4 is a
+% Postscript-like function (type 4 function of the PDF specification)
+% as described in Section 3.9.4 of the PDF Specification version 1.7.
+% Parameter #2 and #3 are pgf point specifications that specifies the
+% lower left and upper right coordinate.
+%
+% When function #4 is evaluated, the coordinate of the current
+% point will be on the (virtual) PostScript stack in bp units. After
+% the function has been evaluated, the stack should consist of three
+% numbers (not integers! - the Apple PDF renderer is broken in this
+% regard, so add cvr's at the end if needed) that represent the red,
+% green, and blue components of the color.
+%
+% A buggy #4 will result is *totally unpredictable chaos* during
+% rendering.
+
+\def\pgf@sys@noshading#1{\expandafter\global\expandafter\let\csname @pgfshading#1!\endcsname=\pgfutil@empty}
+
+
+
+
+%
+%
+% Pattern stuff
+%
+%
+
+\def\pgfsys@declarepattern#1#2#3#4#5#6#7#8#9{\pgf@sys@fail{patterns}}
+% This command declares a new colored or uncolored pattern. Uncolored
+% patterns have no inherent color, the color is provided when they are
+% set. Colored patters have an inherent color.
+% #1 = name of the pattern (must be a plain suffix for use in
+% postscript/pdf/etc.)
+% #2 to #5 = four coordinates describing the corners of a bounding box
+% of pattern cells
+% #6 = x-step
+% #7 = y-step
+% #8 = pattern code
+% #9 = 0 if uncolored patter, 1 if colored pattern.
+
+\def\pgfsys@setpatternuncolored#1#2#3#4{\pgf@sys@fail{patterns}}
+% Sets an uncolored pattern #1 as filling color. The numbers #2, #3,
+% #4 must be an rgb-value to be used as the color of the pattern.
+
+\def\pgfsys@setpatterncolored#1{\pgf@sys@fail{patterns}}
+% Sets an colored pattern #1 as filling color.
+
+
+
+
+
+%
+%
+% Animations
+%
+%
+
+
+\newif\ifpgfsysanimationsupported
+% Will be set to true by a driver when animations are supported. Note
+% that snapshots are always supported.
+
+
+\def\pgfsys@animate#1{\pgf@sys@fail{animations}}
+% Adds an animation of the attribute #1 to the current scope.
+% The configuration of the animation (like start times, etc.) is taken
+% from the current values of the animation keys, which are configured
+% using calls to \pgfsys@animation@..., which setup an animation
+% key for the local scope. This means that you typically setup these
+% keys in a scope and at the end of the scope call \pgfsys@animate.
+%
+% Some keys accumulate (like begin or keytime), most do not. In those
+% cases, the last call overrides the previous one.
+%
+% Not all value types make sense or are allowed, it depends on the
+% specific \pgfsys@animate call.
+%
+% Example:
+%
+% {
+% \pgfsys@animation@offset{10}{begin}%
+% \pgfsys@animation@event{}{click}{1}{begin}%
+% \pgfsys@animation@time{5}{1}{1}{0}{0}
+% \pgfsys@animation@val@scalar{1}
+% \pgfsys@animation@time{8}{1}{1}{0}{0}
+% \pgfsys@animation@val@scalar{0.5}
+% \pgfsys@animation@sum%
+% \pgfsys@animate{fillopacity}%
+% }
+%
+% When a driver does not support a specific attribute #1, it should
+% issue a \pgf@sys@fail. Typical attributes are things like "opacity"
+% or "linewidth" or "dash".
+%
+% The following values are permissible for "#1":
+%
+% "opacity" adds an animation of the opacity.
+% Type: scalar
+%
+% "fillopacity" adds an animation of the fill opacity.
+% Type: scalar
+%
+% "strokeopacity" adds an animation of the stroke opacity.
+% Type: scalar
+%
+% "visibility" adds an animation of the visibility.
+% Type: text ("visible" or "hidden")
+%
+% "linewidth" adds an animation of the line width.
+% Type: dimension
+%
+% "dash" adds an animation of the dash.
+% Type: dash
+%
+% "translate" adds an animation of the transformation.
+% Type: translate
+%
+% "scale" adds an animation of the transformation.
+% Type: scale
+%
+% "rotate" adds an animation of the transformation.
+% Type: scalar
+%
+% "skewx" adds an animation of the transformation.
+% Type: scalar
+%
+% "skewy" adds an animation of the transformation.
+% Type: scalar
+%
+% "motion" adds a movement along a path.
+% Type: motion
+%
+% "strokecolor" adds an animation of the stroke color.
+% Type: color
+%
+% "fillcolor" adds an animation of the fill color.
+% Type: color
+%
+% "viewbox" adds an animation of the view box.
+% Type: view box
+%
+% "path" adds an animation of the path to the path specified by
+% \pgfsys@animation@whom
+% Type: path
+%
+% "syncbase" adds a sync base to the animation. A sync base does not animate
+% anything by itself, but other animations can begin and end relative
+% to it.
+%
+% "none" suppresses the animation
+% Type: any
+
+
+
+
+% Animation timing :
+%
+% You specify an animation using a timeline. A timeline consists of a
+% sequence of times together with values for these times. The times
+% must be given in increasing order. You use the command
+% \pgfsys@animation@time to specify a time and
+% \pgfsys@animation@val@... to specify a value. The time must be
+% specified first, the time--value is created when the value command is
+% used.
+%
+% Times are given in seconds (so 0.01 is one hundredth of a second).
+%
+% The animation's timeline will start with the first time mentioned
+% (not necessarily zero and not necessarily a positive value) and ends
+% with the last value. The duration is the difference between these
+% two values.
+
+\def\pgfsys@animation@restart@always{}
+% Specifies that the animation can always restart
+
+\def\pgfsys@animation@restart@never{}
+% Specifies that the animation should never restart
+
+\def\pgfsys@animation@restart@whennotactive{}
+% Specifies that the animation should only restart when it is not active
+
+\def\pgfsys@animation@repeat#1{}
+% #1 must be a number
+
+\def\pgfsys@animation@repeat@indefinite{}
+% Repeats forever
+
+\def\pgfsys@animation@repeat@dur#1{}
+% #1 must be a clock value
+
+\def\pgfsys@animation@freezeatend{}
+% Specifies that the last value of the animation remains in force at
+% the end
+
+\def\pgfsys@animation@removeatend{}
+% Specifies that the effect of the animation is removed at the end
+
+\def\pgfsys@animation@time#1#2#3#4#5{}
+% Specifies a time together with spline control points for the entry
+% and the exit to this time. The value #1 is a time in seconds (so 60
+% means 1 minute, 0.001 means one millisecond). The values #2 and #3
+% specify the control point of the spline *entering* the time point,
+% while the values #4 and #5 specify the control point of the spline
+% *leaving* the time point. They are all dimensionless values between
+% 0 and 1. For a linear animation, set the first two to 1 and the last
+% two to 0.
+%
+% Example:
+% \pgfsys@animation@time{5}{1}{1}{0.25}{0.1}
+% \pgfsys@animation@val@scalar{80}
+% \pgfsys@animation@time{8}{.75}{1}{0}{0}
+% \pgfsys@animation@val@scalar{90}
+%
+% In SVG, this will create the following entries:
+% begin = +5s
+% duration = 3s
+% keyTimes = 0;1
+% values = 80;90
+% keySpline = 0.25 0.1 0.75 1
+%
+% For the key spline, note that the entry spline controls of the first
+% time and the exit spline controls of the last point are dropped.
+%
+%
+% When the exit spline takes the special values #4="stay" and #5="0",
+% the attribute's value "stays" until the next value for the next time
+% (it "jumps" to the next value then). This corresponds, roughly, to
+% an "infinite" #4.
+%
+% Similarly, when the entry spline takes the special value #2="jump"
+% and #3="1", the value immediately jumps from the previous value to
+% the next value when the previous value was "created".
+
+\def\pgfsys@stay@text{{stay}{0}}
+\def\pgfsys@jump@text{{jump}{1}}
+
+\def\pgfsys@animation@base{}
+% Think of this command as setting the value of the attribute in the
+% timeline before the timeline starts. Normally, an animation only
+% influences the timeline while the animation is running (which may be
+% forever) and before and after the animation is running, the
+% attribute's value is not modified by the animation (so, it is just
+% inherited from the surrounding scope). When a base value is set,
+% while the animation is not running, this value is used. For most
+% attributes you can achieve the same effect by surrounding the
+% to-be-animated object by a scope and setting the value there, but
+% using bases is often more convenient and, for instance for the
+% visibility attribute, it is necessary to use a base.
+%
+% Note that when a backend driver does not support animations, base
+% values will not be depicted unless a snapshot is used explicitly.
+
+\def\pgfsys@animation@offset#1#2{}
+% #1 must be a value in seconds, #2 is the target "begin" or "end" to
+% which this offset is appended.
+
+\def\pgfsys@animation@syncbegin#1#2#3#4{}
+% #1 is the id of a sync base (obtained by
+% \pgfsys@new@id), #2 is the id type (or empty), #3 is an optional
+% offset, #4 is the target.
+
+\def\pgfsys@animation@syncend#1#2#3#4{}
+% Like the previous command.
+
+\def\pgfsys@animation@event#1#2#3#4#5{}
+% #1 is the optional id of another element (obtained by
+% \pgfsys@new@id), #2 is the optional type of the id, #3 is an event
+% name, #4 is an optional offset, #5 is the target.
+
+\def\pgfsys@animation@repeat@event#1#2#3#4#5{}
+% #1 is the optional id of another element, #2 is the type, #3 is a
+% repeat count, and #4 is an optional offset, #5 is the target.
+
+\def\pgfsys@animation@accesskey#1#2#3{}
+% #1 is a character, #2 is an optional offset, #3 is the target.
+
+\def\pgf@sys@begin@text{begin}
+
+
+% Accumulation
+
+\def\pgfsys@animation@accumulate{}
+% Corresponds to accumulate="sum" in SVG
+
+\def\pgfsys@animation@noaccumulate{}
+% Corresponds to accumulate="none" in SVG
+
+
+% Targeting
+
+\def\pgfsys@animation@whom#1#2{}
+% Sets the target of the animation. #1 must be an id previously
+% created using \pgfsys@new@id and #2 must be empty or a type
+% previously created using \pgfsys@new@id@type
+
+
+% Attribute definitions
+
+\def\pgfsys@animation@rotatealong{}
+% Applicable only to motion animations. Indicates that the
+% to-be-animated group should be rotated automatically so that it
+% points along the path as time progresses.
+
+\def\pgfsys@animation@norotatealong{}
+% Corresponds to rotate="0"
+
+\def\pgfsys@animation@movealong#1{}
+% Applicable only to motion animations. #1 is a softpath along which
+% the movement will be done.
+
+\def\pgfsys@animation@tip@markers#1#2{}
+% Applicable only to path animations. #1 and #2 are markers (declared
+% using \pgfsys@marker@declare) that store marker symbols to be added
+% at the start and at the end of the to-be-animated path. If empty, no
+% markers are added.
+
+\def\pgfsys@animation@canvas@transform#1#2{}
+% #1 is some code that may call \pgfsys@transformcm at most once. It
+% will be executed when a canvas transformation animation is
+% installed for a scope id. #2 is some further codes that may also
+% call \pgfsys@transformcm at most once. It will be installed right
+% after the animation.
+%
+% Typically, #1 is some pgf coordinate shift followed by
+% {\pgflowlevelsynccm} and #2 is \pgftransforminvert followed by
+% \pgflowlevelsynccm.
+
+
+
+% Values
+
+\def\pgfsys@animation@val@current{}
+% The current value of the attribute. At least with SVG, this can only
+% be used for the first value and, then, only if there is only one
+% other value.
+
+\def\pgfsys@animation@val@text#1{}
+% #1 should be some text.
+
+\def\pgfsys@animation@val@scalar#1{}
+% #1 should be a single value.
+
+\def\pgfsys@animation@val@dimension#1{}
+% #1 must be a dimension.
+
+\def\pgfsys@animation@val@color@rgb#1#2#3{}
+% #1,#2,#3 must be an rgb tuple
+
+\def\pgfsys@animation@val@color@cmyk#1#2#3#4{}
+% #1,#2,#3,#4 must be an cmyk tuple
+
+\def\pgfsys@animation@val@color@cmy#1#2#3{}
+% #1,#2,#3 must be an cmy tuple
+
+\def\pgfsys@animation@val@color@gray#1{}
+% #1 must be a gray value
+
+\def\pgfsys@animation@val@path#1{}
+% #1 must consist of path-construction tokens (as returned by the
+% softpath layer)
+
+\def\pgfsys@animation@val@translate#1#2{}
+% #1,#2 must be dimensions
+
+\def\pgfsys@animation@val@scale#1#2{}
+% #1,#2 must be dimensionless
+
+\def\pgfsys@animation@val@viewbox#1#2#3#4{}
+% #1,#2 describe the lower left, #3,#4 the upper right corner of the
+% view box.
+
+\def\pgfsys@animation@val@dash#1#2{}
+% #1,#2 have the syntax of \pgfsys@setdash.
+
+
+
+%
+%
+% Markers
+%
+%
+
+\def\pgfsys@marker@declare#1#2{%
+ {%
+ \pgfpicturetrue%
+ \pgfsysprotocol@getcurrentprotocol\pgfsys@marker@temp%
+ \pgfsysprotocol@setcurrentprotocol\pgfutil@empty%
+ \pgfsysprotocol@bufferedtrue%
+ \pgfsys@beginscope%
+ #2%
+ \pgfsys@endscope%
+ \xdef#1{\the\pgf@sys@id@count}%
+ \expandafter\expandafter\expandafter\global\expandafter\pgfsysprotocol@getcurrentprotocol\csname pgf@sys@marker@prot@#1\endcsname%
+ \pgfsys@marker@declare@% curtesy hook
+ \pgfsysprotocol@setcurrentprotocol\pgfsys@marker@temp%
+ \global\advance\pgf@sys@id@count by1\relax%
+ }%
+}
+\let\pgfsys@marker@declare@\relax
+% Declares a new marker symbol whose code is in #2. #1 should be a
+% macro name, which will be set to a unique
+% value by which the marker can be referenced later on. #2 should be
+% code that, when executed, produces recordable code.
+
+\def\pgfsys@marker@use#1{%
+ \pgfsysprotocol@literal{\csname pgf@sys@marker@prot@#1\endcsname}%
+}
+% Draws the marker symbol not at the end of a path, but simply with
+% the current transformation matrix
+
+
+
+
+
+
+%
+%
+% RDF
+%
+%
+
+\def\pgfsys@rdf@about#1{\pgf@sys@fail{rdf}}
+% Adds the rdf attribute "about" with value #1 to the next
+% idscope. The RDF-spec says: "a SafeCURIEorCURIEorIRI, used for
+% stating what the data is about (a 'subject' in RDF terminology);"
+
+\def\pgfsys@rdf@content#1{\pgf@sys@fail{rdf}}
+% Adds the rdf attribute content with value #1 to the next
+% idscope. The RDF-spec says: "a CDATA string, for supplying
+% machine-readable content for a literal (a 'literal object', in RDF
+% terminology);"
+
+\def\pgfsys@rdf@datatype#1{\pgf@sys@fail{rdf}}
+% Adds the rdf attribute datatype with value #1 to the next
+% idscope. The RDF-spec says: "a TERMorCURIEorAbsIRI representing a
+% datatype, to express the datatype of a literal;"
+
+\def\pgfsys@rdf@href#1{\pgf@sys@fail{rdf}}
+% Adds the rdf attribute href with value #1 to the next idscope
+% The RDF-spec says: "a traditionally navigable IRI for
+% expressing the partner resource of a relationship (a 'resource
+% object', in RDF terminology);"
+
+\def\pgfsys@rdf@inlist{\pgf@sys@fail{rdf}}
+% Adds the rdf attribute inlist to the next idscope. The
+% RDF-spec says: "An attribute used to indicate that the object
+% associated with a rel or property attribute on the same element is
+% to be added to the list for that predicate. The value of this
+% attribute must be ignored. Presence of this attribute causes a list
+% to be created if it does not already exist."
+
+\def\pgfsys@rdf@prefix#1{\pgf@sys@fail{rdf}}
+% Adds #1 to the list of the rdf prefix attribute to the next
+% idscope. Can be called several times, in which case all values of #1
+% are concatenated with whitespaces. The RDF-spec says: "a white space
+% separated list of prefix-name IRI pairs of the form NCName ':' ' '+
+% xsd:anyURI"
+
+\def\pgfsys@rdf@property#1{\pgf@sys@fail{rdf}}
+% Adds #1 to the list of the rdf property attribute to the next
+% idscope. Can be called repeatedly. The RDF-spec says: "a white space
+% separated list of TERMorCURIEorAbsIRIs, used for expressing
+% relationships between a subject and either a resource object if
+% given or some literal text (also a 'predicate');"
+
+\def\pgfsys@rdf@rel#1{\pgf@sys@fail{rdf}}
+% Adds #1 to the list of the rdf rel attribute to the next
+% next idscope. Can be called repeatedly. The
+% RDF-spec says: "a white space separated list of
+% TERMorCURIEorAbsIRIs, used for expressing relationships between two
+% resources ('predicates' in RDF terminology);"
+
+\def\pgfsys@rdf@resource#1{\pgf@sys@fail{rdf}}
+% Adds the rdf attribute resource with value #1 to the next idscope. The
+% RDF-spec says: "a SafeCURIEorCURIEorIRI for expressing the partner
+% resource of a relationship that is not intended to be navigable
+% (e.g., a 'clickable' link) (also an 'object');"
+
+\def\pgfsys@rdf@rev#1{\pgf@sys@fail{rdf}}
+% Adds #1 to the list of the rdf rev attribute to the next
+% idscope. Can be called repeatedly. The
+% RDF-spec says: "a white space separated list of
+% TERMorCURIEorAbsIRIs, used for expressing reverse relationships
+% between two resources (also 'predicates');
+
+\def\pgfsys@rdf@src#1{\pgf@sys@fail{rdf}}
+% Adds an rdf attribute src with value #1 to the next idscope. The
+% RDF-spec says: "an IRI for expressing the partner resource of a
+% relationship when the resource is embedded (also a 'resource
+% object');"
+
+\def\pgfsys@rdf@typeof#1{\pgf@sys@fail{rdf}}
+% Adds #1 to the list of the rdf typeof attribute to the next
+% idscope. Can be called repeatedly. The
+% RDF-spec says: "a white space separated list of TERMorCURIEorAbsIRIs
+% that indicate the RDF type(s) to associate with a subject;"
+
+\def\pgfsys@rdf@vocab#1{\pgf@sys@fail{rdf}}
+% Adds an rdf attribute vocab with value #1 to the next idscope. The
+% RDF-spec says: "an IRI that defines the mapping to use when a TERM
+% is referenced in an attribute value. See General Use of Terms in
+% Attributes and the section on Vocabulary Expansion."
+
+
+
+%
+%
+% Page size stuff
+%
+%
+
+\def\pgfsys@papersize#1#2{\pgf@sys@fail{papersize}}
+% This command sets the paper size in a portable way. It tries to do
+% so "locally" for the current page, but what really happens depends
+% strongly on the driver. For instance, dvips will use whatever is
+% used with the first call to this command that is part of the
+% shipped-out document and will ignore all other uses. In contrast,
+% pdftex will use the current value of the papersize for each page
+% and, additionally, setting the papersize is local to the current TeX
+% group.
+% #1 = width
+% #2 = height
+
+\def\pgfsys@global@papersize#1#2{\pgfsys@papersize{#1}{#2}}
+% This command does the same as the papersize command, only for
+% drivers that support this, \global is used to set the papersize.
+% #1 = width
+% #2 = height
+
+\def\pgfsys@prepare@papersize#1#2{\pgfsys@papersize{#1}{#2}}
+% Like \pgfsys@papersize, this prepares the paper size in a portable
+% way -- but it is supposed to be a preparation step before the
+% document has started. Drivers may decide to postpone the action
+% until the document has started.
+%
+% The root cause why I added this method is that image externalization
+% seems to suffer from the fact that some drivers need a "prepared"
+% routine whereas others must not have a prepared routine and have to
+% apply the action right-away. This method is the solution for image
+% externalization.
+% #1 = width
+% #2 = height
+
+\ifx\paperheight\@undefined
+ \def\pgfsys@thepageheight{\the\vsize} % this is wrong, but I do not
+ % know how to compute the page height
+ % in plain tex.
+ \def\pgfsys@thepagewidth{\the\hsize}
+\else
+ \def\pgfsys@thepageheight{\paperheight}
+ \def\pgfsys@thepagewidth{\paperwidth}
+\fi
+
+
+%
+%
+% Position tracking commands
+%
+%
+
+% Marks the current position on the page. This position can later be
+% referenced using \pgfsys@getposition
+\def\pgfsys@markposition#1{\pgf@sys@fail{marking the current position}}
+
+% Sets #2 to a pgfpoint macro that returns the position #1 is
+% returned in a coordinate system where the x-axis goes right and the
+% y-axis goes up. The origin of this coordinate system may or may not
+% lie in the lower left corner; you should shift the coordinate system
+% to the position "pgfpageorigin" to make sure that the origin is at
+% the lower left corner. Typically, getting this position
+% requires two runs of TeX. On the first run, the macro will be set to
+% \relax, indicating that the position is not available.
+%
+% If #1 is set to the special position "pgfpageorigin", the position
+% of the the lower left page corner is returned.
+
+\def\pgfsys@getposition#1#2{\let#2=\relax}
+
+
+
+%
+%
+% Commands having a default implementation. These commands only need
+% not be implemented by drivers if this results in a better
+% performance.
+%
+%
+
+
+\def\pgfsys@shadingoutsidepgfpicture#1{%
+ #1%
+}
+% This command gets the definition of a shading (@pgfshadingxxxx!) as
+% an argument and should insert this shading into the normal text.
+%
+% This command has a default implementation.
+
+
+\def\pgfsys@shadinginsidepgfpicture#1{%
+ \pgf@makehbox{#1}%
+ \setbox\pgf@hbox=\hbox{\hskip-.5\wd\pgf@hbox\lower.5\ht\pgf@hbox\hbox{\box\pgf@hbox}}%
+ \pgfqbox{\pgf@hbox}%
+}
+% This command works like \pgfsys@shadingoutsidepgfpicture, only it is
+% called when a shading should be inserted inside a picture. This
+% command should insert the shading centered on the origin (which will
+% typically have been low-level translated somewhere else.)
+%
+% This command has a default implementation.
+
+
+\def\pgfsys@hbox#1{%
+ \pgfsys@begin@idscope%
+ \pgfsys@beginscope%
+ \setbox#1=\hbox{\box#1}%
+ \wd#1=0pt%
+ \ht#1=0pt%
+ \dp#1=0pt%
+ \box#1%
+ \pgfsys@endscope%
+ \pgfsys@end@idscope%
+}
+% Called to insert a TeX hbox into a pgfpicture.
+
+\def\pgfsys@hboxsynced#1{%
+ \pgfsys@beginscope\pgflowlevelsynccm\pgfsys@hbox#1\pgfsys@endscope%
+}%
+% Called to insert box #1 into a pgfpicture, but with the current
+% coordinate transformation matrix synced with the canvas
+% transformation matrix and surrounded by a scope.
+%
+% In essence, this command does the same as if you first said
+% \pgflowlevelsynccm and then \pgfsys@hbox#1. However, a
+% ``TeX-translation'' is used for the translation part of the
+% transformation cm. This will ensure that hyperlinks ``survive'' at
+% least translations.
+
+\def\pgfsys@pictureboxsynced#1{%
+ {%
+ \setbox0=\hbox{\pgfsys@beginpicture\box#1\pgfsys@endpicture}%
+ \pgfsys@hboxsynced0%
+ }%
+}
+% Basically, this should do the same as doing a (scoped) low level sync
+% followed by inserting the box #1 directly into the output
+% stream. However, the default implementation uses \pgfsys@hboxsynced
+% in conjunction with \pgfsys@beginpicture to ensure that, if
+% possible, hyperlinks survive in pdfs. Drivers that are sensitive to
+% picture-in-picture scopes should replace this implementation by
+% \pgfsys@beginscope\pgflowlevelsynccm\box#1\pgfsys@endscope
+
+\def\pgfsys@beginpicture{}
+% Called at the beginning of a pgfpicture. Used to setup things.
+
+\def\pgfsys@endpicture{}
+% Called at the end of a pgfpicture.
+
+\def\pgfsys@typesetpicturebox#1{%
+ \pgf@ya=\pgf@shift@baseline\relax%
+ \advance\pgf@ya by-\pgf@picminy\relax%
+ %
+ %
+ \advance\pgf@picmaxy by-\pgf@picminy\relax% maxy is now the height
+ \advance\pgf@picmaxx by-\pgf@picminx\relax% maxx is now the width
+ \setbox#1=\hbox{\hskip-\pgf@picminx\lower\pgf@picminy\box#1}%
+ \ht#1=\pgf@picmaxy%
+ \wd#1=\pgf@picmaxx%
+ \dp#1=0pt%
+ \leavevmode%
+ \pgf@xa=\pgf@trimleft@final\relax \ifdim\pgf@xa=0pt \else\kern\pgf@xa\fi
+ \raise-\pgf@ya\box#1%
+ \pgf@xa=\pgf@trimright@final\relax \ifdim\pgf@xa=0pt \else\kern\pgf@xa\fi
+}
+% Called after a picture has been typeset in box #1. This
+% command should insert the box into the normal TeX code. The box #1
+% will still be a ``raw'' box that contains only the \special's. The
+% job of this command is to resize and shift this box according to the
+% baseline shift and the size of the box.
+%
+% This command has a default implementation.
+
+\def\pgfsys@beginpurepicture{\pgfsys@beginpicture}
+% This version of the beginpicture command can be used for pictures
+% that are guaranteed not to contain any hboxes. In this case, a
+% driver might provide a more compact version of the command.
+
+\def\pgfsys@endpurepicture{\pgfsys@endpicture}
+% Called at the end of a ``pure'' pgfpicture.
+
+\def\pgfsys@defineimage{%
+ \ifx\pgf@imagewidth\pgfutil@empty\else\edef\pgf@imagewidth{width=\pgf@imagewidth,}\fi%
+ \ifx\pgf@imageheight\pgfutil@empty\else\edef\pgf@imageheight{height=\pgf@imageheight,}\fi%
+ \ifx\pgf@imagepage\pgfutil@empty\else\edef\pgf@imagepage{page=\pgf@imagepage,}\fi%
+ \edef\pgf@image{\noexpand\includegraphics[\pgf@imageheight\pgf@imagewidth]{\pgf@filename}}%
+}
+% Called, when an image should be defined.
+%
+% This command does not take any parameters. Instead, certain macros
+% will be preinstalled with appropriate values when this command is
+% invoked. These are:
+%
+% - \pgf@filename
+% File name of the image to be defined.
+%
+% - \pgf@imagewidth
+% Will be set to the desired (scaled) width of the image.
+%
+% - \pgf@imageheight
+% Will be set to the desired (scaled) height of the image.
+%
+% If this macro and also the height macro are empty, the image
+% should have its `natural' size.
+%
+% If exactly only of them is specified, the undefined value the
+% image is scaled so that the aspect ratio is kept.
+%
+% If both are set, the image is scaled in both directions
+% independently, possibly changing the aspect ratio.
+%
+%
+% The following macros presumable mostly make sense for drivers that
+% can handle pdf:
+%
+% - \pgf@imagepage
+% The desired page number to be extracted from a multi-page
+% `image'.
+%
+% - \pgf@imagemask
+% If set, it will be set to `/SMask x 0 R', where x is the pdf
+% object number of a soft mask to be applied to the image.
+%
+% - \pgf@imageinterpolate
+% If set, it will be set to `/Interpolate true' or `/Interpolate
+% false', indicating whether the image should be interpolated in
+% pdf.
+%
+%
+% The command should now setup the macro \pgf@image such that calling
+% this macro will result in typesetting the image. Thus, \pgf@image is
+% the `return value' of the command.
+
+
+\def\pgfsys@defobject#1#2#3#4{%
+ \pgfsysprotocol@getcurrentprotocol\pgfsys@temp%
+ {%
+ \pgfpicturetrue%
+ \pgfsysprotocol@setcurrentprotocol\pgfutil@empty%
+ \pgfsysprotocol@bufferedtrue%
+ \pgfsys@beginscope%
+ #4%
+ \pgfsys@endscope%
+ \pgfsysprotocol@getcurrentprotocol\pgfsys@@temp%
+ \expandafter\global\expandafter\let\csname #1\endcsname=\pgfsys@@temp%
+ }%
+ \pgfsysprotocol@setcurrentprotocol\pgfsys@temp%
+}
+% Declares an object for later use. The idea is that the object can be
+% precached in some way and then be rendered more quickly when used
+% several times. For example, an arrow head might be defined and
+% prerendered in this way.
+%
+% The parameter #1 is the name for later use. #2 and #3 are pgf points
+% specifying a bounding box for the object. #4 is the code for the
+% object. The code may only contain protocolable code.
+
+
+\def\pgfsys@useobject#1#2{%
+ \pgfsysprotocol@getcurrentprotocol\pgfsys@temp%
+ {%
+ \pgfsysprotocol@setcurrentprotocol\pgfutil@empty%
+ \pgfsysprotocol@bufferedfalse%
+ #2%
+ \expandafter\pgfsysprotocol@setcurrentprotocol\csname #1\endcsname%
+ \pgfsysprotocol@invokecurrentprotocol%
+ }%
+ \pgfsysprotocol@setcurrentprotocol\pgfsys@temp%
+}
+% Renders a previously declared object. The first parameter is the
+% name of the object. The second parameter is extra code that
+% should be executed right *before* the object is rendered. Typically,
+% this will be some transformation code.
+
+
+\def\pgfsys@begininvisible{\pgfsys@transformcm{1}{0}{0}{1}{2000bp}{2000bp}}
+% Between this command and the closing endinvisible, all output should
+% be suppressed. Nothing should be drawn at all, which includes all
+% paths, images and shadings. This command typically should not open a
+% graphic scope.
+
+\def\pgfsys@endinvisible{\pgfsys@transformcm{1}{0}{0}{1}{-2000bp}{-2000bp}}
+% Ends the invisibility section, unless invisibility blocks have been
+% nested. In this case, only the `last' one restores visibility.
+
+\def\pgfsys@begininvisiblescope{\pgfsys@beginscope\pgfsys@begininvisible}
+% Works like pgfsys@begininvisible, but it may open a graphics scope.
+
+\def\pgfsys@endinvisiblescope{\pgfsys@endinvisible\pgfsys@endscope}
+% Closes the invisibility scope.
+
+
+\def\pgfsys@atbegindocument{}
+% This command will be executed at the begin of the document. If for
+% whatever reason this is not done, you may wish to execute this
+% command yourself. It will setup certain specials that need to be
+% inserted into the resulting .pdf/.ps/.xxx file.
+
+
+% String comparison
+\ifdefined\pdfstrcmp
+ \let\pgfsys@strcmp\pdfstrcmp
+\else\ifdefined\strcmp
+ \let\pgfsys@strcmp\strcmp
+\else\ifdefined\directlua
+ \directlua{
+ local lft = lua.get_functions_table()
+ lft[\string#lft+1] = function()
+ local lhs = token.scan_string()
+ local rhs = token.scan_string()
+ if lhs < rhs then
+ tex.sprint(-2, "-1")
+ elseif lhs == rhs then
+ tex.sprint(-2, "0")
+ else
+ tex.sprint(-2, "1")
+ end
+ end
+ token.set_lua("pgfsys@strcmp", \string#lft, "global")
+ }
+\else
+ \def\pgfsys@strcmp#1#2{\pgf@sys@fail{string comparison}}%
+\fi\fi\fi
+
+
+% Discern the driver:
+
+% Default driver:
+\ifx\pgfsysdriver\@undefined
+ \pgfutil@guessdriver
+\fi
+
+\input pgf.cfg
+
+\immediate\write-1{Driver file for pgf: \pgfsysdriver}
+\pgfutil@InputIfFileExists{\pgfsysdriver}{}{%
+ \pgferror{Driver file ``\pgfsysdriver'' not found.}}
+
+
+
+% This will insert always-present-specials at the beginning of the
+% code.
+\AtBeginDocument{
+ \pgfsys@atbegindocument
+ \let\pgfsys@atbegindocument=\pgfutil@empty
+}
+
+
+
+% Read aux file in plain and context mode:
+
+\pgfutil@aux@read@hook
+
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/systemlayer/pgfsysanimations.code.tex b/graphics/pgf/base/tex/generic/systemlayer/pgfsysanimations.code.tex
new file mode 100644
index 0000000000..05bf9c3328
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/systemlayer/pgfsysanimations.code.tex
@@ -0,0 +1,2010 @@
+% 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.
+
+
+
+% Guard against reading twice
+\ifx\pgfsysanimationsloaded\pgfutil@undefined
+ \let\pgfsysanimationsloaded=\relax
+\else
+ \expandafter\endinput
+\fi
+
+
+% We need some support:
+\usepgfmodule{decorations}
+
+
+% Animation abstraction layer
+%
+% This layer provides an abstraction of the
+% \pgfsys@anim... commands. The idea is to provide an interface that
+% can map animation commands either to "real" animations (for instance
+% in the sense of SVG) or to "snapshots" of animations, which are
+% especially useful for printing. For these snapshots, instead of
+% adding an animation property to a scope, the property is actually
+% set to a certain value computed by \TeX.
+%
+% For each \pgfsys@animation@... command there is a corresponding
+% \pgfsysanim command.
+
+
+% Set the current time to a snapshot time
+%
+% #1 = a global snapshot time (a dimensionless number, measured in
+% seconds).
+%
+% Description:
+%
+% When this command is used in a scope, instead of creating an
+% animation, pgf will insert appropriate commands that show the state
+% of the animation at the given time.
+%
+% The value #1 can be thought of as the "global time", which can be
+% thought of as the time that elapsed since the "onload" event.
+%
+% The command \pgfsysanimsnapshotafter works the same way as
+% pgfsysanimsnapshot, only the time #1 is interpreted as "global time
+% #1 + epsilon". This means that when two or more values are specified
+% for time #1, the last of them is used rather than the
+% first. Likewise, when a non-freezing timeline ends at time #1,
+% \pgfsysanimsnapshot will set the value to the last value in the
+% timeline, while \pgfsysanimsnapshotafter removes the animation.
+%
+% The following commands and effect for animations are ignored / not
+% implemented for snapshots (meaning that even if the "real" animation
+% would look in a certain way because of one of the following commands
+% or effects, the snapshot will not reflect this):
+%
+% - Events and restarts are ignored. For the snapshot, all animations
+% start at global time 0, except if the command
+% \pgfsysanimkeysnapshotstart is used to specify a different
+% start for a specific animation.
+% - The "current value" as starting value (pgf has no real chance of
+% determining the correct value of this). Using this with a snapshot
+% will raise an error.
+%
+% Example:
+%
+% {
+% \pgfsyssnapshot{2}%
+% \pgfsysanimkeytime{0}{1}{1}{0}{0}
+% \pgfsysanimvalscalar{1}
+% \pgfsysanimkeytime{5}{1}{1}{0}{0}
+% \pgfsysanimvalscalar{0}
+% \pgfsysanimkeywhom{\someid}{}
+% \pgfsysanimate{fillopacity}%
+% % Will set the opacity of \someid to 0.6
+% }
+
+\def\pgfsysanimsnapshot#1{%
+ \def\pgfsysanim@snaptime{#1}%
+ \pgfsysanim@snap@firsttrue%
+ \pgfsysanim@is@snaptrue%
+}
+\def\pgfsysanimsnapshotafter#1{%
+ \def\pgfsysanim@snaptime{#1}%
+ \pgfsysanim@snap@firstfalse%
+ \pgfsysanim@is@snaptrue%
+}
+\newif\ifpgfsysanim@is@snap
+\newif\ifpgfsysanim@snap@first
+
+
+
+% Companion for \pgfsys@animate
+%
+% #1 = attribute
+%
+% Description:
+%
+% If not snapshot is set, \pgfsys@animate is simply called. Otherwise,
+% appropriate code is generated that sets the specified attribute of
+% the whom object to the value it would have during the animation at
+% the moment of the snapshot.
+
+\def\pgfsysanimate#1{%
+ \csname pgfsysanim@checks@#1\endcsname%
+ \ifpgfsysanim@is@snap%
+ \pgfsysanim@do@snap{#1}%
+ \else%
+ \pgfsys@animate{#1}%
+ \fi%
+}
+
+\def\pgfsysanim@do@snap#1{%
+ {%
+ \expandafter\ifx\csname pgfsysanim@prep@attr@#1\endcsname\pgfutil@undefined%
+ \else%
+ % First, compute time frame:
+ \pgfsysanim@compute@interval%
+ % Second, compute code:
+ \let\pgfsysanim@code@begin\relax%
+ \let\pgfsysanim@code@end\pgfutil@empty%
+ \csname pgfsysanim@prep@attr@#1\endcsname%
+ \ifx\pgfsysanim@code@begin\relax%
+ \else%
+ % Attach to object:
+ \expandafter\expandafter\expandafter\pgfsysanim@call@attacher%
+ \expandafter\expandafter\expandafter{\expandafter\pgfsysanim@code@begin\expandafter}\expandafter{\pgfsysanim@code@end}{}%
+ \fi%
+ \fi%
+ }%
+}
+\def\pgfsysanim@call@attacher{\pgfsys@attach@to@id{\pgfsysanim@whom@id}{\pgfsysanim@whom@type}}
+
+
+% Do some checks:
+\def\pgfsysanim@checks@path{%
+ \expandafter\global\expandafter\let\csname pgfsysanim@path@is@animated@\pgfsysanim@whom@id @\pgfsysanim@whom@type\endcsname\pgfutil@empty%
+}
+
+
+% Companions for \pgfsys@animation@restart@...
+%
+% Description:
+%
+% These commands just call \pgfsys@animation@restart@... and they are
+% *ignored* when it comes to snapshots.
+
+\def\pgfsysanimkeyrestartalways{\pgfsys@animation@restart@always}
+\def\pgfsysanimkeyrestartnever{\pgfsys@animation@restart@never}
+\def\pgfsysanimkeyrestartwhennotactive{\pgfsys@animation@restart@whennotactive}
+
+
+
+% Companions for \pgfsys@animation@repeat...
+%
+% Description:
+%
+% These commands call \pgfsys@animation@repeat... and, if there is a
+% snapshot installed, the passed values are taken into consideration.
+
+\def\pgfsysanimkeyrepeat#1{%
+ \pgfsys@animation@repeat{#1}%
+ % Snapshot
+ \let\pgfsysanim@snap@repeat@kind\pgfsysanim@snap@repeat@normal%
+ {%
+ \pgf@x#1pt\relax%
+ \expandafter}%
+ \expandafter\def\expandafter\pgfsysanim@snap@repeat@arg\expandafter{\the\pgf@x}%
+}
+\def\pgfsysanimkeyrepeatindefinite{%
+ \pgfsys@animation@repeat@indefinite%
+ % Snapshot
+ \let\pgfsysanim@snap@repeat@kind\pgfsysanim@snap@repeat@indefinite%
+ \let\pgfsysanim@snap@repeat@arg\pgfutil@empty%
+}
+\def\pgfsysanimkeyrepeatdur#1{%
+ \pgfsys@animation@repeat@dur{#1}%
+ % Snapshot
+ \let\pgfsysanim@snap@repeat@kind\pgfsysanim@snap@repeat@dur%
+ {%
+ \pgf@x#1pt\relax%
+ \expandafter}%
+ \expandafter\def\expandafter\pgfsysanim@snap@repeat@arg\expandafter{\the\pgf@x}%
+}
+\def\pgfsysanim@snap@repeat@none{n}%
+\def\pgfsysanim@snap@repeat@normal{m}%
+\def\pgfsysanim@snap@repeat@indefinite{i}%
+\def\pgfsysanim@snap@repeat@dur{d}%
+\let\pgfsysanim@snap@repeat@kind\pgfsysanim@snap@repeat@none
+\let\pgfsysanim@snap@repeat@arg\pgfutil@empty
+
+
+
+% Companions for \pgfsys@animation@freezeatend and
+% \pgfsys@animation@removeatend
+%
+% Description:
+%
+% These commands call the two system commands and, if there is a
+% snapshot installed, the settings are taken into consideration.
+
+\def\pgfsysanimkeyfreezeatend{\pgfsys@animation@freezeatend\pgfsysanim@freezeatendtrue}
+\def\pgfsysanimkeyremoveatend{\pgfsys@animation@removeatend\pgfsysanim@freezeatendfalse}
+\newif\ifpgfsysanim@freezeatend
+
+
+
+% Companion for \pgfsys@animation@time
+%
+% #1 to #5 = as in \pgfsys@animation@time
+%
+% Description:
+%
+% Calls \pgfsys@animation@time. Furthermore, the specified times are
+% recorded so that they can later be analysed for the computation
+% needed for a snapshot.
+
+\def\pgfsysanimkeytime#1#2#3#4#5{%
+ % Setup animation
+ \pgfsys@animation@time{#1}{#2}{#3}{#4}{#5}%
+ % and remember for snapshots
+ \def\pgfsysanim@time{{#1}{#2}{#3}{#4}{#5}}%
+}
+
+
+% Sets the base value
+%
+% Description:
+%
+% This will set the "base" value for an animation, which is installed
+% prior to any animation of the attribute.
+
+\def\pgfsysanimkeybase{%
+ \pgfsys@animation@base%
+ \let\pgfsysanim@time\pgfsysanim@base@text%
+}
+\def\pgfsysanim@base@text{base}%
+
+% Sets the beginning of the timeline for snapshots
+%
+% #1 = a time (a scalar)
+%
+% Description:
+%
+% Sets the start of current animation to #1 for snapshots. For
+% instance, if #1 is 5 (=five seconds), and you say
+% \pgfsysanimsnapshot{6}, the attribute will be set to whatever the
+% animation specifies after one second.
+
+\def\pgfsysanimkeysnapshotstart#1{%
+ \def\pgfsysanim@snapshotstart{#1}%
+}
+\def\pgfsysanim@snapshotstart{0}
+
+
+% Companion for \pgfsys@animation@offset
+%
+% #1, #2 = as in \pgfsys@animation@offset
+%
+% Description:
+%
+% Calls \pgfsys@animation@offset.
+
+\def\pgfsysanimkeyoffset#1#2{%
+ \pgfsys@animation@offset{#1}{#2}%
+}
+
+
+% Companion for \pgfsys@animation@sync(begin|end)
+%
+% #1 to #4 = as in \pgfsys@animation@sync(begin|end)
+%
+% Description:
+%
+% Calls \pgfsys@animation@sync(begin|end).
+
+\def\pgfsysanimkeysyncbegin#1#2#3#4{%
+ \pgfsys@animation@syncbegin{#1}{#2}{#3}{#4}%
+}
+
+\def\pgfsysanimkeysyncend#1#2#3#4{%
+ \pgfsys@animation@syncend{#1}{#2}{#3}{#4}%
+}
+
+
+% Companion for \pgfsys@animation@event
+%
+% #1 to #5 = as in \pgfsys@animation@event
+%
+% Description:
+%
+% Calls \pgfsys@animation@event.
+
+\def\pgfsysanimkeyevent#1#2#3#4#5{%
+ \pgfsys@animation@event{#1}{#2}{#3}{#4}{#5}%
+}
+
+
+% Companion for \pgfsys@animation@repeat@event
+%
+% #1 to #5 = as in \pgfsys@animation@repeat@event
+%
+% Description:
+%
+% Calls \pgfsys@animation@repeat@event.
+
+\def\pgfsysanimkeyrepeatevent#1#2#3#4#5{%
+ \pgfsys@animation@repeat@event{#1}{#2}{#3}{#4}{#5}%
+}
+
+
+
+% Companion for \pgfsys@animation@accesskey
+%
+% #1 to #3 = as in \pgfsys@animation@accesskey
+%
+% Description:
+%
+% Calls \pgfsys@animation@accesskey.
+
+\def\pgfsysanimkeyaccesskey#1#2#3{%
+ \pgfsys@animation@accesskey{#1}{#2}{#3}%
+}
+
+
+
+
+% Companions for \pgfsys@animation@(no)accumulate
+%
+% Description:
+%
+% Calls \pgfsys@animaion@(no)accumulate and records the setting for
+% snapshots.
+
+\def\pgfsysanimkeyaccumulate{\pgfsys@animation@accumulate\pgfsysanim@accumulatetrue}
+\def\pgfsysanimkeynoaccumulate{\pgfsys@animation@noaccumulate\pgfsysanim@accumulatefalse}
+\newif\ifpgfsysanim@accumulate
+
+
+
+
+% Companion for \pgfsys@animation@whom
+%
+% #1 and #2 = as for \pgfsys@animation@whom
+%
+% Description:
+%
+% Calls \pgfsys@animation@whom and records the setting for snapshots.
+
+\def\pgfsysanimkeywhom#1#2{%
+ \pgfsys@register@type{#2}%
+ \pgfsys@animation@whom{#1}{#2}%
+ % Snapshots
+ \def\pgfsysanim@whom@id{#1}%
+ \def\pgfsysanim@whom@type{#2}%
+}
+
+
+
+
+
+% Companions for \pgfsys@animation@rotatealong and
+% \pgfsys@animation@norotatealong
+%
+% Description:
+%
+% Calls the system layer command and records the setting for
+% snapshots.
+
+\def\pgfsysanimkeyrotatealong{\pgfsys@animation@rotatealong\pgfsysanim@rotatealongtrue}
+\def\pgfsysanimkeynorotatealong{\pgfsys@animation@norotatealong\pgfsysanim@rotatealongfalse}
+\newif\ifpgfsysanim@rotatealong
+
+
+% Companion for \pgfsys@animation@movealong
+%
+% #1 = the path
+%
+% Description:
+%
+% Calls the system layer command and records the setting for
+% snapshots.
+
+\def\pgfsysanimkeymovealong#1{%
+ \pgfsys@animation@movealong{#1}%
+ % Snapshot
+ \def\pgfsysanim@snap@movealong{#1}%
+}
+
+
+
+
+% Companion for \pgfsys@animation@tip@markers
+%
+% #1, #2 = the markers
+%
+% Description:
+%
+% Calls the system layer command and records the setting for
+% snapshots.
+
+\def\pgfsysanimkeytipmarkers#1#2{%
+ \pgfsys@animation@tip@markers{#1}{#2}%
+ % Snapshot
+ \def\pgfsysanim@snap@tip@start{#1}%
+ \def\pgfsysanim@snap@tip@end{#2}%
+}
+\let\pgfsysanim@snap@tip@start\pgfutil@empty%
+\let\pgfsysanim@snap@tip@end\pgfutil@empty%
+
+
+% Companion for \pgfsys@animation@canvas@transform
+%
+% Description:
+%
+% Calls the system layer command and records the setting for
+% snapshots.
+
+\def\pgfsysanimkeycanvastransform#1#2{%
+ \pgfsys@animation@canvas@transform{#1}{#2}%
+ % Snapshot
+ \def\pgfsysanim@snap@canvas@transform@pre{#1}%
+ \def\pgfsysanim@snap@canvas@transform@post{#2}%
+}
+\let\pgfsysanim@snap@canvas@transform@pre\relax
+\let\pgfsysanim@snap@canvas@transform@post\relax
+
+
+
+% Companion for \pgfsys@animation@val@current
+%
+% Description:
+%
+% Calls the system layer command. If a snapshot is currently active,
+% an error results.
+
+\def\pgfsysanimvalcurrent{%
+ \pgfsys@animation@val@current%
+ \ifpgfsysanim@is@snap%
+ \pgferror{You may not use "current value" with an animation snapshot}%
+ \fi%
+}
+
+
+% Suppresses the animation value
+%
+% Description:
+%
+% The animation value is simply ignored.
+
+\def\pgfsysanimvalnone{%
+}
+
+
+
+% Companion for \pgfsys@animation@val@text
+%
+% #1 = as for \pgfsys@animation@val@text
+%
+% Description:
+%
+% Calls the system layer command. If a snapshot is currently active,
+% the value is recorded in the timeline.
+
+\def\pgfsysanimvaltext#1{%
+ \pgfsys@animation@val@text{#1}%
+ \ifpgfsysanim@is@snap%
+ \pgfsysanim@esnap@record{#1}%
+ \fi%
+}
+
+
+
+
+% Companion for \pgfsys@animation@val@scalar
+%
+% #1 = as for \pgfsys@animation@val@scalar
+%
+% Description:
+%
+% Calls the system layer command. If a snapshot is currently active,
+% the value is recorded in the timeline.
+
+\def\pgfsysanimvalscalar#1{%
+ \pgfsys@animation@val@scalar{#1}%
+ \ifpgfsysanim@is@snap%
+ \pgfsysanim@esnap@record{#1}%
+ \fi%
+}
+
+
+
+% Companion for \pgfsys@animation@val@dimension
+%
+% #1 = as for \pgfsys@animation@val@dimension
+%
+% Description:
+%
+% Calls the system layer command. If a snapshot is currently active,
+% the value is recorded in the timeline.
+
+\def\pgfsysanimvaldimension#1{%
+ \pgfsys@animation@val@dimension{#1}%
+ \ifpgfsysanim@is@snap%
+ \pgfsysanim@esnap@record{#1}%
+ \fi%
+}
+
+
+
+% Dispatcher for different color values
+%
+% #1 = a color value (like "red" or "black!20")
+%
+% Description:
+%
+% This macro transforms #1 into its correct color model and, then,
+% calls the correct \pgfsysanimcolor... macro.
+
+\def\pgfsysanimvalcolor#1{%
+ \pgfutil@colorlet{pgf@anim@temp}{#1}%
+ \pgfutil@ifundefined{applycolormixins}{}{\applycolormixins{pgf@anim@temp}}%
+ \expandafter\let\expandafter\pgf@sys@temp\csname\string\color@pgf@anim@temp\endcsname
+ \expandafter\pgfanim@parse@type@color@\pgf@sys@temp%
+}
+\def\pgfanim@parse@type@color@#1#2#3#4#5{%
+ \expandafter\ifx\csname pgfsysanimvalcolor#4\endcsname\relax%
+ \pgferror{Unsupported color model `#4'}%
+ \else%
+ \edef\pgf@sys@colmarshal{\expandafter\noexpand\csname pgfsysanimvalcolor#4\endcsname}%
+ \pgf@sys@uncomma#5,,%
+ \pgf@sys@colmarshal%
+ \fi%
+}
+
+\def\pgf@sys@uncomma#1,{%
+ \def\pgf@sys@coltest{#1}%
+ \ifx\pgf@sys@coltest\pgfutil@empty%
+ \else%
+ \expandafter\def\expandafter\pgf@sys@colmarshal\expandafter{\pgf@sys@colmarshal{#1}}%
+ \expandafter\pgf@sys@uncomma%
+ \fi%
+}
+
+
+
+
+% Companion for \pgfsys@animation@val@color@rgb
+%
+% #1, #2, #3 = as for \pgfsys@animation@val@color@rgb
+%
+% Description:
+%
+% Calls the system layer command. If a snapshot is currently active,
+% the value is recorded in the timeline.
+
+\def\pgfsysanimvalcolorrgb#1#2#3{%
+ \pgfsys@animation@val@color@rgb{#1}{#2}{#3}%
+ \ifpgfsysanim@is@snap%
+ \pgfsysanim@esnap@record{{#1}{#2}{#3}}%
+ \fi%
+}
+
+
+
+% Companion for \pgfsys@animation@val@color@cmyk
+%
+% #1, #2, #3, #4 = as for \pgfsys@animation@val@color@cmyk
+%
+% Description:
+%
+% Calls the system layer command. If a snapshot is currently active,
+% the value is recorded in the timeline.
+
+\def\pgfsysanimvalcolorcmyk#1#2#3#4{%
+ \pgfsys@animation@val@color@cmyk{#1}{#2}{#3}{#4}%
+ \ifpgfsysanim@is@snap%
+ {%
+ \pgf@xa=1pt%
+ \advance\pgf@xa by-#1pt%
+ \advance\pgf@xa by-#4pt\relax%
+ \ifdim\pgf@xa<0pt\pgf@xa0pt\fi%
+ \pgf@xb=1pt%
+ \advance\pgf@xb by-#1pt%
+ \advance\pgf@xb by-#4pt\relax%
+ \ifdim\pgf@xb<0pt\pgf@xb0pt\fi%
+ \pgf@xc=1pt%
+ \advance\pgf@xc by-#1pt%
+ \advance\pgf@xc by-#4pt\relax%
+ \ifdim\pgf@xc<0pt\pgf@xc0pt\fi%
+ \edef\pgfsys@temp{{\pgf@sys@tonumber\pgf@xa}{\pgf@sys@tonumber\pgf@xb}{\pgf@sys@tonumber\pgf@xc}}%
+ \expandafter}%
+ \expandafter\pgfsysanim@esnap@record\expandafter{\pgfsys@temp}%
+ \fi%
+}
+
+
+% Companion for \pgfsys@animation@val@color@cmy
+%
+% #1, #2, #3 = as for \pgfsys@animation@val@color@cmy
+%
+% Description:
+%
+% Calls the system layer command. If a snapshot is currently active,
+% the value is recorded in the timeline.
+
+\def\pgfsysanimvalcolorcmy#1#2#3{%
+ \pgfsys@animation@val@color@cmy{#1}{#2}{#3}%
+ \ifpgfsysanim@is@snap%
+ {%
+ \pgf@xa=1pt%
+ \advance\pgf@xa by-#1pt%
+ \pgf@xb=1pt%
+ \advance\pgf@xb by-#1pt%
+ \pgf@xc=1pt%
+ \advance\pgf@xc by-#1pt%
+ \edef\pgfsys@temp{{\pgf@sys@tonumber\pgf@xa}{\pgf@sys@tonumber\pgf@xb}{\pgf@sys@tonumber\pgf@xc}}%
+ \expandafter}%
+ \expandafter\pgfsysanim@esnap@record\expandafter{\pgfsys@temp}%
+ \fi%
+}
+
+
+
+% Companion for \pgfsys@animation@val@color@gray
+%
+% #1 = as for \pgfsys@animation@val@color@gray
+%
+% Description:
+%
+% Calls the system layer command. If a snapshot is currently active,
+% the value is recorded in the timeline.
+
+\def\pgfsysanimvalcolorgray#1{%
+ \pgfsys@animation@val@color@gray{#1}%
+ \ifpgfsysanim@is@snap%
+ \pgfsysanim@esnap@record{{#1}{#1}{#1}}%
+ \fi%
+}
+
+
+
+% Special companion for \pgfsys@animation@val@path
+%
+% #1 = as for \pgfsys@animation@val@path
+%
+% Description:
+%
+% Calls the system layer command. If a snapshot is currently active,
+% the value is recorded in the timeline.
+
+\def\pgfsysanimvalpath#1{%
+ \pgfsys@animation@val@path{#1}%
+ \ifpgfsysanim@is@snap%
+ \pgfsysanim@snap@record{#1}%
+ \fi%
+}
+
+
+% Companion for \pgfsys@animation@val@translate
+%
+% #1, #2 = as for \pgfsys@animation@val@translate
+%
+% Description:
+%
+% Calls the system layer command. If a snapshot is currently active,
+% the value is recorded in the timeline.
+
+\def\pgfsysanimvaltranslate#1#2{%
+ \pgfsys@animation@val@translate{#1}{#2}%
+ \ifpgfsysanim@is@snap%
+ \pgfsysanim@esnap@record{{#1}{#2}}%
+ \fi%
+}
+
+
+
+% Companion for \pgfsys@animation@val@scale
+%
+% #1, #2 = as for \pgfsys@animation@val@scale
+%
+% Description:
+%
+% Calls the system layer command. If a snapshot is currently active,
+% the value is recorded in the timeline.
+
+\def\pgfsysanimvalscale#1#2{%
+ \pgfsys@animation@val@scale{#1}{#2}%
+ \ifpgfsysanim@is@snap%
+ \pgfsysanim@esnap@record{{#1}{#2}}%
+ \fi%
+}
+
+
+
+% Companion for \pgfsys@animation@val@viewbox
+%
+% #1, #2, #3, #4 = as for \pgfsys@animation@val@viewbox
+%
+% Description:
+%
+% Calls the system layer command. If a snapshot is currently active,
+% the value is recorded in the timeline.
+
+\def\pgfsysanimvalviewbox#1#2#3#4{%
+ \pgfsys@animation@val@viewbox{#1}{#2}{#3}{#4}%
+ \ifpgfsysanim@is@snap%
+ \pgfsysanim@esnap@record{{#1}{#2}{#3}{#4}}%
+ \fi%
+}
+
+
+
+
+% Companion for \pgfsys@animation@val@dash
+%
+% #1, #2 = as for \pgfsys@animation@val@dash
+%
+% Description:
+%
+% Calls the system layer command. If a snapshot is currently active,
+% the value is recorded in the timeline.
+
+\def\pgfsysanimvaldash#1#2{%
+ \pgfsys@animation@val@dash{#1}{#2}%
+ \ifpgfsysanim@is@snap%
+ \pgfsysanim@esnap@record{{#1}{#2}}%
+ \fi%
+}
+
+
+
+
+
+%
+% Recording mechanism: We record entries in an array.
+%
+
+\def\pgfsysanim@esnap@record#1{% records a new entry for the timeline
+ \edef\pgfsysanim@temp{#1}%
+ \expandafter\pgfsysanim@snap@record\expandafter{\pgfsysanim@temp}%
+}
+\def\pgfsysanim@snap@record#1{% records a new entry for the timeline
+ \ifx\pgfsysanim@time\pgfsysanim@base@text%
+ \def\pgfsysanim@base@value{#1}%
+ \else%
+ \advance\pgfsysanim@snap@count by1\relax%
+ \expandafter\def\expandafter\pgfsysanim@temp\expandafter{\pgfsysanim@time{#1}}%
+ \expandafter\let\csname pgfsysanim@snap@\the\pgfsysanim@snap@count\endcsname\pgfsysanim@temp%
+ \fi%
+}
+\newcount\pgfsysanim@snap@count
+\let\pgfsysanim@base@value\pgfutil@empty%
+
+
+% Compute the time-value interval of the snapshot: Based on the value of \pgfsysanim@snaptime,
+% computes the interval containing the specified time. This interval
+% will start at \pgfsysanim@prev@time and end at
+% \pgfsysanim@next@time. The values will be \pgfsysanim@prev@val and
+% \pgfsysanim@next@val.
+%
+\def\pgfsysanim@compute@interval{%
+ \let\pgfsysanim@prev@val\relax%
+ \let\pgfsysanim@prev@time\relax%
+ \let\pgfsysanim@prev@spline\pgfsysanim@default@spline%
+ \let\pgfsysanim@next@val\relax%
+ \let\pgfsysanim@next@time\relax%
+ \let\pgfsysanim@next@spline\pgfsysanim@default@spline%
+ \let\pgfsysanim@first@time\relax%
+ \let\pgfsysanim@last@time\relax%
+ \let\pgfsysanim@last@val\relax%
+ \ifnum\pgfsysanim@snap@count>0\relax%
+ \pgf@xc\pgfsysanim@snaptime pt\relax%
+ \pgf@x\pgfsysanim@snapshotstart pt\relax%
+ \advance\pgf@xc-\pgf@x\relax%
+ % Compute the start and end times:
+ \pgfsysanim@compute@start@end%
+ \pgfsysanim@compute@value%
+ \fi%
+ % Test whether a valid interval has been found:
+ \pgfsysanim@valid@snapshot@timefalse%
+ \ifx\pgfsysanim@prev@time\relax%
+ \else\ifx\pgfsysanim@next@time\relax%
+ \else\pgfsysanim@valid@snapshot@timetrue%
+ \fi\fi%
+ \ifpgfsysanim@valid@snapshot@time%
+ % ok, computed later
+ \else%
+ \ifx\pgfsysanim@base@value\pgfutil@empty%
+ \else%
+ % Ah, use base value!
+ \let\pgfsysanim@prev@val\pgfsysanim@base@value%
+ \def\pgfsysanim@prev@time{0}%
+ \let\pgfsysanim@prev@spline\pgfsysanim@default@spline%
+ \let\pgfsysanim@next@val\pgfsysanim@base@value%
+ \let\pgfsysanim@next@time\pgfsysanim@prev@time%
+ \let\pgfsysanim@next@spline\pgfsysanim@default@spline%
+ \def\pgfsysanim@first@time{-16382}%
+ \let\pgfsysanim@last@time\pgfsysanim@prev@time%
+ \let\pgfsysanim@last@val\pgfsysanim@base@value%
+ \def\pgfsysanim@frac@a{1}%
+ \def\pgfsysanim@frac@b{0}%
+ \pgfsysanim@valid@snapshot@timetrue% counts as valid!
+ \fi%
+ \fi%
+}
+\newif\ifpgfsysanim@cont%
+\newif\ifpgfsysanim@valid@snapshot@time
+\def\pgfsysanim@default@spline{{0}{0}{1}{1}}
+
+\def\pgfsysanim@compute@start@end{%
+ \expandafter\expandafter\expandafter\pgfsysanim@compute@start\csname pgfsysanim@snap@1\endcsname%
+ \expandafter\expandafter\expandafter\pgfsysanim@compute@end\csname pgfsysanim@snap@\the\pgfsysanim@snap@count\endcsname%
+}
+\def\pgfsysanim@compute@start#1#2#3#4#5#6{%
+ \def\pgfsysanim@first@time{#1}%
+}
+\def\pgfsysanim@compute@end#1#2#3#4#5#6{%
+ \def\pgfsysanim@last@time{#1}%
+ \def\pgfsysanim@last@val{#6}%
+}
+
+
+\def\pgfsysanim@compute@value{%
+ % First, are we before start?
+ \ifdim\pgf@xc<\pgfsysanim@first@time pt\relax%
+ % snapshot time (xc) is before start of animation. So, nothing happens:
+ \else%
+ \ifx\pgfsysanim@snap@repeat@kind\pgfsysanim@snap@repeat@none%
+ \pgfsysanim@handle@repeat@none%
+ \else\ifx\pgfsysanim@snap@repeat@kind\pgfsysanim@snap@repeat@normal%
+ \pgfsysanim@handle@repeat@normal%
+ \else\ifx\pgfsysanim@snap@repeat@kind\pgfsysanim@snap@repeat@indefinite%
+ \pgfsysanim@handle@repeat@indefinite%
+ \else\ifx\pgfsysanim@snap@repeat@kind\pgfsysanim@snap@repeat@dur%
+ \pgfsysanim@handle@repeat@dur%
+ \fi\fi\fi\fi%
+ \fi%
+}
+
+\def\pgfsysanim@handle@repeat@none{%
+ \ifdim\pgf@xc<\pgfsysanim@last@time pt\relax%
+ \pgfsysanim@compute@time%
+ \else%
+ \ifdim\pgf@xc=\pgfsysanim@last@time pt\relax%
+ % A bit tricky:
+ \ifpgfsysanim@snap@first%
+ \pgfsysanim@compute@time%
+ \else%
+ \ifpgfsysanim@freezeatend%
+ \let\pgfsysanim@prev@val\pgfsysanim@last@val%
+ \let\pgfsysanim@prev@time\pgfsysanim@last@time%
+ \let\pgfsysanim@next@val\pgfsysanim@last@val%
+ \let\pgfsysanim@next@time\pgfsysanim@last@time%
+ \fi%
+ \fi%
+ \else%
+ % Called when we are past the end.
+ \ifpgfsysanim@freezeatend%
+ \let\pgfsysanim@prev@val\pgfsysanim@last@val%
+ \let\pgfsysanim@prev@time\pgfsysanim@last@time%
+ \let\pgfsysanim@next@val\pgfsysanim@last@val%
+ \let\pgfsysanim@next@time\pgfsysanim@last@time%
+ \fi%
+ \fi%
+ \fi%
+}
+
+
+\def\pgfsysanim@handle@repeat@indefinite{%
+ \ifdim\pgf@xc<\pgfsysanim@last@time pt\relax%
+ \pgfsysanim@compute@time%
+ \else%
+ % Compute interval length
+ \pgf@xa=\pgfsysanim@last@time pt%
+ \pgf@xb=\pgfsysanim@first@time pt%
+ \advance\pgf@xa by-\pgf@xb%
+ % Compute repeat count and fraction:
+ \pgf@ya\pgf@xc%
+ \advance\pgf@ya by-\pgf@xb%
+ \ifdim\pgf@xa<0.01pt\relax%
+ % Interval too small: Goto end of interval
+ \def\pgfmathresult{1.0}%
+ \else%
+ \pgfmathdivide@{\pgf@sys@tonumber\pgf@ya}{\pgf@sys@tonumber\pgf@xa}%
+ \fi%
+ \pgf@x\pgfmathresult pt\relax%
+ \expandafter\pgfsysanim@splitter\the\pgf@x%
+ \pgf@xc=\pgfsysanim@repeat@frac\pgf@xa%
+ \advance\pgf@xc by\pgf@xb%
+ \pgfsysanim@compute@time%
+ \fi%
+}
+{\catcode`\p=12\catcode`\t=12\gdef\Pgfsysanim@sPliTTer#1.#2pt{\Pgfsysanim@seTTer{#1}{#2}}}
+\let\pgfsysanim@splitter\Pgfsysanim@sPliTTer
+\def\Pgfsysanim@seTTer#1#2{%
+ \def\pgfsysanim@repeat@decimal{#1}%
+ \def\pgfsysanim@repeat@frac{.#2}%
+ \ifdim\pgfsysanim@repeat@frac pt=0pt% goto one before:
+ \c@pgf@counta\pgfsysanim@repeat@decimal%
+ \advance\c@pgf@counta by-1\relax%
+ \edef\pgfsysanim@repeat@decimal{\the\c@pgf@counta}%
+ \def\pgfsysanim@repeat@frac{1}%
+ \fi%
+}
+\def\pgfsysanim@repeat@decimal{0}%
+
+
+\def\pgfsysanim@handle@repeat@normal{%
+ % Compute interval length
+ \pgf@xa=\pgfsysanim@last@time pt%
+ \pgf@xb=\pgfsysanim@first@time pt%
+ \advance\pgf@xa by-\pgf@xb%
+ % Compute repeat count and fraction:
+ \pgf@ya\pgf@xc%
+ \advance\pgf@ya by-\pgf@xb%
+ \ifdim\pgf@xa<0.01pt\relax%
+ % Interval too small: Goto end of interval
+ \def\pgfmathresult{1.0}%
+ \else%
+ \pgfmathdivide@{\pgf@sys@tonumber\pgf@ya}{\pgf@sys@tonumber\pgf@xa}%
+ \fi%
+ \pgf@x\pgfmathresult pt\relax%
+ \expandafter\pgfsysanim@splitter\the\pgf@x%
+ % Cases:
+ \ifdim\pgfmathresult pt<\pgfsysanim@snap@repeat@arg\relax%
+ % Ok! Compute!
+ \pgf@xc=\pgfsysanim@repeat@frac\pgf@xa%
+ \advance\pgf@xc by\pgf@xb%
+ \pgfsysanim@compute@time%
+ \else%
+ % Hmm. Freeze?
+ \ifpgfsysanim@freezeatend%
+ \expandafter\pgfsysanim@splitter\pgfsysanim@snap@repeat@arg%
+ \pgf@xc=\pgfsysanim@repeat@frac\pgf@xa%
+ \advance\pgf@xc by\pgf@xb%
+ \pgfsysanim@compute@time%
+ \else%
+ \ifdim\pgfmathresult pt=\pgfsysanim@snap@repeat@arg\relax%
+ \ifpgfsysanim@snap@first%
+ \expandafter\pgfsysanim@splitter\pgfsysanim@snap@repeat@arg%
+ \pgf@xc=\pgfsysanim@repeat@frac\pgf@xa%
+ \advance\pgf@xc by\pgf@xb%
+ \pgfsysanim@compute@time%
+ \fi%
+ % else: nothing!
+ \fi%
+ \fi%
+ \fi%
+}
+
+\def\pgfsysanim@handle@repeat@dur{%
+ \pgf@yb=\pgfsysanim@first@time pt%
+ \advance\pgf@yb by\pgfsysanim@snap@repeat@arg\relax%
+ \ifdim\pgf@xc<\pgf@yb% inside interval
+ \pgf@xa=\pgfsysanim@last@time pt%
+ \pgf@xb=\pgfsysanim@first@time pt%
+ \advance\pgf@xa by-\pgf@xb%
+ % Compute repeat count and fraction:
+ \pgf@ya\pgf@xc%
+ \advance\pgf@ya by-\pgf@xb%
+ \ifdim\pgf@xa<0.01pt\relax%
+ % Interval too small: Goto end of interval
+ \def\pgfmathresult{1.0}%
+ \else%
+ \pgfmathdivide@{\pgf@sys@tonumber\pgf@ya}{\pgf@sys@tonumber\pgf@xa}%
+ \fi%
+ \pgf@x\pgfmathresult pt\relax%
+ \expandafter\pgfsysanim@splitter\the\pgf@x%
+ %
+ \pgf@xc=\pgfsysanim@repeat@frac\pgf@xa%
+ \advance\pgf@xc by\pgf@xb%
+ \pgfsysanim@compute@time%
+ \else%
+ \ifpgfsysanim@freezeatend%
+ \pgfsysanim@handle@repeat@dur@freeze%
+ \else%
+ \ifdim\pgf@xc=\pgf@yb%
+ \ifpgfsysanim@snap@first%
+ \pgfsysanim@handle@repeat@dur@freeze%
+ \fi%
+ \fi%
+ \fi%
+ \fi%
+}
+
+\def\pgfsysanim@handle@repeat@dur@freeze{%
+ \pgf@xa=\pgfsysanim@last@time pt%
+ \pgf@xb=\pgfsysanim@first@time pt%
+ \advance\pgf@xa by-\pgf@xb%
+ % Compute repeat count and fraction:
+ \ifdim\pgf@xa<0.01pt\relax%
+ % Interval too small: Goto end of interval
+ \def\pgfmathresult{1.0}%
+ \else%
+ % `\pgfsysanim@snap@repeat@arg` is a macro storing a dimen value, eg "4.0pt"
+ \pgfmathdivide@{\pgf@sys@tonumber\dimexpr\pgfsysanim@snap@repeat@arg}{\pgf@sys@tonumber\pgf@xa}%
+ \fi%
+ \pgf@x\pgfmathresult pt\relax%
+ \expandafter\pgfsysanim@splitter\the\pgf@x%
+ %
+ \pgf@xc=\pgfsysanim@repeat@frac\pgf@xa%
+ \advance\pgf@xc by\pgf@xb%
+ \pgfsysanim@compute@time%
+}
+
+
+
+
+
+\def\pgfsysanim@compute@time{%
+ % Ok, let us iterate over all points of time.
+ \pgfutil@tempcnta=1\relax%
+ \pgfsysanim@conttrue%
+ \pgfutil@loop%
+ \ifnum\pgfutil@tempcnta>\pgfsysanim@snap@count%
+ \pgfsysanim@contfalse%
+ \else%
+ \expandafter\let\expandafter\pgfsys@temp\csname pgfsysanim@snap@\the\pgfutil@tempcnta\endcsname%
+ \expandafter\pgfsysanim@test@time\pgfsys@temp%
+ \fi%
+ \ifpgfsysanim@cont%
+ \advance\pgfutil@tempcnta by1\relax%
+ \pgfutil@repeat%
+}
+
+
+\def\pgfsysanim@test@time#1#2#3#4#5#6{%
+ % #1 = time in seconds
+ % #2 to #5 = spline controls
+ % #6 = value
+ \ifdim#1pt<\pgf@xc%
+ % snap time not yet reached. Update previous:
+ \def\pgfsysanim@prev@val{#6}%
+ \def\pgfsysanim@prev@time{#1}%
+ \def\pgfsysanim@prev@spline{{#2}{#3}{#4}{#5}}%
+ \else%
+ \ifdim#1pt=\pgf@xc%
+ \ifpgfsysanim@snap@first%
+ \ifx\pgfsysanim@next@val\relax%
+ % first? Save!
+ \def\pgfsysanim@prev@val{#6}%
+ \def\pgfsysanim@prev@time{#1}%
+ \def\pgfsysanim@prev@spline{{#2}{#3}{#4}{#5}}%
+ \let\pgfsysanim@next@val\pgfsysanim@prev@val%
+ \let\pgfsysanim@next@time\pgfsysanim@prev@time%
+ \let\pgfsysanim@next@spline\pgfsysanim@prev@spline%
+ \pgfsysanim@contfalse%
+ % else, do nothing
+ \fi
+ \else%
+ % always overwrite:
+ \def\pgfsysanim@prev@val{#6}%
+ \def\pgfsysanim@prev@time{#1}%
+ \def\pgfsysanim@prev@spline{{#2}{#3}{#4}{#5}}%
+ \let\pgfsysanim@next@val\pgfsysanim@prev@val%
+ \let\pgfsysanim@next@time\pgfsysanim@prev@time%
+ \let\pgfsysanim@next@spline\pgfsysanim@prev@spline%
+ \fi%
+ \else%
+ % we passed the time!
+ \ifx\pgfsysanim@next@val\relax%
+ % first? Then save!
+ \def\pgfsysanim@next@val{#6}%
+ \def\pgfsysanim@next@time{#1}%
+ \def\pgfsysanim@next@spline{{#2}{#3}{#4}{#5}}%
+ \else%
+ % ignore later times!
+ \pgfsysanim@contfalse%
+ \fi%
+ \fi%
+ \fi%
+}
+
+\let\pgfsysanim@prev@val\relax%
+\let\pgfsysanim@prev@time\relax%
+\let\pgfsysanim@next@val\relax%
+\let\pgfsysanim@next@time\relax%
+
+% Help function
+\def\pgfsysanim@attach#1#2#3{%
+ \expandafter\pgfsysanim@prep@beg\expandafter{\pgfsysanim@first@time}{#2}{#3}%
+ \expandafter\def\expandafter\pgfsysanim@code@main\expandafter{\csname pgfsysanim@main@of@\pgfsysanim@whom@id @\pgfsysanim@whom@type @#1\endcsname}%
+ \expandafter\ifx\pgfsysanim@code@main\relax%
+ \edef\pgfsysanim@code@begin{%
+ \let\noexpand\pgfsysanim@c@begin\noexpand\pgfutil@empty%
+ \let\noexpand\pgfsysanim@c@end\noexpand\pgfutil@empty%
+ \pgfsysanim@lasttime-16383pt\relax%
+ \expandafter\noexpand\pgfsysanim@code@main%
+ \global\let\expandafter\noexpand\pgfsysanim@code@main\relax%
+ \noexpand\pgfsysanim@c@begin%
+ }%
+ \let\pgfsysanim@code@end\pgfsysanim@code@closer%
+ \expandafter\global\expandafter\let\pgfsysanim@code@main\pgfutil@empty%
+ \else%
+ \let\pgfsysanim@code@begin\relax%
+ \let\pgfsysanim@code@end\relax%
+ \fi%
+ \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\pgfsysanim@new@main%
+ \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter{\expandafter\pgfsysanim@code@main\pgfsysanim@add@main}
+ \expandafter\global\expandafter\let\pgfsysanim@code@main\pgfsysanim@new@main%
+}
+\def\pgfsysanim@code@closer{\pgfsysanim@c@end}
+
+\def\pgfsysanim@prep@beg#1#2#3{%
+ \edef\pgfsysanim@add@main{%
+ \noexpand\ifdim\pgfsysanim@lasttime>#1pt%
+ % ignore!
+ \noexpand\else%
+ \pgfsysanim@lasttime#1pt%
+ \def\noexpand\pgfsysanim@c@begin{#2}%
+ \def\noexpand\pgfsysanim@c@end{#3}%
+ \noexpand\fi%
+ }
+}
+
+\def\pgfsysanim@prep@beg@special#1#2{%
+ \def\pgfsysanim@add@main{%
+ \ifdim\pgfsysanim@lasttime>#1pt%
+ % ignore!
+ \else%
+ \pgfsysanim@lasttime#1pt%
+ \def\pgfsysanim@c@begin{#2}%
+ \fi%
+ }
+}
+
+
+
+\def\pgfsysanim@attach@special#1#2{%
+ \expandafter\expandafter\expandafter\pgfsysanim@prep@beg@special\expandafter\expandafter\expandafter{\expandafter\pgfsysanim@first@time\expandafter}\expandafter{#2}%
+ \ifx#1\relax%
+ \def#1{%
+ \pgfsysanim@lasttime-16383pt\relax%
+ \let\pgfsysanim@c@begin\pgfutil@empty%
+ }%
+ \fi%
+ \expandafter\expandafter\expandafter\gdef\expandafter\expandafter\expandafter#1\expandafter\expandafter\expandafter{\expandafter#1\pgfsysanim@add@main}%
+}
+
+
+
+\newdimen\pgfsysanim@lasttime
+
+
+\def\pgfsysanim@add@trans{%
+ \ifx\pgfsysanim@snap@canvas@transform@pre\relax%
+ \else%
+ \ifx\pgfsysanim@code@begin\relax%
+ \let\pgfsysanim@code@begin\pgfutil@empty%
+ \fi%
+ \pgfsysanim@add@trans@%
+ \fi%
+}
+\def\pgfsysanim@add@trans@{%
+ \toks0\expandafter{\pgfsysanim@snap@canvas@transform@pre}%
+ \toks1\expandafter{\pgfsysanim@code@begin}%
+ \toks2\expandafter{\pgfsysanim@snap@canvas@transform@post}%
+ \edef\pgfsysanim@code@begin{{\the\toks0 \the\toks1 \the\toks2}}%
+}
+
+% The code for the different attributes
+
+\def\pgfsysanim@prep@attr@opacity{%
+ \ifpgfsysanim@valid@snapshot@time%
+ \pgfsysanim@comp@scalar%
+ \pgfsysanim@cap@scalar{\pgfsysanim@x@val}{0}{1}%
+ \pgfsysanim@attach{opacity}{\noexpand\pgfsys@opacity{\pgfsysanim@x@val}}{}%
+ \fi%
+}
+
+\def\pgfsysanim@prep@attr@fillopacity{%
+ \ifpgfsysanim@valid@snapshot@time%
+ \pgfsysanim@comp@scalar%
+ \pgfsysanim@cap@scalar{\pgfsysanim@x@val}{0}{1}%
+ \pgfsysanim@attach{fillopacity}{\noexpand\pgfsys@fill@opacity{\pgfsysanim@x@val}}{}%
+ \fi%
+}
+
+\def\pgfsysanim@prep@attr@strokeopacity{%
+ \ifpgfsysanim@valid@snapshot@time%
+ \pgfsysanim@comp@scalar%
+ \pgfsysanim@cap@scalar{\pgfsysanim@x@val}{0}{1}%
+ \pgfsysanim@attach{strokeopacity}{\noexpand\pgfsys@stroke@opacity{\pgfsysanim@x@val}}{}%
+ \fi%
+}
+
+\def\pgfsysanim@prep@attr@visibility{%
+ \ifpgfsysanim@valid@snapshot@time%
+ \pgfsysanim@comp@text%
+ \ifx\pgfsysanim@text@val\pgf@hidden@text%
+ \pgfsysanim@attach{visibility}{\noexpand\pgfsys@begininvisiblescope}{\noexpand\pgfsys@endinvisiblescope}%
+ \else%
+ \pgfsysanim@attach{visibility}{}{}%
+ \fi%
+ \fi%
+}
+\def\pgf@hidden@text{hidden}
+
+\def\pgfsysanim@prep@attr@linewidth{%
+ \ifpgfsysanim@valid@snapshot@time%
+ \pgfsysanim@comp@dimension%
+ \pgfsysanim@cap@scalar{\pgfsysanim@x@val}{0}{16382}%
+ \pgfsysanim@attach{linewidth}{\noexpand\pgfsys@setlinewidth{\pgfsysanim@x@val pt}}{}%
+ \fi%
+}
+
+\def\pgfsysanim@prep@attr@dash{%
+ \ifpgfsysanim@valid@snapshot@time%
+ \pgfsysanim@comp@dash%
+ \pgfsysanim@attach{dash}{\noexpand\pgfsys@setdash{\pgfsysanim@dash@vals}{\pgfsysanim@x@val pt}}{}%
+ \fi%
+}
+
+\def\pgfsysanim@prep@attr@translate{%
+ \ifpgfsysanim@valid@snapshot@time%
+ \pgfsysanim@comp@translate%
+ \edef\pgfsysanim@code@begin{\noexpand\pgfsys@transformshift{\pgfsysanim@x@val pt}{\pgfsysanim@y@val pt}}%
+ \fi%
+ \pgfsysanim@add@trans%
+}
+
+
+\def\pgfsysanim@prep@attr@scale{%
+ \ifpgfsysanim@valid@snapshot@time%
+ \pgfsysanim@comp@scale%
+ \edef\pgfsysanim@code@begin{\noexpand\pgfsys@transformxyscale{\pgfsysanim@x@val}{\pgfsysanim@y@val}}%
+ \fi%
+ \pgfsysanim@add@trans%
+}
+
+\def\pgfsysanim@prep@attr@rotate{%
+ \ifpgfsysanim@valid@snapshot@time%
+ \pgfsysanim@comp@scalar%
+ {%
+ \pgfmathsin@{\pgfsysanim@x@val}%
+ \let\pgftransform@sin=\pgfmathresult%
+ \pgfmathcos@{\pgfsysanim@x@val}%
+ \let\pgftransform@cos=\pgfmathresult%
+ \pgf@x=\pgftransform@sin pt%
+ \pgf@xa=-\pgf@x%
+ \edef\pgfsysanim@code@begin{\noexpand\pgfsys@transformcm{\pgftransform@cos}{\pgftransform@sin}{\pgf@sys@tonumber{\pgf@xa}}{\pgftransform@cos}{0pt}{0pt}}%
+ \expandafter}%
+ \expandafter\def\expandafter\pgfsysanim@code@begin\expandafter{\pgfsysanim@code@begin}%
+ \fi%
+ \pgfsysanim@add@trans%
+}
+
+\def\pgfsysanim@prep@attr@skewx{%
+ \ifpgfsysanim@valid@snapshot@time%
+ \pgfsysanim@comp@scalar%
+ {%
+ \pgfmathtan@{\pgfsysanim@x@val}%
+ \edef\pgfsysanim@code@begin{\noexpand\pgfsys@transformcm{1}{0}{\pgfmathresult}{1}{0pt}{0pt}}%
+ \expandafter}%
+ \expandafter\def\expandafter\pgfsysanim@code@begin\expandafter{\pgfsysanim@code@begin}%
+ \fi%
+ \pgfsysanim@add@trans%
+}
+
+\def\pgfsysanim@prep@attr@skewy{%
+ \ifpgfsysanim@valid@snapshot@time%
+ \pgfsysanim@comp@scalar%
+ {%
+ \pgfmathtan@{\pgfsysanim@x@val}%
+ \edef\pgfsysanim@code@begin{\noexpand\pgfsys@transformcm{1}{\pgfmathresult}{0}{1}{0pt}{0pt}}%
+ \expandafter}%
+ \expandafter\def\expandafter\pgfsysanim@code@begin\expandafter{\pgfsysanim@code@begin}%
+ \fi%
+ \pgfsysanim@add@trans%
+}
+
+\def\pgfsysanim@prep@attr@motion{%
+ \ifx\pgfsysanim@base@value\pgfutil@empty%
+ \else%
+ \pgferror{You may not provide a base value for a motion}%
+ \let\pgfsysanim@base@value\pgfutil@empty%
+ \fi%
+ \ifpgfsysanim@valid@snapshot@time%
+ \pgfsysanim@comp@motion%
+ \expandafter\pgfsysanim@prep@attr@motion@\pgfsysanim@motion@trans%
+ \fi%
+ \pgfsysanim@add@trans%
+}
+\def\pgfsysanim@prep@attr@motion@#1#2#3#4#5#6{%
+ \ifpgfsysanim@rotatealong%
+ \def\pgfsysanim@code@begin{\pgfsys@transformcm{#1}{#2}{#3}{#4}{#5}{#6}}%
+ \else%
+ \def\pgfsysanim@code@begin{\pgfsys@transformshift{#5}{#6}}%
+ \fi%
+}
+
+
+\def\pgfsysanim@prep@attr@strokecolor{%
+ \ifpgfsysanim@valid@snapshot@time%
+ \pgfsysanim@comp@color%
+ \pgfsysanim@cap@scalar{\pgfsysanim@x@val}{0}{1}%
+ \pgfsysanim@cap@scalar{\pgfsysanim@y@val}{0}{1}%
+ \pgfsysanim@cap@scalar{\pgfsysanim@z@val}{0}{1}%
+ \pgfsysanim@attach{strokecolor}{\noexpand\pgfsys@color@rgb@stroke{\pgfsysanim@x@val}{\pgfsysanim@y@val}{\pgfsysanim@z@val}}{}%
+ \fi%
+}
+
+\def\pgfsysanim@prep@attr@fillcolor{%
+ \ifpgfsysanim@valid@snapshot@time%
+ \pgfsysanim@comp@color%
+ \pgfsysanim@cap@scalar{\pgfsysanim@x@val}{0}{1}%
+ \pgfsysanim@cap@scalar{\pgfsysanim@y@val}{0}{1}%
+ \pgfsysanim@cap@scalar{\pgfsysanim@z@val}{0}{1}%
+ \pgfsysanim@attach{fillcolor}{\noexpand\pgfsys@color@rgb@fill{\pgfsysanim@x@val}{\pgfsysanim@y@val}{\pgfsysanim@z@val}}{}%
+ \fi%
+}
+
+\def\pgfsysanim@prep@attr@color{%
+ \ifpgfsysanim@valid@snapshot@time%
+ \pgfsysanim@comp@color%
+ \pgfsysanim@cap@scalar{\pgfsysanim@x@val}{0}{1}%
+ \pgfsysanim@cap@scalar{\pgfsysanim@y@val}{0}{1}%
+ \pgfsysanim@cap@scalar{\pgfsysanim@z@val}{0}{1}%
+ \pgfsysanim@attach{color}{\noexpand\pgfsys@color@rgb{\pgfsysanim@x@val}{\pgfsysanim@y@val}{\pgfsysanim@z@val}}{}%
+ \fi%
+}
+
+\newif\ifpgfsys@animation@view@hooked
+
+\def\pgfsysanim@prep@attr@viewbox{%
+ \ifpgfsysanim@valid@snapshot@time%
+ \pgfsysanim@comp@viewbox%
+ \pgfsys@attach@to@id{\pgfsysanim@whom@id}{}{%
+ \ifpgfsys@animation@view@hooked%
+ \else%
+ % Hook into viewbox systems layer commands
+ \let\pgfsys@viewboxmeet@orig\pgfsys@viewboxmeet%
+ \let\pgfsys@viewboxmeet\pgfsysanim@hooked@viewboxmeet%
+ \let\pgfsys@viewboxslice@orig\pgfsys@viewboxslice%
+ \let\pgfsys@viewboxslice\pgfsysanim@hooked@viewboxslice%
+ \pgfsys@animation@view@hookedtrue%
+ \fi%
+ }{}{}%
+ \edef\pgfsysanim@temp{{\pgfsysanim@x@val}{\pgfsysanim@y@val}{\pgfsysanim@z@val}{\pgfsysanim@w@val}}%
+ \expandafter\pgfsysanim@attach@special\csname pgfsysanim@hook@for@\pgfsys@id@ref{\pgfsysanim@whom@id}{\pgfsysanim@whom@type}\endcsname\pgfsysanim@temp%
+ \fi%
+}
+\def\pgfsysanim@hooked@viewboxmeet#1#2#3#4#5#6#7#8{%
+ \expandafter\ifx\csname pgfsysanim@hook@for@\pgfsys@id@refcurrent\endcsname\relax%
+ \pgfsys@viewboxmeet@orig{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}%
+ \else%
+ \csname pgfsysanim@hook@for@\pgfsys@id@refcurrent\endcsname%
+ \ifx\pgfsysanim@c@begin\pgfutil@empty%
+ % should not happen, but, then, ignore
+ \else%
+ \expandafter\pgfsysanim@hooked@viewboxmeet@\pgfsysanim@c@begin{#1}{#2}{#3}{#4}%
+ \fi%
+ \expandafter\global\expandafter\let\csname pgfsysanim@hook@for@\pgfsys@id@refcurrent\endcsname\relax%
+ \fi%
+}
+\def\pgfsysanim@hooked@viewboxmeet@#1#2#3#4#5#6#7#8{%
+ \pgfsys@viewboxmeet@orig{#5}{#6}{#7}{#8}{#1}{#2}{#3}{#4}%
+}
+\def\pgfsysanim@hooked@viewboxslice#1#2#3#4#5#6#7#8{%
+ \expandafter\ifx\csname pgfsysanim@hook@for@\pgfsys@id@refcurrent\endcsname\relax%
+ \pgfsys@viewboxslice@orig{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}%
+ \else%
+ \csname pgfsysanim@hook@for@\pgfsys@id@refcurrent\endcsname%
+ \expandafter\pgfsysanim@hooked@viewboxslice@\pgfsysanim@c@begin{#1}{#2}{#3}{#4}%
+ \expandafter\global\expandafter\let\csname pgfsysanim@hook@for@\pgfsys@id@refcurrent\endcsname\relax%
+ \fi%
+}
+\def\pgfsysanim@hooked@viewboxslice@#1#2#3#4#5#6#7#8{%
+ \pgfsys@viewboxslice@orig{#5}{#6}{#7}{#8}{#1}{#2}{#3}{#4}%
+}
+
+
+\newif\ifpgfsys@animation@path@hooked
+
+\def\pgfsysanim@prep@attr@path{%
+ \ifpgfsysanim@valid@snapshot@time%
+ \pgfsysanim@comp@path%
+ \pgfsys@attach@to@id{\pgfsysanim@whom@id}{}{%
+ \ifpgfsys@animation@path@hooked%
+ \else%
+ % Hook into path systems layer commands
+ \let\pgfsys@discardpath@orig\pgfsys@discardpath%
+ \let\pgfsys@stroke@orig\pgfsys@stroke%
+ \let\pgfsys@fill@orig\pgfsys@fill%
+ \let\pgfsys@fillstroke@orig\pgfsys@fillstroke%
+ \let\pgfsys@closestroke@orig\pgfsys@closestroke%
+ \let\pgfsys@discardpath\pgfsys@discardpath@hook%
+ \let\pgfsys@stroke\pgfsys@stroke@hook%
+ \let\pgfsys@fill\pgfsys@fill@hook%
+ \let\pgfsys@fillstroke\pgfsys@fillstroke@hook%
+ \let\pgfsys@closestroke\pgfsys@closestroke@hook%
+ \pgfsys@animation@path@hookedtrue%
+ \fi%
+ }{}{}%
+ \expandafter\pgfsysanim@attach@special\csname pgfsysanim@phook@for@\pgfsys@id@ref{\pgfsysanim@whom@id}{\pgfsysanim@whom@type}\endcsname\pgfsysanim@path@all%
+ \fi%
+}
+\def\pgfsys@stroke@hook{\pgfsysanim@with@tipstrue\pgfsysanim@path@hooks\pgfsys@stroke@orig}
+\def\pgfsys@fill@hook{\pgfsysanim@with@tipsfalse\pgfsysanim@path@hooks\pgfsys@fill@orig}
+\def\pgfsys@fillstroke@hook{\pgfsysanim@with@tipstrue\pgfsysanim@path@hooks\pgfsys@fillstroke@orig}
+\def\pgfsys@closestroke@hook{\pgfsysanim@with@tipsfalse\pgfsysanim@path@hooks\pgfsys@closestroke@orig}
+\def\pgfsys@discardpath@hook{\pgfsysanim@with@tipsfalse\pgfsysanim@path@hooks\pgfsys@discardpath@orig}
+
+\newif\ifpgfsysanim@with@tips
+
+\def\pgfsysanim@path@hooks#1{%
+ {%
+ \expandafter\ifx\csname pgfsysanim@phook@for@\pgfsys@id@refcurrent\endcsname\relax%
+ #1%
+ \else%
+ \pgfsys@discardpath@orig%
+ \csname pgfsysanim@phook@for@\pgfsys@id@refcurrent\endcsname%
+ \pgfsysanim@c@begin%
+ \pgfsysanim@path@val%
+ #1%
+ \ifpgfsysanim@with@tips%
+ \ifx\pgfsysanim@path@val\pgfutil@empty\else%
+ \pgfsysanim@prepare@end@of@path%
+ \begingroup%
+ \pgfsysanim@prepare@start@of@path%
+ \pgfsysanim@add@marker@at@start%
+ \endgroup%
+ \pgfsysanim@add@marker@at@end%
+ \fi%
+ \fi%
+ \expandafter\global\expandafter\let\csname pgfsysanim@phook@for@\pgfsys@id@refcurrent\endcsname\relax%
+ \fi%
+ }%
+}
+
+
+\def\pgfsysanim@prepare@start@of@path{%
+ \ifx\pgfsysanim@snap@tip@start\pgfutil@empty\else
+ %
+ % Step 1: Split
+ %
+ \ifx\pgfprocessresultpathsuffix\relax%
+ % Ok, still need to compute the split:
+ \pgfprocesssplitpath{\pgf@arrowpath}%
+ \fi%
+ %
+ % Step 2: extract
+ %
+ \expandafter\pgf@parse@start\pgfprocessresultpathsuffix\pgf@stop\pgf@stop\pgf@stop%
+ %
+ % Step 3: prep
+ %
+ \pgf@prep@start%
+ \fi%
+}
+\def\pgfsysanim@add@marker@at@start{%
+ \ifx\pgfsysanim@snap@tip@start\pgfutil@empty\else
+ %
+ % Step 4: draw
+ %
+ {%
+ \pgftransformreset%
+ \pgftransformarrow{\pgfqpoint{\pgf@xc}{\pgf@yc}}{\pgfqpoint{\pgf@xb}{\pgf@yb}}%
+ \pgfsys@beginscope%
+ \pgflowlevelsynccm%
+ \pgfsys@marker@use{\pgfsysanim@snap@tip@start}%
+ \pgfsys@endscope%
+ }%
+ \fi%
+}
+
+
+\def\pgfsysanim@prepare@end@of@path{%
+ \let\pgfprocessresultpathsuffix\relax% flag that nothing has happened...
+ \let\pgfprocessresultsubpathsuffix\relax%
+ \pgf@precise@shorteningfalse%
+ \edef\pgf@path@shortening@distance{0pt}%
+ \ifx\pgfsysanim@snap@tip@end\pgfutil@empty\else
+ %
+ % Step 1: Split
+ %
+ \pgfprocesssplitpath{\pgfsysanim@path@val}%
+ \pgfprocesssplitsubpath{\pgfprocessresultpathsuffix}%
+ %
+ % Step 2: extract
+ %
+ \expandafter\pgf@parse@end\pgfprocessresultsubpathsuffix\pgf@stop\pgf@stop\pgf@stop%
+ %
+ % Step 3: prep
+ %
+ \pgf@prep@end%
+ \fi%
+}
+\def\pgfsysanim@add@marker@at@end{%
+ \ifx\pgfsysanim@snap@tip@end\pgfutil@empty\else
+ %
+ % Step 4: draw
+ %
+ {%
+ \pgftransformreset%
+ \pgftransformarrow{\pgfqpoint{\pgf@xc}{\pgf@yc}}{\pgfqpoint{\pgf@xb}{\pgf@yb}}%
+ \pgfsys@beginscope%
+ \pgflowlevelsynccm%
+ \pgfsys@marker@use{\pgfsysanim@snap@tip@end}%
+ \pgfsys@endscope%
+ }%
+ \fi%
+}
+
+
+
+%
+% Interpolation functions
+%
+
+% Scalar interpolation
+
+\def\pgfsysanim@comp@scalar{%
+ \pgfsysanim@compute@fractions%
+ \pgfsysanim@mix@scalar%
+ \ifpgfsysanim@accumulate%
+ \ifnum\pgfsysanim@repeat@decimal=0\else%
+ \let\pgfsysanim@frac@b\pgfsysanim@one%
+ \let\pgfsysanim@prev@val\pgfsysanim@x@val%
+ \let\pgfsysanim@frac@a\pgfsysanim@repeat@decimal%
+ \let\pgfsysanim@next@val\pgfsysanim@last@val%
+ \pgfsysanim@mix@scalar%
+ \fi%
+ \fi%
+}
+\def\pgfsysanim@one{1}
+
+\def\pgfsysanim@mix@scalar{%
+ \pgf@x\pgfsysanim@prev@val pt%
+ \pgf@x\pgfsysanim@frac@b\pgf@x%
+ \pgf@y\pgfsysanim@next@val pt%
+ \advance\pgf@x by\pgfsysanim@frac@a\pgf@y%
+ \edef\pgfsysanim@x@val{\pgf@sys@tonumber\pgf@x}%
+}
+\def\pgfsysanim@cap@scalar#1#2#3{%
+ \ifdim#1 pt<#2 pt%
+ \def#1{#2}%
+ \else\ifdim#1 pt>#3 pt%
+ \def#1{#3}%
+ \fi\fi%
+}
+
+
+% Scale interpolation
+
+\def\pgfsysanim@comp@scale{%
+ \pgfsysanim@compute@fractions%
+ \expandafter\expandafter\expandafter\pgfsysanim@mix@scale\expandafter\pgfsysanim@prev@val\pgfsysanim@next@val%
+ \ifpgfsysanim@accumulate%
+ \ifnum\pgfsysanim@repeat@decimal=0\else%
+ \let\pgfsysanim@frac@b\pgfsysanim@one%
+ \let\pgfsysanim@frac@a\pgfsysanim@repeat@decimal%
+ \expandafter\pgfsysanim@mix@scale\expandafter\pgfsysanim@x@val\expandafter\pgfsysanim@y@val\pgfsysanim@last@val%
+ \fi%
+ \fi%
+}
+\def\pgfsysanim@mix@scale#1#2#3#4{%
+ \pgf@x#1pt%
+ \pgf@x\pgfsysanim@frac@b\pgf@x%
+ \pgf@y#3pt%
+ \advance\pgf@x by\pgfsysanim@frac@a\pgf@y%
+ \edef\pgfsysanim@x@val{\pgf@sys@tonumber\pgf@x}%
+ \pgf@x#2pt%
+ \pgf@x\pgfsysanim@frac@b\pgf@x%
+ \pgf@y#4pt%
+ \advance\pgf@x by\pgfsysanim@frac@a\pgf@y%
+ \edef\pgfsysanim@y@val{\pgf@sys@tonumber\pgf@x}%
+}
+
+
+% Dimension interpolation
+
+\def\pgfsysanim@comp@dimension{%
+ \pgfsysanim@compute@fractions%
+ \pgfsysanim@mix@dimension%
+ \ifpgfsysanim@accumulate%
+ \ifnum\pgfsysanim@repeat@decimal=0\else%
+ \let\pgfsysanim@frac@b\pgfsysanim@one%
+ \def\pgfsysanim@prev@val{\pgfsysanim@x@val pt}%
+ \let\pgfsysanim@frac@a\pgfsysanim@repeat@decimal%
+ \let\pgfsysanim@next@val\pgfsysanim@last@val%
+ \pgfsysanim@mix@dimension%
+ \fi%
+ \fi%
+}
+\def\pgfsysanim@mix@dimension{%
+ \pgf@x\pgfsysanim@prev@val%
+ \pgf@x\pgfsysanim@frac@b\pgf@x%
+ \pgf@y\pgfsysanim@next@val%
+ \advance\pgf@x by\pgfsysanim@frac@a\pgf@y%
+ \edef\pgfsysanim@x@val{\pgf@sys@tonumber\pgf@x}%
+}
+
+
+
+% Translate interpolation
+
+\def\pgfsysanim@comp@translate{%
+ \pgfsysanim@compute@fractions%
+ \expandafter\expandafter\expandafter\pgfsysanim@mix@translate\expandafter\pgfsysanim@prev@val\pgfsysanim@next@val%
+ \ifpgfsysanim@accumulate%
+ \ifnum\pgfsysanim@repeat@decimal=0\else%
+ \let\pgfsysanim@frac@b\pgfsysanim@one%
+ \let\pgfsysanim@frac@a\pgfsysanim@repeat@decimal%
+ \edef\pgfsysanim@prev@val{{\pgfsysanim@x@val pt}{\pgfsysanim@y@val pt}}
+ \expandafter\expandafter\expandafter\pgfsysanim@mix@translate\expandafter\pgfsysanim@prev@val\pgfsysanim@last@val%
+ \fi%
+ \fi%
+}
+\def\pgfsysanim@mix@translate#1#2#3#4{%
+ \pgf@x#1%
+ \pgf@x\pgfsysanim@frac@b\pgf@x%
+ \pgf@y#3%
+ \advance\pgf@x by\pgfsysanim@frac@a\pgf@y%
+ \edef\pgfsysanim@x@val{\pgf@sys@tonumber\pgf@x}%
+ \pgf@x#2%
+ \pgf@x\pgfsysanim@frac@b\pgf@x%
+ \pgf@y#4%
+ \advance\pgf@x by\pgfsysanim@frac@a\pgf@y%
+ \edef\pgfsysanim@y@val{\pgf@sys@tonumber\pgf@x}%
+}
+
+
+
+% Color interpolation
+
+\def\pgfsysanim@comp@color{%
+ \pgfsysanim@compute@fractions%
+ \expandafter\expandafter\expandafter\pgfsysanim@mix@color\expandafter\pgfsysanim@prev@val\pgfsysanim@next@val%
+ \ifpgfsysanim@accumulate%
+ \ifnum\pgfsysanim@repeat@decimal=0\else%
+ \let\pgfsysanim@frac@b\pgfsysanim@one%
+ \let\pgfsysanim@frac@a\pgfsysanim@repeat@decimal%
+ \expandafter\pgfsysanim@mix@color\expandafter\pgfsysanim@x@val\expandafter\pgfsysanim@y@val\expandafter\pgfsysanim@z@val\pgfsysanim@last@val%
+ \fi%
+ \fi%
+}
+\def\pgfsysanim@mix@color#1#2#3#4#5#6{%
+ \pgf@x#1pt%
+ \pgf@x\pgfsysanim@frac@b\pgf@x%
+ \pgf@y#4pt%
+ \advance\pgf@x by\pgfsysanim@frac@a\pgf@y%
+ \edef\pgfsysanim@x@val{\pgf@sys@tonumber\pgf@x}%
+ \pgf@x#2pt%
+ \pgf@x\pgfsysanim@frac@b\pgf@x%
+ \pgf@y#5pt%
+ \advance\pgf@x by\pgfsysanim@frac@a\pgf@y%
+ \edef\pgfsysanim@y@val{\pgf@sys@tonumber\pgf@x}%
+ \pgf@x#3pt%
+ \pgf@x\pgfsysanim@frac@b\pgf@x%
+ \pgf@y#6pt%
+ \advance\pgf@x by\pgfsysanim@frac@a\pgf@y%
+ \edef\pgfsysanim@z@val{\pgf@sys@tonumber\pgf@x}%
+}
+
+
+% Text interpolation
+
+\def\pgfsysanim@comp@text{%
+ \let\pgfsysanim@text@val\pgfsysanim@prev@val%
+}
+
+
+
+% Dash interpolation
+
+\def\pgfsysanim@comp@dash{%
+ \pgfsysanim@compute@fractions%
+ \expandafter\expandafter\expandafter\pgfsysanim@mix@dash\expandafter\pgfsysanim@prev@val\pgfsysanim@next@val%
+ \ifpgfsysanim@accumulate%
+ \ifnum\pgfsysanim@repeat@decimal=0\else%
+ \let\pgfsysanim@frac@b\pgfsysanim@one%
+ \let\pgfsysanim@frac@a\pgfsysanim@repeat@decimal%
+ \edef\pgfsysanim@prev@val{{\pgfsysanim@dash@vals}{\pgfsysanim@x@val pt}}%
+ \expandafter\expandafter\expandafter\pgfsysanim@mix@dash\expandafter\pgfsysanim@prev@val\pgfsysanim@last@val%
+ \fi%
+ \fi%
+}
+\def\pgfsysanim@mix@dash#1#2#3#4{%
+ \pgf@x#2\relax%
+ \pgf@x\pgfsysanim@frac@b\pgf@x%
+ \pgf@y#4\relax%
+ \advance\pgf@x by\pgfsysanim@frac@a\pgf@y%
+ \edef\pgfsysanim@x@val{\pgf@sys@tonumber\pgf@x}%
+ \let\pgfsysanim@dash@vals\pgfutil@empty%
+ \pgfsysanim@parse@dash#1,\pgf@stop#3,\pgf@stop%
+}
+\def\pgfsysanim@parse@dash{\pgfutil@ifnextchar\pgf@stop\pgfsysanim@parse@dash@done\pgfsysanim@parse@dash@first}
+\def\pgfsysanim@parse@dash@done\pgf@stop\pgf@stop{}%
+\def\pgfsysanim@parse@dash@first#1,#2\pgf@stop#3\pgf@stop{%
+ \pgf@x#1\relax%
+ \pgf@x\pgfsysanim@frac@b\pgf@x%
+ \pgfsysanim@parse@dash@second#3\pgf@stop{#2}%
+}
+\def\pgfsysanim@parse@dash@second#1,#2\pgf@stop#3{%
+ \pgf@y#1\relax%
+ \advance\pgf@x by\pgfsysanim@frac@a\pgf@y%
+ \def\pgfsys@temp{#2}%
+ \edef\pgfsysanim@dash@vals{\pgfsysanim@dash@vals\the\pgf@x\ifx\pgfsys@temp\pgfutil@empty\else,\fi}%
+ \pgfsysanim@parse@dash#3\pgf@stop#2\pgf@stop%
+}
+
+
+
+
+% Viewbox interpolation
+
+\def\pgfsysanim@comp@viewbox{%
+ \pgfsysanim@compute@fractions%
+ \expandafter\expandafter\expandafter\pgfsysanim@mix@viewbox\expandafter\pgfsysanim@prev@val\pgfsysanim@next@val%
+ \ifpgfsysanim@accumulate%
+ \pgferror{viewbox animations cannot accumulate / add}%
+ \fi%
+}
+\def\pgfsysanim@mix@viewbox#1#2#3#4#5#6#7#8{%
+ \pgf@x#1%
+ \pgf@x\pgfsysanim@frac@b\pgf@x%
+ \pgf@y#5%
+ \advance\pgf@x by\pgfsysanim@frac@a\pgf@y%
+ \edef\pgfsysanim@x@val{\the\pgf@x}%
+ \pgf@x#2%
+ \pgf@x\pgfsysanim@frac@b\pgf@x%
+ \pgf@y#6%
+ \advance\pgf@x by\pgfsysanim@frac@a\pgf@y%
+ \edef\pgfsysanim@y@val{\the\pgf@x}%
+ \pgf@x#3%
+ \pgf@x\pgfsysanim@frac@b\pgf@x%
+ \pgf@y#7%
+ \advance\pgf@x by\pgfsysanim@frac@a\pgf@y%
+ \edef\pgfsysanim@z@val{\the\pgf@x}%
+ \pgf@x#4%
+ \pgf@x\pgfsysanim@frac@b\pgf@x%
+ \pgf@y#8%
+ \advance\pgf@x by\pgfsysanim@frac@a\pgf@y%
+ \edef\pgfsysanim@w@val{\the\pgf@x}%
+}
+
+
+
+
+% Path interpolation
+
+\def\pgfsysanim@comp@path{%
+ \pgfsysanim@compute@fractions%
+ \edef\pgfsysanim@path@tips{%
+ \def\noexpand\pgfsysanim@snap@tip@start{\pgfsysanim@snap@tip@start}%
+ \def\noexpand\pgfsysanim@snap@tip@end{\pgfsysanim@snap@tip@end}%
+ }%
+ \let\pgfsysanim@path@val\pgfutil@empty%
+ \expandafter\expandafter\expandafter\pgfsysanim@parse@path\expandafter\pgfsysanim@prev@val\expandafter\pgf@stop\expandafter\relax\pgfsysanim@next@val\pgf@stop\relax%
+ \expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter\pgfsysanim@path@all\expandafter\expandafter\expandafter{\expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter\pgfsysanim@path@val\expandafter\expandafter\expandafter{\expandafter\pgfsysanim@path@val\expandafter}\pgfsysanim@path@tips}%
+ \ifpgfsysanim@accumulate%
+ \pgferror{path animations cannot accumulate / add}%
+ \fi%
+}
+\def\pgfsysanim@parse@path{\pgfutil@ifnextchar\pgf@stop\pgfsysanim@parse@path@done\pgfsysanim@parse@path@first}
+\def\pgfsysanim@parse@path@done\pgf@stop\relax\pgf@stop\relax{}%
+\def\pgfsysanim@parse@path@first{\pgfutil@ifnextchar\bgroup\pgfsysanim@parse@path@first@num\pgfsysanim@parse@path@token}
+\def\pgfsysanim@parse@path@token#1#2\relax#3#4\relax{%
+ \expandafter\def\expandafter\pgfsysanim@path@val\expandafter{\pgfsysanim@path@val#1}%
+ \pgfsysanim@parse@path#2\relax#4\relax%
+}
+\def\pgfsysanim@parse@path@first@num#1#2\relax#3#4\relax{%
+ \pgf@x#1%
+ \pgf@x\pgfsysanim@frac@b\pgf@x%
+ \pgf@y#3%
+ \advance\pgf@x by\pgfsysanim@frac@a\pgf@y%
+ \expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter\pgfsysanim@path@val\expandafter\expandafter\expandafter{\expandafter\pgfsysanim@path@val\expandafter{\the\pgf@x}}%
+ \pgfsysanim@parse@path#2\relax#4\relax%
+}
+
+
+
+% Motion interpolation
+
+\def\pgfsysanim@comp@motion{%
+ \pgfsysanim@compute@fractions%
+ \pgf@x\pgfsysanim@prev@val pt%
+ \pgf@x\pgfsysanim@frac@b\pgf@x%
+ \pgf@y\pgfsysanim@next@val pt%
+ \advance\pgf@x by\pgfsysanim@frac@a\pgf@y%
+ \edef\pgfsysanim@x@val{\pgf@sys@tonumber\pgf@x}%
+ \ifdim\pgfsysanim@x@val pt=1pt%
+ \def\pgfsysanim@x@val{0.9999}% because of rounding problems in decorations
+ \fi%
+ \pgf@relevantforpicturesizefalse%
+ \pgfdecoratepath{pgfsysanim@motion}{%
+ \pgfsyssoftpath@setcurrentpath\pgfsysanim@snap@movealong%
+ }%
+ \ifpgfsysanim@accumulate%
+ \pgferror{motion animations cannot accumulate / add}%
+ \fi%
+}
+\pgfdeclaredecoration{pgfsysanim@motion}{s}{%
+ \state{s}[width=\pgfsysanim@x@val\pgfdecoratedremainingdistance,next state=final]{}%
+ \state{final}{\pgfgettransform\pgfsysanim@motion@trans\global\let\pgfsysanim@motion@trans\pgfsysanim@motion@trans}%
+}
+
+
+
+
+
+
+% Compute fractions and splines:
+
+\def\pgfsysanim@compute@fractions{%
+ \ifdim\pgf@xc=\pgfsysanim@prev@time pt%
+ \def\pgfsysanim@frac@a{0}%
+ \def\pgfsysanim@frac@b{1}%
+ \else%
+ \pgfmathsubtract@{\pgfsysanim@next@time}{\pgfsysanim@prev@time}%
+ \ifdim\pgfmathresult pt<0.01pt%
+ \def\pgfsysanim@frac@a{0}%
+ \def\pgfsysanim@frac@b{1}%
+ \else%
+ \let\pgfsysanim@divby\pgfmathresult%
+ \pgfmathsubtract@{\pgf@sys@tonumber\pgf@xc}{\pgfsysanim@prev@time}%
+ \pgfmathdivide@{\pgfmathresult}{\pgfsysanim@divby}%
+ \ifdim\pgfmathresult pt<0pt\def\pgfmathresult{0}\fi%
+ \ifdim\pgfmathresult pt>1pt\def\pgfmathresult{1}\fi%
+ \let\pgfsysanim@frac@a\pgfmathresult%
+ \pgfmathsubtract@{1}{\pgfmathresult}%
+ \let\pgfsysanim@frac@b\pgfmathresult%
+ \fi%
+ \fi%
+ \ifdim\pgfsysanim@frac@a pt=0pt%
+ \else\ifdim\pgfsysanim@frac@b pt=0pt%
+ \else%
+ \expandafter\expandafter\expandafter\pgfsysanim@apply@spline\expandafter\pgfsysanim@prev@spline\pgfsysanim@next@spline%
+ \fi\fi%
+}
+
+
+\def\pgfsysanim@apply@spline#1#2#3#4#5#6#7#8{%
+ \edef\pgfsys@temp{#3,#5,#4,#6}%
+ \ifx\pgfsys@temp\pgfsysanim@id@spline%
+ \else%
+ \def\pgfsysanim@prev@out@time{{#3}{#4}}%
+ \def\pgfsysanim@next@in@time{{#5}{#6}}%
+ \ifx\pgfsysanim@prev@out@time\pgfsys@stay@text%
+ \pgfsysanim@jump@splines%
+ \else\ifx\pgfsysanim@next@in@time\pgfsys@jump@text%
+ \pgfsysanim@jump@splines%
+ \else%
+ \pgf@xa#3pt%
+ \pgf@xb#5pt%
+ % #4 is val support a
+ % #6 is val support b
+ % our first approximation
+ \let\pgfsysanim@t\pgfsysanim@frac@a%
+ \let\pgfsysanim@s\pgfsysanim@frac@b%
+ \pgfsysanim@eval@spline%
+ \edef\pgfsysanim@ft{\the\pgf@x}%
+ \pgf@x\pgfsysanim@t pt%
+ \advance\pgf@x by256sp%
+ \pgf@y1pt%
+ \advance\pgf@y by-\pgf@x%
+ \edef\pgfsysanim@t{\pgf@sys@tonumber\pgf@x}%
+ \edef\pgfsysanim@s{\pgf@sys@tonumber\pgf@y}%
+ \pgfsysanim@eval@spline%
+ % Ok, now do Newton one step
+ \advance\pgf@x by-\pgfsysanim@ft%
+ \pgf@x256\pgf@x%
+ % \pgf@x is f'(t)
+ % must compute t - (f(t)-frac@a)/f'(t)
+ \pgf@ya\pgfsysanim@ft%
+ \advance\pgf@ya by-\pgfsysanim@frac@a pt%
+ \pgf@yb\pgf@x
+ \pgfmathreciprocal@{\pgf@sys@tonumber\pgf@yb}%
+ \ifdim\pgfmathresult pt>2.5pt%
+ \def\pgfmathresult{2.5}%
+ \fi%
+ \ifdim\pgfmathresult pt<-2.5pt%
+ \def\pgfmathresult{-2.5}%
+ \fi%
+ \pgf@x\pgfsysanim@t pt%
+ \advance\pgf@x by-\pgfmathresult\pgf@ya%
+ % \pgf@x is new t:
+ \pgf@y1pt%
+ \advance\pgf@y by-\pgf@x%
+ \edef\pgfsysanim@t{\pgf@sys@tonumber\pgf@x}%
+ \edef\pgfsysanim@s{\pgf@sys@tonumber\pgf@y}%
+ \pgfsysanim@eval@spline%
+ \edef\pgfsysanim@ft{\the\pgf@x}%
+ \pgf@x\pgfsysanim@t pt%
+ \advance\pgf@x by256sp%
+ \pgf@y1pt%
+ \advance\pgf@y by-\pgf@x%
+ \edef\pgfsysanim@t{\pgf@sys@tonumber\pgf@x}%
+ \edef\pgfsysanim@s{\pgf@sys@tonumber\pgf@y}%
+ \pgfsysanim@eval@spline%
+ % Ok, now do Newton one step2
+ \advance\pgf@x by-\pgfsysanim@ft%
+ \pgf@x256\pgf@x%
+ % \pgf@x is f'(t)
+ % must compute t - (f(t)-frac@a)/f'(t)
+ \pgf@ya\pgfsysanim@ft%
+ \advance\pgf@ya by-\pgfsysanim@frac@a pt%
+ \pgf@yb\pgf@x
+ \pgfmathreciprocal@{\pgf@sys@tonumber\pgf@yb}%
+ \ifdim\pgfmathresult pt>2.5pt%
+ \def\pgfmathresult{2.5}%
+ \fi%
+ \ifdim\pgfmathresult pt<-2.5pt%
+ \def\pgfmathresult{-2.5}%
+ \fi%
+ \pgf@x\pgfsysanim@t pt%
+ \advance\pgf@x by-\pgfmathresult\pgf@ya%
+ % \pgf@x is new t:
+ \pgf@y1pt%
+ \advance\pgf@y by-\pgf@x%
+ \edef\pgfsysanim@t{\pgf@sys@tonumber\pgf@x}%
+ \edef\pgfsysanim@s{\pgf@sys@tonumber\pgf@y}%
+ % Third Newton:
+ \pgfsysanim@eval@spline%
+ \edef\pgfsysanim@ft{\the\pgf@x}%
+ \pgf@x\pgfsysanim@t pt%
+ \advance\pgf@x by256sp%
+ \pgf@y1pt%
+ \advance\pgf@y by-\pgf@x%
+ \edef\pgfsysanim@t{\pgf@sys@tonumber\pgf@x}%
+ \edef\pgfsysanim@s{\pgf@sys@tonumber\pgf@y}%
+ \pgfsysanim@eval@spline%
+ % Ok, now do Newton one step2
+ \advance\pgf@x by-\pgfsysanim@ft%
+ \pgf@x256\pgf@x%
+ % \pgf@x is f'(t)
+ % must compute t - (f(t)-frac@a)/f'(t)
+ \pgf@ya\pgfsysanim@ft%
+ \advance\pgf@ya by-\pgfsysanim@frac@a pt%
+ \pgf@yb\pgf@x
+ \pgfmathreciprocal@{\pgf@sys@tonumber\pgf@yb}%
+ \ifdim\pgfmathresult pt>2.5pt%
+ \def\pgfmathresult{2.5}%
+ \fi%
+ \ifdim\pgfmathresult pt<-2.5pt%
+ \def\pgfmathresult{-2.5}%
+ \fi%
+ \pgf@x\pgfsysanim@t pt%
+ \advance\pgf@x by-\pgfmathresult\pgf@ya%
+ % \pgf@x is new t:
+ \pgf@y1pt%
+ \advance\pgf@y by-\pgf@x%
+ \edef\pgfsysanim@t{\pgf@sys@tonumber\pgf@x}%
+ \edef\pgfsysanim@s{\pgf@sys@tonumber\pgf@y}%
+ % now, evaluate target:
+ \pgf@xa#4pt%
+ \pgf@xb#6pt%
+ \pgfsysanim@eval@spline%
+ % \pgf@x is result:
+ \pgf@y1pt%
+ \advance\pgf@y by-\pgf@x%
+ \edef\pgfsysanim@frac@a{\pgf@sys@tonumber\pgf@x}%
+ \edef\pgfsysanim@frac@b{\pgf@sys@tonumber\pgf@y}%
+ \fi\fi%
+ \fi%
+}
+\def\pgfsysanim@id@spline{0,1,0,1}
+
+\def\pgfsysanim@eval@spline{%
+ % Iteration one: (0,#1,#2,1) reduced to (ya,yb,yc)
+ \pgf@ya\pgfsysanim@t\pgf@xa%
+ \pgf@yb\pgfsysanim@t\pgf@xb%
+ \advance\pgf@yb by\pgfsysanim@s\pgf@xa%
+ \pgf@yc\pgfsysanim@t pt%
+ \advance\pgf@yc by\pgfsysanim@s\pgf@xb%
+ % Iteration two: (ya,yb,yc) reduced to (y,xc)
+ \pgf@y\pgfsysanim@t\pgf@yb%
+ \advance\pgf@y by\pgfsysanim@s\pgf@ya%
+ \pgf@xc\pgfsysanim@t\pgf@yc%
+ \advance\pgf@xc by\pgfsysanim@s\pgf@yb%
+ % Iteration three: (y,xc) reduced to (x)
+ \pgf@x\pgfsysanim@t\pgf@xc%
+ \advance\pgf@x by\pgfsysanim@s\pgf@y%
+}
+
+\def\pgfsysanim@jump@splines{%
+ \ifx\pgfsysanim@prev@out@time\pgfsys@stay@text%
+ \ifx\pgfsysanim@next@in@time\pgfsys@jump@text%
+ \ifdim\pgfsysanim@frac@a pt<0.5pt%
+ \def\pgfsysanim@frac@a{0}%
+ \def\pgfsysanim@frac@b{1}%
+ \else%
+ \def\pgfsysanim@frac@a{1}%
+ \def\pgfsysanim@frac@b{0}%
+ \fi%
+ \else%
+ % Only stay, so go to begin
+ \def\pgfsysanim@frac@a{0}%
+ \def\pgfsysanim@frac@b{1}%
+ \fi%
+ \else
+ % Only jump, so go to end
+ \def\pgfsysanim@frac@a{1}%
+ \def\pgfsysanim@frac@b{0}%
+ \fi%
+}
+
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/systemlayer/pgfsysprotocol.code.tex b/graphics/pgf/base/tex/generic/systemlayer/pgfsysprotocol.code.tex
new file mode 100644
index 0000000000..32052b8a29
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/systemlayer/pgfsysprotocol.code.tex
@@ -0,0 +1,70 @@
+% 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{pgfsysprotocol.code.tex}
+
+
+
+% This package provides the pgf system protocol layer. Protocolling is
+% used to record a bunch of graphic operations so that they can be
+% reused quickly at a later point.
+%
+% Basically, all ``recordable'' \pgfsys@xxxx commands call
+% \pgfsysprotocol@protocol for their protocolable literal
+% specials. The literal text will either be stored in the current
+% protocol. At a later point (actually, normally this happens
+% immediately afterwards), the accumulated protocolled text is invoked
+% using pgfsys@invokeprotocol.
+
+
+
+\let\pgfsysprotocol@currentprotocol=\pgfutil@empty
+\newif\ifpgfsysprotocol@buffered
+
+
+% Add to the protocol buffered
+\def\pgfsysprotocol@literalbuffered#1{%
+ \edef\pgfsysprotocol@temp{{#1\space}}%
+ \expandafter\pgfutil@g@addto@macro\expandafter\pgfsysprotocol@currentprotocol\pgfsysprotocol@temp%
+}
+
+% Add to the protocol
+\def\pgfsysprotocol@literal#1{%
+ \pgfsysprotocol@literalbuffered{#1}%
+ \ifpgfsysprotocol@buffered%
+ \else%
+ \pgfsysprotocol@flushcurrentprotocol%
+ \fi%
+}
+
+% Getting and setting the current protocol
+\def\pgfsysprotocol@getcurrentprotocol#1{%
+ \let#1=\pgfsysprotocol@currentprotocol%
+}
+
+\def\pgfsysprotocol@setcurrentprotocol#1{%
+ \global\let\pgfsysprotocol@currentprotocol=#1%
+}
+
+
+% Invoking the current protocol
+\def\pgfsysprotocol@invokecurrentprotocol{%
+ \ifx\pgfsysprotocol@currentprotocol\pgfutil@empty%
+ \else%
+ \expandafter\pgfsys@invoke\expandafter{\pgfsysprotocol@currentprotocol}%
+ \fi%
+}
+
+\def\pgfsysprotocol@flushcurrentprotocol{%
+ \pgfsysprotocol@invokecurrentprotocol%
+ \pgfsysprotocol@setcurrentprotocol\pgfutil@empty%
+}
+
+
+\endinput
diff --git a/graphics/pgf/base/tex/generic/systemlayer/pgfsyssoftpath.code.tex b/graphics/pgf/base/tex/generic/systemlayer/pgfsyssoftpath.code.tex
new file mode 100644
index 0000000000..9fe3f1e7db
--- /dev/null
+++ b/graphics/pgf/base/tex/generic/systemlayer/pgfsyssoftpath.code.tex
@@ -0,0 +1,204 @@
+% 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{pgfsyssoftpath.code.tex}
+
+
+% This package provides the pgf system path abstraction layer. This
+% layer is used to construct paths first ``abstractly.'' These
+% abstract paths can still be modified, before they are ``made
+% concrete.''
+%
+% An abstract path consists of a sequence of basic building blocks,
+% each of which is a tuple consisting of two numbers (specifying a
+% coordinate) and a token. Possible tokens are:
+%
+% 1. moveto
+% 2. lineto
+% 3. rectcorner
+% 4. rectsize
+% 5. curvetosupporta
+% 6. curvetosupportb
+% 7. curveto
+% 8. closepath
+% 9. specialround
+%
+% A curveto must always be preceded by a curvetosupporta and a
+% curvetosupportb. A non-empty path must always begin with a
+% moveto. The coordinates of a closepath are non-specified, currently,
+% but they might be set to the coordinate of the path segment start,
+% in the future.
+
+
+% Access to the current path:
+%
+% Lots of stuff is added to the current path and it can get very long
+% (containing literally tens of thousands of tokens). For such macros,
+% adding things using a simple "g@addtomacro" takes more and more
+% time, resulting in quadratic runtime. To avoid this, ideally, one
+% would collect things in an array and then use a divide and conquer
+% merger. A simple intermediate solution is the following, implemented
+% here: We have the path and two buffers. New tokens are added to the
+% first buffer, which is quite small. When it overflow, its contents
+% is added to the second buffer, which is large. If that buffer
+% overflow, the contents is finally added to the main path (which can
+% have arbitrary length). Whenever the main path is set or read, the
+% buffers are flushed.
+%
+% Because of this buffering, it is imperative that the main path is
+% accessed only via appropriate interface macros.
+
+
+
+% The current path
+\let\pgfsyssoftpath@thepath=\pgfutil@empty
+\let\pgfsyssoftpath@bigbuffer=\pgfutil@empty
+\let\pgfsyssoftpath@smallbuffer=\pgfutil@empty
+\newcount\pgfsyssoftpath@smallbuffer@items
+\newcount\pgfsyssoftpath@bigbuffer@items
+
+\def\pgfsyssoftpath@flushbuffers{%
+ \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\gdef%
+ \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\pgfsyssoftpath@thepath%
+ \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter{%
+ \expandafter\expandafter\expandafter\pgfsyssoftpath@thepath%
+ \expandafter\pgfsyssoftpath@bigbuffer\pgfsyssoftpath@smallbuffer}%
+ \global\let\pgfsyssoftpath@smallbuffer=\pgfutil@empty
+ \global\let\pgfsyssoftpath@bigbuffer=\pgfutil@empty
+ \global\pgfsyssoftpath@bigbuffer@items0\relax%
+ \global\pgfsyssoftpath@smallbuffer@items0\relax%
+}
+
+% Getting and setting the current path
+\def\pgfsyssoftpath@getcurrentpath#1{%
+ \pgfsyssoftpath@flushbuffers%
+ \let#1=\pgfsyssoftpath@thepath%
+}
+
+\def\pgfsyssoftpath@setcurrentpath#1{%
+ \global\let\pgfsyssoftpath@thepath=#1%
+ \global\let\pgfsyssoftpath@smallbuffer=\pgfutil@empty
+ \global\let\pgfsyssoftpath@bigbuffer=\pgfutil@empty
+ \global\pgfsyssoftpath@bigbuffer@items0\relax%
+ \global\pgfsyssoftpath@smallbuffer@items0\relax%
+}
+
+
+% Invoking the current path (slightly optimized)
+\def\pgfsyssoftpath@invokecurrentpath{%
+ \pgfsyssoftpath@thepath%
+ \pgfsyssoftpath@bigbuffer%
+ \pgfsyssoftpath@smallbuffer%
+}
+
+\def\pgfsyssoftpath@flushcurrentpath{%
+ \pgfsyssoftpath@invokecurrentpath%
+ \pgfsyssoftpath@setcurrentpath\pgfutil@empty%
+}
+
+% Add an item at the end
+\def\pgfsyssoftpath@addtocurrentpath#1{%
+ \global\advance\pgfsyssoftpath@smallbuffer@items by1\relax%
+ \ifnum\pgfsyssoftpath@smallbuffer@items<40\relax% good number?
+ \expandafter\gdef\expandafter\pgfsyssoftpath@smallbuffer\expandafter{\pgfsyssoftpath@smallbuffer#1}%
+ \else%
+ \pgfsyssoftpath@smalloverflow{#1}%
+ \fi%
+}
+\def\pgfsyssoftpath@smalloverflow#1{%
+ \global\advance\pgfsyssoftpath@bigbuffer@items by1\relax%
+ \ifnum\pgfsyssoftpath@bigbuffer@items<30\relax% good number?
+ \expandafter\expandafter\expandafter\gdef%
+ \expandafter\expandafter\expandafter\pgfsyssoftpath@bigbuffer%
+ \expandafter\expandafter\expandafter{\expandafter\pgfsyssoftpath@bigbuffer\pgfsyssoftpath@smallbuffer#1}%
+ \global\let\pgfsyssoftpath@smallbuffer=\pgfutil@empty%
+ \global\pgfsyssoftpath@smallbuffer@items0\relax%
+ \else%
+ \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\gdef%
+ \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\pgfsyssoftpath@thepath%
+ \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter{%
+ \expandafter\expandafter\expandafter\pgfsyssoftpath@thepath
+ \expandafter\pgfsyssoftpath@bigbuffer\pgfsyssoftpath@smallbuffer#1}%
+ \global\let\pgfsyssoftpath@smallbuffer=\pgfutil@empty
+ \global\let\pgfsyssoftpath@bigbuffer=\pgfutil@empty
+ \global\pgfsyssoftpath@bigbuffer@items0\relax%
+ \global\pgfsyssoftpath@smallbuffer@items0\relax%
+ \fi%
+}
+
+
+
+\def\pgfsyssoftpath@lastmoveto{{0pt}{0pt}}
+
+\newif\ifpgfsyssoftpathmovetorelevant
+\pgfsyssoftpathmovetorelevanttrue
+
+% Add a moveto element to the current path
+\def\pgfsyssoftpath@moveto#1#2{%
+ \edef\pgfsyssoftpath@coord{{#1}{#2}}%
+ \expandafter\pgfsyssoftpath@addtocurrentpath\expandafter{\expandafter\pgfsyssoftpath@movetotoken\pgfsyssoftpath@coord}%
+ \ifpgfsyssoftpathmovetorelevant%
+ \global\let\pgfsyssoftpath@lastmoveto\pgfsyssoftpath@coord%
+ \fi%
+}
+
+% Add a lineto element to the current path
+\def\pgfsyssoftpath@lineto#1#2{%
+ \edef\pgfsyssoftpath@coord{{#1}{#2}}%
+ \expandafter\pgfsyssoftpath@addtocurrentpath\expandafter{\expandafter\pgfsyssoftpath@linetotoken\pgfsyssoftpath@coord}%
+}
+
+
+% Add curveto elements to the current path
+\def\pgfsyssoftpath@curveto#1#2#3#4#5#6{%
+ \edef\pgfsyssoftpath@temp{{%
+ \noexpand\pgfsyssoftpath@curvetosupportatoken{#1}{#2}%
+ \noexpand\pgfsyssoftpath@curvetosupportbtoken{#3}{#4}%
+ \noexpand\pgfsyssoftpath@curvetotoken{#5}{#6}%
+ }}%
+ \expandafter\pgfsyssoftpath@addtocurrentpath\pgfsyssoftpath@temp%
+}
+
+
+% Add rectangle elements to the current path
+\def\pgfsyssoftpath@rect#1#2#3#4{%
+ \edef\pgfsyssoftpath@temp{{%
+ \noexpand\pgfsyssoftpath@rectcornertoken{#1}{#2}%
+ \noexpand\pgfsyssoftpath@rectsizetoken{#3}{#4}%
+ }}%
+ \expandafter\pgfsyssoftpath@addtocurrentpath\pgfsyssoftpath@temp%
+}
+
+% Add closepath element to the current path
+\def\pgfsyssoftpath@closepath{%
+ \expandafter\pgfsyssoftpath@addtocurrentpath\expandafter{\expandafter\pgfsyssoftpath@closepathtoken\pgfsyssoftpath@lastmoveto}%
+}
+
+% Add special element to the current path
+\def\pgfsyssoftpath@specialround#1#2{%
+ \edef\pgfsyssoftpath@temp{{#1}{#2}}%
+ \expandafter\pgfsyssoftpath@addtocurrentpath\expandafter{\expandafter\pgfsyssoftpath@specialroundtoken\pgfsyssoftpath@temp}%
+}
+
+% Marshallers
+\def\pgfsyssoftpath@movetotoken#1#2{\pgfsys@moveto{#1}{#2}}
+\def\pgfsyssoftpath@linetotoken#1#2{\pgfsys@lineto{#1}{#2}}
+\def\pgfsyssoftpath@rectcornertoken#1#2#3#4#5{\pgfsys@rect{#1}{#2}{#4}{#5}} % #3 = \pgfsyssoftpath@rectsizetoken
+\def\pgfsyssoftpath@curvetosupportatoken#1#2#3#4#5#6#7#8{\pgfsys@curveto{#1}{#2}{#4}{#5}{#7}{#8}}
+\def\pgfsyssoftpath@closepathtoken#1#2{\pgfsys@closepath}
+\let\pgfsyssoftpath@specialroundtoken=\pgfutil@gobbletwo
+\def\pgfsyssoftpath@curvetosupportbtoken#1#2{curvetotokenb} % make sure this \ifx-equal only to itself
+\def\pgfsyssoftpath@curvetotoken#1#2{curvetotoken}% make sure this \ifx-equal only to itself
+
+
+\endinput
+
+%%% Local Variables:
+%%% mode: latex
+%%% End: