% !TeX spellcheck = en_US
% !TeX root = tikz-ext-manual.tex
% Copyright 2023 by Qrrbrbirlbel
%
% This file may be distributed and/or modified
%
% 1. under the LaTeX Project Public License and/or
% 2. under the GNU Free Documentation License.
%

\section{Arrow Tips}
\label{pgflibrary:arrows}
\tikzset{external/export/.try=false}%
\begin{pgflibrary}{ext.arrows}
  This library adds arrows to \pgfname/\tikzname.
  
  \inspiration{ArrowLoop-Q,ArrowHug-Q,ArrowUntipped1-Q,ArrowUntipped2-Q}
              {ArrowLoop-A,ArrowHug-A,ArrowUntipped1-A,ArrowUntipped2-A}
\end{pgflibrary}
\begin{multicols}{2}
The arrow tips of the \referenceLibraryandIndexO{arrows.meta} library always
just touch the end of original line -- which is usually
what you want.

But for some arrow tips (and when they lie along a path) it makes sense
that these tips shoot a bit over the end of the line.
This is why these arrow tips exist.
They can be categorized into three groups:
\begin{enumerate}
\item Centered
\item Untipped
\item Overtipped\footnote{The Overtipped arrow tips aren't yet implemented.}
\end{enumerate}
Not all original arrow tips got all variants.
For a summary, refer to table on the right side.
As with the original tips of the \referenceLibraryandIndexO{arrows.meta} library
these can be organized in the following categories.
\newcolumn
\begin{center}
\newcommand*\tip[2][]{%
  \tikzset{external/export/.try=false}%
  \tikz[arrows={#2 \arrowtiprow[reversed] - \arrowtiprow[sep] . #2 \arrowtiprow[]}, baseline=+-.5ex,
    trim left=+-3mm, trim right=+13mm]
    \draw[line width=+.5mm, postaction={draw, gray, thin,-}] (0,0) -- + (right:1);%
}%
\def\tiprow#1 &{#1\gdef\arrowtiprow{#1} &}%
\def\Tiprow#1 &{\quad#1\gdef\arrowtiprow{#1} &}%
%\centering
%\caption{Variants of the original \texttt{arrows.meta} arrow tips.
%  For each example, the order is 1. reversed variant, 2. original, 3. variant.
%  They gray line shows where the path actually ends.
%}\label{tab:tips}
\begin{tabular}{ll ccc}
  \toprule
  Group        & Original                   & Centered       &    Untipped    & Overtipped \\ \midrule
  Barbed       & \tiprow Arc Barb           & \tip{Centered} & \tip{Untipped} &     --     \\
               & \Tiprow Parenthesis        & \tip{Centered} & \tip{Untipped} &     --     \\
               & \tiprow Hooks              & \tip{Centered} &       --       &     --     \\
               & \tiprow Straight Barb      & \tip{Centered} &       --       &     --     \\
               & \tiprow Tee Barb           & \tip{Centered} & \tip{Untipped} &     --     \\
               & \Tiprow Bar                & \tip{Centered} & \tip{Untipped} &     --     \\
               & \Tiprow Bracket            & \tip{Centered} & \tip{Untipped} &     --     \\ \midrule
%  Mathematical & Classical TikZ Rightarrow  & --             &       --       &     --     \\
%               & Computer Modern Rightarrow & --             &       --       &     --     \\
%               & \quad To                   & --             &       --       &     --     \\
%               & Implies                    & --             &       --       &     --     \\ \midrule
  Geometric    & \tiprow Circle             & \tip{Centered} & \tip{Untipped} &     --     \\
               & \Tiprow Ellipse            & \tip{Centered} & \tip{Untipped} &     --     \\
               & \tiprow Kite               & \tip{Centered} &       --       &     --     \\
               & \Tiprow Diamond            & \tip{Centered} &       --       &     --     \\
               & \Tiprow Turned Square      & \tip{Centered} &       --       &     --     \\
               & \tiprow LaTeX              & --             &       --       &     --     \\
               & \tiprow Square             & \tip{Centered} &       --       &     --     \\
               & \Tiprow Rectangle          & \tip{Centered} &       --       &     --     \\
               & \tiprow Stealth            & \tip{Centered} &       --       &     --     \\
               & \Tiprow Triangle           & \tip{Centered} &       --       &     --     \\ \midrule
%  Caps         &                            & --             &       --       &     --     \\
  Rays         & \tiprow Rays               & \tip{Centered} &       --       &     --     \\ \bottomrule
\end{tabular}
\end{center}
\newcolumn

\subsection{Centered}
\subsubsection{Barbed Arrow Tips}
\begin{arrowtipsimple}{Centered Arc Barb}
    This is a variant of the \referenceArrowtipandIndexO{Arc Barb} tip.
    The center of the arc lies on the original end of the path.
\end{arrowtipsimple}

\begin{arrowtipsimple}{Centered Bar}
    A variant of the simple \referenceArrowtipandIndexO{Bar} tip.
    This is a simple instance of |Centered Tee Barb| for length zero.
    
    The middle of the line will lie on original end of the path.
\end{arrowtipsimple}

\begin{arrowtipsimple}{Centered Bracket}
    This is a variant of the \referenceArrowtipandIndexO{Bracket} tip and
    therefore an instance of the |Centered Tee Barb| arrow tip that results in something
    resembling a bracket.
    
    The middle of the vertical part will lie on the original end of the path.
\end{arrowtipsimple}

\begin{arrowtipsimple}{Centered Hooks}
    A variant of the \referenceArrowtipandIndexO{Hooks} tip.
    The starting point of the hooks will lie on the original end of the path.
\end{arrowtipsimple}

\begin{arrowtipsimple}{Centered Parenthesis}
    This is a variant of the \referenceArrowtipandIndexO{Parenthesis} tip and
    thus an instance of the |Centered Arc Barb| arrow tip.
\end{arrowtipsimple}

\begin{arrowtipsimple}{Centered Straight Barb}
    A variant of the \referenceArrowtipandIndexO{Straight Barb} tip.
\end{arrowtipsimple}

\begin{arrowtipsimple}{Centered Tee Barb}
    A variant of the \referenceArrowtipandIndexO{Tee Barb} tip.
    
    The middle of the vertical part will lie on the original end of the path.
\end{arrowtipsimple}

\subsubsection{Geometric Arrow Tips}
\begin{arrowtipsimple}{Centered Circle}
    A variant of the \referenceArrowtipandIndexO{Circle} tip.
    The center of the circle will lie on the original end of the path.
\end{arrowtipsimple}

\begin{arrowtipsimple}{Centered Diamond}
    This is a variant of the \referenceArrowtipandIndexO{Diamond} tip and
    thus an instance of |Centered Kite| where the length is larger than the width.
\end{arrowtipsimple}

\begin{arrowtipsimple}{Centered Ellipse}
    This is a variant of the \referenceArrowtipandIndexO{Ellipse} tip
    and thus another name for the |Centered Circle| tip
    that is twice as wide as high.
\end{arrowtipsimple}

\begin{arrowtipsimple}{Centered Kite}
    A variant of the \referenceArrowtipandIndexO{Kite} tip.
    
    The widest part will lie on the original end of the path.
\end{arrowtipsimple}

\begin{arrowtipsimple}{Centered Rectangle}
    A variant of the \referenceArrowtipandIndexO{Rectangle} tip.
    By default, it is twice as long as high.
\end{arrowtipsimple}

\begin{arrowtipsimple}{Centered Square}
    A variant of the \referenceArrowtipandIndexO{Square} tip.
\end{arrowtipsimple}

\begin{arrowtipsimple}{Centered Stealth}
    This is a variant of the \referenceArrowtipandIndexO{Stealth} tip.
    
    The weighted center will lie at the original end of the path.
\end{arrowtipsimple}

\begin{arrowtipsimple}{Centered Triangle}
    This is a variant of the \referenceArrowtipandIndexO{Triangle} tip and
    thus an instance of the |Centered Kite| tip with zero inset.
\end{arrowtipsimple}

\begin{arrowtipsimple}{Centered Turned Square}
    This is a variant of the \referenceArrowtipandIndexO{Turned Square} tip and
    thus an instance of the |Centered Kite| tip with identical width and height and mid-inset.
\end{arrowtipsimple}

\subsubsection{Special Arrow Tips}
\begin{arrowtipsimple}{Centered Rays}
    A variant of the \referenceArrowtipandIndexO{Rays} tip.
    The origin of the rays will lie on the original end of the path.
\end{arrowtipsimple}

\subsection{Untipped}
\subsubsection{Barbed Arrow Tips}
\begin{arrowtipsimple}{Centered Arc Barb}
    This is a variant of the \referenceArrowtipandIndexO{Arc Barb} tip.
    The arrow tip will protrude half its line width over the original end of the path.
\end{arrowtipsimple}

\begin{arrowtipsimple}{Untipped Bar}
    A variant of the simple \referenceArrowtipandIndexO{Bar} tip.
    This is a simple instance of |Untipped Tee Barb| for length zero.
    
    The middle of the line will lie on original end of the path.
\end{arrowtipsimple}

\begin{arrowtipsimple}{Untipped Bracket}
    This is a variant of the \referenceArrowtipandIndexO{Bracket} tip and
    therefore an instance of the |Untipped Tee Barb| arrow tip that results in something
    resembling a bracket.
    
    The arrow tip will protrude half its line width over the original end of the path.
\end{arrowtipsimple}

\begin{arrowtipsimple}{Untipped Parenthesis}
    This is a variant of the \referenceArrowtipandIndexO{Parenthesis} tip and
    thus an instance of the |Untipped Arc Barb| arrow tip.
\end{arrowtipsimple}

\begin{arrowtipsimple}{Untipped Tee Barb}
    A variant of the \referenceArrowtipandIndexO{Tee Barb} tip.
    
    The middle of the vertical part will lie on the original end of the path.
\end{arrowtipsimple}

\subsubsection{Geometric Arrow Tips}
\begin{arrowtipsimple}{Untipped Circle}
    A variant of the \referenceArrowtipandIndexO{Circle} tip.
    This tip will protrude half its line width over the original end of the path.
\end{arrowtipsimple}

\begin{arrowtipsimple}{Untipped Ellipse}
    This is a variant of the \referenceArrowtipandIndexO{Ellipse} tip
    and thus another name for the |Untipped Circle| tip
    that is twice as wide as high.
\end{arrowtipsimple}

\subsection{Original Arrow Tips}
\begin{arrowtipsimple}{Hug Cap}
This arrow tips will hug a circle that would touch the end of the path.

Use the \referenceKeyandIndexO[/pgf/arrow keys/]{length} key to set up the radius of that circle.

\begin{codeexample}[preamble=\usepgflibrary{ext.arrows}]
\begin{tikzpicture}[
  dot/.style 2 args={
    shape=circle, outer sep=+0pt, fill={#1}, minimum size={#2}}]
\node[dot={red} {2cm}] (A)           {};
\node[dot={blue}{3cm}] (B) at (6,0) {};
\draw[
  line width=1.5cm,
  arrows={Hug Cap[length=1cm]-Hug Cap[length=1.5cm]}
] (A) to[out=45, in=180] (B);
\end{tikzpicture}
\end{codeexample}
\end{arrowtipsimple}

\begin{arrowtip}{Loop}{
  This arrow tip attaches a one-sided loop to the end of the line.
  The |length| refers to the length of the whole tip while the |radius|
  specifies the radius of the three rounded corners.
  The width of the tip is twice the |length| (but can't specified independently).
}{length=1.5cm,radius=3.5mm}{length=1.5cm,radius=3.5mm}
    \begin{arrowexamples}
        \arrowexample[]
        \arrowexampledup[sep]
        \arrowexampledupdot[sep]
        \arrowexample[open]
        \arrowexample[open, swap]
        \arrowexample[length=5pt,radius=0pt]
        \arrowexample[reversed]
        \arrowexample[slant=.3]
        \arrowexample[red]
    \end{arrowexamples}
    %
    The following options have no effect: |harpoon|, |round|, |line width|.

    On |double| lines, the arrow tip will not look correct.
\end{arrowtip}
\end{multicols}
\tikzset{external/export/.try=true}%
\endinput
