Fichier islandsB.mp (figure 1) — Modifié le 15 Février 2003 à 23 h 34

islandsB.mp (figure 1)
Source

input tortue;

numeric nc,nt;

nt = 18 * 18 * 4;
vardef trace(expr a,b) =
   draw a--b withpen pencircle scaled 2pt
             withcolor (nc/nt)*(1,.5,0);
enddef;

vardef deplace(expr a,b) =
enddef;

vardef F(expr n,m) =
   if m>0:
        F(n,m-1);
        tourne(n,90);
        f(n,m-1);
        tourne(n,-90);
        F(n,m-1);
        F(n,m-1);
        tourne(n,90);
        F(n,m-1);
        tourne(n,90);
        F(n,m-1);
        F(n,m-1);
        tourne(n,90);
        F(n,m-1);
        f(n,m-1);
        tourne(n,90);
        F(n,m-1);
        F(n,m-1);
        tourne(n,-90);
        f(n,m-1);
        tourne(n,90);
        F(n,m-1);
        F(n,m-1);
        tourne(n,-90);
        F(n,m-1);
        tourne(n,-90);
        F(n,m-1);
        F(n,m-1);
        tourne(n,-90);
        F(n,m-1);
        f(n,m-1);
        tourne(n,-90);
        F(n,m-1);
        F(n,m-1);
        F(n,m-1);
   else:
        avance(n,longueur,trace);
        nc := incr(nc);
   fi
enddef;

vardef f(expr n,m) =
   if m>0:
        f(n,m-1);
        f(n,m-1);
        f(n,m-1);
        f(n,m-1);
        f(n,m-1);
        f(n,m-1);
   else:
        avance(n,longueur,deplace);
   fi
enddef;

vardef axiome(expr n,m) =
        F(n,m);
        tourne(n,90);
        F(n,m);
        tourne(n,90);
        F(n,m);
        tourne(n,90);
        F(n,m);
enddef;

picture lsystem;
path cadre;


beginfig(1);
    nc := 0;
    longueur = 236 / ( 6 ** 2 );
    tortue(1,118,-118,90,1);
    lsystem = image(
        axiome(1,2);
        );
    cadre = bbox(lsystem);
    fill cadre withcolor (.6,.6,1);
    draw lsystem; 
    show nc;       
endfig;
end