![圆角三角形箭头尖](https://linux22.com/image/469502/%E5%9C%86%E8%A7%92%E4%B8%89%E8%A7%92%E5%BD%A2%E7%AE%AD%E5%A4%B4%E5%B0%96.png)
我正在尝试使用 Tikz 绘制一个圆形三角形尖端,如所附的屏幕截图所示。
Triangle Cap[]
太尖锐,Round Cap[]
倾斜度不够平缓。
我尝试过使用Stealth
调整为线宽的箭头,但结果并不理想。
本质上,我要找的箭头看起来像一支略圆的铅笔:略圆的尖端;倾斜线与水平线相交处略有曲线。
我的尝试如下:
\documentclass[letterpaper]{article}
\usepackage{amsmath}
\usepackage{array}
\usepackage{multirow}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\usetikzlibrary{fadings}
\usetikzlibrary{shadings}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{bending}
\makeatletter
\pgfarrowsdeclare{open cap}{open cap}
{\pgfarrowsleftextend{+0pt}\pgfarrowsrightextend{+0.5\pgflinewidth}}
{
\pgfmathsetlength{\pgfutil@tempdimb}{.5*\pgflinewidth-.5*\pgfinnerlinewidth}%
\pgfsetlinewidth{\pgfutil@tempdimb}
\pgfsetbuttcap
\pgfsetdash{}{0pt}
\pgfmathsetlength{\pgfutil@tempdima}{0.5*\pgfutil@tempdimb+0.5*\pgfinnerlinewidth}%
\pgfpathmoveto{\pgfqpoint{0pt}{\pgfutil@tempdima}}
\pgfpatharc{270}{90}{-\pgfutil@tempdima}
\pgfusepathqstroke
}
\begin{document}
\tikzset{every picture/.style={line width=5pt, color=blue, text = black}}
\begin{tikzpicture}[remember picture ]
\draw[open cap-open cap] (0,0)--node [above] {Rounded ends: end is round as desired but arcs to end rather than straight lines}(10,0);
\draw[{Triangle Cap[]}-{Triangle Cap[]}] (0,1)--node [above] {Short triangles: right width but join between tip and line is sharp not rounded}(10,1);
\draw[{Triangle Cap[length=10pt]}-{Triangle Cap[length=10pt]}] (0,2)--node [above] {\scriptsize{Longer triangles: still right width but meeting point between tip and line is still a sharp corner}}(10,2);
\draw[{Triangle Cap[length=10pt, line cap=round]}-{Triangle Cap[length=10pt, line cap =round]}] (0,3)--node [above] {No difference when specifying "line cap = round"}(10,3);
\draw[{Stealth [round]}-{Stealth[round]}] (0,4)--node [above] {Round stealth: rounded end and edges of tips; perfect but wider/thicker than the line}(10,4);
\draw[{Stealth [width=10pt, round]}-{Stealth[width=10pt, round]}] (0,5)--node [above] {Thinner round stealth: almost perfect but still wider/thicker than the line}(10,5);
\draw[{Stealth [width=5pt, round]}-{Stealth[width=5pt, round]}] (0,6)--node [above] {Very thin round stealth: starts acting unpredictably; tip extends past end of line}(10,6);
\end{tikzpicture}
\end{document}
任何帮助将非常感激。
编辑:
下面的效果几乎完美,但我希望斜线与水平线相交的角也能是圆的。
感谢@Qrrbrbirlbel。
答案1
round
如果做得正确,定义新的箭头尖可能会很繁琐。也许对ed尖进行轻微调整Triangle
就足够了。
该值1.963
是 30° 角度的估计值。它可以正确地随线宽缩放,但更改角度会导致输出不正确。我需要更多地研究箭头尖的各种键,以找出正确的排列方式。(尖头的圆度使计算变得相当烦人。)
这\pgfarrowssetlineend{.5\pgfarrowlinewidth}
使得实际线与箭头重叠。
您可以使用line width
钥匙– 箭头选项里面的那个!– 本质上调整圆角的半径。
代码
\documentclass[tikz]{standalone}
\usetikzlibrary{arrows.meta, spy}
\usetikzlibrary{ext.arrows} % for clone and append setup code,
\pgfdeclarearrow{
name = Stealth X, clone = Stealth,
append setup code=\pgfarrowssetlineend{.5\pgfarrowlinewidth}}
\pgfset{Triangle X/.tip={Stealth X[inset=+0pt, angle=+60:+2.7pt +3.6]}}
\begin{document}
\begin{tikzpicture}[
every path/.append style={line width=4ex},
connect spies/.append style=blue,
Tri/.tip={Triangle X[round, angle=30:+0pt +1.963]},
spy using outlines={%
circle, magnification=5, size=7mm, connect spies,
every spy in node/.append style={fill=white}}]
\draw[ Tri -Tri ] (0,0) -- +(right:2);
\draw[arrows={Tri[color=green]-Tri} ] (0,1) -- +(right:2);
\draw[arrows={Tri[color=green]-Tri}, opacity=.5] (0,2) -- +(right:2);
\spy on ( .59, 0.3) in node at (1,-0.2);
\spy on ( .59, 1.3) in node at (1, 0.7);
\spy on ( .59, 2.3) in node at (1, 1.7);
\spy on ( .59, 2.3) in node at (2, 1.7) [magnification=20];
\end{tikzpicture}
\end{document}