TikZ:具有两个转弯的水平垂直路径的不同圆角半径

TikZ:具有两个转弯的水平垂直路径的不同圆角半径

我想在两个节点之间绘制一条水平垂直路径,并具有不同的圆角半径。

这是我的原始代码(单半径):

\documentclass[tikz]{standalone}

\usetikzlibrary{fit,arrows.meta,mindmap,shadows,backgrounds,calc,positioning,shapes.misc}
\tikzset{Arrow/.style={-{stealth},very thick}}

\begin{document}

\begin{tikzpicture} [every node/.style={draw,rectangle,rounded corners,minimum width=22mm},
    every text node part/.style={align=center}]
\node (A) at (0,0) {A};
\node (B) at (5,5) {B};

\draw[Arrow,rounded corners=5pt]
    % start at source
    (A)
    % go right and up to anchor
    -| ($ (B.south) - (18.5mm,3mm) $)
    % go right and up to target
    -| ([xshift=-7mm]B.south)
    ;
\end{tikzpicture}

\end{document}

结果:

在此处输入图片描述

现在我希望第一个转弯的半径更大一些。预期成绩看起来应该像下面这样(由于我的 GIMP 技能不好,请忽略造成的不完美之处):

在此处输入图片描述

我跟着这个答案为第一个转弯设置不同的半径:

\documentclass[tikz]{standalone}
    
\usetikzlibrary{fit,arrows.meta,mindmap,shadows,backgrounds,calc,positioning,shapes.misc}
\tikzset{Arrow/.style={-{stealth},very thick}}

\begin{document}

\begin{tikzpicture} [every node/.style={draw,rectangle,rounded corners,minimum width=22mm},
    every text node part/.style={align=center}]
\node (A) at (0,0) {A};
\node (B) at (5,5) {B};

\draw[Arrow,rounded corners=5pt]
    % start at source
    (A)
    % go right and up to anchor
        { [rounded corners=30pt]
        -| ($ (B.south) - (18.5mm,3mm) $)
        }
    % go right and up to target
    -| ([xshift=-7mm]B.south)
    ;
\end{tikzpicture}

\end{document}

结果不如预期:

在此处输入图片描述

非常感谢您的帮助!

答案1

有三个回合,但只有两个是明确的。TikZ 直觉地知道第三个。

\documentclass[tikz]{standalone}

\usetikzlibrary{fit,arrows.meta,mindmap,shadows,backgrounds,calc,positioning,shapes.misc}
\tikzset{Arrow/.style={-{stealth},very thick}}

\begin{document}

\begin{tikzpicture} [every node/.style={draw,rectangle,minimum width=22mm},
    every text node part/.style={align=center}]
\node (A) at (0,0) {A};
\node (B) at (5,5) {B};

\draw[Arrow,rounded corners=30pt]
    % start at source
    (A)
    % go right and up to midpoint
    -| ($ (B.south) - (18.5mm,2.5) $)
    % got up and right to the anchor
    [rounded corners=5pt]
    |- ($ (B.south) - (12mm,3mm) $)
    % go right and up to target
    -| ([xshift=-7mm]B.south)
    ;
\end{tikzpicture}

\end{document}

演示


此版本使用角而不是中点。

\documentclass[tikz]{standalone}

\usetikzlibrary{fit,arrows.meta,mindmap,shadows,backgrounds,calc,positioning,shapes.misc}
\tikzset{Arrow/.style={-{stealth},very thick}}

\begin{document}

\begin{tikzpicture} [every node/.style={draw,rectangle,minimum width=22mm},
    every text node part/.style={align=center}]
\node (A) at (0,0) {A};
\node (B) at (5,5) {B};

\coordinate (AB) at ($ (B.south) - (18.5mm,3mm) $); % for simplicity
\coordinate (BB) at ([xshift=-7mm]B.south);

\draw[Arrow,rounded corners=30pt]
    % start at source
    (A) -- (A -| AB) % first corner
    [rounded corners=5pt]
     -- (AB) -- (AB -| BB) -- (BB);
\end{tikzpicture}

\end{document}

相关内容