% --- start of displayed preamble in the book ---
vardef hatch(expr pth, angle, shift, trace)=
 save pic,support,st;
 picture pic;
 path support;
 pair st;
 st=shift*dir(angle+90);
 support=((37cm*left)--(37cm*right)) rotated angle;
 if trace=1:drawoptions(dashed evenly);fi;
 pic=image(
   for j=-200 upto 200:
     if ((support shifted (j*st))
          intersectiontimes pth) <> (-1,-1):
       draw support shifted (j*st);
     fi
   endfor;
   );
 clip pic to pth;
 drawoptions();
 pic
enddef;
% --- end of displayed preamble in the book ---
defaultfont:="ptmr8r";
warningcheck:=0;
beginfig(1)
path p,q,r;
p=fullcircle scaled 3cm;
draw hatch(p,45,2mm,0) withcolor red;
draw p;
q=(p scaled .75) shifted (1.5cm,5cm);
draw hatch(q,10,2mm,1);
draw q;
r=(0,100)..(0,50)..(60,90)..(60,60)..cycle;
draw hatch(r,150,1mm,1) withcolor blue;
draw r;
endfig;
end;