%%%
% Geometrie
%%%
\setKVdefault[Geometrie]{CoinBG={(0,0)},CoinHD={(10u,10u)},TypeTrace="Instruments"}%

\ifluatex
\NewDocumentEnvironment{Geometrie}{o +b}{%
  \useKVdefault[Geometrie]%
  \setKV[Geometrie]{#1}%
  \mplibforcehmode
  \begin{mplibcode}
    % input PfCMPFr;
    pair Coinbg,Coinhd;
    Coinbg=\useKV[Geometrie]{CoinBG};
    Coinhd=\useKV[Geometrie]{CoinHD};
    if \useKV[Geometrie]{TypeTrace}="Instruments":
    typetrace:="normal";
    elseif \useKV[Geometrie]{TypeTrace}="MainLevee":
    typetrace:="mainlevee";
    elseif \useKV[Geometrie]{TypeTrace}="Espace":
    typetrace:="3D";
    typerepre:="persp";
    fi;
    xa=xpart(Coinbg);
    xb=xpart(Coinhd);
    ya=ypart(Coinbg);
    yb=ypart(Coinhd);
    feuille(xa,ya,xb,yb);
    _tfig:=if (xb-xa)>(yb-ya): (xb-xa) else: (yb-ya) fi;
    _tfig:=2*_tfig;
    #2%
  \end{mplibcode}
}{}
\else
\NewDocumentEnvironment{Geometrie}{o +b}{%
  \useKVdefault[Geometrie]%
  \setKV[Geometrie]{#1}%
  \begin{mpost}[mpsettings={
      pair Coinbg,Coinhd;
      Coinbg=\useKV[Geometrie]{CoinBG};
      Coinhd=\useKV[Geometrie]{CoinHD};
      if \useKV[Geometrie]{TypeTrace}="Instruments":
      typetrace:="normal";
      elseif \useKV[Geometrie]{TypeTrace}="MainLevee":
      typetrace:="mainlevee";
      elseif \useKV[Geometrie]{TypeTrace}="Espace":
      typetrace:="3D";
      typerepre:="persp";
      fi;}
    ]%
    xa=xpart(Coinbg);
    xb=xpart(Coinhd);;
    ya=ypart(Coinbg);
    yb=ypart(Coinhd);
    feuille(xa,ya,xb,yb);
    _tfig:=if (xb-xa)>(yb-ya): (xb-xa) else: (yb-ya) fi;
    _tfig:=2*_tfig;
    #2%
  \end{mpost}
}{}
\fi%