0

I would like to draw a horizontal-vertical path between two nodes, with different radii of rounded corners.

Here's my original code (single-radius):

\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}

Results:

enter image description here

Now I would like the first turn to have a larger radius. The expected results should look like the following (please ignore the imperfections due to my bad GIMP skills):

enter image description here

I followed this answer to set a different radius for the first turn:

\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}

Results are not as expected:

enter image description here

Thank you very much in advance for your help!

f10w
  • 791

1 Answers1

2

You have three turns, but only two are explicit. TikZ intuits the third.

\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}

demo


This version uses corners instead of midpoints.

\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}

John Kormylo
  • 79,712
  • 3
  • 50
  • 120