.png)
Wie PostScript (mit seinem rmoveto
und rlineto
) macht TikZ es trivial, eine relative Bewegung des aktuellen Punkts zu erzeugen. Ich sehe nichts Entsprechendes in PGF. Fehlt es? Wenn ja, ist es leicht zu sagen, warum? (Und was ist der beabsichtigte Ersatz in PFG?) Selbst wenn die relative Bewegung für die Systemschicht nicht niedrig genug ist (schwer zu glauben?), scheint sie für die Basisschicht niedrig genug zu sein.
Bearbeiten (Verwandte Suchanfragen):Ist es \pgfrelative
veraltet (steht nicht im aktuellen Handbuch)? Und welcher PGF-Befehl erzeugt den aktuellen Punkt?
Antwort1
Im folgenden Beispiel werden zwei neue Makros \pgfpathrlineto{<coord>}
und \pgfpathrmoveto{<coord>}
bereitgestellt. Sie sind nicht vollständig getestet, seien Sie also vorsichtig.
Eigentlich müssen wir die ursprünglichen (nicht transformierten) Koordinaten des letzten Punkts im Auge behalten, hier aber die transformierten Koordinaten speichern \pgf@x
.\pgf@y
Der Punkt ist, dass in (x, y) -- ++(2, 3)
die erwartete Zeile vor der Transformation ist (x, y) -- (x+2, y+3)
, während das, was ich im folgenden Beispiel implementiert habe, ist (x, y) -- ($ (x, y) + T'(2, 3) $)
, wobei T'
die Umkehrung der Transformation ist.
\documentclass{article}
\usepackage{pgf}
\makeatletter
\def\pgf@path@last@point{%
\pgfpoint{\pgf@path@lastx}{\pgf@path@lasty}}
% rlineto
\def\pgfpathrlineto#1{%
\pgf@process{#1}%
\global\advance\pgf@x\pgf@path@lastx
\global\advance\pgf@y\pgf@path@lasty
% similar to \pgfpathlineto, but without applying transformation
\pgf@nlt@lineto{\pgf@x}{\pgf@y}%
\global\pgf@path@lastx=\pgf@x
\global\pgf@path@lasty=\pgf@y
}
% rmoveto
\def\pgfpathrmoveto#1{%
\pgf@process{#1}%
\global\advance\pgf@x\pgf@path@lastx
\global\advance\pgf@y\pgf@path@lasty
% similar to \pgfpathlineto, but without applying transformation
\pgf@nlt@moveto{\pgf@x}{\pgf@y}%
\global\pgf@path@lastx=\pgf@x
\global\pgf@path@lasty=\pgf@y
}
\makeatother
\begin{document}
\begin{pgfpicture}
\pgfpathmoveto{\pgfpointorigin}
\pgfpathlineto{\pgfpoint{20pt}{0pt}}
\pgfpathmoveto{\pgfpoint{40pt}{0pt}}
\pgfpathlineto{\pgfpoint{60pt}{0pt}}
\pgfusepath{draw}
\pgftransformshift{\pgfpoint{10pt}{10pt}}
\pgfsetcolor{red}
\pgfpathmoveto{\pgfpointorigin}
\pgfpathlineto{\pgfpoint{20pt}{0pt}}
\pgfpathmoveto{\pgfpoint{40pt}{0pt}}
\pgfpathlineto{\pgfpoint{60pt}{0pt}}
\pgfusepath{draw}
\end{pgfpicture}
\qquad
% use r(line|move)to
\begin{pgfpicture}
\pgfpathmoveto{\pgfpointorigin}
\pgfpathrlineto{\pgfpoint{20pt}{0pt}}
\pgfpathrmoveto{\pgfpoint{20pt}{0pt}}
\pgfpathrlineto{\pgfpoint{20pt}{0pt}}
\pgfusepath{draw}
\pgftransformshift{\pgfpoint{10pt}{10pt}}
\pgfsetcolor{red}
\pgfpathmoveto{\pgfpointorigin}
\pgfpathrlineto{\pgfpoint{20pt}{0pt}}
\pgfpathrmoveto{\pgfpoint{20pt}{0pt}}
\pgfpathrlineto{\pgfpoint{20pt}{0pt}}
\pgfusepath{draw}
\end{pgfpicture}
\end{document}