我正在寻找一种方法,使向上弯曲的 TikZ 箭头在“碰到”上限时受到上限的限制,即它不得超过不可见的上线,但要平滑地跟随它(圆角)。挑战还在于两种不同的情况:
备注:在我的具体情况下,我给出了两个坐标对象,但我无法控制确切的位置。我将箭头弯曲了out
一定in
角度,请参见示例。
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
% two nodes that shall be connected via arrow
\node[draw, circle] (A) at (0, 0) {};
\node[draw, circle] (B) at (4, -0.1) {};
% invisible bound to "bump" against
\draw[dashed, red] (0, 0.3) -- (4, 0.3);
% arrow that shall limited by the upper bound
\draw[->] (B.north west) to [out=160,in=25] (A.north east);
\end{tikzpicture}
\end{document}
答案1
通过使用选项max distance
:
\documentclass[border=3.141592]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[
every node/.style = {circle, draw, minimum size=4mm, inner sep=0pt}
]
% two nodes that shall be connected via arrow
\node (A) at (0, 0) {};
\node (B) at (4, 0) {};
% invisible bound to "bump" against
\draw[dashed, red] (0, 0.3) -- (4, 0.3);
% arrow that shall limited by the upper bound
\draw[->] (B.north west) to [out=160,in=25] (A.north east);
\draw[blue, ->] (B.north west) to [out=160,in=25,
max distance=5mm] % <---
(A.north east);
\end{tikzpicture}
\end{document}