%@AUTEUR:Guillaume Connan
prologues:=2;

input courbes;
input geo;

color vert_e, turquoise, orange, vert_fonce, rose, vert_mer, bleu_ciel, or, rouge_v,bleu_m,bleu,bleu_f;
vert_e:=(0,0.790002,0.340007);
turquoise:=(0.250999,0.878399,0.815699);
orange:=(0.589999,0.269997,0.080004);
vert_fonce:=(0,1.4*0.392193,0);
rose:=(1.0, 0.752907, 0.796106);
bleu_ciel:=(1.2*0.529405,1.2*0.807794,1);%.2*0.921598);
or:=(1,0.843104,0);
rouge_v:=(0.829997,0.099994,0.119999);
bleu_m:=(0.7*0.529405,0.7*0.807794,0.7);%*0.921598);
bleu_f:=(0.211762,0.3231176,0.3686392);
bleu:=(0.529405,0.807794,1);

%ARCHIMEDE

%% Un peu de couleurs
color couleurtrace;
couleurtrace := (0.3,0.4,1);

%% Procédure d'affectation
def affecte(suffix p)(expr coords,nom) =
  pair p.c; string p.n;
  p.c := coords;
  p.n := nom;
enddef;

%% Lecture des coordonnées
vardef getcoordonnees suffix p = p.c enddef;

%% Lecture du nom
vardef getnom suffix p = p.n enddef;

%% La « procédure »
vardef placePolygone(text t) =
  pair g,c__[] ; string n__[]; path P;
  n_:=0;
  forsuffixes pp = t:
    c__[incr n_] = getcoordonnees pp;
    n__[n_] = getnom pp;
  endfor
  g := (0,0);
  for i=1 upto n_:
    g := g + c__[i];
  endfor
  g := (1/n_)*g;
  draw c__[1]--for i=2 upto n_:c__[i]--endfor cycle withcolor couleurtrace withpen pencircle scaled 2bp;
  P:=c__[1]--for i=2 upto n_:c__[i]--endfor cycle;  
  for i=1 upto n_:
    draw c__[i] withpen pencircle scaled 2bp withcolor couleurtrace;
  endfor;
enddef;


beginfig(1);

% Affectation des points
  pair A,B,C,D,E,F;
  A=(2cm,0);
  B=A rotated 60;
  C=A rotated 120;
  D=A rotated 180;
  E=A rotated 240;
  F=A rotated 300;
 
  affecte(a,A,"A");
  affecte(b,B,"B");
  affecte(c,C,"C");
  affecte(d,D,"D");
  affecte(e,E,"E");
  affecte(g,F,"F");
% Construction du triangle ABC avec sommets nommés
  couleurtrace := bleu_f;
  placePolygone(a,b,c,d,e,g);
  fill P withcolor bleu_ciel;
  transform T;
  T := identity zscaled (1,0.5773502);
 
  pair AA,BB,CC,DD,EE,FF;
 
  AA= A transformed T;
  BB= B transformed T;
  CC= C transformed T;
  DD= D transformed T;
  EE= E transformed T;
  FF= F transformed T;
 
  affecte(aa,AA,"A' ");
  affecte(bb,BB,"B' ");
  affecte(cc,CC,"C' ");
  affecte(dd,DD,"D' ");
  affecte(ee,EE,"E' ");
  affecte(ff,FF,"F' ");
 
% Construction du quadrilatère ABCD avec sommets nommés
  couleurtrace := bleu_m;
  placePolygone(aa,bb,cc,dd,ee,ff);
 
  draw fullcircle scaled 4cm;
 
endfig;
end