オートマトン描画には 6 つの状態があります。
\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
これは、パスに曲線状のテキストを重ねる 1 つの方法を示しています。太い半透明の線を使用して幅の広いパスを描画します。text along path
で線を描画した後、装飾を使用してテキストを追加しますpostaction
。最後に、細い縁取り線を使用して最初のパスの上に 2 つのパスを追加描画し、パスに不透明なエッジを付けます。
\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}