如何用装饰代替线段对象的长度?

如何用装饰代替线段对象的长度?

在以下 TikZ 示例中,我想用装饰代替蛇的用法。我该如何调整装饰segment object length

\documentclass[tikz, preview=true]{standalone}

\usetikzlibrary{snakes}
\usetikzlibrary{decorations.pathmorphing}
\tikzstyle{radiowave old}=[snake=waves,
                           segment length=1mm,
                           segment object length=4mm,
                           segment angle=30
                         ]

\tikzstyle{radiowave new}=[decorate, 
                       decoration={waves,
                         segment length=1mm,
                         %segment object length=4mm, <- not available
                         angle=30}
                      ]

\begin{document}
  \begin{tikzpicture}                         
    \draw[radiowave old] (-1,1) to node[left,pos=0] {old} (1,-1);                     
    \draw[radiowave new] (-1,-1) to node[right,pos=1] {new} (1,1);
\end{tikzpicture}
\end{document}

TikZ example with waves

答案1

关键是调用radius。我还将您对弃用的用法转换\tikzstyle为现代的\tikzset

\documentclass[tikz, preview=true]{standalone}
\usetikzlibrary{snakes}
\usetikzlibrary{decorations.pathmorphing}
\tikzset{
  radiowave old/.style={
    snake=waves,
    segment length=1mm,
    segment object length=4mm,
    segment angle=30
  },
  radiowave new/.style={
    decorate, 
    decoration={
      waves,
      segment length=1mm,
      radius=4mm,
      angle=30
    }
  }
}
\begin{document}
\begin{tikzpicture}                         
  \draw[radiowave old] (-1,1) to node[left,pos=0] {old} (1,-1);                     
  \draw[radiowave new] (-1,-1) to node[right,pos=1] {new} (1,1);
\end{tikzpicture}
\end{document}

enter code here

相关内容