# How to draw slit diffraction pattern in TikZ?

Does anyone know how to do this scheme? Thanks in advance

New contributor
Quentin Mosset is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

This is one option (it is a bit bloated, but you will see why below)

\documentclass[border = 5pt, tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}

\def\nframes{20}
\def\frame{0}

\begin{document}

\foreach \frame in {0,...,\nframes}
{
\pgfmathsetmacro{\time}{\frame / \nframes}

\begin{tikzpicture}[
slit/.style={
line width = 3pt,
blue
},
wave/.style={
green!30!black
},
arrow/.style={
->,
tips = proper,
color = magenta,
line width = 1.5mm
}
]

%
\path (-4, -4) rectangle (4, 4);

% slit
\draw[slit] (0, 1) -- ++(0, 2) (0, -1) -- ++(0, -2);

% wave in
\foreach \x in {-4,...,-1} {
\draw[wave] (\x + \time, -3) -- (\x + \time, 3);
}

% wave out
\foreach \x in {0,...,3} {
\draw[wave] (\x + \time, -1) -- (\x + \time, 1);
}

\foreach \x in {0,...,2} {
\draw[wave, xshift = 1cm, yshift = 1cm, rotate = 30] (\x + \time, -1) -- (\x + \time, 1);
\draw[wave, xshift = 1cm, yshift = -1cm, rotate = -30] (\x + \time, -1) -- (\x + \time, 1);
}

% arrow
\draw[arrow] (0.5, 1) ++ (30:\time) -- ++(30: 1);
\draw[arrow] (-3.0, 0.0) ++ (0:\time) -- ++(0: 1);
\draw[arrow] (1.0, 0.0) ++ (0:\time) -- ++(0: 1);
\draw[arrow] (0.5, -1) ++ (-30:\time) -- ++(-30: 1);

\end{tikzpicture}
}
\end{document}


Now, if you uncomment the line \foreach \frame in {0,...,\nframes} this is what you get