优雅地放置沿路径不等距的标记

优雅地放置沿路径不等距的标记

我想沿路径放置圆,但它们的距离不等。问题是代码重复且丑陋。还有其他更优雅的方法吗?

梅威瑟:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}

\begin{document}

\begin{tikzpicture}
\draw[decoration={markings,%
  mark=at position 0.1 with {\fill (0,0) circle (0.06);},%
  mark=at position 0.35 with {\fill (0,0) circle (0.06);},%
  mark=at position 0.5 with {\fill (0,0) circle (0.06);},%
  mark=at position 0.7 with {\fill (0,0) circle (0.06);},%
  mark=at position 0.85 with {\fill (0,0) circle (0.06);}},%
  postaction={decorate}] (0,0) arc (-35:-30:15) arc (-30:35:2) arc (215:170:1.5) arc (170:165:15);
\end{tikzpicture}

\end{document}

在此处输入图片描述

答案1

改用/.list自定义样式,使用几次标记。否则,您必须破解一个不那么有趣的宏。

\documentclass[tikz]{standalone}
\usetikzlibrary{decorations.markings}
\pgfkeys{
  /pgf/decoration/irregular markings/.style = {
    mark= at position#1with {\fill (0,0) circle (0.06);}
  }
}

\begin{document}
\begin{tikzpicture}
\draw[decoration={markings,irregular markings/.list={0.1,0.35,0.5,0.7,0.85}},
      postaction={decorate}
] (0,0) arc (-35:-30:15) arc (-30:35:2) arc (215:170:1.5) arc (170:165:15);
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容