vardef tall(expr level, a, b, c) =
if level = 0:
fill a--b--c--cycle withcolor 3/4[blue, white];
draw a--c--b;
else:
save m; pair m; m = 1/3 (a + b + c); % the centroid
wide(level - 1, a, b, m);
wide(level - 1, b, c, m);
wide(level - 1, c, a, m);
fi
enddef;
vardef wide(expr level, a, b, c) =
if level = 0:
fill a--b--c--cycle withcolor 7/8[blue, white];
draw a--c--b;
else:
save p, q; pair p, q; p = 1/3[a,b]; q = 1/3[b,a];
wide(level - 1, c, a, p);
tall(level - 1, p, q, c);
wide(level - 1, b, c, q);
fi
enddef;
beginfig(1);
picture P[];
for i=0,1,2: z[1+i] = 173.2 up rotated 120i; endfor
for i=0,1,2: z[4+i] = 17.32 up rotated 120i; endfor
P7 = image(
drawarrow 10 left -- 10 right;
label.lft(P5, 12 left);
label.rt(P6, 12 right);
label.top("The \textit{wide} macro dissects a wide triangle into 2 wides, and 1 tall.",
point 5/2 of bbox currentpicture shifted 6 up);
);
draw P1;
label.top(P7, point 5/2 of bbox currentpicture shifted 12 up);
label.top(P4, point 5/2 of bbox currentpicture shifted 12 up);
label.bot(btex \vbox{\hsize 4.2in\raggedright\noindent
Note that only part of the perimeter of each triangle is drawn, to give
the illusion that the completed tiling is made up of identical rhombs.} etex,
point 1/2 of bbox currentpicture shifted 12 down);
endfig;
\end{mplibcode}
\end{document}