![如何顺利地限制/裁剪/绑定弯曲的箭头?](https://linux22.com/image/442046/%E5%A6%82%E4%BD%95%E9%A1%BA%E5%88%A9%E5%9C%B0%E9%99%90%E5%88%B6%2F%E8%A3%81%E5%89%AA%2F%E7%BB%91%E5%AE%9A%E5%BC%AF%E6%9B%B2%E7%9A%84%E7%AE%AD%E5%A4%B4%EF%BC%9F.png)
我正在寻找一种方法,使向上弯曲的 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}