% tkz-obj-eu-protractor.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.00}
\def\filedate{2022/01/04} 
\typeout{2022/01/04 4.00 tkz-obj-eu-protractor.tex}  
\makeatletter
%<--------------------------------------------------------------------------–>  
%                   !!! idea from Y. Combe  !!! 
%<--------------------------------------------------------------------------–> 
%                \tkzProtractor  Protractor
%
% Rapporteur ajustable et positionable
%
% Par défaut: 
%                  centre en (0,0)
%                  rayon de 5 cm
%                  ligne de base horizontale.
%                  épaisseur de ligne 0.4 pt
%
% Paramètres (optionnels, gérés par xkeyval)
%             shift : coordonées (n'importe quelle forme 
%                                            acceptée par tikz).
%             scale : facteur d'échelle
%             rotate : rotation
%             lw : line width (épaisseur des lignes)
%                   ce paramètre subit le facteur d'échelle.
%<--------------------------------------------------------------------------–> 
\def\FullProtractor{%
\draw[fill=black!50!yellow!20!,even odd rule,semitransparent]%
     (0,0) circle (4cm);
\draw (0,0) circle (3.3cm);
\draw (0,0) circle (4cm);
\draw[fill=black] (0,0) circle (.08mm);
\node[draw, circle, inner sep=.2mm] (a) at (0,0) {};
\foreach \x in {0, 90, ..., 360}{%
    \draw[very thin, gray!40] (a) -- (\x:4cm);} 
\foreach \x in {0,...,359} {\draw (\x:3.8cm) -- (\x:4cm);}
\foreach \x in {0,5,...,355}  {\draw (\x:3.725cm) -- (\x:4cm);}   
\foreach \x in {0,10,...,350}{%
     \node[rotate=(\x-90)] at (\x:3.6cm) {\tiny\x};
} 
    \draw [>=stealth',->, thick,black] (0:2.5) arc(0:32:2.5);
    \draw [>=stealth',->, thick,black] (0:2) arc(0:32:2); 
    \draw [>=stealth',->, thick,black] (0:1.5) arc(0:32:1.5);
}

\def\FullProtractorReturn{%
\draw[fill=black!50!yellow!20!,even odd rule,semitransparent] (0,0) circle (4cm);
\draw (0,0) circle (3.3cm);
\draw (0,0) circle (4cm);
\draw[fill=black] (0,0) circle (.08mm);
\node[draw, circle, inner sep=.2mm] (a) at (0,0) {};
\foreach \x in {0, 90, ..., 360}{%
    \draw[very thin, gray!40] (a) -- (\x:4cm);} 
\foreach \x in {0,...,359} {\draw (\x:3.8cm) -- (\x:4cm);}
\foreach \x in {0,5,...,355}  {\draw (\x:3.725cm) -- (\x:4cm);}   
\begin{scope}
   \foreach \x in {0,10,...,350}{%
      \node[rotate=(-\x-90)] at (-\x:3.6cm) {\tiny\x};
} 
  \end{scope}
  \draw [>=stealth',->, thick,black] (0:2.5) arc(0:-32:2.5);
  \draw [>=stealth',->, thick,black] (0:2) arc(0:-32:2); 
  \draw [>=stealth',->, thick,black] (0:1.5) arc(0:-32:1.5); 
} 

\pgfkeys{
  protractor/.cd,
  lw/.code        = {\def\cmdMO@Rap@lw{#1}},
  shift/.code     = {\def\cmdMO@Rap@shift{#1}},
  rotate/.code    = {\def\cmdMO@Rap@rotate{#1}},
  scale/.code     = {\def\cmdMO@Rap@scale{#1}},
  return/.is if   = tkz@RappReturn,
  return/.code     = \tkz@RappReturnfalse,
  /protractor/.search also={/tikz},
  lw = 0.4pt,
  scale=1,
  shift={(0,0)},
  rotate=0
  }  

\def\tkzProtractor{\pgfutil@ifnextchar[{\tkz@Protractor}{\tkz@Protractor[]}}
\def\tkz@Protractor[#1](#2,#3){%
\tkz@RappReturntrue
\pgfqkeys{/protractor}{#1}
  \tkz@@extractxy{#2}
  \global\tkz@ax\pgf@x
  \global\tkz@ay\pgf@y
  \tkzFindSlopeAngle(#2,#3)
  \tkzGetAngle{cmdMO@Rap@rotate}%
  \global\let\tkz@@Protractor\FullProtractor%
  \iftkz@RappReturn
     \global\let\tkz@@Protractor\FullProtractorReturn
     \else
     \global\let\tkz@@Protractor\FullProtractor
 \fi
  \pgfmathsetlengthmacro{\MO@lw}{\cmdMO@Rap@lw * \cmdMO@Rap@scale}
  \begin{scope}[shift             = {(\tkz@ax,\tkz@ay)},%
                scale             = \cmdMO@Rap@scale,%
                rotate            = \cmdMO@Rap@rotate,%
                every node/.style = {scale =\cmdMO@Rap@scale,
                                     rotate =\cmdMO@Rap@rotate},%
                line width=\MO@lw]%
  \tkz@@Protractor 
\end{scope}
}
%<--------------------------------------------------------------------------–>
% fin de \tkzProtractor
%<--------------------------------------------------------------------------–>
\makeatother
\endinput