# How to draw curved paths

I'm trying to do this picture :

I have a problem to draw the curved paths.

MWE

\documentclass[scale=0.5,border=12pt]{standalone}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{tkz-euclide}
\usepackage{lmodern}
\usetkzobj{all}
\usetikzlibrary{shapes.geometric,arrows,positioning,fit,calc,backgrounds}

\usepackage{hyperref}

\tikzset{
b/.style={
draw,
rectangle,
rounded corners=2ex,
minimum height=0.2cm,
minimum width=1in,
align=center,
font=\small},
c/.style={
draw,
rectangle,
rounded corners=2ex,
minimum height=0.5in,
minimum width=2in,
align=center,
rotate=-90,
font=\large},
ar/.style={
rounded corners=2ex,
->,
>=latex},
myarrow/.style args={#1 colored by #2 and #3}{
-stealth,
line width=#1,
#2,
postaction={draw,-stealth,#3,line width=(#1)/3,
shorten <=(#1)/3,
shorten >=2*(#1)/3},
},
toptext/.style={    % <-- New
above,
text width=6cm,
align=center,
font=\large}
}

\begin{document}
\begin{tikzpicture}
\node (string) [b] {string};
\node (number) [b, below=0.3 cm of string] {number};
\node (object) [b, below=0.3 cm of number] {object};
\node (array) [b, below=0.3 cm of object] {array};
\node (true) [b, below=0.3 cm of array] {true};
\node (false) [b, below=0.3 cm of true] {false};
\node (null) [b, below=0.3 cm of false] {null};

\draw  (string.west) -- ++(-70pt,0pt);
\draw  (string.east) -- ++(70pt,0pt);

\end{tikzpicture}

\end{document}

-
Yeah I will look at it. We should change it's title to that question! I haven't found that question when asked mine. –  user230137 May 25 '14 at 17:17
The answer here use pst-node. I use tikz. –  user230137 May 25 '14 at 17:21

Some ideas:

1. Define coordinates named left and right (for example) which contain the coordinate at which the curve starts and ends at the sides of (string) node. For example:

\coordinate (left) at ($(string.west)+(-20pt,0pt)$);
\coordinate (right) at ($(string.east)+(20pt,0pt)$);

2. Use the syntax (left) -- +(2ex,0) |- (number) for example, to draw a polygonal line between the point named left, another point 2ex to its right, and a L shaped line descending up to the level of node named number, and finally to that node. The trick is to use rounded corners=2ex for this polygonal, so that the radius is equal to the distance to the second point.

3. Similarly, the curve at the right side is drawn with (number) -| ($(right)+(-2ex,0)$) -- +(right)

4. In fact, both parts can be combined in a single \draw command, unless you want arrows for the first half but not for the second half, for example.

5. All the above has to be done for each node below (string), so it can be easily iterated in a loop.

So the code will be:

\coordinate (left) at ($(string.west)+(-20pt,0pt)$);
\coordinate (right) at ($(string.east)+(20pt,0pt)$);

\draw  ($(left) +(-30pt, 0)$) -- (string);
\draw  (string.east) -- ($(right) + (30pt,0)$);

\foreach \token in {number, object, array, true, false, null} {
\draw[rounded corners=2ex] (left) -- +(2ex,0) |- (\token) -| ($(right)+(-2ex,0)$) -- (right);
}


Producing:

Note: the rest of the code is not shown because is identical to the one you provided, except that I changed rounded corners=1ex (instead of 2ex) for the b/.style. Using 2ex caused some artifacts because this radius is greater than half the height of the boxes.

-