path wide[], tall[];
wide0 = origin -- right -- phi * dir 36 -- cycle;
wide1 = origin -- right -- phi * dir -36 -- cycle;
tall0 = origin -- right -- (1+phi) * dir 72 -- cycle;
tall1 = origin -- right -- (1+phi) * dir -72 -- cycle;
vardef half_thick(expr level, a, b, side) =
save T; path T; T = wide[side] zscaled (b-a) shifted a;
if level = 0:
fill T withcolor Purples[9][1+side];
draw subpath (1, 3) of T;
else:
half_thick(level - 1, point phi of T, point 0 of T, 1-side);
half_thick(level - 1, point 1 of T, point 2 of T, side);
half_thin(level - 1, point 2 of T, point -phi of T, side);
fi
enddef;
vardef half_thin(expr level, a, b, side) =
save T; path T; T = tall[side] zscaled (b-a) shifted a;
if level = 0:
fill T withcolor Blues[9][2+side];
draw subpath (1, 3) of T;
else:
half_thick(level - 1, point 0 of T, point 2 of T, 1-side);
half_thin(level - 1, point 1 of T, point 2-phi of T, side);
fi
enddef;