summaryrefslogtreecommitdiff
path: root/graphics/pgf/contrib/tikz-ext/tikzlibrarytopaths.arcthrough.code.tex
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/pgf/contrib/tikz-ext/tikzlibrarytopaths.arcthrough.code.tex')
-rw-r--r--graphics/pgf/contrib/tikz-ext/tikzlibrarytopaths.arcthrough.code.tex50
1 files changed, 50 insertions, 0 deletions
diff --git a/graphics/pgf/contrib/tikz-ext/tikzlibrarytopaths.arcthrough.code.tex b/graphics/pgf/contrib/tikz-ext/tikzlibrarytopaths.arcthrough.code.tex
new file mode 100644
index 0000000000..d90a2edc78
--- /dev/null
+++ b/graphics/pgf/contrib/tikz-ext/tikzlibrarytopaths.arcthrough.code.tex
@@ -0,0 +1,50 @@
+% Copyright 2022 by Qrrbrbirlbel
+%
+% This file may be distributed and/or modified
+%
+% 1. under the LaTeX Project Public License and/or
+% 2. under the GNU Free Documentation License.
+%
+
+\pgfqkeys{/tikz/arc through}{
+ .unknown/.code=\pgfkeyssetevalue{/tikz/arc through/through}{\pgfkeyscurrentname},
+ through/.initial={(0,0)},
+ center suffix/.initial=,
+ clockwise/.code=%
+ \def\tikz@arcthrough@clockwise{%
+ \pgfmathsubtract@{\pgfkeysvalueof{/tikz/end angle}}{360}%
+ \pgfkeyssetevalue{/tikz/end angle}{+\pgfmathresult}},
+ counter clockwise/.code=\let\tikz@arcthrough@clockwise\relax,
+ clockwise/.value forbidden, counter clockwise/.value forbidden, counter clockwise}
+\tikzset{
+ arc through/.code={%
+ \tikzset{every arc through/.try}%
+ \pgfqkeys{/tikz/arc through}{#1}%
+ \pgfkeysgetvalue{/tikz/arc through/through}\tikz@temp
+ \pgfextract@process\pgf@tostart{\tikz@scan@one@point\pgfutil@firstofone(\tikztostart)\relax}%
+ \expandafter\pgfextract@process\expandafter\pgf@tothrough\expandafter
+ {\expandafter\tikz@scan@one@point\expandafter\pgfutil@firstofone\tikz@temp\relax}%
+ \pgfextract@process\pgf@totarget{\tikz@scan@one@point\pgfutil@firstofone(\tikztotarget)\relax}%
+ \pgfextract@process\pgf@topointMidA{\pgfpointlineattime{.5}{\pgf@tostart}{\pgf@tothrough}}%
+ \pgfextract@process\pgf@topointMidB{\pgfpointlineattime{.5}{\pgf@totarget}{\pgf@tothrough}}%
+ \pgfextract@process\pgf@tocenter{%
+ \pgfpointintersectionoflines
+ {\pgf@topointMidA}{\pgfmathrotatepointaround{\pgf@tothrough}{\pgf@topointMidA}{90}}%
+ {\pgf@topointMidB}{\pgfmathrotatepointaround{\pgf@tothrough}{\pgf@topointMidB}{90}}}%
+ \pgfcoordinate{arc through center\pgfkeysvalueof{/tikz/arc through/center suffix}}{\pgf@tocenter}%
+ \pgfpointdiff{\pgf@tocenter}{\pgf@tostart}%
+ \pgfmathveclen@{\pgfmath@tonumber\pgf@x}{\pgfmath@tonumber\pgf@y}%
+ \pgfkeyssetevalue{/tikz/x radius}{+\pgfmathresult pt}%
+ \pgfkeyssetevalue{/tikz/y radius}{+\pgfmathresult pt}%
+ \pgfmathanglebetweenpoints{\pgf@tocenter}{\pgf@totarget}%
+ \pgfkeyssetevalue{/tikz/end angle}{+\pgfmathresult}%
+ \pgfmathanglebetweenpoints{\pgf@tocenter}{\pgf@tostart}%
+ \ifdim\pgfmathresult pt>\pgfkeysvalueof{/tikz/end angle}pt\relax
+ \pgfmathsubtract@{\pgfmathresult}{360}%
+ \fi
+ \pgfkeyssetevalue{/tikz/start angle}{+\pgfmathresult}%
+ \tikz@arcthrough@clockwise
+ \pgfkeyslet{/tikz/delta angle}\pgfutil@empty
+ \def\tikz@to@path{arc[]\tikztonodes}%
+ }%
+}