I'd like to achieve the following effect in a TikZ picture when drawing a straight edge from one node to another. How can I achieve this tapering effect? Notice what happens when an edge exists from A to B and also from B to A (but I suspect this will come for free). This image comes from:
www.win.tue.nl/~dholten/papers/directed_edges_chi.pdf
From "Wedged/tapering paths in TikZ", I was able to hack up something that looked decent, but I was curious if anyone could up with something better.
In particular, I'd like the direction of the tapering reversed. Or at least an API that would allow me to set the direction. Some people might want thick edges at the head and tapered edges at the tail. In the example I provide, I want the thick edge at the head, but the implementation is reversed, so I have to reverse all my edges. It would also be nice if you could specify edges as you do with the \path command:
\path (A) edge [tapered tail] (B);
\path (B) edge [tapered head] (C);
\path (A) edge [tapered tail, <-] (B); % effectively: tapered head
Here is the example:
\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{decorations}
\begin{document}
% Need to reverse this!
\pgfdeclaredecoration{triangle}{start}{
\state{start}[width=0.99\pgfdecoratedinputsegmentremainingdistance,next state=up from center]
{\pgfpathlineto{\pgfpointorigin}}
\state{up from center}[next state=do nothing]
{
\pgfpathlineto{\pgfqpoint{\pgfdecoratedinputsegmentremainingdistance}{\pgfdecorationsegmentamplitude}}
\pgfpathlineto{\pgfqpoint{\pgfdecoratedinputsegmentremainingdistance}{-\pgfdecorationsegmentamplitude}}
\pgfpathlineto{\pgfpointdecoratedpathfirst}
}
\state{do nothing}[width=\pgfdecorationsegmentlength,next state=do nothing]{
\pgfpathlineto{\pgfpointdecoratedinputsegmentfirst}
\pgfpathmoveto{\pgfpointdecoratedinputsegmentlast}
}
}
\tikzset{
triangle path/.style={decoration={triangle,amplitude=#1}, decorate},
triangle path/.default=1ex}
\colorlet{mygray}{gray!50}
\pgfdeclarelayer{bg} % declare background layer
\pgfsetlayers{bg,main} % set the order of the layers (main is the standard layer)
\begin{tikzpicture}
\begin{scope}[circle]
\node[draw=gray,fill=mygray] at (0,0) {};
\node[draw=gray,fill=mygray] at (1,2) {};
\node[draw=gray,fill=mygray] at (.3,2.5) {};
\node[draw=gray,fill=mygray] at (0,-2) {};
\node[draw=gray,fill=mygray] at (-3,1) {};
\node[draw=gray,fill=mygray] at (3,1.5) {};
\end{scope}
\begin{pgfonlayer}{bg}
\begin{scope}[color=gray, opacity=.8]
\draw [fill=black!70, triangle path=.7ex] (1,2) -- (0,0);
\draw [fill=black!70, triangle path=.7ex] (.3,2.5) -- (0,0);
\draw [fill=black!70, triangle path=.7ex] (0,-2) -- (0,0);
\draw [fill=black!70, triangle path=.7ex] (0,0) -- (0,-2);
\draw [fill=black!70, triangle path=.7ex] (3,1.5) -- (-3,1);
\end{scope}
\end{pgfonlayer}
\end{tikzpicture}
\end{document}
The resulting image doesn't have quite the same polished look, perhaps its just because I don't have enough edges. Any improvements?
transparency group
option. What exactly does not look good? I think it looks just fine.to path
(especially good foredge
).