編輯

編輯

我在自動機繪圖中有六種狀態:

\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}

自動機上的箭頭

相關內容