# Using for loop in tikz to draw repeated shapes

I am trying to create a lenticular pattern like the one in the picture. I believe the repeated shape can be drawn using a for loop in tikz, but I wasn't able to get it done properly.

Appreciate any help on looping.

Edit: This is a part of a bigger diagram and below is the code.

\begin{document}
\begin{tikzpicture}[>={Stealth[inset=0pt,length=10pt,angle'=35,round]}]

\pgfmathsetmacro{\lensRadius}{6}
\pgfmathsetmacro{\lensHeight}{3}
\pgfmathsetmacro{\startAngle}{asin(\lensHeight/\lensRadius)}

\draw []  (0,\lensHeight)
arc[start angle=180-\startAngle,delta
angle=2*\startAngle,radius=\lensRadius]node [below, align=center] {\\
[1em]Main\\[-1ex]lens}
arc[start angle=-\startAngle,delta angle=2*\startAngle,radius=\lensRadius]
-- cycle;

\draw [line width=1mm ] (-1.5,3) -- (-1.5,-3) node [below, align=center] {\\
[1em]Weak\\[-1ex]diffuser};

\draw []  (6,\lensHeight)
arc[start angle=180-\startAngle,delta
angle=2*\startAngle,radius=\lensRadius]node [below, align=center] {\\
[1em]Field\\[-1ex]lens}
-- cycle;

\draw[] plot[only marks, mark=*,mark size=10pt,mark options={fill=Sepia}]
coordinates{(-6.5,0)} node[below, align=center]{\\[1em]Object};
\draw[] (-6,0) -- (0,3);
\draw[] (-6,0) -- (0,-3);

\draw[] (6.5,0) -- (0,3);
\draw[] (6.5,0) -- (0,-3);

%lenticular pattern
\pgfmathsetmacro{\lensRadius}{0.2}
\pgfmathsetmacro{\lensHeight}{0.2}
\pgfmathsetmacro{\startAngle}{asin(\lensHeight/\lensRadius)}
\draw []  (8,\lensHeight)
arc[start angle=180-\startAngle,delta
angle=2*\startAngle,radius=\lensRadius];
\draw [line width=0.25mm ] (8,3) -- (8,-3) -- (8.2,-3) -- (8.2,3) -- cycle;

\end{tikzpicture}
\end{document}


Output:

• @Raaja sometimes one simply has no clue where to start :) I wouldn't close a question simply because one doesn't know how to do something: that's why they're here. – Superuser27 Mar 13 '19 at 7:38
• @Superuser27 An OP doesnt always need a perfect MWE to start with. But atleast some commitment or motivation should be there behind a question, instead of knowing the way how to proceed and not trying it. Everyone of us makes mistakes (I am also learning things that way). In this case OP knows what to do, and has the recipies to do. It's just a matter of trial-and-error to atleast begin something. If you see this: tex.stackexchange.com/questions/472117/… then OP already has some knowledge on where to start with :). – Raaja is not active on TEXSE Mar 13 '19 at 7:45
• @Raaja Thanks for pointing out. Added the code and the output I got so far. – Sndn Mar 13 '19 at 8:22
• @sndn good!! +1 since, this question already has an answer given by marmot. Consider accepting it, if you think that solves your issue. – Raaja is not active on TEXSE Mar 13 '19 at 8:30

## 1 Answer

There are many possibilities to draw something like is, here is one of them.

\documentclass[tikz,border=3.14mm]{standalone}
\begin{document}
\begin{tikzpicture}[pics/rr/.style={code={\draw (0.2,-0.2) |- ++(-0.4,0.4)
to[out=180,in=180] ++ (0,-0.4) -- cycle;}}]
\path foreach \X in {0,1,...,10}
{(0,0.4*\X) pic{rr}};
\draw (0.2,-0.2) rectangle (0.4,10*0.4+0.2);
\end{tikzpicture}
\end{document}