![tikz 中箭头的圆角](https://linux22.com/image/437814/tikz%20%E4%B8%AD%E7%AE%AD%E5%A4%B4%E7%9A%84%E5%9C%86%E8%A7%92.png)
我有一个如下所示的箭头:
\documentclass[tikz]{standalone}
\usetikzlibrary{shapes, arrows.meta, positioning}
\tikzset{every picture/.style={/utils/exec={\sffamily\normalsize}}}
\tikzstyle{textbox} = [rectangle, minimum width = 3.2cm, minimum height = 1cm, rounded corners = 1pt, line width = 1pt, draw = black, align = center]
\tikzstyle{arrow} = [solid, line width = 9pt, -{Triangle[width = 18pt, length = 12pt]}, color = black, shorten >= 3pt, shorten <= 3pt]
\begin{document}
\begin{tikzpicture}[node distance = 2cm and 1cm, outer sep = 0, inner sep = 0]
\node [textbox] (box1) {box1};
\node [textbox, right = of box1] (box2) {box2};
\draw [arrow] (box1) -- (box2);
\end{tikzpicture}
\end{document}
我的目标是将箭头的所有角都圆化 1pt,就像我对文本框所做的那样。我已经尝试过线帽和圆角,但没有效果。我怎样才能将箭头的所有角和线帽都圆化 1pt?
答案1
\documentclass[tikz]{standalone}
\usetikzlibrary{shapes, arrows.meta, positioning}
\tikzset{every picture/.style={/utils/exec={\sffamily\normalsize}}}
\tikzstyle{textbox} = [rectangle, minimum width = 3.2cm, minimum height = 1cm, rounded corners = 1pt, line width = 1pt, draw = black, align = center]
\tikzstyle{arrow} = [solid, line width = 9pt, -{Triangle[width = 18pt, length = 12pt, round, line width=1pt]}, color = black, shorten >= 3pt, shorten <= 3pt]
\begin{document}
\begin{tikzpicture}[node distance = 2cm and 1cm, outer sep = 0, inner sep = 0]
\node [textbox] (box1) {box1};
\node [textbox, right = of box1] (box2) {box2};
\draw [arrow] (box1) -- (box2);
\end{tikzpicture}
\end{document}
为了使左端变圆,你可以Square
像这样在末端添加一个圆形:
\documentclass[tikz]{standalone}
\usetikzlibrary{shapes, arrows.meta, positioning}
\tikzset{every picture/.style={/utils/exec={\sffamily\normalsize}}}
\tikzstyle{textbox} = [rectangle, minimum width = 3.2cm, minimum height = 1cm, rounded corners = 1pt, line width = 1pt, draw = black, align = center]
\tikzstyle{arrow} = [solid, line width = 9pt, {Square[round, line width=1pt, length= 2pt, width=9pt]}-{Triangle[width = 18pt, length = 12pt, round, line width=1pt]}, color = black, shorten >= 3pt, shorten <= 3pt]
\begin{document}
\begin{tikzpicture}[node distance = 2cm and 1cm, outer sep = 0, inner sep = 0]
\node [textbox] (box1) {box1};
\node [textbox, right = of box1] (box2) {box2};
\draw [arrow] (box1) -- (box2);
\end{tikzpicture}
\end{document}
另一种方法是根本不使用箭头,而是使用single arrow
节点形状。
编辑:
使用single arrow
节点也会使内角变圆,但是当然它不会像正常的绘制箭头那样延伸:
\documentclass[tikz]{standalone}
\usetikzlibrary{shapes, arrows.meta, positioning, shapes.arrows}
\tikzset{every picture/.style={/utils/exec={\sffamily\normalsize}}}
\tikzstyle{textbox} = [rectangle, minimum width = 3.2cm, minimum height = 1cm, rounded corners = 1pt, line width = 1pt, draw = black, align = center]
\begin{document}
\begin{tikzpicture}[node distance = 2cm and 1cm, outer sep = 0, inner sep = 0]
\node [textbox] (box1) {box1};
\node [textbox, right = of box1] (box2) {box2};
\path (box1) -- (box2) node[midway, xshift= -2pt, draw, single arrow, minimum height=0.8cm, minimum width=0.7cm, single arrow head extend=0.01cm, single arrow tip angle=75,rounded corners=1pt, fill]{};
\end{tikzpicture}
\end{document}