如何绘制军事地图上的箭头?

如何绘制军事地图上的箭头?

我想画一个弯曲的箭头,其粗细从末端到头部变化。这种箭头通常用于军事地图中,以表示部队的移动。下面是一个例子。

军事地图

可以在 tikz 中做到这一点吗?谢谢!

答案1

并不惊人,而且使用极端曲线或参数值时会产生可怕的结果。目前curveto仅适用于单一操作(即由一条贝塞尔曲线组成的路径)。

\documentclass[tikz,margin=5]{standalone}
\usetikzlibrary{calc,decorations.pathreplacing,decorations.markings}
\tikzset{big arrow/.style={
  /tikz/big arrow/.cd, #1, /tikz/.cd,
  decoration={show path construction,
  curveto code={%
%
\path [discard, decoration={ markings, 
  mark=at position -\bigarrowlength with {\coordinate (@); }}, decorate] 
  (\tikzinputsegmentfirst) .. controls (\tikzinputsegmentsupporta)
  and (\tikzinputsegmentsupportb) .. (\tikzinputsegmentlast);
\path[big arrow/.cd,#1] 
  let \p1=(\tikzinputsegmentfirst), \p2=(\tikzinputsegmentsupporta),
  \p3=(\tikzinputsegmentsupportb), \p4=(@), \p5=(\tikzinputsegmentlast),
  \n1={atan2(\y2-\y1,\x2-\x1)}, \n2={atan2(\y4-\y3,\x4-\x3)} in
  (\p1) -- ++(\n1+90:\bigarrowstartwidth/2) 
  .. controls ++(\x2-\x1, \y2-\y1) and ++(\x3-\x4, \y3-\y4) .. 
  ($(\p4)+(\n2+90:\bigarrowendwidth/2)$) -- 
  ($(\p4)+(\n2+90:\bigarrowwidth/2)$) -- (\p5) --
  ($(\p4)+(\n2-90:\bigarrowwidth/2)$) -- 
  ($(\p4)+(\n2-90:\bigarrowendwidth/2)$)
  .. controls ++(\x3-\x4, \y3-\y4) and ++(\x2-\x1, \y2-\y1) ..
  ($(\p1)+(\n1-90:\bigarrowstartwidth/2)$) -- cycle;
%
  }}, decorate
},
big arrow/.cd,
  start width/.store in=\bigarrowstartwidth,
  end width/.store in=\bigarrowendwidth,
  length/.store in=\bigarrowlength,
   width/.store in=\bigarrowwidth,
  start width=1cm,
  end width=0.5cm,
  length=0.25cm,
  width=1cm,
  .unknown/.code=%
    {\let\searchname=\pgfkeyscurrentname\pgfkeysalso{/tikz/\searchname=#1}}%
}
\begin{document}
\begin{tikzpicture}
\draw [big arrow={fill=red}] (0,0) to [bend left] (5,5);
\draw [big arrow={fill=green, length=0.5cm}] (0,0) to [bend right] (-3,3);
\draw [big arrow={fill=blue, start width=1.5cm, end width=1cm,
  width=1.5cm, length=0.75cm}] (0,0) to [bend right] (4,0);
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容