I use the following code from the answer to this post to draw the progress of Coloraddo game, which uses 3x3 cards to be arranged in a board; displaying only a part of the board, as illustrated below.
Other cards are used in different arrangements in other locations of the document.
Is it possible to put each card in a \pic and then insert each \pic in its respective location; instead of repeating drawing the whole board!
\documentclass[12pt,a4paper]{article}
\usepackage{geometry}
\geometry{a4paper, left=10mm, right=10mm, top=8mm, bottom=15mm}
\usepackage{verbatim}
\usepackage{tikz}
\usetikzlibrary{calc,shapes}
\begin{document}
%begin defining shapes ==========================
\pgfmathsetmacro{\lwdth}{.3mm}% for line width
\tikzset{%
trg/.style={%
regular polygon, regular polygon sides=3, draw=black, line width=\lwdth, fill=blue, minimum size=1.4cm, rounded corners=0.1cm},
crc/.style={%
circle, draw=black, line width=\lwdth, fill=green!70!black, minimum size=1.cm},
sqr/.style={%
regular polygon, regular polygon sides=4, draw=black, line width=\lwdth, fill=yellow, minimum size=1.2cm},
str/.style={%
star, star points=6, draw=black, line width=\lwdth, fill=red, minimum size=1.1cm},
filrd/.style={%
fill=red},
filgr/.style={%
fill=green},
filyw/.style={%
fill=yellow},
filbl/.style={%
fill=blue},
}
%end defining shapes ==========================
%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);
}}}
\renewcommand\sqw{1.3}
%end defining grid ==========================
An example of the placement of the first 4 cards of a game
starting board before play begins
\begin{tikzpicture}[scale=0.3, transform shape]
\draw[step=\sqw] (\sqw,\sqw) grid (10\sqw, 7\sqw);
%
\foreach \i in {3,2,1}{
\foreach \j in {1,2,3}{
\pic[filrd] at (\j\sqw,\i\sqw) {square};};};
%
\foreach \i in {3,2,1}{
\foreach \j in {4,5,6}{
\pic[filbl] at (\j\sqw,\i\sqw) {square};};};
%
\foreach \i in {6,5,4}{
\foreach \j in {7,8,9}{
\pic[filbl] at (\j\sqw,\i\sqw) {square};};};
%
\foreach \i in {3,2,1}{
\foreach \j in {7,8,9}{
\pic[filyw] at (\j\sqw,\i\sqw) {square};};};
%
\foreach \i in {6,5,4}{
\foreach \j in {4,5,6}{
\pic[filyw] at (\j\sqw,\i\sqw) {square};};};
%
%
\foreach\x/\y in {1.5/5.4,2.5/5.4,3.5/4.4}
\node[trg] at (\x\sqw,\y\sqw) {};
%
\foreach\x/\y in {1.5/4.5,2.5/6.5}
\node[sqr] at (\x\sqw,\y\sqw) {};
%
\foreach\x/\y in {1.5/6.5,3.5/5.5}
\node[str] at (\x\sqw,\y\sqw) {};
%
\foreach\x/\y in {2.5/4.5,3.5/6.5}
\node[crc] at (\x\sqw,\y\sqw) {};
\end{tikzpicture}
\vskip .6cm
after player 1 places card 1 \kern 4.9mm
\begin{tikzpicture}[scale=0.3, transform shape]
\draw[step=\sqw] (\sqw,\sqw) grid (10\sqw, 7\sqw);
%
\foreach \i in {3,2,1}{
\foreach \j in {1,2,3}{
\pic[filrd] at (\j\sqw,\i\sqw) {square};};};
%
\foreach \i in {3,2,1}{
\foreach \j in {4,5,6}{
\pic[filbl] at (\j\sqw,\i\sqw) {square};};};
%
\foreach \i in {6,5,4}{
\foreach \j in {7,8,9}{
\pic[filbl] at (\j\sqw,\i\sqw) {square};};};
%
\foreach \i in {3,2,1}{
\foreach \j in {7,8,9}{
\pic[filyw] at (\j\sqw,\i\sqw) {square};};};
%
%
\foreach\x/\y in {1.5/5.4,2.5/5.4,3.5/4.4,4.5/4.4}
\node[trg] at (\x\sqw,\y\sqw) {};
%
\foreach\x/\y in {1.5/4.5,2.5/6.5}
\node[sqr] at (\x\sqw,\y\sqw) {};
%
\foreach\x/\y in {1.5/6.5,3.5/5.5,4.5/5.5,5.5/5.5,5.5/4.5}
\node[str] at (\x\sqw,\y\sqw) {};
%
\foreach\x/\y in {2.5/4.5,3.5/6.5,4.5/6.5,5.5/6.5,6.5/6.5,6.5/5.5,6.5/4.5}
\node[crc] at (\x\sqw,\y\sqw) {};
\end{tikzpicture}
\vskip .4cm
after player 2 places card 2 \kern 4.9mm
\begin{tikzpicture}[scale=0.3, transform shape]
\draw[step=\sqw] (\sqw,\sqw) grid (10\sqw, 7\sqw);
%
\foreach \i in {3,2,1}{
\foreach \j in {1,2,3}{
\pic[filrd] at (\j\sqw,\i\sqw) {square};};};
%
\foreach \i in {6,5,4}{
\foreach \j in {7,8,9}{
\pic[filbl] at (\j\sqw,\i\sqw) {square};};};
%
\foreach \i in {3,2,1}{
\foreach \j in {7,8,9}{
\pic[filyw] at (\j\sqw,\i\sqw) {square};};};
%
%
\foreach\x/\y in {1.5/5.4,2.5/5.4,3.5/4.4,4.5/4.4}
\node[trg] at (\x\sqw,\y\sqw) {};
%
\foreach\x/\y in {1.5/4.5,2.5/6.5,4.5/3.5,4.5/1.5}
\node[sqr] at (\x\sqw,\y\sqw) {};
%
\foreach\x/\y in {1.5/6.5,3.5/5.5,4.5/5.5,5.5/5.5,5.5/4.5,4.5/2.5,5.5/3.5,5.5/2.5,5.5/1.5,6.5/2.5}
\node[str] at (\x\sqw,\y\sqw) {};
%
\foreach\x/\y in {2.5/4.5,3.5/6.5,4.5/6.5,5.5/6.5,6.5/6.5,6.5/5.5,6.5/4.5,6.5/3.5,6.5/1.5}
\node[crc] at (\x\sqw,\y\sqw) {};
\end{tikzpicture}
\vskip .4cm
after player 3 places card 3 \kern 4.9mm
\begin{tikzpicture}[scale=0.3, transform shape]
\draw[step=\sqw] (\sqw,\sqw) grid (10\sqw, 7\sqw);
%
\foreach \i in {6,5,4}{
\foreach \j in {7,8,9}{
\pic[filbl] at (\j\sqw,\i\sqw) {square};};};
%
\foreach \i in {3,2,1}{
\foreach \j in {7,8,9}{
\pic[filyw] at (\j\sqw,\i\sqw) {square};};};
%
%
\foreach\x/\y in {1.5/5.4,2.5/5.4,3.5/4.4,4.5/4.4,3.5/3.4}
\node[trg] at (\x\sqw,\y\sqw) {};
%
\foreach\x/\y in {1.5/4.5,2.5/6.5,4.5/3.5,4.5/1.5,1.5/3.5,1.5/2.5,1.5/1.5,2.5/1.5,3.5/1.5}
\node[sqr] at (\x\sqw,\y\sqw) {};
%
\foreach\x/\y in {1.5/6.5,3.5/5.5,4.5/5.5,5.5/5.5,5.5/4.5,4.5/2.5,5.5/3.5,5.5/2.5,5.5/1.5,6.5/2.5}
\node[str] at (\x\sqw,\y\sqw) {};
%
\foreach\x/\y in {2.5/4.5,3.5/6.5,4.5/6.5,5.5/6.5,6.5/6.5,6.5/5.5,6.5/4.5,6.5/3.5,6.5/1.5,2.5/3.5,2.5/2.5,3.5/2.5}
\node[crc] at (\x\sqw,\y\sqw) {};
\end{tikzpicture}
\vskip 1.cm
central square
\begin{tikzpicture}[scale=0.5, transform shape]
\draw[step=\sqw] (\sqw,\sqw) grid (4\sqw, 4\sqw);
%
\foreach\x/\y in {1.5/2.4,2.5/2.4,3.5/1.4}
\node[trg] at (\x\sqw,\y\sqw) {};
%
\foreach\x/\y in {1.5/3.5,3.5/2.5}
\node[str] at (\x\sqw,\y\sqw) {};
%
\foreach\x/\y in {1.5/1.5,2.5/3.5}
\node[sqr] at (\x\sqw,\y\sqw) {};
%
\foreach\x/\y in {2.5/1.5,3.5/3.5}
\node[crc] at (\x\sqw,\y\sqw) {};
\end{tikzpicture}
\hskip .6cm
card1
\begin{tikzpicture}[scale=0.5, transform shape]
\draw[step=\sqw] (\sqw,\sqw) grid (4\sqw, 4\sqw);
%
\foreach\x/\y in {1.5/1.4}
\node[trg] at (\x\sqw,\y\sqw) {};
%
\foreach\x/\y in {1.5/2.5,2.5/2.5,3.5/2.5,2.5/1.5}
\node[str] at (\x\sqw,\y\sqw) {};
%
\foreach\x/\y in {1.5/3.5,2.5/3.5,3.5/3.5,3.5/2.5,3.5/1.5}
\node[crc] at (\x\sqw,\y\sqw) {};
\end{tikzpicture}
\hskip .6cm
card2
\begin{tikzpicture}[scale=0.5, transform shape]
\draw[step=\sqw] (\sqw,\sqw) grid (4\sqw, 4\sqw);
%
\foreach\x/\y in {1.5/2.5,2.5/1.5,2.5/2.5,2.5/3.5,3.5/2.5}
\node[str] at (\x\sqw,\y\sqw) {};
%
\foreach\x/\y in {1.5/1.5,1.5/3.5}
\node[sqr] at (\x\sqw,\y\sqw) {};
%
\foreach\x/\y in {3.5/1.5,3.5/3.5}
\node[crc] at (\x\sqw,\y\sqw) {};
\end{tikzpicture}
\hskip .6cm
card3
\begin{tikzpicture}[scale=0.5, transform shape]
\draw[step=\sqw] (\sqw,\sqw) grid (4\sqw, 4\sqw);
%
\foreach\x/\y in {3.5/3.4}
\node[trg] at (\x\sqw,\y\sqw) {};
%
\foreach\x/\y in {1.5/1.5,1.5/2.5,1.5/3.5,2.5/1.5,3.5/1.5}
\node[sqr] at (\x\sqw,\y\sqw) {};
%
\foreach\x/\y in {2.5/2.5,2.5/3.5,3.5/2.5}
\node[crc] at (\x\sqw,\y\sqw) {};
\end{tikzpicture}
\end{document}






pic, IMO. – Black Mild Sep 24 '22 at 22:58