
Ich weiß, dass ich in TikZ auf das Ende eines Pfads zugreifen kann, indem ich die Koordinate wie folgt benenne:
\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{svg.path}
\begin{document}
\begin{tikzpicture}
\draw [green] svg {M201.1,673.2c1.4-39.8,2-52.2,18.2-70.8c11.7-13.5,18.3-24.3-7.7-49.4
c-39.3-38-43.2-59.2,1-90.2c18.1-12.7,67.1-20.2,25.4-36.6c-18.2-7.2-23.5-9.7-26.9-39.2c-3-26.7-17.7-28.2-37.7-35
c-20-6.9-87.7-28.8-50.2-78.2c23.5-31,58.6-73.9,83.1-118.2c13.3-24,22.4-56.5,38.6-85.9} coordinate (End);
\fill [red] (End) circle (4pt);
\end{tikzpicture}
\end{document}
Wie kann ich auf die gleiche Weise auf den Anfang des Pfades zugreifen?
Antwort1
Das ist eine knifflige Sache! Die svg
Syntax verkürzt einen Großteil des TikZ-Pfadkonstruktionsmechanismus, sodass die offensichtliche Lösung coordinate[pos=0] (Start)
nicht zu funktionieren scheint.
Diese Methode ruft den Pfad ab, sobald er erstellt wurde, und entfernt die Anfangskoordinate. Anschließend erstellt sie an diesem Punkt eine TikZ-Koordinate.
\documentclass{standalone}
%\url{http://tex.stackexchange.com/q/364315/86}
\usepackage{tikz}
\usetikzlibrary{svg.path}
\makeatletter
\def\tikz@startcoord#1#2#3#4\pgf@stop#5{%
\begingroup
\pgftransformreset
\pgftransformshift{\pgfpoint{#2}{#3}}%
\pgfnode{coordinate}{center}{}{#5}{}%
\endgroup
}
\tikzset{
coordinate at start/.code={
\tikz@addmode{%
\pgfsyssoftpath@getcurrentpath\@temp
\expandafter\tikz@startcoord\@temp\pgf@stop{#1}
}%
}
}
\makeatother
\begin{document}
\begin{tikzpicture}
\begin{scope}[xshift=1cm]
\draw [coordinate at start=Start,green,yshift=2cm] svg {M201.1,673.2c1.4-39.8,2-52.2,18.2-70.8c11.7-13.5,18.3-24.3-7.7-49.4
c-39.3-38-43.2-59.2,1-90.2c18.1-12.7,67.1-20.2,25.4-36.6c-18.2-7.2-23.5-9.7-26.9-39.2c-3-26.7-17.7-28.2-37.7-35
c-20-6.9-87.7-28.8-50.2-78.2c23.5-31,58.6-73.9,83.1-118.2c13.3-24,22.4-56.5,38.6-85.9} coordinate (End);
\end{scope}
\fill [red] (End) circle (4pt);
\fill [blue] (Start) circle (4pt);
\end{tikzpicture}
\end{document
}
Möglicherweise gibt es einen einfacheren Weg, dies zu tun ...
Aktualisiert, um die aktuelle Koordinatentransformation zu ignorieren (ansonsten werden sie zweimal angewendet).
Antwort2
Wahrscheinlich etwas gröber als die Anforderungen des OP, aber wenn das Aufteilen des SVG-Pfads tolerierbar ist, kann das Einfügen einer Koordinate nach dem ersten Moveto funktionieren:
\documentclass[tikz,border=5]{standalone}
\usetikzlibrary{svg.path}
\begin{document}
\begin{tikzpicture}
\draw [green, xshift=25]
svg {M201.1,673.2}
coordinate (Start)
svg {c1.4-39.8,2-52.2,18.2-70.8c11.7-13.5,18.3-24.3-7.7-49.4
c-39.3-38-43.2-59.2,1-90.2c18.1-12.7,67.1-20.2,25.4-36.6
c-18.2-7.2-23.5-9.7-26.9-39.2c-3-26.7-17.7-28.2-37.7-35
c-20-6.9-87.7-28.8-50.2-78.2c23.5-31,58.6-73.9,83.1-118.2
c13.3-24,22.4-56.5,38.6-85.9}
coordinate (End);
\fill [blue] (Start) circle [radius=.1];
\fill [red] (End) circle [radius=.1];
\end{tikzpicture}
\end{document}