%
% shift.tex -- template for standalon tikz images
%
% (c) 2021 Prof Dr Andreas Müller, OST Ostschweizer Fachhochschule
%
\documentclass[tikz]{standalone}
\usepackage{amsmath}
\usepackage{times}
\usepackage{txfonts}
\usepackage{pgfplots}
\usepackage{csvsimple}
\usetikzlibrary{arrows,intersections,math}
\begin{document}
\def\skala{1}
\begin{tikzpicture}[>=latex,thick,scale=\skala]

\definecolor{darkgreen}{rgb}{0,0.6,0}

\def\s{0.8}
\def\punkt#1#2{({#1*\s},{#2*\s})}

\def\feld#1#2#3#4{
	\fill[color=#3] \punkt{#1}{#2} rectangle \punkt{(#1+1)}{(#2+1)};
	\node at \punkt{(#1+0.5)}{(#2+0.5)} {$\mathstrut #4$};
}
\def\gitter{
	\draw \punkt{0}{0} rectangle \punkt{8}{4};
	\foreach \x in {1,...,7}{
		\draw \punkt{\x}{0} -- \punkt{\x}{4};
	}
	\foreach \y in {1,...,3}{
		\draw \punkt{0}{\y} -- \punkt{8}{\y};
	}
}

\begin{scope}
	\feld{0}{3}{red!20}{b_{0}}
	\feld{0}{2}{red!20}{b_{1}}
	\feld{0}{1}{red!20}{b_{2}}
	\feld{0}{0}{red!20}{b_{3}}

	\feld{1}{3}{red!10}{b_{4}}
	\feld{1}{2}{red!10}{b_{5}}
	\feld{1}{1}{red!10}{b_{6}}
	\feld{1}{0}{red!10}{b_{7}}

	\feld{2}{3}{yellow!20}{b_{8}}
	\feld{2}{2}{yellow!20}{b_{9}}
	\feld{2}{1}{yellow!20}{b_{10}}
	\feld{2}{0}{yellow!20}{b_{11}}

	\feld{3}{3}{yellow!10}{b_{12}}
	\feld{3}{2}{yellow!10}{b_{13}}
	\feld{3}{1}{yellow!10}{b_{14}}
	\feld{3}{0}{yellow!10}{b_{15}}

	\feld{4}{3}{darkgreen!20}{b_{16}}
	\feld{4}{2}{darkgreen!20}{b_{17}}
	\feld{4}{1}{darkgreen!20}{b_{18}}
	\feld{4}{0}{darkgreen!20}{b_{19}}

	\feld{5}{3}{darkgreen!10}{b_{20}}
	\feld{5}{2}{darkgreen!10}{b_{21}}
	\feld{5}{1}{darkgreen!10}{b_{22}}
	\feld{5}{0}{darkgreen!10}{b_{23}}

	\feld{6}{3}{blue!20}{b_{24}}
	\feld{6}{2}{blue!20}{b_{25}}
	\feld{6}{1}{blue!20}{b_{26}}
	\feld{6}{0}{blue!20}{b_{27}}

	\feld{7}{3}{blue!10}{b_{28}}
	\feld{7}{2}{blue!10}{b_{29}}
	\feld{7}{1}{blue!10}{b_{30}}
	\feld{7}{0}{blue!10}{b_{31}}

	\gitter

	\draw[->] \punkt{8.1}{2} -- \punkt{9.3}{2};
\end{scope}


\begin{scope}[xshift=7.5cm]

	\feld{0}{3}{red!20}{b_{0}}
	\feld{1}{2}{red!20}{b_{1}}
	\feld{2}{1}{red!20}{b_{2}}
	\feld{3}{0}{red!20}{b_{3}}

	\feld{1}{3}{red!10}{b_{4}}
	\feld{2}{2}{red!10}{b_{5}}
	\feld{3}{1}{red!10}{b_{6}}
	\feld{4}{0}{red!10}{b_{7}}

	\feld{2}{3}{yellow!20}{b_{8}}
	\feld{3}{2}{yellow!20}{b_{9}}
	\feld{4}{1}{yellow!20}{b_{10}}
	\feld{5}{0}{yellow!20}{b_{11}}

	\feld{3}{3}{yellow!10}{b_{12}}
	\feld{4}{2}{yellow!10}{b_{13}}
	\feld{5}{1}{yellow!10}{b_{14}}
	\feld{6}{0}{yellow!10}{b_{15}}

	\feld{4}{3}{darkgreen!20}{b_{16}}
	\feld{5}{2}{darkgreen!20}{b_{17}}
	\feld{6}{1}{darkgreen!20}{b_{18}}
	\feld{7}{0}{darkgreen!20}{b_{19}}

	\feld{5}{3}{darkgreen!10}{b_{20}}
	\feld{6}{2}{darkgreen!10}{b_{21}}
	\feld{7}{1}{darkgreen!10}{b_{22}}
	\feld{0}{0}{darkgreen!10}{b_{23}}

	\feld{6}{3}{blue!20}{b_{24}}
	\feld{7}{2}{blue!20}{b_{25}}
	\feld{0}{1}{blue!20}{b_{26}}
	\feld{1}{0}{blue!20}{b_{27}}

	\feld{7}{3}{blue!10}{b_{28}}
	\feld{0}{2}{blue!10}{b_{29}}
	\feld{1}{1}{blue!10}{b_{30}}
	\feld{2}{0}{blue!10}{b_{31}}

	\gitter

\end{scope}

\end{tikzpicture}
\end{document}

