1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
% --- start of displayed preamble in the book ---
def sierpinski(expr a,b,n)=
if n=0:
fill a--(b rotatedabout(a,60))--b--cycle;
else:
sierpinski(a,0.5[a,b],n-1);
sierpinski(0.5[a,b],b,n-1);
sierpinski(0.5[a,b rotatedabout(a,60)],
0.5[a rotatedabout(b,-60),b],n-1);
fi
enddef;
% --- end of displayed preamble in the book ---
defaultfont:="ptmr8r";
warningcheck:=0;
beginfig(1)
sierpinski((0,0),(0,6cm),6);
endfig;
end;
|