关于这个问题:按长度比例缩短弯曲箭头
我曾尝试使用curveto
装饰来按比例缩短曲线。我唯一的问题是箭头。是否可以将箭头附加到装饰上而不是路径上?
“缩短”为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}
“缩短”为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}
我知道箭头可以随后用 制作markings
,但我的问题是关于制作“ curveto with arrow
”装饰。
答案1
如果用 缩短pre=moveto
,则添加一个简短的(当然post length=<length>
伴随着)也可以。post=lineto|curveto
如果用 缩短post=moveto
,将其更改为post=empty
其中empty
是一个新定义的虚拟装饰,它不执行任何操作(甚至不执行 moveto 操作)似乎有效。
请注意,这对于起始箭头不起作用。警告:本段中的其余句子可能完全错误。装饰只是一种(强大而复杂的)软路径替换,我认为没有机会在不添加 moveto 软路径的情况下执行 moveto 操作。也许是一次性转换矩阵?或者修补箭头内部以有条件地跳过第一个 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}