TikZ: Startpunkt von Verbindungslinie ändern
Verfasst: Mi 15. Jun 2022, 14:51
Hallo Community!
Ich habe hier ein Minimalbeispiel, in dem sogenannte Parallelepiped (geometrischer Körper) definiert werden. Bei der Verwendung dieser startet die Verbindungslinie von Block 1 zu Block 2 bei der vorderen rechten Linie des Block 1. Allerdings möchte ich, dass die Linie bei der hinteren rechten Linie des Blocks startet.
Kann mir jemand helfen?
Ich habe hier ein Minimalbeispiel, in dem sogenannte Parallelepiped (geometrischer Körper) definiert werden. Bei der Verwendung dieser startet die Verbindungslinie von Block 1 zu Block 2 bei der vorderen rechten Linie des Block 1. Allerdings möchte ich, dass die Linie bei der hinteren rechten Linie des Blocks startet.
Kann mir jemand helfen?
\documentclass{article} \usepackage{tikz} \usepackage{xcolor} \definecolor{grey}{RGB}{200,200,200} \makeatletter \pgfkeys{/pgf/.cd, parallelepiped offset x/.initial=2mm, parallelepiped offset y/.initial=2mm } \pgfdeclareshape{parallelepiped} { \inheritsavedanchors[from=rectangle] % this is nearly a rectangle \inheritanchorborder[from=rectangle] \inheritanchor[from=rectangle]{north} \inheritanchor[from=rectangle]{north west} \inheritanchor[from=rectangle]{north east} \inheritanchor[from=rectangle]{center} \inheritanchor[from=rectangle]{west} \inheritanchor[from=rectangle]{east} \inheritanchor[from=rectangle]{mid} \inheritanchor[from=rectangle]{mid west} \inheritanchor[from=rectangle]{mid east} \inheritanchor[from=rectangle]{base} \inheritanchor[from=rectangle]{base west} \inheritanchor[from=rectangle]{base east} \inheritanchor[from=rectangle]{south} \inheritanchor[from=rectangle]{south west} \inheritanchor[from=rectangle]{south east} \backgroundpath{ % store lower right in xa/ya and upper right in xb/yb \southwest \pgf@xa=\pgf@x \pgf@ya=\pgf@y \northeast \pgf@xb=\pgf@x \pgf@yb=\pgf@y \pgfmathsetlength\pgfutil@tempdima{\pgfkeysvalueof{/pgf/parallelepiped offset x}} \pgfmathsetlength\pgfutil@tempdimb{\pgfkeysvalueof{/pgf/parallelepiped offset y}} \def\ppd@offset{\pgfpoint{\pgfutil@tempdima}{\pgfutil@tempdimb}} \pgfpathmoveto{\pgfqpoint{\pgf@xa}{\pgf@ya}} \pgfpathlineto{\pgfqpoint{\pgf@xb}{\pgf@ya}} \pgfpathlineto{\pgfqpoint{\pgf@xb}{\pgf@yb}} \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@yb}} \pgfpathclose \pgfpathmoveto{\pgfqpoint{\pgf@xb}{\pgf@ya}} \pgfpathlineto{\pgfpointadd{\pgfpoint{\pgf@xb}{\pgf@ya}}{\ppd@offset}} \pgfpathlineto{\pgfpointadd{\pgfpoint{\pgf@xb}{\pgf@yb}}{\ppd@offset}} \pgfpathlineto{\pgfpointadd{\pgfpoint{\pgf@xa}{\pgf@yb}}{\ppd@offset}} \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@yb}} \pgfpathmoveto{\pgfqpoint{\pgf@xb}{\pgf@yb}} \pgfpathlineto{\pgfpointadd{\pgfpoint{\pgf@xb}{\pgf@yb}}{\ppd@offset}} } } \makeatother \begin{document} \begin{tikzpicture} \node[parallelepiped,draw=black,fill=grey, minimum width=2.5cm,minimum height=1.5cm, align=center] (1) at (0,0) {Block 1}; \node[parallelepiped,draw=black,fill=grey, minimum width=2.5cm, minimum height=1.5cm, align=center] (2) at (4,0) {Block 2}; \draw[thin, -] (1) -- (2); \end{tikzpicture} \end{document}