texlive[65437] Master/texmf-dist: profcollege (2jan23)

commits+karl at tug.org commits+karl at tug.org
Mon Jan 2 22:24:14 CET 2023


Revision: 65437
          http://tug.org/svn/texlive?view=revision&revision=65437
Author:   karl
Date:     2023-01-02 22:24:14 +0100 (Mon, 02 Jan 2023)
Log Message:
-----------
profcollege (2jan23)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/profcollege/ProfCollege-doc.pdf
    trunk/Master/texmf-dist/doc/latex/profcollege/ProfCollege-doc.zip
    trunk/Master/texmf-dist/metapost/profcollege/PfCGeometrie.mp
    trunk/Master/texmf-dist/metapost/profcollege/PfCSolid.mp
    trunk/Master/texmf-dist/tex/latex/profcollege/ProfCollege.sty

Modified: trunk/Master/texmf-dist/doc/latex/profcollege/ProfCollege-doc.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/profcollege/ProfCollege-doc.zip
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/metapost/profcollege/PfCGeometrie.mp
===================================================================
--- trunk/Master/texmf-dist/metapost/profcollege/PfCGeometrie.mp	2023-01-02 21:23:26 UTC (rev 65436)
+++ trunk/Master/texmf-dist/metapost/profcollege/PfCGeometrie.mp	2023-01-02 21:24:14 UTC (rev 65437)
@@ -811,6 +811,28 @@
   cot
 enddef;
 
+vardef cotationarc(expr aaa,bbb,decal,ecart,sens,texte)=%pour le texte sens=1 ou -1
+   save ty;
+   picture ty;
+   pair mnp,ctr;
+   mnp=iso(aaa,bbb)+decal*unitvector(rotation(bbb,iso(aaa,bbb),90)-iso(aaa,bbb));
+   ctr=CentreCercleC(aaa,bbb,mnp);
+   path cts[];
+   cts0=arccercle(bbb,aaa,ctr);
+   cts1=arccercle(bbb,cts0 intersectionpoint perpendiculaire(aaa,bbb,iso(aaa,bbb)),ctr);
+   cts2=arccercle(cts0 intersectionpoint perpendiculaire(aaa,bbb,iso(aaa,bbb)),aaa,ctr);
+   ty=image(
+     trace subpath(0,arctime(arclength cts1*(1-(ecart/10))) of cts1) of cts1 dashed evenly;
+     trace subpath(0,arctime(arclength cts2*(1-(ecart/10))) of reverse(cts2)) of reverse(cts2) dashed evenly;
+     if sens=1:
+       label(texte rotated (angle(bbb-aaa)),mnp);
+     else:
+       label(texte rotated (angle(bbb-aaa)+180),mnp);
+     fi;
+     );
+   ty
+ enddef;
+
 %%%%%%%%%%
 %francisation
 %%%%%%%%%

Modified: trunk/Master/texmf-dist/metapost/profcollege/PfCSolid.mp
===================================================================
--- trunk/Master/texmf-dist/metapost/profcollege/PfCSolid.mp	2023-01-02 21:23:26 UTC (rev 65436)
+++ trunk/Master/texmf-dist/metapost/profcollege/PfCSolid.mp	2023-01-02 21:24:14 UTC (rev 65437)
@@ -988,4 +988,89 @@
   endgroup;
 enddef;
 
+vardef Cercles(text t)=
+  save Cer;
+  save n;
+  n:=0;
+  for p_=t:
+    if color p_:
+      n:=n+1;
+      _T[n]:=p_;
+    fi;
+  endfor;
+  path Cer;
+  color ptcer[];
+  for k=0 step 5 until 360 :
+    ptcer[k div 5]-_T[1]=Distance(_T[1],_T[2])*((_T[4]-_T[3])*cosd(k)/Distance(_T[3],_T[4])+(_T[5]-_T[3])*sind(k)/Distance(_T[3],_T[5]));
+  endfor;
+  Cer=Projette(ptcer0)
+    for k=0 step 5 until 360 :
+    ..Projette(ptcer[k div 5])
+  endfor
+  ..cycle;
+  Cer
+enddef;
+
+vardef Label@#(expr s,z)=
+  save p; picture p;
+  label@#(s,Projette(z));
+enddef;
+vardef DotLabel@#(expr s,z)=
+  save p; picture p;
+  dotlabel@#(s,Projette(z));
+enddef;
+
+vardef DefinirSommets(text t)=
+  color t;
+  nbauto:=0;
+  for p_=t:
+    nbauto:=nbauto+1;
+    if unknown p_:p_=Sommet[nbauto]; else: p_:=Sommet[nbauto] fi;
+  endfor;
+enddef;
+
+vardef DefinirSommetsSection(text t)=
+  color t;
+  nbauto:=0;
+  for p_=t:
+    nbauto:=nbauto+1;
+    if unknown p_:p_=MSection[nbauto]; else: p_:=MSection[nbauto] fi;
+  endfor;
+enddef;
+
+vardef EcrireSommetsPave(text t)=
+  if AutoLabel:
+    nb:=0;
+    for p_=t:
+      nb:=nb+1;
+      if nb=1:
+	label.llft(TEX(""&p_&""),Projette(Sommet1));
+      fi;
+      if nb=2:
+	label.lrt(TEX(""&p_&""),Projette(Sommet2));
+      fi;
+      if nb=3:
+	label.rt(TEX(""&p_&""),Projette(Sommet3));
+      fi;
+      if nb=4:
+	if Pointilles:
+	  label.ulft(TEX(""&p_&""),Projette(Sommet4));
+	fi;
+      fi;
+      if nb=5:
+	label.ulft(TEX(""&p_&""),Projette(Sommet5));
+      fi;
+      if nb=6:
+	label.lft(TEX(""&p_&""),Projette(Sommet6));
+      fi;
+      if nb=7:
+	label.lrt(TEX(""&p_&""),Projette(Sommet7));
+      fi;
+      if nb=8:
+	label.urt(TEX(""&p_&""),Projette(Sommet8));
+      fi;
+    endfor;
+  fi;
+enddef;
+
 endinput;

Modified: trunk/Master/texmf-dist/tex/latex/profcollege/ProfCollege.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/profcollege/ProfCollege.sty	2023-01-02 21:23:26 UTC (rev 65436)
+++ trunk/Master/texmf-dist/tex/latex/profcollege/ProfCollege.sty	2023-01-02 21:24:14 UTC (rev 65437)
@@ -2,9 +2,9 @@
 % licence    : Released under the LaTeX Project Public License v1.3c
 % or later, see http://www.latex-project.org/lppl.txtf
 \NeedsTeXFormat{LaTeX2e}%
-\def\filedate{2022/12/01}%
+\def\filedate{2023/01/01}%
 \let\PfCfiledate\filedate%
-\def\fileversion{0.99-z-c}%
+\def\fileversion{0.99-z-d}%
 \let\PfCfileversion\fileversion%
 \ProvidesPackage{ProfCollege}[\filedate\space v\fileversion\space Aide pour utiliser LaTeX au college]
 
@@ -348,6 +348,739 @@
 }
 
 %%%
+% Calisson
+%
+\setKVdefault[Calisson]{Taille=3,Solution=false,Rayon=5cm,Couleur=red}%
+
+\def\UpdatetoksCalissong#1\nil{\addtotok\tokcalissonlistetracesg{,"#1"}}%
+\def\UpdatetoksCalissongDepart#1\nil{\addtotok\tokcalissonlistetracesg{"#1"}}%
+\def\UpdatetoksCalissond#1\nil{\addtotok\tokcalissonlistetracesd{,"#1"}}%
+\def\UpdatetoksCalissondDepart#1\nil{\addtotok\tokcalissonlistetracesd{"#1"}}%
+
+\newtoks\tokcalissonlistetracesg
+\newtoks\tokcalissonlistetracesd
+
+\NewDocumentCommand\Calisson{o m}{%
+  \useKVdefault[Calisson]%
+  \setKV[Calisson]{#1}%
+  % Essai de cassage du code
+  \tokcalissonlistetracesg{}%
+  \tokcalissonlistetracesd{}%
+  %Partie Gauche -> ok
+  \StrLeft{0#2}{2}[\Depart]%
+  \StrGobbleLeft{0#2}{2}[\Reste]%
+  \expandafter\UpdatetoksCalissongDepart\Depart0\nil%
+  \xintFor* ##1 in {\xintSeq{1}{\fpeval{\useKV[Calisson]{Taille}-1}}}\do{%
+    \StrLeft{0\Reste}{3}[\Depart]%
+    \expandafter\UpdatetoksCalissong\Depart\nil%
+    \StrGobbleLeft{0\Reste}{3}[\Reste]%
+  }%
+  \StrLeft{00\Reste}{3}[\Depart]%
+  \StrGobbleLeft{00\Reste}{3}[\Reste]%
+  \expandafter\UpdatetoksCalissong\Depart\nil%
+  % fin premiere ligne
+  \xintFor* ##1 in {\xintSeq{1}{\fpeval{\useKV[Calisson]{Taille}-1}}}\do{%
+    \StrLeft{\Reste}{2}[\Depart]%
+    \expandafter\UpdatetoksCalissong\Depart0\nil%
+    \StrGobbleLeft{\Reste}{2}[\Reste]%
+    \xintFor* ##2 in {\xintSeq{1}{\fpeval{\useKV[Calisson]{Taille}-1}}}\do{%
+      \StrLeft{\Reste}{3}[\Depart]%
+      \expandafter\UpdatetoksCalissong\Depart\nil%
+      \StrGobbleLeft{\Reste}{3}[\Reste]%
+    }%
+    \StrLeft{00\Reste}{3}[\Depart]%
+    \expandafter\UpdatetoksCalissong\Depart\nil%
+    \StrGobbleLeft{00\Reste}{3}[\Reste]%
+  }%
+  % fin des lignes intermédiaires
+  \xintFor* ##1 in {\xintSeq{1}{\fpeval{\useKV[Calisson]{Taille}}}}\do{%
+    \StrLeft{\Reste}{2}[\Depart]%
+    \expandafter\UpdatetoksCalissong\Depart0\nil%
+    \StrGobbleLeft{\Reste}{2}[\Reste]
+    \xintifboolexpr{##1>\fpeval{\useKV[Calisson]{Taille}-1}}{}{%
+      \xintFor* ##2 in {\xintSeq{\fpeval{\useKV[Calisson]{Taille}-##1}}{1}}\do{%
+        \StrLeft{\Reste}{3}[\Depart]%
+        \expandafter\UpdatetoksCalissong\Depart\nil%
+        \StrGobbleLeft{\Reste}{3}[\Reste]%
+      }%
+    }%
+  }%
+  %Liste gauche : \the\tokcalissonlistetracesg%
+  % Partie droite
+  \StrLeft{0\Reste}{3}[\Depart]%
+  \expandafter\UpdatetoksCalissondDepart\Depart\nil%
+  \StrGobbleLeft{0\Reste}{3}[\Reste]%
+  \xintFor* ##1 in {\xintSeq{1}{\fpeval{\useKV[Calisson]{Taille}-2}}}\do{%
+    \StrLeft{0\Reste}{3}[\Depart]%
+    \expandafter\UpdatetoksCalissond\Depart\nil%
+    \StrGobbleLeft{0\Reste}{3}[\Reste]%
+  }%
+  \StrLeft{00\Reste}{3}[\Depart]%
+  \StrGobbleLeft{00\Reste}{3}[\Reste]%
+  \expandafter\UpdatetoksCalissond\Depart\nil%
+% fin premiere ligne
+  \xintFor* ##1 in {\xintSeq{1}{\fpeval{\useKV[Calisson]{Taille}-1}}}\do{%
+    \StrLeft{\Reste}{1}[\Depart]%
+    \expandafter\UpdatetoksCalissond\Depart00\nil%
+    \StrGobbleLeft{\Reste}{1}[\Reste]%
+    \xintFor* ##2 in {\xintSeq{1}{\fpeval{\useKV[Calisson]{Taille}-1}}}\do{%
+      \StrLeft{\Reste}{3}[\Depart]%
+      \expandafter\UpdatetoksCalissond\Depart\nil%
+      \StrGobbleLeft{\Reste}{3}[\Reste]%
+    }%
+    \StrLeft{00\Reste}{3}[\Depart]%
+    \expandafter\UpdatetoksCalissond\Depart\nil%
+    \StrGobbleLeft{00\Reste}{3}[\Reste]%
+  }%
+  %% fin des lignes intermédiaires
+  \xintFor* ##1 in {\xintSeq{1}{\fpeval{\useKV[Calisson]{Taille}}}}\do{%
+    \StrLeft{\Reste}{1}[\Depart]%
+    \expandafter\UpdatetoksCalissond\Depart00\nil%
+    \StrGobbleLeft{\Reste}{1}[\Reste]%
+    \xintifboolexpr{##1>\fpeval{\useKV[Calisson]{Taille}-1}}{}{%
+      \xintFor* ##2 in {\xintSeq{\fpeval{\useKV[Calisson]{Taille}-##1}}{1}}\do{%
+        \StrLeft{\Reste}{3}[\Depart]%
+        \expandafter\UpdatetoksCalissond\Depart\nil%
+        \StrGobbleLeft{\Reste}{3}[\Reste]%
+      }%
+    }%
+  }%
+%  \par Liste droite :\the\tokcalissonlistetracesd
+  \BuildCalisson{\the\tokcalissonlistetracesg}{\the\tokcalissonlistetracesd}%
+}%
+
+\NewDocumentCommand\BuildCalisson{m m}{%
+  \ifluatex
+  \mplibforcehmode
+  \begin{mplibcode}
+    boolean Solution;
+    Solution:=\useKV[Calisson]{Solution};
+
+    color CouleurSolution;
+    CouleurSolution:=\useKV[Calisson]{Couleur};
+    
+    Rayon=\useKV[Calisson]{Rayon};
+    Taille=\useKV[Calisson]{Taille};
+    
+    pair A,B,C,D,E,F,O;
+    O=(0,0);
+    path cc;
+    cc=cercles(O,Rayon);
+    D=pointarc(cc,30);
+    E=pointarc(cc,90);
+    F=pointarc(cc,150);
+    A=pointarc(cc,210);
+    B=pointarc(cc,270);
+    C=pointarc(cc,330);
+    trace polygone(A,B,C,D,E,F) withpen pencircle scaled 2;
+    path Gauche,Droit,Haut,Bas,TopGauche,BasDroit;
+    Gauche=F--A--B;
+    Droit=E--D--C;
+    Haut=F--E--D;
+    Bas=A--B--C;
+    TopGauche=E--F--A;
+    BasDroit=D--C--B;
+    for k=1 upto 2*Taille-1:
+    trace (point(k*length Gauche/(2*Taille)) of Gauche)--(point(k*length Droit/(2*Taille)) of Droit) dashed evenly;
+    trace (point(k*length Haut/(2*Taille)) of Haut)--(point(k*length Bas/(2*Taille)) of Bas) dashed evenly;
+    trace (point(k*length TopGauche/(2*Taille)) of TopGauche)--(point(k*length BasDroit/(2*Taille)) of BasDroit) dashed evenly;
+    endfor;
+    
+    pair Hor,Ver,Horn;
+    Hor=(1/Taille)[E,F];
+    Ver=rotation(Hor,E,60);
+    Horn=rotation(Hor,E,120);
+
+    % On positionne les points
+    pair M[];
+    n=0;
+    %Partie Gauche -> ok
+    for k=0 upto Taille-1:
+    for l=0 upto Taille:
+    n:=n+1;
+    M[n]=E+k*(Ver-E)+l*(Hor-E);
+    %dotlabel.top(decimal(n),M[n]);
+    endfor;
+    endfor;
+    for k=Taille upto 2*Taille-1:
+    for l=0 upto (2*Taille-1-k):
+    n:=n+1;
+    M[n]=E+k*(Ver-E)+l*(Hor-E);
+    %dotlabel.top(decimal(n),M[n]);
+    endfor;
+    endfor;
+    % Partie Droite -> ok
+    for k=1 upto Taille:
+    n:=n+1;
+    M[n]=E+k*(Horn-E);
+    %dotlabel.top(decimal(n),M[n]);
+    endfor;
+    for k=1 upto Taille-1:
+    for l=0 upto Taille:
+    n:=n+1;
+    M[n]=E+k*(Ver-E)+l*(Horn-E);
+    %dotlabel.top(decimal(n),M[n]);
+    endfor;
+    endfor;
+    for k=Taille upto 2*Taille-1:
+    for l=0 upto (2*Taille-1-k):
+    n:=n+1;
+    M[n]=E+k*(Ver-E)+l*(Horn-E);
+    %dotlabel.top(decimal(n),M[n]);
+    endfor;
+    endfor;
+    %
+    
+    string Retiens;
+    Retiens="";
+
+    pair Depla;
+    Depla:=Hor;
+    
+    vardef LesTracesg(text t)=
+    n:=0;
+    for p_=t:
+    n:=n+1;
+    for d=1 upto 3:
+    Retiens:=substring(d-1,d) of p_;
+    if d=1:Depla:=Hor
+    elseif d=2:Depla:=Ver
+    else : Depla:=Horn
+    fi;
+    if (Retiens="0") or (Retiens="f"):
+    elseif Retiens="t":
+    trace (chemin(Depla,E) shifted (M[n]-E)) withpen pencircle scaled 2;
+    elseif Retiens="s":
+    if Solution:
+    trace (chemin(Depla,E) shifted (M[n]-E)) withpen pencircle scaled 2 withcolor CouleurSolution;
+    fi;
+    fi;
+    endfor;
+    endfor;
+    enddef;
+
+    vardef LesTracesd(text t)=
+    for p_=t:
+    n:=n+1;
+    for d=1 upto 3:
+    Retiens:=substring(d-1,d) of p_;
+    if d=1:Depla:=Horn
+    elseif d=2:Depla:=Ver
+    else : Depla:=Hor
+    fi;
+    if (Retiens="0") or (Retiens="f"):
+    elseif Retiens="t":
+    trace (chemin(Depla,E) shifted (M[n]-E)) withpen pencircle scaled 2;
+    elseif Retiens="s":
+    if Solution:
+    trace (chemin(Depla,E) shifted (M[n]-E)) withpen pencircle scaled 2 withcolor CouleurSolution;
+    fi;
+    fi;
+    endfor;
+    endfor;
+    enddef;
+    
+    LesTracesg(#1);
+    LesTracesd(#2);
+  \end{mplibcode}
+  \else
+  \begin{mpost}[mpsettings={boolean Solution; Solution:=\useKV[Calisson]{Solution}; Rayon=\useKV[Calisson]{Rayon};Taille=\useKV[Calisson]{Taille};color CouleurSolution; CouleurSolution:=\useKV[Calisson]{Couleur};}]
+    pair A,B,C,D,E,F,O;
+    O=(0,0);
+    path cc;
+    cc=cercles(O,Rayon);
+    D=pointarc(cc,30);
+    E=pointarc(cc,90);
+    F=pointarc(cc,150);
+    A=pointarc(cc,210);
+    B=pointarc(cc,270);
+    C=pointarc(cc,330);
+    trace polygone(A,B,C,D,E,F) withpen pencircle scaled 2;
+    path Gauche,Droit,Haut,Bas,TopGauche,BasDroit;
+    Gauche=F--A--B;
+    Droit=E--D--C;
+    Haut=F--E--D;
+    Bas=A--B--C;
+    TopGauche=E--F--A;
+    BasDroit=D--C--B;
+    for k=1 upto 2*Taille-1:
+    trace (point(k*length Gauche/(2*Taille)) of Gauche)--(point(k*length Droit/(2*Taille)) of Droit) dashed evenly;
+    trace (point(k*length Haut/(2*Taille)) of Haut)--(point(k*length Bas/(2*Taille)) of Bas) dashed evenly;
+    trace (point(k*length TopGauche/(2*Taille)) of TopGauche)--(point(k*length BasDroit/(2*Taille)) of BasDroit) dashed evenly;
+    endfor;
+    
+    pair Hor,Ver,Horn;
+    Hor=(1/Taille)[E,F];
+    Ver=rotation(Hor,E,60);
+    Horn=rotation(Hor,E,120);
+
+    % On positionne les points
+    pair M[];
+    n=0;
+    %Partie Gauche -> ok
+    for k=0 upto Taille-1:
+    for l=0 upto Taille:
+    n:=n+1;
+    M[n]=E+k*(Ver-E)+l*(Hor-E);
+    %dotlabel.top(decimal(n),M[n]);
+    endfor;
+    endfor;
+    for k=Taille upto 2*Taille-1:
+    for l=0 upto (2*Taille-1-k):
+    n:=n+1;
+    M[n]=E+k*(Ver-E)+l*(Hor-E);
+    %dotlabel.top(decimal(n),M[n]);
+    endfor;
+    endfor;
+    % Partie Droite -> ok
+    for k=1 upto Taille:
+    n:=n+1;
+    M[n]=E+k*(Horn-E);
+    %dotlabel.top(decimal(n),M[n]);
+    endfor;
+    for k=1 upto Taille-1:
+    for l=0 upto Taille:
+    n:=n+1;
+    M[n]=E+k*(Ver-E)+l*(Horn-E);
+    %dotlabel.top(decimal(n),M[n]);
+    endfor;
+    endfor;
+    for k=Taille upto 2*Taille-1:
+    for l=0 upto (2*Taille-1-k):
+    n:=n+1;
+    M[n]=E+k*(Ver-E)+l*(Horn-E);
+    %dotlabel.top(decimal(n),M[n]);
+    endfor;
+    endfor;
+    %
+    
+    string Retiens;
+    Retiens="";
+
+    pair Depla;
+    Depla:=Hor;
+    
+    vardef LesTracesg(text t)=
+    n:=0;
+    for p_=t:
+    n:=n+1;
+    for d=1 upto 3:
+    Retiens:=substring(d-1,d) of p_;
+    if d=1:Depla:=Hor
+    elseif d=2:Depla:=Ver
+    else : Depla:=Horn
+    fi;
+    if (Retiens="0") or (Retiens="f"):
+    elseif Retiens="t":
+    trace (chemin(Depla,E) shifted (M[n]-E)) withpen pencircle scaled 2;
+    elseif Retiens="s":
+    if Solution:
+    trace (chemin(Depla,E) shifted (M[n]-E)) withpen pencircle scaled 2 withcolor CouleurSolution;
+    fi;
+    fi;
+    endfor;
+    endfor;
+    enddef;
+
+    vardef LesTracesd(text t)=
+    for p_=t:
+    n:=n+1;
+    for d=1 upto 3:
+    Retiens:=substring(d-1,d) of p_;
+    if d=1:Depla:=Horn
+    elseif d=2:Depla:=Ver
+    else : Depla:=Hor
+    fi;
+    if (Retiens="0") or (Retiens="f"):
+    elseif Retiens="t":
+    trace (chemin(Depla,E) shifted (M[n]-E)) withpen pencircle scaled 2;
+    elseif Retiens="s":
+    if Solution:
+    trace (chemin(Depla,E) shifted (M[n]-E)) withpen pencircle scaled 2 withcolor CouleurSolution;
+    fi;
+    fi;
+    endfor;
+    endfor;
+    enddef;
+    
+    LesTracesg(#1);
+    LesTracesd(#2);
+  \end{mpost}
+  \fi
+}
+
+%%%
+% Tectonic
+%%%
+\setKVdefault[ClesTectonic]{CouleurCase=LightGray,TLargeur=5,THauteur=5,Solution=false,Largeur=25pt,CouleurSolution=black,Tailles=false,Aide=false}%
+\defKV[ClesTectonic]{Taille=\setKV[ClesTectonic]{Tailles}}%
+\defKV[ClesTectonic]{ListeNombres=\setKV[ClesTectonic]{Aide}}%
+
+\newlength\PfCTectonic
+
+\NewDocumentCommand\Tectonic{o m}{%
+  \useKVdefault[ClesTectonic]%
+  \setKV[ClesTectonic]{#1}%
+  \ifboolKV[ClesTectonic]{Tailles}{%
+    \setKV[ClesTectonic]{THauteur=\useKV[ClesTectonic]{Taille}}%
+    \setKV[ClesTectonic]{TLargeur=\useKV[ClesTectonic]{Taille}}%
+  }{}%
+  \setlength{\PfCTectonic}{\useKV[ClesTectonic]{Largeur}+\tabcolsep}%
+  \setsepchar[*]{,*/}%
+  \readlist*\ListeCasesTectonic{#2}%
+  \savecomparemode%
+  \comparestrict%
+  \begin{NiceTabular}{*{\useKV[ClesTectonic]{TLargeur}}{m{\useKV[ClesTectonic]{Largeur}}}}%
+    \CodeBefore%
+    \xintFor* ##1 in {\xintSeq{2}{\fpeval{\useKV[ClesTectonic]{THauteur}}}}\do{%
+      \tikz\draw[gray] (##1-|1) -- (##1-|last);%
+    }%
+    \xintFor* ##1 in {\xintSeq{2}{\fpeval{\useKV[ClesTectonic]{TLargeur}}}}\do{%
+      \tikz\draw[gray] (1-|##1) -- (last-|##1);%
+    }%
+    \Body%
+    \xintFor* ##1 in {\xintSeq{0}{\fpeval{\useKV[ClesTectonic]{THauteur}-1}}}\do{%
+      \xintFor* ##2 in {\xintSeq{1}{\useKV[ClesTectonic]{TLargeur}}}\do{%
+        \rule{0pt}{\PfCTectonic}%
+        \StrCompare{\ListeCasesTectonic[\fpeval{\useKV[ClesTectonic]{TLargeur}*##1+##2},1]}{b}[\PfCTestb]%\PfCTestb
+        \StrCompare{\ListeCasesTectonic[\fpeval{\useKV[ClesTectonic]{TLargeur}*##1+##2},1]}{l}[\PfCTestl]%\PfCTestr
+        \StrCompare{\ListeCasesTectonic[\fpeval{\useKV[ClesTectonic]{TLargeur}*##1+##2},1]}{lb}[\PfCTestlb]%\PfCTestbr
+        \xintifboolexpr{\PfCTestb==0}{%
+          \Block[borders={bottom},line-width=2pt]{1-1}{%
+            \ifboolKV[ClesTectonic]{Solution}{%
+              \StrCompare{\ListeCasesTectonic[\fpeval{\useKV[ClesTectonic]{TLargeur}*##1+##2},2]}{\ListeCasesTectonic[\fpeval{\useKV[ClesTectonic]{TLargeur}*##1+##2},3]}[\PfCTestMeme]
+                \xintifboolexpr{\PfCTestMeme>0}{\color{\useKV[ClesTectonic]{CouleurSolution}}}{}%
+              \Large\ListeCasesTectonic[\fpeval{\useKV[ClesTectonic]{TLargeur}*##1+##2},3]%
+            }{%
+              \ifboolKV[ClesTectonic]{Aide}{%
+                \xintifboolexpr{\ListeCasesTectonic[\fpeval{\useKV[ClesTectonic]{TLargeur}*##1+##2},3]==\useKV[ClesTectonic]{Nombre}}{%
+                  \cellcolor{LightGray}\ListeCasesTectonic[\fpeval{\useKV[ClesTectonic]{TLargeur}*##1+##2},3]%
+                }{}%
+              }{}%
+            }%
+          }%
+        }{%
+          \xintifboolexpr{\PfCTestl==0}{%
+            \Block[borders={left},line-width=2pt]{1-1}{\ifboolKV[ClesTectonic]{Solution}{%
+                \StrCompare{\ListeCasesTectonic[\fpeval{\useKV[ClesTectonic]{TLargeur}*##1+##2},2]}{\ListeCasesTectonic[\fpeval{\useKV[ClesTectonic]{TLargeur}*##1+##2},3]}[\PfCTestMeme]
+                \xintifboolexpr{\PfCTestMeme>0}{\color{\useKV[ClesTectonic]{CouleurSolution}}}{}%
+                \Large\ListeCasesTectonic[\fpeval{\useKV[ClesTectonic]{TLargeur}*##1+##2},3]}{%
+                \ifboolKV[ClesTectonic]{Aide}{%
+                  \xintifboolexpr{\ListeCasesTectonic[\fpeval{\useKV[ClesTectonic]{TLargeur}*##1+##2},3]==\useKV[ClesTectonic]{Nombre}}{%
+                    \cellcolor{LightGray}\ListeCasesTectonic[\fpeval{\useKV[ClesTectonic]{TLargeur}*##1+##2},3]%
+                  }{}%
+                }{}%
+              }%
+            }%
+          }{%
+            \xintifboolexpr{\PfCTestlb==0}{%
+              \Block[borders={bottom,left},line-width=2pt]{1-1}{\ifboolKV[ClesTectonic]{Solution}{%
+                  \StrCompare{\ListeCasesTectonic[\fpeval{\useKV[ClesTectonic]{TLargeur}*##1+##2},2]}{\ListeCasesTectonic[\fpeval{\useKV[ClesTectonic]{TLargeur}*##1+##2},3]}[\PfCTestMeme]
+                  \xintifboolexpr{\PfCTestMeme>0}{\color{\useKV[ClesTectonic]{CouleurSolution}}}{}
+                  \Large\ListeCasesTectonic[\fpeval{\useKV[ClesTectonic]{TLargeur}*##1+##2},3]}{%
+                  \ifboolKV[ClesTectonic]{Aide}{%
+                    \xintifboolexpr{\ListeCasesTectonic[\fpeval{\useKV[ClesTectonic]{TLargeur}*##1+##2},3]==\useKV[ClesTectonic]{Nombre}}{%
+                      \cellcolor{LightGray}\ListeCasesTectonic[\fpeval{\useKV[ClesTectonic]{TLargeur}*##1+##2},3]%
+                    }{}%
+                  }{}%
+                }%
+              }%
+            }{%
+              \Block{1-1}{\ifboolKV[ClesTectonic]{Solution}{%
+                  \StrCompare{\ListeCasesTectonic[\fpeval{\useKV[ClesTectonic]{TLargeur}*##1+##2},2]}{\ListeCasesTectonic[\fpeval{\useKV[ClesTectonic]{TLargeur}*##1+##2},3]}[\PfCTestMeme]
+                  \xintifboolexpr{\PfCTestMeme>0}{\color{\useKV[ClesTectonic]{CouleurSolution}}}{}
+                  \Large\ListeCasesTectonic[\fpeval{\useKV[ClesTectonic]{TLargeur}*##1+##2},3]}{%
+                  \ifboolKV[ClesTectonic]{Aide}{%
+                    \xintifboolexpr{\ListeCasesTectonic[\fpeval{\useKV[ClesTectonic]{TLargeur}*##1+##2},3]==\useKV[ClesTectonic]{Nombre}}{%
+                      \cellcolor{LightGray}\ListeCasesTectonic[\fpeval{\useKV[ClesTectonic]{TLargeur}*##1+##2},3]%
+                    }{}%
+                  }{}%
+                }%
+              }%
+            }%
+          }%
+        }%
+        \xintifForLast{\\}{&}%
+      }%
+    }%
+    \CodeAfter%
+    \tikz\draw[line width=2pt] (1-|1) rectangle (last-|last);%
+    \xintFor* ##1 in {\xintSeq{1}{\fpeval{\useKV[ClesTectonic]{THauteur}}}}\do{%
+      \xintFor* ##2 in {\xintSeq{1}{\useKV[ClesTectonic]{TLargeur}}}\do{%
+        \ifboolKV[ClesTectonic]{Solution}{%
+          %\tikz\node[fill=white] at (\fpeval{##1+0.5} -|\fpeval{##2+0.5}) {\Large$\ListeCasesTectonic[\fpeval{\useKV[ClesTectonic]{TLargeur}*(##1-1)+##2},2]$};%
+        }{%
+          \tikz\node at (\fpeval{##1+0.5} -|\fpeval{##2+0.5}) {\Large$\ListeCasesTectonic[\fpeval{\useKV[ClesTectonic]{TLargeur}*(##1-1)+##2},2]$};%
+        }%
+      }%
+    }%
+  \end{NiceTabular}%
+  \restorecomparemode%
+}%
+
+%%%
+% Enigme Aire
+%%%
+\setKVdefault[EnigmeAire]{Modele=A,Couleur=LightSteelBlue,Echelle=7mm,Etape=1}
+
+\def\MPEnigmeAireA{%
+  \ifluatex
+  \mplibforcehmode
+  \begin{mplibcode}
+    u:=\useKV[EnigmeAire]{Echelle};
+    pair A[],B[];
+    numeric la[];
+    la1=ceiling(3+uniformdeviate(7));
+    la2=ceiling(3+uniformdeviate(7));
+    la3=ceiling(3+uniformdeviate(7));
+    la4=ceiling(4+uniformdeviate(6));
+    A1=u*(1,1);
+    A2-A1=u*(10,0);
+    A3-A2=u*(0,5);
+    A4-A3=A1-A2;
+    B1=(la1/(la1+la2+la3))[A1,A2];
+    B2=((la1+la2)/(la1+la2+la3))[A1,A2];
+    B3-B2=A4-A1;
+    B4-B1=B3-B2;
+    fill polygone(B1,B2,B3,B4) withcolor \useKV[EnigmeAire]{Couleur};
+    trace polygone(B1,B2,B3,B4);
+    trace polygone(A1,A2,A3,A4);
+    label(TEX("\Aire[m]{"&decimal(la1*la4)&"}"),iso(A1,B4));
+    label(TEX("?\,\si{\square\meter}"),iso(B1,B3));
+    label(TEX("\Aire[m]{"&decimal(la3*la4)&"}"),iso(B2,A3));
+    trace cotation(A4,B3,3mm,3mm,TEX("\Lg[m]{"&decimal(la1+la2)&"}"));
+    trace cotation(B1,A2,-3mm,-3mm,TEX("\Lg[m]{"&decimal(la3+la2)&"}"));
+  \end{mplibcode}
+  \fi
+}
+
+\def\MPEnigmeAireB{%
+  \ifluatex
+  \mplibforcehmode
+  \begin{mplibcode}
+    u:=\useKV[EnigmeAire]{Echelle};
+    pair A[],B[];
+    numeric La[],la[],Ca[];
+    la1=ceiling(3+uniformdeviate(7));
+    la2=ceiling(3+uniformdeviate(7));
+    La1=ceiling(8+uniformdeviate(7));
+    La2=ceiling(uniformdeviate(5));
+    Ca1=1+ceiling(uniformdeviate(La1-La2-2));
+    Ca2=ceiling(uniformdeviate(la2-2));
+    A1=u*(1,1);
+    A2-A1=u*(10,0);
+    A3-A2=u*(0,2);
+    A4-A3=u*(-7,0);
+    A5-A4=u*(0,4);
+    A6-A5=(xpart(A1-A4),0);
+    A7-A6=A4-A5;
+    B1=(Ca1/(La1-La2))[A4,A3];
+    B3=((Ca2+1)/la2)[A4,A5];
+    B2-B1=B3-A4;
+    fill polygone(A4,B1,B2,B3) withcolor \useKV[EnigmeAire]{Couleur};
+    trace chemin(B1,B2,B3);
+    trace polygone(A1,A2,A3,A4,A5,A6);
+    trace chemin(A7,A4);
+    label(TEX("\Aire[m]{"&decimal(la1*La1)&"}"),iso(A1,A3));
+    label(TEX("?\,\si{\square\meter}"),iso(B1,B3));
+    label(TEX("\Aire[m]{"&decimal(la2*La2)&"}"),iso(A7,A5));
+    trace appelation(A6,A5,3mm,TEX("\Lg[m]{"&decimal(La2)&"}"));
+    trace appelation(B1,A3,3mm,TEX("\Lg[m]{"&decimal(La1-La2-Ca1)&"}"));
+    label.rt(TEX("\Lg[m]{"&decimal(la2-Ca2)&"}"),iso(A5,B3));
+    label.rt(TEX("\Lg[m]{"&decimal(la1)&"}"),iso(A2,A3));
+  \end{mplibcode}
+  \fi
+}
+
+\def\MPEnigmeAireC{%
+  \ifluatex
+  \mplibforcehmode
+  \begin{mplibcode}
+    u:=\useKV[EnigmeAire]{Echelle};
+    pair A[];
+    numeric la[],La[];
+    La1=ceiling(3+uniformdeviate(7));
+    La2=ceiling(3+uniformdeviate(7));
+    La3=ceiling(3+uniformdeviate(7));
+    la1=ceiling(3+uniformdeviate(7));
+    la2=ceiling(3+uniformdeviate(7));
+    la3=ceiling(3+uniformdeviate(7));
+    A1=u*(1,1);
+    A4-A1=if La1+La2+La3>la1+la2+la3:
+    u*(10,0)
+    else:
+    u*(8,0);
+    fi;
+    A2=(La1/(La1+La2+La3))[A1,A4];
+    A3=((La1+La2)/(La1+La2+La3))[A1,A4];
+    A5-A4=if La1+La2+La3>la1+la2+la3:
+    u*(0,7)
+    else:
+    u*(0,10);
+    fi;
+    A6-A5=A3-A4;
+    A7-A3=((la1+la2)/(la1+la2+la3))[A4,A5]-A4;
+    A8-A7=A2-A3;
+    A9-A2=(la1/(la1+la2+la3))[A4,A5]-A4;
+    A10-A9=A1-A2;
+    trace polygone(A1,A4,A5,A6,A7,A8,A9,A10);
+    trace segment(A2,A9);
+    trace segment(A3,A7);
+    label(TEX("\Aire[cm]{"&decimal(la1*La1)&"}"),iso(A1,A9));
+    label(TEX("\Aire[cm]{"&decimal((la1+la2)*La2)&"}"),iso(A2,A7));
+    label(TEX("\Aire[cm]{"&decimal((la1+la2+la3)*La3)&"}"),iso(A3,A5));
+    trace cotation(A1,A4,-3mm,-3mm,TEX("\Lg[cm]{"&decimal(La1+La2+La3)&"}"));
+    label.lft(TEX("\Lg{"&decimal(la1)&"}"),iso(A1,A10));
+    label.lft(TEX("\Lg{"&decimal(la2)&"}"),iso(A9,A8));
+    label.lft(TEX("?\,\si{\centi\meter}"),iso(A7,A6));
+  \end{mplibcode}
+  \fi
+}
+
+\def\MPEnigmeAireD{%
+  \ifluatex
+  \mplibforcehmode
+  \begin{mplibcode}
+    u:=\useKV[EnigmeAire]{Echelle};
+    Etape:=\useKV[EnigmeAire]{Etape};
+    pair A[];
+    numeric la[],La[];
+    la[1]=ceiling(3+uniformdeviate(7));
+    la[2]=ceiling(3+uniformdeviate(7));
+    k=1;
+    La[k]=ceiling(3+uniformdeviate(7));
+    A[1]=u*(9,-9);
+    A[6*(k-1)+2]-A[6*(k-1)+1]=u*(0,3);
+    A[6*(k-1)+3]-A[6*(k-1)+2]=u*(-6,0);
+    A[6*(k-1)+4]-A[6*(k-1)+3]=A[6*(k-1)+1]-A[6*(k-1)+2];
+    A[6*(k-1)+5]=(la[k]/(la[k]+la[k+1]))[A[6*(k-1)+1],A[6*(k-1)+4]];
+    A[6*(k-1)+6]-A[6*(k-1)+5]=A[6*(k-1)+2]-A[6*(k-1)+1];
+    trace polygone(A[6*(k-1)+1],A[6*(k-1)+2],A[6*(k-1)+3],A[6*(k-1)+4]);
+    trace segment(A[6*(k-1)+5],A[6*(k-1)+6]);
+    trace cotation(A[6*(k-1)+5],A[6*(k-1)+1],-3mm,-3mm,TEX("?\,\si{\centi\meter}"));
+    label(TEX("\Aire{"&decimal(la[k]*La[k])&"}"),iso(A[6*(k-1)+5],A[6*(k-1)+2]));
+    label(TEX("\Aire{"&decimal(la[k+1]*La[k])&"}"),iso(A[6*(k-1)+4],A[6*(k-1)+6]));
+    if Etape<2:
+    trace cotation(A[6*(k-1)+3],A[6*(k-1)+6],3mm,3mm,TEX("\Lg{"&decimal(la[k+1])&"}"));
+    fi;
+    for k=2 upto Etape:
+    La[k]=ceiling(3+uniformdeviate(7));
+    la[k+1]=ceiling(3+uniformdeviate(7));
+    A[6*(k-1)+1]=A[6*(k-1)];
+    A[6*(k-1)+2]-A[6*(k-1)+1]=u*(0,3);
+    A[6*(k-1)+3]-A[6*(k-1)+2]=u*(-6,0);
+    A[6*(k-1)+4]-A[6*(k-1)+3]=A[6*(k-1)+1]-A[6*(k-1)+2];
+    A[6*(k-1)+5]=A[6*(k-1)-3];%(la[k]/(la[k]+la[k+1]))[A[6*(k-1)+1],A[6*(k-1)+4]];
+    A[6*(k-1)+6]-A[6*(k-1)+5]=A[6*(k-1)+2]-A[6*(k-1)+1];
+    trace polygone(A[6*(k-1)+1],A[6*(k-1)+2],A[6*(k-1)+3],A[6*(k-1)+4]);
+    trace segment(A[6*(k-1)+5],A[6*(k-1)+6]);
+    if k=Etape:
+    trace cotation(A[6*(k-1)+3],A[6*(k-1)+6],3mm,3mm,TEX("\Lg{"&decimal(la[k+1])&"}"));
+    fi;
+    label(TEX("\Aire[cm]{"&decimal(la[k]*La[k])&"}"),iso(A[6*(k-1)+6],A[6*(k-1)]));
+    label(TEX("\Aire[cm]{"&decimal(la[k+1]*La[k])&"}"),iso(A[6*(k-1)+4],A[6*(k-1)+6]));
+    endfor;
+  \end{mplibcode}
+  \fi
+}
+
+\def\MPEnigmeAireE{%
+  \ifluatex
+  \mplibforcehmode
+  \begin{mplibcode}
+    u:=\useKV[EnigmeAire]{Echelle};
+    pair A[];
+    numeric la[],La[];
+    La1=ceiling(3+uniformdeviate(7));
+    La2=ceiling(3+uniformdeviate(7));
+    La3=ceiling(3+uniformdeviate(7));
+    la1=ceiling(4+uniformdeviate(5));
+    la2=ceiling(4+uniformdeviate(5));
+    la3=la1+la2+2;
+    A1=u*(7,1);
+    A11-A1=if la3>(La1+La2+La3):u*(0,10) else:u*(0,7) fi;
+    A2=(La1/(La1+La2+La3))[A1,A11];
+    A3=((La1+La2)/(La1+La2+La3))[A1,A11];
+    A8-A2=if la3>(La1+La2+La3):u*(-7,0) else:u*(-10,0) fi;
+    A6-A8=A11-A2;
+    A7-A8=A3-A2;
+    A4=(la2/la3)[A7,A3];
+    A5-A4=A6-A7;
+    A9=(la1/la3)[A2,A8];
+    A10-A9=A1-A2;
+    trace polygone(A1,A3,A4,A5,A6,A8,A9,A10);
+    trace segment(A7,A4);
+    trace segment(A2,A9);
+    label(TEX("\Aire[cm]{"&decimal(la1*La1)&"}"),iso(A1,A9));
+    label(TEX("\Aire[cm]{"&decimal(la3*La2)&"}"),iso(A2,A7));
+    label(TEX("\Aire[cm]{"&decimal(la2*La3)&"}"),iso(A4,A6));
+    trace cotationarc(A5,A4,5mm,4,1,TEX("\Lg[cm]{"&decimal(La3)&"}") rotated 90);
+    trace cotationarc(A9,A8,3mm,4,1,TEX("\Lg[cm]{"&decimal(la3-la1)&"}") rotated 180);
+    trace cotationarc(A4,A3,3mm,4,1,TEX("\Lg[cm]{"&decimal(la3-la2)&"}"));
+    trace cotationarc(A3,A1,5mm,3,1,TEX("?") rotated 90);
+  \end{mplibcode}
+  \fi
+}
+
+\def\MPEnigmeAireF{%
+  \ifluatex
+  \mplibforcehmode
+  \begin{mplibcode}
+    u:=\useKV[EnigmeAire]{Echelle};
+    pair A[];
+    numeric la[],La[];
+    la1=ceiling(2+uniformdeviate(4));
+    la2=ceiling(2+uniformdeviate(4));
+    la3=ceiling(2+uniformdeviate(4));
+    la4=ceiling(2+uniformdeviate(4));
+    La1=ceiling(8+uniformdeviate(4));
+    La2=ceiling(8+uniformdeviate(4));
+    La3=ceiling(8+uniformdeviate(4));
+    La4=ceiling(8+uniformdeviate(4));
+    A1=(0,0);
+    A2-A1=u*(0,-3.5);
+    A3-A2=u*(2.25,0);
+    A4-A1=A3-A2;
+    A5-A1=u*(6,0);
+    A6-A5=u*(0,2.5);
+    A7-A6=A1-A5;
+    A8-A7=u*(0,2);
+    A9-A8=u*(-2,0);
+    A10-A9=A1-A8;
+    A11-A1=u*(-4.5,0);
+    A12-A11=u*(0,-1.5);
+    A13-A12=A1-A11;
+    fill polygone(A1,A5,A6,A7) withcolor \useKV[EnigmeAire]{Couleur};
+    trace polygone(A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13);
+    trace segment(A7,A13);
+    trace segment(A10,A4);
+    label(TEX("?\,\si{\square\centi\meter}"),iso(A1,A6));
+    label(TEX("\Aire[cm]{"&decimal(la1*La1)&"}"),iso(A2,A4));
+    label(TEX("\Aire[cm]{"&decimal(la3*La3)&"}"),iso(A10,A8));
+    label(TEX("\Aire[cm]{"&decimal(la4*La4)&"}"),iso(A12,A1));
+    trace cotationarc(A12,A11,5mm,4,1,TEX("\Lg[cm]{"&decimal(la4)&"}") rotated -90);
+    trace cotationarc(A5,A4,5mm,4,1,TEX("\Lg[cm]{"&decimal(La2-la1)&"}") rotated 180);
+    trace cotationarc(A8,A7,5mm,4,1,TEX("\Lg[cm]{"&decimal(La3-la2)&"}") rotated 90);
+    trace cotationarc(A11,A10,3mm,4,1,TEX("\Lg[cm]{"&decimal(La4-la3)&"}"));
+    trace cotationarc(A2,A13,5mm,3,1,TEX("\Lg[cm]{"&decimal(La1-la4)&"}") rotated -90);
+  \end{mplibcode}
+  \fi
+}
+
+\NewDocumentCommand\EnigmeAire{o}{%
+  \useKVdefault[EnigmeAire]%
+  \setKV[EnigmeAire]{#1}%
+  \IfStrEqCase{\useKV[EnigmeAire]{Modele}}{%
+    {A}{\MPEnigmeAireA}
+    {B}{\MPEnigmeAireB}
+    {C}{\MPEnigmeAireC}
+    {D}{\MPEnigmeAireD}
+    {E}{\MPEnigmeAireE}
+    {F}{\MPEnigmeAireF}
+  }%
+}%
+
+%%%
 % Barres de calculs
 %%%
 \setKVdefault[SuiteBarre]{Litteral=false,Perso=false,Decimaux=false}
@@ -1893,12 +2626,35 @@
 
     pair K;
     K=(0,0);
+
+    trace Engrenage(Mm[1],Zz[1],(0,0));
     
-    trace Engrenage(Mm[1],Zz[1],(0,0));
+    Signe=1;
+    
     for w=2 upto (n div 2):
     K:=K+pointarc(cercles((0,0),u*Mm[w]*(Zz[w-1]+Zz[w])*0.5+0.04*u),0);
-    AngleRot:=360/(2*Zz[w]);
-    trace rotation(Engrenage(Mm[w],Zz[w],K),K,180-AngleRot);
+    AngleRot[w]:=360/(2*Zz[w]);
+    if w=2:
+    trace rotation(Engrenage(Mm[w],Zz[w],K),K,180-AngleRot[w]);
+    if (Zz[w] mod 2)=0:
+    Signe:=Signe*(-1);
+    fi;
+    else:
+    if (Zz[w] mod 2)=1:
+    if Signe=-1:
+    trace rotation(Engrenage(Mm[w],Zz[w],K),K,180);
+    else:
+    trace rotation(Engrenage(Mm[w],Zz[w],K),K,180-AngleRot[w]);
+    fi;
+    else:
+    Signe:=Signe*(-1);
+    if Signe=1:
+trace rotation(Engrenage(Mm[w],Zz[w],K),K,180);
+    else:
+trace rotation(Engrenage(Mm[w],Zz[w],K),K,180-AngleRot[w]);
+    fi;
+    fi;
+    fi;
     endfor;
   \end{mplibcode}
   \else
@@ -1921,16 +2677,39 @@
 
     pair K;
     K=(0,0);
+
+    trace Engrenage(Mm[1],Zz[1],(0,0));
     
-    trace Engrenage(Mm[1],Zz[1],(0,0));
+    Signe=1;
+    
     for w=2 upto (n div 2):
     K:=K+pointarc(cercles((0,0),u*Mm[w]*(Zz[w-1]+Zz[w])*0.5+0.04*u),0);
-    AngleRot:=360/(2*Zz[w]);
-    trace rotation(Engrenage(Mm[w],Zz[w],K),K,180-AngleRot);
+    AngleRot[w]:=360/(2*Zz[w]);
+    if w=2:
+    trace rotation(Engrenage(Mm[w],Zz[w],K),K,180-AngleRot[w]);
+    if (Zz[w] mod 2)=0:
+    Signe:=Signe*(-1);
+    fi;
+    else:
+    if (Zz[w] mod 2)=1:
+    if Signe=-1:
+    trace rotation(Engrenage(Mm[w],Zz[w],K),K,180);
+    else:
+    trace rotation(Engrenage(Mm[w],Zz[w],K),K,180-AngleRot[w]);
+    fi;
+    else:
+    Signe:=Signe*(-1);
+    if Signe=1:
+trace rotation(Engrenage(Mm[w],Zz[w],K),K,180);
+    else:
+trace rotation(Engrenage(Mm[w],Zz[w],K),K,180-AngleRot[w]);
+    fi;
+    fi;
+    fi;
     endfor;
   \end{mpost}
   \fi
-}%
+}
 
 %%%
 % Tortue
@@ -19889,7 +20668,8 @@
 %%%
 % Fonction
 %%%
-\setKVdefault[ClesFonction]{Nom=f,Variable=x,Calcul=x,Tableau=false,Largeur=5mm,Ecriture=false,Definition=false,Points=false,Tangentes=false,PasX=1,PasY=1,UniteX=1,UniteY=1,Prolonge=false,Trace=false,Catmull=false,Epaisseur=1}
+\setKVdefault[ClesFonction]{Nom=f,Variable=x,Calcul=x,Tableau=false,Largeur=5mm,Ecriture=false,Definition=false,Points=false,Tangentes=false,PasX=1,PasY=1,UniteX=1,UniteY=1,Prolonge=false,Trace=false,Catmull=false,Epaisseur=1,Couleur=black,PointsCourbe=true,Codes=false}
+\defKV[ClesFonction]{Traces=\setKV[ClesFonction]{Codes}}%
 
 \newtoks\toklistePtsFn%pour la discipline
 
@@ -20227,11 +21007,17 @@
   \ifluatex
   \mplibforcehmode
   \begin{mplibcode}
+    boolean PointsCourbe;
+    PointsCourbe=\useKV[ClesFonction]{PointsCourbe};
+
+    boolean Code;
+    Code=\useKV[ClesFonction]{Codes};
+        
     x.u:=#2;
     y.u:=#3;
     X.u:=#4;
     Y.u:=#5;
-    numeric dirav[],dirap[];
+
     pair Fn[],Gn[];
     n=0;
     for p_=#1:
@@ -20244,7 +21030,13 @@
     MaxX=-999;
     MinY=999;
     MaxY=-999;
-    for k=0 upto N:
+    debutbalai=0;
+    finbalai=N;
+    if \useKV[ClesFonction]{Prolonge}:
+    debutbalai:=2;
+    finbalai:=N-2;
+    fi;
+    for k=debutbalai upto finbalai:
     if xpart(Gn[k])<MinX:
     MinX:=xpart(Gn[k]);
     fi;
@@ -20258,6 +21050,23 @@
     MaxY:=ypart(Gn[k]);
     fi;
     endfor;
+    if MaxY<1:
+    MaxY:=2;
+    fi;
+    if MinY>-1:
+    MinY:=-2;
+    fi;
+    %
+    path cadreexterieur;
+    cadreexterieur=(((MinX-1)*X.u*cm,(MinY-1)*Y.u*cm)--((MaxX+1)*X.u*cm,(MinY-1)*Y.u*cm)--((MaxX+1)*X.u*cm,(MaxY+1)*Y.u*cm)--((MinX-1)*X.u*cm,(MaxY+1)*Y.u*cm)--cycle);
+    draw Fn[1]
+    for k=2 upto N-1:
+    ..{dir angle(Fn[k+1]-Fn[k-1])}Fn[k]{dir angle(Fn[k+1]-Fn[k-1])}
+    endfor withpen pencircle scaled \useKV[ClesFonction]{Epaisseur} withcolor \useKV[ClesFonction]{Couleur};
+    clip currentpicture to cadreexterieur;
+    picture RetiensCourbe;
+    RetiensCourbe=currentpicture;
+    currentpicture:=nullpicture;
     for k=MinY-1 step y.u until MaxY+1:
     draw cm*((MinX-1)*X.u,k*Y.u)--cm*((MaxX+1)*X.u,k*Y.u) withcolor 0.75white;
     endfor;
@@ -20264,28 +21073,28 @@
     for k=MinX-1 step x.u until MaxX+1:
     draw cm*(k*X.u,(MinY-1)*Y.u)--cm*(k*X.u,(MaxY+1)*Y.u) withcolor 0.75white;
     endfor;
-    for k=0 upto N:
+    if PointsCourbe:
+    for k=debutbalai upto finbalai:
     fill cercles(Fn[k],0.5mm);
     endfor;
     drawarrow (0,(MinY-1)*Y.u*cm)--(0,(MaxY+1)*Y.u*cm);
     drawarrow ((MinX-1)*X.u*cm,0)--((MaxX+1)*X.u*cm,0);
     %
+    draw RetiensCourbe;
     label.llft(btex O etex,(0,0));
     dotlabel.bot(btex 1 etex,cm*X.u*(1,0));
     dotlabel.lft(btex 1 etex,cm*Y.u*(0,1));
-    %
-    draw Fn[1]
-    for k=2 upto N-1:
-    ..{dir angle(Fn[k+1]-Fn[k-1])}Fn[k]{dir angle(Fn[k+1]-Fn[k-1])}
-    endfor withpen pencircle scaled \useKV[ClesFonction]{Epaisseur};
+    fi;
+    if Code:
+    \useKV[ClesFonction]{Traces};
+    fi;
   \end{mplibcode}
   \else
-  \begin{mpost}[mpsettings={numeric Epaisseur; Epaisseur=\useKV[ClesFonction]{Epaisseur};}]
+  \begin{mpost}[mpsettings={numeric Epaisseur; Epaisseur=\useKV[ClesFonction]{Epaisseur}; color CouleurCourbe; CouleurCourbe=\useKV[ClesFonction]{Couleur};boolean PointsCourbe;PointsCourbe=\useKV[ClesFonction]{PointsCourbe};}]
     x.u:=#2;
     y.u:=#3;
     X.u:=#4;
     Y.u:=#5;
-    numeric dirav[],dirap[];
     pair Fn[],Gn[];
     n=0;
     for p_=#1:
@@ -20298,7 +21107,13 @@
     MaxX=-999;
     MinY=999;
     MaxY=-999;
-    for k=0 upto N:
+    debutbalai=0;
+    finbalai=N;
+    if \useKV[ClesFonction]{Prolonge}:
+    debutbalai:=2;
+    finbalai:=N-2;
+    fi;
+    for k=debutbalai upto finbalai:
     if xpart(Gn[k])<MinX:
     MinX:=xpart(Gn[k]);
     fi;
@@ -20312,6 +21127,23 @@
     MaxY:=ypart(Gn[k]);
     fi;
     endfor;
+    if MaxY<1:
+    MaxY:=2;
+    fi;
+    if MinY>-1:
+    MinY:=-2;
+    fi;
+    %
+    path cadreexterieur;
+    cadreexterieur=(((MinX-1)*X.u*cm,(MinY-1)*Y.u*cm)--((MaxX+1)*X.u*cm,(MinY-1)*Y.u*cm)--((MaxX+1)*X.u*cm,(MaxY+1)*Y.u*cm)--((MinX-1)*X.u*cm,(MaxY+1)*Y.u*cm)--cycle);
+    draw Fn[1]
+    for k=2 upto N-1:
+    ..{dir angle(Fn[k+1]-Fn[k-1])}Fn[k]{dir angle(Fn[k+1]-Fn[k-1])}
+    endfor withpen pencircle scaled \useKV[ClesFonction]{Epaisseur} withcolor \useKV[ClesFonction]{Couleur};
+    clip currentpicture to cadreexterieur;
+    picture RetiensCourbe;
+    RetiensCourbe=currentpicture;
+    currentpicture:=nullpicture;
     for k=MinY-1 step y.u until MaxY+1:
     draw cm*((MinX-1)*X.u,k*Y.u)--cm*((MaxX+1)*X.u,k*Y.u) withcolor 0.75white;
     endfor;
@@ -20318,20 +21150,18 @@
     for k=MinX-1 step x.u until MaxX+1:
     draw cm*(k*X.u,(MinY-1)*Y.u)--cm*(k*X.u,(MaxY+1)*Y.u) withcolor 0.75white;
     endfor;
-    for k=0 upto N:
+    if PointsCourbe:
+    for k=debutbalai upto finbalai:
     fill cercles(Fn[k],0.5mm);
     endfor;
     drawarrow (0,(MinY-1)*Y.u*cm)--(0,(MaxY+1)*Y.u*cm);
     drawarrow ((MinX-1)*X.u*cm,0)--((MaxX+1)*X.u*cm,0);
-    % 
+    %
+    draw RetiensCourbe;
     label.llft(btex O etex,(0,0));
     dotlabel.bot(btex 1 etex,cm*X.u*(1,0));
     dotlabel.lft(btex 1 etex,cm*Y.u*(0,1));
-    % 
-    draw Fn[1]
-    for k=2 upto N-1:
-    ..{dir angle(Fn[k+1]-Fn[k-1])}Fn[k]{dir angle(Fn[k+1]-Fn[k-1])}
-    endfor withpen pencircle scaled Epaisseur;
+    fi;
   \end{mpost}
   \fi
 }%
@@ -20411,7 +21241,8 @@
 %%%
 % Diff\'erentes représentations graphiques
 %%%
-\setKVdefault[TraceG]{Grille=false,Graduations=false,PasGradX=1,PasGradY=1,PasGrilleX=1,PasGrilleY=1,Xmin=-5.5,Xmax=5.5,Xstep=1,Ymin=-5.5,Ymax=5.5,Ystep=1,Bornea=-5.5,Borneb=5.5,LabelX={},LabelY={},LabelC=0.5,NomCourbe={},Origine={(5.5,5.5)},Fonction=false,Points=false,Invisible=false,CouleurPoint=red,CouleurTrace=black,Epaisseur=1,Relie=false,RelieSegment=false,Marque=dot}
+\setKVdefault[TraceG]{Grille=false,Graduations=false,PasGradX=1,PasGradY=1,PasGrilleX=1,PasGrilleY=1,Xmin=-5.5,Xmax=5.5,Xstep=1,Ymin=-5.5,Ymax=5.5,Ystep=1,Bornea=-5.5,Borneb=5.5,LabelX={},LabelY={},LabelC=0.5,NomCourbe={},Origine={(5.5,5.5)},Fonction=false,Points=false,Invisible=false,CouleurPoint=red,CouleurTrace=black,Epaisseur=1,Relie=false,RelieSegment=false,Marque=dot,Code=false}%
+\defKV[TraceG]{Traces=\setKV[TraceG]{Code}}%
 
 \newcommand\TraceGraphique[2][]{%
   \useKVdefault[TraceG]%
@@ -20664,6 +21495,14 @@
     vardef arccos(expr x)=%Définition mathématique en radian
     pi*angle((x,sqrt(1-x**2)))/180
     enddef;
+
+    def enplace=
+    xscaled x.u yscaled y.u shifted (Origine*cm)
+    enddef;
+
+    vardef placepoint(expr q,r)=
+    (q,r) enplace
+    enddef;
     
     path Cb[];
     
@@ -20700,10 +21539,10 @@
     drawoptions();
     fi;
     if Graduations:
-    for k=gradx step gradx until xmax*gradx/grillex:
+    for k=gradx step gradx until bornesup:%xmax*gradx/grillex:
     dotlabel.bot(TEX("\num{"&decimal(k)&"}"),(k*x.u+xpart(Origine*cm),ypart(Origine*cm)));
     endfor;
-    for k=-gradx step -gradx until xmin*gradx/grillex:
+    for k=-gradx step -gradx until borneinf:%xmin*gradx/grillex:
     dotlabel.bot(TEX("\num{"&decimal(k)&"}"),(k*x.u+xpart(Origine*cm),ypart(Origine*cm)));
     endfor;
     for k=grady step grady until ymax*grady/grilley:
@@ -20713,6 +21552,7 @@
     dotlabel.lft(TEX("\num{"&decimal(k)&"}"),(xpart(Origine*cm),k*y.u+ypart(Origine*cm)));
     endfor;
     fi;
+
     drawoptions(withpen pencircle scaled(1));
     drawarrow (u*(0,ymin)--u*(0,ymax)) shifted (u*(xpart(Origine),0));
     drawarrow (u*(xmin,0)--u*(xmax,0)) shifted (u*(0,ypart(Origine)));
@@ -20725,11 +21565,14 @@
     pair PT,Tangente;
     PT:=point (pos*length Cb1) of Cb1;
     Tangente:=unitvector(direction t of Cb1);
-    label(btex \useKV[TraceG]{NomCourbe} etex rotated angle(Tangente),PT+2mm*(Tangente rotated 90));
+    label(TEX("\useKV[TraceG]{NomCourbe}") rotated angle(Tangente),PT+2mm*(Tangente rotated 90));
     % fin labelisation
     clip currentpicture to polygone(u*(xmin,ymin),u*(xmax,ymin),u*(xmax,ymax),u*(xmin,ymax));
     label.rt(btex \useKV[TraceG]{LabelX} etex,u*(xmax,ypart(Origine)));
     label.top(btex \useKV[TraceG]{LabelY} etex,u*(xpart(Origine),ymax));
+    if \useKV[TraceG]{Code}:
+    \useKV[TraceG]{Traces}
+    fi;
   \end{mplibcode}
   \else
   \mpxcommands{%
@@ -22151,7 +22994,8 @@
 %%%
 % Reperage
 %%%
-\setKVdefault[ClesReperage]{Unitex=1,Pasx=1,Unitey=1,Pasy=1,Unitez=1,Pasz=1,DemiDroite=false,Droite=false,Plan=false,Trace=false,ListeSegment={},Espace=false,Sphere=false,AnglePhi=30,CouleurLa=white,CouleurLon=Tomato,AffichageNom=false,AffichageGrad=false,AffichageAbs=0,AffichageCoord=false,LectureCoord=false,ValeurUnitex=1,ValeurUnitey=1,ValeurOrigine=0,NomOrigine=O,EchelleEspace=50,CouleurCoord=black,Thermometre=false,Mercure=false,CouleurMercure=black,Celsius,Kelvin=false,Farenheit=false,ValeurMin=-4000,ValeurMax=4000,Etages=4}
+\setKVdefault[ClesReperage]{Unitex=1,Pasx=1,Unitey=1,Pasy=1,Unitez=1,Pasz=1,DemiDroite=false,Droite=false,Plan=false,Trace=false,ListeSegment={},Espace=false,Sphere=false,AnglePhi=30,CouleurLa=white,CouleurLon=Tomato,AffichageNom=false,AffichageGrad=false,AffichageAbs=0,AffichageCoord=false,LectureCoord=false,ValeurUnitex=1,ValeurUnitey=1,ValeurOrigine=0,NomOrigine=O,EchelleEspace=50,CouleurCoord=black,Thermometre=false,Mercure=false,CouleurMercure=black,Celsius,Kelvin=false,Farenheit=false,ValeurMin=-4000,ValeurMax=4000,Etages=4,Code=false}
+\defKV[ClesReperage]{Traces=\setKV[ClesReperage]{Code}}
 % ValeurOrigine permet de faire des morceaux de demi-droite gradu\'ee en passant par droite :)
 
 \def\Updatetoksdroite#1/#2\nil{\addtotok\toklistepointdroite{#1,"#2",}}
@@ -22394,7 +23238,7 @@
     drawarrow Projette(A)--Projette(1.5[D,A]);
     drawarrow Projette(C)--Projette(1.5[D,C]);
     drawarrow Projette(E)--Projette(1.5[D,E]);
-    label.bot(btex $x$ etex,Projette(1.5[D,A]));
+    label.top(btex $x$ etex,Projette(1.5[D,A]));
     label.top(btex $y$ etex,Projette(1.5[D,C]));
     label.top(btex $z$ etex,Projette(1.5[D,E]));
     label.ulft(btex 1 etex,Projette((1/#2)[D,A]));
@@ -22508,6 +23352,9 @@
     toto(#7);
     fi;
     draw Pave(A,B,C,D,E,F,G,H)(#1,#3,#5);
+    if \useKV[ClesReperage]{Code}:
+    \useKV[ClesReperage]{Traces}
+    fi;
   \end{mplibcode}
   \else
   \begin{mpost}[mpsettings={input PfCGeometrie;}]
@@ -24001,8 +24848,8 @@
     temp=Tc1--Tc5--Tc6--Tc4--arccercle(Tc4,Tc1,Tc0)--cycle;
     if nbt>0:
     fill temp withcolor ColMercure;
+    trace Tc5--Tc6;
     fi;
-    trace Tc5--Tc6;
     trace arccercle(Tc4,Tc1,Tc0);
     trace Tc1--Tc2--arccercle(Tc2,Tc3,iso(Tc2,Tc3))--Tc4;
     enddef;
@@ -24183,11 +25030,11 @@
     path temp;
     temp=Tc1--Tc5--Tc6--Tc4--arccercle(Tc4,Tc1,Tc0)--cycle;
     if nbt>0:
-    fill temp;
+    fill temp withcolor ColMercure;
+    trace Tc5--Tc6;
     fi;
     trace arccercle(Tc4,Tc1,Tc0);
     trace Tc1--Tc2--arccercle(Tc2,Tc3,iso(Tc2,Tc3))--Tc4;
-    trace Tc5--Tc6;
     enddef;
 
     if Mercure:Thermo(1) else : Thermo(0) fi;
@@ -26897,7 +27744,8 @@
 %%%
 % Papiers
 %%%
-\setKVdefault[Papiers]{Cinq=true,Seyes=false,Isometrique=false,IsometriquePointe=false,Millimetre=false,Triangle=false,Largeur=5,Hauteur=4,Couleur=black,Grille=-1,GrillePointe=-1,PageEntiere=false,ZoneTexte=false,Baseline=false}%
+\setKVdefault[Papiers]{Cinq=true,Seyes=false,Isometrique=false,IsometriquePointe=false,Millimetre=false,Triangle=false,Largeur=5,Hauteur=4,Couleur=black,Grille=-1,GrillePointe=-1,PageEntiere=false,ZoneTexte=false,Baseline=false,CodeAfter=false}%
+\defKV[Papiers]{Traces=\setKV[Papiers]{CodeAfter}}
 
 %\def\MPBaseLineSkip#1#2#3{%à retravailler : ne fonctionne pas :(
 %  %
@@ -26990,6 +27838,9 @@
     for k=0 step 0.5 until #2:
     draw horizon shifted((0,k*cm));
     endfor;
+    if \useKV[Papiers]{CodeAfter}:
+    \useKV[Papiers]{Traces};
+    fi;
   \end{mplibcode}%
   \else%
   \begin{mpost}



More information about the tex-live-commits mailing list.