I'm trying to find the best way of dynamically positioning the blue path. The important part is its position relative to b
and c
. I currently am using \path [line,blue] let \p1=(a.south), \p2=(c) in (h.south) |- +(2,-0.5) |- (\x2, \y1) -- (c.north);
for the blue path, but it really doesn't give me much dynamic control.
I've thought about trying add a couple of let points and taking the middle of their x-values, but I can't seem to figure out how to do that. It would look something like: \path [line,blue] let \p1=(a.south), \p2=(c), \p3=(b.east), \p4=(c.west) in (h.south) -| +( AAA , -0.5) |- (\x2, \y1) -- (c.north);
where AAA
would be something like ($(\x3 !0.25! \x4)$)
or (\x3 + \x4)*0.75
but that really seems like a kludgy way of doing it.
So, what's the best way to draw this path so that it will scale dynamically??
Also open to any suggestions on improving the red path.
\documentclass{article}
\usepackage{tikz}
\usepackage[margin=0.5in]{geometry}
\pagestyle{empty}
\begin{document}
%\input{../tikz-setup.tex}
\usetikzlibrary{shapes, arrows, calc, positioning}
% Define block styles
\tikzstyle{state} = [ rounded rectangle,
draw,
text centered,
minimum height=3em
]
\tikzstyle{test} = [ diamond,
draw,
shape aspect=2,
inner sep = 0pt,
text width = 7em,
text centered
]
\tikzstyle{action} = [ rectangle, draw,
text width=8em,
inner sep = 5pt,
minimum height=5em
]
\tikzstyle{line} = [ draw, -triangle 45 ]
\begin{center}
\begin{tikzpicture}[align = flush center, font = \small]
% Place nodes
\matrix [column sep = 3em, row sep = 1.2em] (mtrx)
{
\node [state] (a) {a};\\
\node [action] (b) {b}; &
\node [test] (c) {c}; \\
\node [action] (d) {d}; &
&
\node [action] (e) {e}; \\
\node [action] (f) {f}; &
&
\node [action] (g) {g}; \\
\node [action] (h) {h}; \\
};
% Draw edges
\path [line, red] (c.west) -- ($(b.east)!0.75!(c.west)$) |- ($(e.south)!0.5!(g.north)$);
%\path [line, red] let \p1=(e), \p2=(f), \p3=(c.west), \p4=(b.east) in (c.west) -- ($(\x3, \y3)!0.25!(\x4, \y3)$) |- ($(\x1, \y1)!0.5!(\x1, \y2)$); %alt
\path [line,blue] let \p1=(a.south), \p2=(c) in (h.south) |- +(2,-0.5) |- (\x2, \y1) -- (c.north);
\end{tikzpicture}
\end{center}
\end{document}