# TikZ: How to decorate a path with the open diamond arrow tip that “bends” with the path?

I have a curved path that I want to put an open diamond arrow tip on. Here is a MWE with my best attempt:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows,decorations.markings}
\begin{document}
\begin{tikzpicture}[decoration={
markings,
mark=at position .5 with {\arrow[>=open diamond] {>} } }
]
\node (0)                     {};
\node (1) [right       of=0]  {};
\node (2) [below right of=1]  {};
\path (0) edge[out=0, in=135, postaction={decorate}] (2);
\end{tikzpicture}
\end{document}


As you can see, the bottom-right point of the diamond is perfectly on the path, but the top-left point is clearly above the path. It appears that the diamond lies on the tangent line of the path at the bottom-right point of the diamond.

# Question:

How can I place this open diamond arrow tip so that both points of the diamond are on the path?

### Bonus Question:

What is the best solution to make the area inside the diamond completely white? I don't want to see the path in the inside of the diamond. I currently have a solution that I feel is a hack, which is to place a white (closed) diamond arrow tip in the same spot first:

mark=at position .5 with {\arrow[>=diamond, white] {>} },

-

Here's a very over the top approach that places a coordinate at a specified location along the path, places a circle with a specified diameter on that coordinate, calculates the intersections of the curve and the circle, and then draws a diamond between the two intersections.

Drawbacks: The diamonds will have slightly different sizes, depending on the curvature of the original path. The original path isn't interrupted, instead the diamonds are just drawn on top. With the current implementation, while you can have several diamonds on the same path, the options like diamond ratio, diamond length, and every diamond will apply to all diamonds equally.

\documentclass{standalone}
\usepackage{tikz}

\tikzset{
diamond helpers/.code={
\path [draw,name path=circle] (middle) circle [radius=0.1cm];
},
diamond/.style={
decoration={
markings,
mark=at position #1 with {
\coordinate (middle);
\path [name path=circle] (middle) circle [radius=0.5*\diamondlength];
\draw [every diamond, name intersections={of=curve and circle}]
(intersection-1) --
($($(intersection-1)!0.5!(intersection-2)$)!\diamondaspect!90:(intersection-2)$) --
(intersection-2) --
($($(intersection-1)!0.5!(intersection-2)$)!\diamondaspect!-90:(intersection-2)$) --
cycle;}
},
postaction=decorate,
name path global=curve
},
diamond/.default=0.5,
diamond aspect/.store in=\diamondaspect,
diamond aspect=0.75,
diamond length/.store in=\diamondlength,
diamond length=0.2cm,
every diamond/.style={draw,fill=white}
}

\usetikzlibrary{decorations.markings,intersections,calc}
\begin{document}
\begin{tikzpicture}
*  \draw [diamond, diamond=0.1] (0,0) to [out=70, in=100] (1,-1);
\end{tikzpicture}
\end{document}

-
For the purposes of this question, I like this solution better since it uses the actual diamond shape (instead of making the node into a diamond) and is a bit more automated. In practice however, I decided to be content with the behavior of the example in my question. – Tyson Williams Apr 10 '12 at 13:04

You can mark the curve with a node with diamond shape and customize its aspect ratio for your needs.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.markings,shapes}
\begin{document}
\begin{tikzpicture}[decoration={
markings,
mark connection node=connode,
mark=at position 0.5 with {
\node[transform shape,shape=diamond,fill=white,draw] (connode) {};
}
}
]
\node (0)                     {};
\node (1) [right       of=0]  {};
\node (2) [below right of=1]  {};
\path (0) edge[out=0, in=135, postaction={decorate}] (2);
\end{tikzpicture}
\end{document}


I have edited the code for a slightly better placement however it is still not perfectly following the curvature, this is due to the size of the diamond shape compared to the curvature in the markings library and I don't see a direct fix other than drawing to an intermediate diamond node and then drawing to the final point.

-
I think your diamond tips are also above the path. It appears that the center of your diamond is on the path. – Tyson Williams Apr 2 '12 at 18:39
Can arrows tips be rotated? – Tyson Williams Apr 2 '12 at 19:57
@TysonWilliams No (at least not easily) but node that I have given can. By the way, I did not try to match it exactly since you might be looking for a full automated solution however adding yshift=-0.5pt, to the node options come pretty close. – percusse Apr 2 '12 at 20:05
Of course I would prefer an automated solution, but a would also settle for a "good" hack. – Tyson Williams Apr 2 '12 at 20:15