Recursiveness.mp
u:=10; % 10 = 10bp = 10 PostScript points = 10/72 in
wi:=10; % width in units u
he:=11.5; % height in units u
hoehe:=he*u; % height
breite:=wi*u; % width
pair P[];
rd:=u;
bHilbert:=80;
P0:=(rd, hoehe-rd);
vardef hilbert(expr s, n) =
%
% returns a picture h
%
pair ur, lr, ref[];
picture h, hOLD;
h:=currentpicture;
clip h to P0--P0--P0--P0--cycle;
if n>0:
hOLD:=hilbert(s, n-1); % ``hilbert(s, n)'' envokes itself!
hOLD:=hOLD rotatedaround(center hOLD, -90);
clip h to P0--P0--P0--P0--cycle; % necessary to get rid of old h
addto h also hOLD;
ur:=urcorner h; lr:=lrcorner h;
ref1:=(xpart P0, ypart lr - .5s);
ref2:=ref1 shifted (s, 0);
addto h doublepath ur--(ur shifted (s, 0));
addto h doublepath (lr shifted (s, 0))--(lr shifted (s, -s));
w:=xpart(ur-P0);
addto h also hOLD rotatedaround(center hOLD, 90) shifted (s+w, 0);
addto h also (h reflectedabout(ref1, ref2));
fi
h
enddef;
beginfig(1)
draw (0, 0)--(breite, 0)--(breite, hoehe)--(0, hoehe)--cycle;
draw hilbert(bHilbert/7, 3);
label.urt("latex2html 2000-1", (0,0));
endfig;
beginfig(2)
draw (0, 0)--(breite, 0)--(breite, hoehe)--(0, hoehe)--cycle;
draw hilbert(bHilbert/15, 4);
label.urt("latex2html 2000-1", (0,0));
endfig;
end