I use the following code from the answers to this post and this post to fill rectangular grids with predefined shapes.
Is it possible to fill grids with predefined outlines, other than the default rectangular shape; for example as in the included lower picture!
\documentclass[12pt,a4paper]{article}
\usepackage{verbatim}
\usepackage{tikz}
\usepackage{geometry}
\geometry{a4paper, left=10mm, right=10mm, top=8mm, bottom=15mm}
\begin{document}
\pgfmathsetmacro{\lwdth}{.3mm}
\pgfmathsetmacro{\opc}{0.6}
\def\refpnt{%
\fill[black] (0,0) circle [radius=4pt];
}
%begin defining fill colours ==========================
\tikzset{%
filrd/.style={%
fill=red},
filgr/.style={%
fill=green},
filbl/.style={%
fill=blue},
}
%end defining fill colours ==========================
%begin defining grid ==========================
\newcommand\sqw{1}
\tikzset{
pics/square/.default={\sqw},
pics/square/.style = {
code = {
\draw[pic actions, draw=none] (0,0) rectangle (#1,#1);
}}}%draw=none is to avoid displaying the little squares outline
\renewcommand\sqw{1.4}
%end defining grid ==========================
%begin defining pentoshapes solution ==========================
\tikzset
{%
%
pics/pent-W/.style={code={\draw[xscale=#1, filrd] (1\sqw,0\sqw) |- (0\sqw,1\sqw) |- (1\sqw,3\sqw) |- (2\sqw,2\sqw) |- (3\sqw,1\sqw) |- cycle;
\refpnt
}},%
pics/pent-W/.default={1},%
%
pics/pent-Z/.style={code={\draw[xscale=#1, filbl] (1\sqw,0\sqw) |- (0\sqw,2\sqw) |- (2\sqw,3\sqw) |- (3\sqw,1\sqw) |- cycle;
\refpnt
}},%
pics/pent-Z/.default={1},%
%
pics/pent-L/.style={code={\draw[xscale=#1, filgr] (0\sqw,0\sqw) |- (1\sqw,4\sqw) |- (2\sqw,1\sqw) |- cycle;
\refpnt
}},%
pics/pent-L/.default={1},%
}%
%end defining pentoshapes solution ==========================
\begin{center}
\begin{tikzpicture}[scale=1, transform shape, fill opacity=\opc, line width=\lwdth]
\draw[step=\sqw] (\sqw,\sqw) grid (15\sqw, 16\sqw);
%
\node at (4.5\sqw,10.5\sqw) {\huge\bf W};
\pic [rotate=90] at (5\sqw,7\sqw) {pent-W};
%
\node at (7.5\sqw,11.5\sqw) {\huge\bf Z};
\pic [rotate=0] at (6\sqw,8\sqw) {pent-Z};
%
\node at (9.5\sqw,13.5\sqw) {\huge\bf L};
\pic [rotate=0] at (10\sqw,9\sqw) {pent-L={-1}};
%
\end{tikzpicture}
\end{center}
\end{document}


\clip? – Symbol 1 Feb 05 '22 at 04:55\pgfdeclarepatternformonly? – Symbol 1 Feb 05 '22 at 07:31\foreachor matrix to create your own grids. – John Kormylo Feb 05 '22 at 18:01