I'm drawing a symbolic image of a DNA with tikz:
I did this using
decorations.markings
:
\documentclass[margin = 12mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\begin{document}\begin{tikzpicture}
\newcommand*{\adenin}[2]{\begin{scope}[shift = {#1}, rotate = #2, fill = red]%
\fill(0, -.1) -- (.35, -.1) -- (.45, 0) -- (.35, .1) -- (0, .1) -- cycle;%
\end{scope}}%
\newcommand*{\thymin}[2]{\begin{scope}[shift = {#1}, rotate = #2, fill = blue]%
\fill(0, -.1) -- (.35, -.1) -- (.25, 0) -- (.35, .1) -- (0, .1) -- cycle;
\end{scope}}%
\newcommand*{\guanin}[2]{\begin{scope}[shift = {#1}, rotate = #2, fill = green]%
\fill(0, -.1) -- (.35, -.1) arc(-90:90:.1) -- (.35, .1) -- (0, .1) -- cycle;% -- (0, .1) -- cycle;%
\end{scope}}%
\newcommand*{\cytosin}[2]{\begin{scope}[shift = {#1}, rotate = #2, fill = yellow]%
\fill(0, -.1) -- (.35, -.1) arc(270:90:.1) -- (.35, .1) -- (0, .1) -- cycle;%
\end{scope}}%
\draw[double distance = 1pt, line cap = rect, decoration = {
markings,
mark = at position 5pt with { \adenin{(0, 0)}{270} },
% 200 more lines with at position ...
mark = at position 370pt with { \cytosin{(0, 0)}{270}{1.25} }
}, preaction = {decorate}, shorten <= -3pt]
(-.5, -1.2) .. controls (2, 1) and (4, -1) .. (6, 0)
.. controls (9, 1.5) and (10, 0) .. (12, 0);
% the other three paths with each 200 lines with at position...
\end{tikzpicture}\end{document}
According to the tikz manual, 31.5 markings can only be specified using either
/pgf/decoration/mark=at position <pos> with <code>
where <pos>
is one number or
/pgf/decoration/mark=between positions <start pos> and <end pos> step <stepping> with <code>
this one being only for regularly repeating markings, which is not the case.
Because it looks like there is no way to specify a list of positions of markings I thought the easiest way would be to do a loop for each position, but I can't figure out how to put the loop inside the options definition.
Although it wouldn't change anything on the outcome, I'm interested in how to simplify my code. Sorry for the long example. Thanks for any help in advance