4

In relation to this question: Shorten curved arrow proportionally to length

I have tried to use a curveto decoration to make a proportional shortening of a curve. My only problem is the arrow head. Is it possible to attach the arrow head to the decoration and not to the path?


"Shortened" with pre=moveto:

\documentclass[tikz, border=1 cm]{standalone}
\usetikzlibrary{decorations.pathmorphing, arrows.meta, bending}
\begin{document}
\begin{tikzpicture}
\newcommand{\mypath}{(0,0) to[out=80, in=100, min distance=1cm] (1,0)}
\draw[ultra thick] \mypath;
\draw[red, ->, decoration={curveto, pre=moveto, pre length=0.5*\pgfmetadecoratedpathlength}, decorate] \mypath; %relative shortening
%\draw[pink, {_[sep=1cm]}->] \mypath; %absolute shortening
\end{tikzpicture}
\end{document}

Curve with arrow head turned


"Shortened" with post=moveto:

\documentclass[tikz, border=1 cm]{standalone}
\usetikzlibrary{decorations.pathmorphing, arrows.meta, bending}
\begin{document}
\begin{tikzpicture}
\newcommand{\mypath}{(0,0) to[out=80, in=100, min distance=1cm] (1,0)}
\draw[ultra thick] \mypath;
\draw[green, ->, decoration={curveto, post=moveto, post length=0.5*\pgfmetadecoratedpathlength}, decorate] \mypath; %relative shortening
%\draw[orange, -{>[sep=1cm]}] \mypath; %absolute shortening
\end{tikzpicture}
\end{document}

Curve with arrow head turned and detached


I know that the arrow head can be made afterwards with markings, but my question is about making a "curveto with arrow" decoration.

1 Answers1

6

If shortened with pre=moveto, adding a short post length=<length> (accompanied with a post=lineto|curveto of course) works.

If shortened with post=moveto, changing it to post=empty where empty is a newly defined dummy decoration that does nothing (not even a moveto) seems to work.

Note this doesn't work for starting arrow(s). Caution: The rest sentences in current paragraph may be totally wrong. Decoration is just a (powerful and complicated) soft path substitution, and I see no chance to do a moveto action with out adding a moveto soft path. Maybe a one-time transformation matrix? Or patch the arrow internals to conditionally skip the first moveto?

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing, arrows.meta, bending}

\pgfdeclaredecoration{empty}{final}{ \state{final}{} }

\begin{document} \begin{tikzpicture} \newcommand{\mypath}{(0,0) to[out=80, in=100, min distance=1cm] (1,0)} \draw[ultra thick] \mypath; \draw[red, ->, decoration={curveto, pre=moveto, pre length=0.5*\pgfmetadecoratedpathlength, post=curveto, % <<< added post length=1pt % <<< added }, decorate] \mypath; %relative shortening %\draw[orange, -{>[sep=1cm]}] \mypath; %absolute shortening \end{tikzpicture}

\begin{tikzpicture} \newcommand{\mypath}{(0,0) to[out=80, in=100, min distance=1cm] (1,0)} \draw[ultra thick] \mypath; \draw[green, ->, decoration={curveto, post=empty, % <<< changed post length=0.5*\pgfmetadecoratedpathlength }, decorate] \mypath; %relative shortening %\draw[orange, -{>[sep=1cm]}] \mypath; %absolute shortening \end{tikzpicture} \end{document}

enter image description here

muzimuzhi Z
  • 26,474