% --- start of displayed preamble in the book ---

% --- end of displayed preamble in the book ---
defaultfont:="ptmr8r";
warningcheck:=0;
beginfig(1)
% Déclaration de mes pictures qui permettront la composition de l'image
picture rond,rondn,rondb;

numeric diamax;

u:=1.5mm;

% Fabrication de l'image de base

rond = image(
   for i:=15 downto 0:
       % cercle permettant de faire la "bande circulaire"
       path cercle, cercleb;
       numeric r,rb,moy,diff;
       % le rayon du plus petit cercle
       r:=6*2.71**((i/10))*0.3*u;
       % celui du plus grand
       rb:=6*2.71**((i+1)/10)*0.3*u;
       % On sauvegarde le diamètre maximal de la figure
       if i=15:
           diamax:=rb;
       fi;
       % rayon du cercle "médiant"
       moy:=(r+rb)/4;
       % laRgeur de la bande circulaire
       diff:=rb-r;
       cercle := fullcircle scaled (r);
       cercleb := fullcircle scaled (rb);
       % astuce permettant de palier au problèmes engendrés
       % par "buildcycle" qui trace dans la suite un disque noir,
       % ceci permet aussi de ne pas avoir de transparant
       fill cercleb withcolor white;
       for j:=0 step 2 until 36:
           pair P,P',O;
           path noir,dr,drb,p,c,d,e,f;
           O:=(0,0);
           % Le point où l'on fixe la première ellipse
           P:=(moy)*(cosd(j*10+i*10),sind(j*10+10*i));
           % Le point ou l'on fixe la deuxième ellipse
           P':=(moy)*(cosd(10*i+(j+1)*10),sind(10*i+(j+1)*10));
           dr:=O--(2*xpart P,  2*ypart P);
           drb:=O--(2*xpart P',  2*ypart P');
           % Partie noire de la bande
           p = buildcycle(cercle,dr,cercleb,drb);
           fill p;
           % tracé des ellipses
           fill fullcircle xscaled (diff/4) yscaled (diff/2)
               rotated(90+10*j+10*i) shifted P withcolor green ;
           fill fullcircle xscaled (diff/4) yscaled (diff/2)
               rotated(90+10*(j+1)+10*i) shifted P' withcolor red ;
       endfor;
   endfor;
);

   %Déclaration de la transformation de symétrie
   transform T;
   T = identity reflectedabout((diamax/2,-20),(diamax/2,20));
   % la picture symétrique
   rondn = rond transformed T;
   % remise à  l'origine
   rondb=rondn shifted (-diamax,0);
   for i:=0 upto 1:
       for j:=0 upto 1:
           if (j mod 2)=0:
               draw rondb rotated(i*10)
                   shifted  (j*diamax,i*diamax) ;
           else:
               draw rond rotated(i*10)
                   shifted  (j*diamax,i*diamax) ;
           fi;
       endfor;
   endfor;
   for i:= 0 upto 0:
       for j:=0 upto 0:
           if j=1:
               draw rondb rotated(i*10)
                   shifted  (j*diamax+diamax/2,i*diamax+diamax/2) ;
           else:
               draw rond rotated(i*10)
                   shifted  (j*diamax+diamax/2,i*diamax+diamax/2) ;
           fi;
       endfor;
   endfor;
endfig;
end;