我在自动机绘图中有六种状态:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{automata}
\begin{document}
\begin{tikzpicture}[node distance=5cm,thick,every state/.style={minimum size=3cm}]
\node[state,draw=blue,fill=blue!20] (A) {A};
\node[state,draw=red,fill=red!20] (B) [right of=A] {B};
\node[state,draw=red,fill=red!20] (E) [below of=B] {E};
\node[state,draw=blue,fill=blue!20] (C) [right of=B] {C};
\node[state,draw=green!50!black,fill=green!20] (D) [below of=A] {D};
\node[state,draw=red,fill=red!20] (F) [below of=C] {F};
\path[-,violet,line width=1mm]
(A) edge node [color=black,sloped,above] {G1,G2,G3} (E)
edge node [color=black,sloped,above] {G1} (B)
(D) edge node [color=black,sloped,above] {G4} (E)
(C) edge node [color=black,sloped,above] {G5} (E)
edge node [color=black,sloped,above] {G5} (F)
(E) edge node [color=black,sloped,above] {G5} (F)
(B) edge node [color=black,sloped,above] {G1} (E);
\end{tikzpicture}
\end{document}
从而产生了这个
我现在想要的是画一个大箭头,触及所有带有文字的节点。
这个例子太棒了但我不知道如何修改它以便通过节点。
我想要这样的东西:
但看起来更漂亮(使用 TiKZ,之前的图像是在 inkscape 中完成的)
答案1
这演示了一种叠加带有曲线文本的路径的方法。使用粗的半透明线绘制宽路径。text along path
在绘制线条后,使用装饰来添加文本postaction
。最后,通过使用细的边缘线在第一条路径上绘制两条附加路径,为路径赋予不透明边缘。
\documentclass[tikz,border=5pt]{standalone}
\usetikzlibrary{automata,calc,positioning,decorations.text}
\begin{document}
\begin{tikzpicture}
[
node distance=5cm,
thick,
every state/.style={minimum size=3cm},
every edge/.append style={
every node/.append style={text=black, sloped, above}
},
]
\node[state,draw=blue,fill=blue!20] (A) {A};
\node[state,draw=red,fill=red!20] (B) [right=of A.center] {B};
\node[state,draw=red,fill=red!20] (E) [below=of B.center] {E};
\node[state,draw=blue,fill=blue!20] (C) [right=of B.center] {C};
\node[state,draw=green!50!black,fill=green!20] (D) [below=of A.center] {D};
\node[state,draw=red,fill=red!20] (F) [below=of C.center] {F};
\path[-,violet,line width=1mm]
(A) edge node {G1,G2,G3}
(E) edge node [below] {G1} (B)
(D) edge node {G4} (E)
(C) edge node {G5} (E)
edge node {G5} (F)
(E) edge node {G5} (F)
(B) edge node {G1} (E);
\path
[
line width=7.5mm,
draw=violet!25,
opacity=.75,
] ($(B.north)!1/2!(E.south)$) coordinate (c) circle (75mm and 40mm);
\path
[
thick,
draw=violet,
] (c) circle (78.75mm and 43.75mm) circle (71.25mm and 36.25mm)
;
\path
[
postaction={
decorate,
opacity=1,
decoration={
text along path,
text={|\LARGE\sffamily|Some text here Some text here ||},
raise=-5pt,
pre length=200mm,
text color=black,
reverse path=true,
pre=moveto
}
}
] (c) circle (75mm and 40mm);
\end{tikzpicture}
\end{document}
编辑
这是一个与您在问题中链接的示例有些相似的例子。它使用带有文本装饰的粗箭头。
\documentclass[tikz,border=5pt]{standalone}
\usetikzlibrary{automata,calc,positioning,decorations.text,arrows.meta,bending}
\begin{document}
\begin{tikzpicture}
[
node distance=5cm,
thick,
every state/.style={minimum size=3cm},
every edge/.append style={
every node/.append style={text=black, sloped, above}
},
my arrow/.style={line width=7.5mm, draw=violet, {Triangle Cap[reversed,bend]}-{Triangle Cap[bend]}},
]
\node[state,draw=blue,fill=blue!20] (A) {A};
\node[state,draw=red,fill=red!20] (B) [right=of A.center] {B};
\node[state,draw=red,fill=red!20] (E) [below=of B.center] {E};
\node[state,draw=blue,fill=blue!20] (C) [right=of B.center] {C};
\node[state,draw=green!50!black,fill=green!20] (D) [below=of A.center] {D};
\node[state,draw=red,fill=red!20] (F) [below=of C.center] {F};
\path[-,violet,line width=1mm]
(A) edge node {G1,G2,G3}
(E) edge node [below] {G1} (B)
(D) edge node {G4} (E)
(C) edge node {G5} (E)
edge node {G5} (F)
(E) edge node {G5} (F)
(B) edge node {G1} (E);
\path [my arrow] ($(B.north)!1/2!(E.south)$) coordinate (c) +(75mm,0) arc (0:-90:75mm and 40mm);
\path [my arrow] (c) +(0,-40mm) arc (270:180:75mm and 40mm);
\path
[
my arrow,
postaction=decorate,
decoration={
text along path,
text={|\LARGE\sffamily|Some text here Some text here ||},
text color=white,
raise=-5pt,
pre length=10mm,
pre=moveto
}
] (c) +(-75mm,0) arc (180:90:75mm and 40mm);
\path
[
my arrow,
postaction=decorate,
decoration={
text along path,
text={|\LARGE\sffamily|More text here More text here ||},
text color=white,
raise=-5pt,
pre length=10mm,
pre=moveto
}
] (c) +(0,40mm) arc (90:0:75mm and 40mm);
\end{tikzpicture}
\end{document}