% --- start of displayed preamble in the book --- % tdraw and trotate as defined above % --- end of displayed preamble in the book --- pair _cp; % current point _cp=(0,0); numeric _tdir; % turtle direction _tdir=0; def tdraw(expr d) text options= draw _cp--(_cp+d*dir(_tdir)) options; _cp:=_cp+d*dir(_tdir); enddef; def trotate(expr a)= _tdir:=_tdir+a; enddef; defaultfont:="ptmr8r"; warningcheck:=0; beginfig(1) numeric u; u=4cm; for i=1 upto 10: tdraw(.1u); trotate(18); endfor; trotate(90); tdraw(.5u); trotate(90); tdraw(.5u); trotate(45); tdraw(.5u); trotate(135); tdraw(1u); endfig; end;