\def\N{6} \startMPinclusions[+] vardef kochpath primary M = save p,q,r,v,m,n; path p; p:=(dir 210)--(dir 330); for m=1 upto M: pair v; r:=arclength subpath (0,1) of p; path q; for n=0 upto (length p - 1): v:=unitvector direction (n+1/2) of p; if known q: q:=q & ((point n of p)--(point (n+1/3) of p)--((point (n+1/3) of p)+(r/3)*(v rotated (-60)))--(point (n+2/3) of p)--(point (n+1) of p)); else: q:=(point 0 of p)--(point (1/3) of p)--((point (1/3) of p)+(r/3)*(v rotated (-60)))--(point (2/3) of p)--(point 1 of p); fi; endfor; p:=q; endfor; p:=subpath (0,(length p)-1) of p; p:=p--(p rotated 120)--(p rotated 240)--cycle; p enddef; def koch primary n = u:=54; path p; p:=kochpath(n); fill p scaled u withcolor (0.75*white); draw p scaled u if (n>0): withpen pencircle scaled (0.5bp/n) fi; enddef \stopMPinclusions \starttext \dorecurse{\luaexpr{\N+1}}{ \startMPpage koch(\recurselevel-1); setbounds currentpicture to (unitsquare shifted (-0.5,-0.5) scaled (2.02*u)); \stopMPpage } \stoptext