Only for comparison, compile with Asymptote.
In all my examples, s
is a scale.
A similar code of Thruston's answer.
size(300);
real s=1/8;
for (int m=3; m<=5; ++m){
path[] a={polygon(m)};
for (int i=1; i<= m/s; ++i){
pair[] A;
for (int j=0; j < size(a[i-1]); ++j)
{
A[j] = point(a[i-1],j+s);
}
a[i]=operator --(... A)--cycle;
}
picture P;
for (int i=0; i<a.length; ++i)
filldraw(P,a[i],interp(white,blue,(i+1)*s));
add(shift((2*m,0))*P);
}

Animation:
settings.tex="pdflatex";
import animate;
size(300);
real s=1/8;
animation Ani;
path[] testpolygon(int m)
{
path[] a={polygon(m)};
for (int i=1; i<= m/s; ++i){
pair[] A;
for (int j=0; j < size(a[i-1]); ++j)
{
A[j] = point(a[i-1],j+s);
}
a[i]=operator --(... A)--cycle;
}
return a;
}
for (int n=3; n<=5; ++n){
for (int i=0; i<testpolygon(n).length; ++i){
save();
filldraw(testpolygon(n)[i],interp(white,blue,(i+1)*s));
Ani.add();
}
erase();
}
erase();
Ani.movie();

Example 1:
unitsize(3cm);
pair A=(0,0),B=(4,0),C=rotate(60,A)*B;
path d=A--B--C--cycle;
int n=15;
path pic(real s=0.2)
{
pair M=A;
A=relpoint(A--B,s);
B=relpoint(B--C,s);
C=relpoint(C--M,s);
return A--B--C--cycle;
}
for (int i=0; i < n; ++i)
{
if (i==0) draw(d,blue);
else draw(pic(0.2),(i%2 == 1) ? red : blue);
}

Example 2:
unitsize(3cm);
pair A=(0,0),B=(4,0),C=(4,4),D=(0,4);
path d=A--B--C--D--cycle;
int n=15;
path pic(real s=0.2)
{
pair M=A;
A=relpoint(A--B,s);
B=relpoint(B--C,s);
C=relpoint(C--D,s);
D=relpoint(D--M,s);
return A--B--C--D--cycle;
}
for (int i=0; i < n; ++i)
{
if (i==0) fill(d,blue);
else fill(pic(0.2),(i%2 == 1) ? red : blue);
}

Example 3:
unitsize(4cm);
path g=polygon(5);
pair A=point(g,0),B=point(g,1),C=point(g,2),D=point(g,3),E=point(g,4);
path d=A--B--C--D--E--cycle;
int n=35;
path pic(real s=0.2)
{
pair M=A;
A=relpoint(A--B,s);
B=relpoint(B--C,s);
C=relpoint(C--D,s);
D=relpoint(D--E,s);
E=relpoint(E--M,s);
return A--B--C--D--E--cycle;
}
for (int i=0; i < n; ++i)
{
if (i==0) fill(d,blue);
else fill(pic(0.2),(i%2 == 1) ? red : blue);
}

Example 4:
size(300);
void testpolygon(pair[] A, int n=3, real s=0.2, pen p1=green, pen p2=magenta)
{
pair[] a=copy(A);
guide g= operator --(... a)--cycle;
guide pic()
{
pair M=a[0];
for (int i=0; i<a.length; ++i)
{
if (i != (a.length-1))
{
a[i]=relpoint(a[i]--a[i+1],s);
} else {
a[i]=relpoint(a[i]--M,s);
}
}
return operator --(... a)--cycle;
}
for (int i=0; i <= n; ++i)
{
if (i==0) filldraw(g,p1);
else filldraw(pic(),(i%2==1) ? p2 : p1);
}
}
int n=25;
path g=rotate(-60)*polygon(6);
testpolygon(new pair[]{(0,0),point(g,0),point(g,1)},n,0.1);
testpolygon(new pair[]{(0,0),point(g,1),point(g,2)},n,0.1);
testpolygon(new pair[]{(0,0),point(g,2),point(g,3)},n,0.1);
testpolygon(new pair[]{(0,0),point(g,3),point(g,4)},n,0.1);
testpolygon(new pair[]{(0,0),point(g,4),point(g,5)},n,0.1);
testpolygon(new pair[]{(0,0),point(g,5),point(g,0)},n,0.1);

The final code:
\documentclass[12pt]{article}
\usepackage[margin=1.5cm]{geometry}
\usepackage[inline]{asymptote}
\usepackage{graphicx}
\usepackage{subcaption} % https://latex-tutorial.com/tutorials/figures/
\begin{document}
In TeXstudio, Options $\rightarrow$ Configure TeXstudio... $\rightarrow$ Build $\rightarrow$ Build \& View is txs:///asy-pdf-chain $\rightarrow$ OK. Then press Build \& View, processing... (Compile two times)
\begin{figure}[h!]
\centering
\begin{subfigure}[b]{0.4\linewidth}
\centering
\begin{asy}
unitsize(1.5cm);
pair A=(0,0),B=(4,0),C=rotate(60,A)*B;
path d=A--B--C--cycle;
int n=10;
path pic(real s=0.2)
{
pair M=A;
A=relpoint(A--B,s);
B=relpoint(B--C,s);
C=relpoint(C--M,s);
return A--B--C--cycle;
}
for (int i=0; i < n; ++i)
{
if (i==0) filldraw(d,blue,green+0.8bp);
else filldraw(pic(0.2),(i%2 == 1) ? red : blue,green+0.8bp);
}
\end{asy}
\caption{Picture 1}
\end{subfigure}
\begin{subfigure}[b]{0.4\linewidth}
\centering
\begin{asy}
unitsize(1.25cm);
pair A=(0,0),B=(4,0),C=(4,4),D=(0,4);
path d=A--B--C--D--cycle;
int n=10;
path pic(real s=0.2)
{
pair M=A;
A=relpoint(A--B,s);
B=relpoint(B--C,s);
C=relpoint(C--D,s);
D=relpoint(D--M,s);
return A--B--C--D--cycle;
}
for (int i=0; i < n; ++i)
{
if (i==0) filldraw(d,blue,green+0.8bp);
else filldraw(pic(0.2),(i%2 == 1) ? red : blue,green+0.8bp);
}
\end{asy}
\caption{Picture 2}
\end{subfigure}
\begin{subfigure}[b]{\linewidth}
\centering
\begin{asy}[width=10cm]
size(300);
void testpolygon(pair[] A, int n=3, real s=0.2, pen p1=green, pen p2=magenta)
{
pair[] a=copy(A);
guide g= operator --(... a)--cycle;
guide pic()
{
pair M=a[0];
for (int i=0; i<a.length; ++i)
{
if (i != (a.length-1))
{
a[i]=relpoint(a[i]--a[i+1],s);
} else {
a[i]=relpoint(a[i]--M,s);
}
}
return operator --(... a)--cycle;
}
for (int i=0; i <= n; ++i)
{
if (i==0) filldraw(g,p1);
else filldraw(pic(),(i%2==1) ? p2 : p1);
}
}
int n=25;
path g=rotate(-60)*polygon(6);
testpolygon(new pair[]{(0,0),point(g,0),point(g,1)},n,0.1);
testpolygon(new pair[]{(0,0),point(g,1),point(g,2)},n,0.1);
testpolygon(new pair[]{(0,0),point(g,2),point(g,3)},n,0.1);
testpolygon(new pair[]{(0,0),point(g,3),point(g,4)},n,0.1);
testpolygon(new pair[]{(0,0),point(g,4),point(g,5)},n,0.1);
testpolygon(new pair[]{(0,0),point(g,5),point(g,0)},n,0.1);
\end{asy}
\caption{Picture 3}
\end{subfigure}
\end{figure}
Done!
\end{document}
