5

I want to put circles along path, but they are not equidistant. The problem is that code is repetitive and ugly. Is there any other more elegant way to do that?

MWE:

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

enter image description here

Pygmalion
  • 6,387
  • 4
  • 34
  • 68

1 Answers1

9

Use a /.list instead with a custom style that uses markings a few times. Otherwise you have to hack a macro that is not so fun.

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

enter image description here

percusse
  • 157,807