% tkz-obj-eu-draw-triangles.tex
% Copyright 2022  Alain Matthes
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
% This work has the LPPL maintenance status “maintained”. 
% The Current Maintainer of this work is Alain Matthes.

\def\fileversion{4.03}
\def\filedate{2022/01/19} 
\typeout{2022/01/19 4.03 tkz-obj-eu-draw-triangles.tex} 
\makeatletter  
%<--------------------------------------------------------------------------–>
%                       Draw Triangles
%<--------------------------------------------------------------------------–>
\def\tkz@numdtr{0}
\pgfkeys{/drawtriangle/.cd,
      equilateral/.code         = {\def\tkz@numdtr{0}},
      half/.code                = {\def\tkz@numdtr{1}},
      pythagore/.code           = {\def\tkz@numdtr{2}},
      pythagoras/.code          = {\def\tkz@numdtr{2}},
      egyptian/.code            = {\def\tkz@numdtr{2}},
      school/.code              = {\def\tkz@numdtr{3}},
      golden/.code              = {\def\tkz@numdtr{4}},
      sublime/.code             = {\def\tkz@numdtr{4}},
      euclid/.code              = {\def\tkz@numdtr{5}},
      gold/.code                = {\def\tkz@numdtr{6}},
      cheops/.code              = {\def\tkz@numdtr{7}},
      two angles/.code  args    = {#1 and #2}{\def\tkz@numdtr{8}%
                                              \def\tkz@alpha{#1}%
                                              \def\tkz@beta{#2}},
      isosceles right/.code    = {\def\tkz@numdtr{9}},
      equilateral,
   /drawtriangle/.search also={/tikz}
} 

\def\tkzDrawTriangle{\pgfutil@ifnextchar[{\tkz@DrawTriangle}{%
                                         \tkz@DrawTriangle[]}}
\def\tkz@DrawTriangle[#1](#2,#3){% 
\begingroup
\pgfkeys{/drawtriangle/.cd,equilateral}   
\pgfqkeys{/drawtriangle}{#1}  
\ifcase\tkz@numdtr%
   \tkzDefEquilateral(#2,#3)
\or% 1
   \tkzDefTwoOne(#2,#3)
\or% 2
   \tkzDefPythagore(#2,#3)
\or% 3
   \tkzDefSchoolTriangle(#2,#3)
\or% 4
   \tkzDefGoldenTriangle(#2,#3)
\or% 5
   \tkzDefEuclideTriangle(#2,#3)
\or% 6
   \tkzDefGoldTriangle(#2,#3) 
\or% 7
   \tkzDefCheopsTriangle(#2,#3)  
\or% 8
   \tkzDefTwoAnglesTriangle(#2,#3)
  \or% 9
   \tkzDefIsoscelesRightTriangle(#2,#3)
\fi
 \draw[/drawtriangle/.cd,line style,#1] (#2)--(#3)--(tkzPointResult)--cycle;  
\endgroup
}

%<--------------------------------------------------------------------------–>
\def\tkz@multitriangles#1 #2\@nil{% 
\protected@edef\tkz@temp{
\noexpand \tkzDrawPolygon[\tkz@opttrianle](#1)}\tkz@temp% 
\def\tkz@nextArg{#2}%
\ifx\tkzutil@empty\tkz@nextArg
     \let\next\@gobble
\fi
\next#2\@nil
}
%<--------------------------------------------------------------------------–>
\def\tkzDrawTriangles{\pgfutil@ifnextchar[{\tkz@DrawTriangles}{\tkz@DrawTriangles[]}} 
\def\tkz@DrawTriangles[#1](#2){%
\xdef\tkz@opttrianle{#1} 
\begingroup
   \let\next\tkz@multitriangles
   \next#2 \@nil %    
\endgroup     
}% 
\makeatother
\endinput