Search color patterm on the grid

Hope it helps. You have done a clear description of what you want.
If you need it could be possible to change the number ratio between shapes.