% proflycee-tools-graphiques.tex
% Copyright 2023  Cédric Pierquet
% 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.

%%------SPLINES
%commande utile pour extraire des infos d'une liste
\newcommand\extractcoeff[2]{%1=liste,2=numero
	\setsepchar{§}%
	\readlist*\lcoeffs{#1}
	\ifnum \lcoeffslen=1
		\def\COEFFA{#1}
		\def\COEFFB{#1}
	\else
		\itemtomacro\lcoeffs[#2]\COEFF
		\IfSubStr{\COEFF}{/}%
			{\StrCut{\COEFF}{/}{\COEFFA}{\COEFFB}}%
			{\def\COEFFA{\COEFF}\def\COEFFB{\COEFF}}
	\fi
}

%splines en tikz avec ..controls
\defKV[spline]{%
	Epaisseur=\def\SPLepaisseur{#1},%
	Couleur=\def\SPLcouleur{#1},%
	Coeffs=\def\SPLcoeffs{#1},%
	CouleurPoints=\def\SPLcouleurpoints{#1},%
	TaillePoints=\def\SPLtaillepoints{#1},%
	Style=\def\SPLstyle{#1}
}

\setKVdefault[spline]{%
	Epaisseur=1.25pt,%
	Couleur=red,%
	Coeffs=3,%
	CouleurPoints=black,%
	TaillePoints=2pt,%
	AffPoints=false,%
	Style={}
}

\newcommand\SplineTikz[2][]{%
	\useKVdefault[spline]
	\setKV[spline]{#1}% on paramètres les nouvelles clés et on les simplifie
	%on lit la liste des points/nbderivés et on stocke dans \listepoints
	\setsepchar[.]{§./}%
	\readlist*\SPLlistepoints{#2}%
	\def\SPLnbsplines{\inteval{\SPLlistepointslen-1}}%
	%si uniquement deux points, pas de boucle...
	\ifnum \SPLlistepointslen=2
		%extraction des coeffs de compensation
		\extractcoeff{\SPLcoeffs}{1}%
		%extraction des coordonnées
		\itemtomacro\SPLlistepoints[1,1]\xa
		\itemtomacro\SPLlistepoints[1,2]\ya
		\itemtomacro\SPLlistepoints[1,3]\fprimea
		\itemtomacro\SPLlistepoints[2,1]\xb
		\itemtomacro\SPLlistepoints[2,2]\yb
		\itemtomacro\SPLlistepoints[2,3]\fprimeb
		\draw[line width=\SPLepaisseur,\SPLcouleur,\SPLstyle] (\xa,\ya) ..controls +({atan \fprimea}:{(\xb-\xa)/\COEFFA}) and +({-180 + atan \fprimeb}:{(\xb-\xa)/\COEFFA}).. (\xb,\yb) ;%
	%sinon on construit bout par bout !
	\else
		\foreach \i in {1,2,...,\SPLnbsplines}{
			%extraction des coeffs de compensation
			\extractcoeff{\SPLcoeffs}{\i}
			\def\j{\inteval{\i+1}}
			\itemtomacro\SPLlistepoints[\i,1]\xa
			\itemtomacro\SPLlistepoints[\i,2]\ya
			\itemtomacro\SPLlistepoints[\i,3]\fprimea
			\itemtomacro\SPLlistepoints[\j,1]\xb
			\itemtomacro\SPLlistepoints[\j,2]\yb
			\itemtomacro\SPLlistepoints[\j,3]\fprimeb
			\draw[line width=\SPLepaisseur,\SPLcouleur,\SPLstyle] (\xa,\ya) ..controls +({atan \fprimea}:{(\xb-\xa)/\COEFFA}) and +({-180 + atan \fprimeb}:{(\xb-\xa)/\COEFFB}).. (\xb,\yb) ;%
		}
	\fi
	\ifboolKV[spline]{AffPoints}%on affiche les points de contrôle
	{%
		\foreach \i in {1,2,...,\SPLlistepointslen}{%
			\itemtomacro\SPLlistepoints[\i,1]\xa
			\itemtomacro\SPLlistepoints[\i,2]\ya
			\filldraw[\SPLcouleurpoints] (\xa,\ya) circle[radius=\SPLtaillepoints] ;%
		}
	}
	{}
}

%tangente(s) en TikZ, avec point/dérivée ou liste points/dérivées
\defKV[tgte]{%
	Epaisseur=\def\TGTepaisseur{#1},%
	Couleur=\def\TGTcouleur{#1},%
	xl=\def\TGTXL{#1},%
	xr=\def\TGTXR{#1},%
	Style=\def\TGTstyle{#1},%
	Point=\def\TGTnumpt{#1}
}

\setKVdefault[tgte]{
	Epaisseur=1.25pt,%
	Couleur=red,%
	xl=0.5,xr=0.5,%
	Style={},%
	Point=1
}

\newcommand\TangenteTikz[2][]{%
	\useKVdefault[tgte]%
	\setKV[tgte]{#1}% on paramètres les nouvelles clés et on les simplifie
	\setsepchar[.]{§./}%
	\readlist*\TGTlistepoints{#2}%
	\itemtomacro\TGTlistepoints[\TGTnumpt,1]\xa
	\itemtomacro\TGTlistepoints[\TGTnumpt,2]\ya
	\itemtomacro\TGTlistepoints[\TGTnumpt,3]\fprimea
	\def\TGTDEB{\fpeval{\xa-\TGTXL}}\def\TGTFIN{\fpeval{\xa+\TGTXR}}%
	\draw[line width=\TGTepaisseur,\TGTcouleur,domain=\TGTDEB:\TGTFIN,\TGTstyle] plot (\x,{\fprimea*(\x-\xa)+\ya}) ;%
}

%%------STATS2VAR
%variables directement dans tikzpicture
\tikzset{%
	Ox/.store in=\axexOx,Ox/.default=0,Ox=0,%essai
	Oy/.store in=\axeyOy,Oy/.default=0,Oy=0,%essai
	xmin/.store in=\xmin,xmin/.default=-5,xmin=-5,
	xmax/.store in=\xmax,xmax/.default=5,xmax=5,
	ymin/.store in=\ymin,ymin/.default=-5,ymin=-5,
	ymax/.store in=\ymax,ymax/.default=5,ymax=5,
	xgrille/.store in=\xgrille,xgrille/.default=1,xgrille=1,
	xgrilles/.store in=\xgrilles,xgrilles/.default=0.5,xgrilles=0.5,
	ygrille/.store in=\ygrille,ygrille/.default=1,ygrille=1,
	ygrilles/.store in=\ygrilles,ygrilles/.default=0.5,ygrilles=0.5,
	xunit/.store in=\xunit,xunit/.default=1,xunit=1,
	yunit/.store in=\yunit,yunit/.default=1,yunit=1
}

%style point croix
\tikzset{pics/PLdotcross/.style args={#1/#2}{
		code={
			\draw[line width={0.5*#1},rotate=#2] (-#1,0) -- (#1,0);
			\draw[line width={0.5*#1},rotate=#2] (0,-#1) -- (0, #1);
		}
	},
	pics/PLdotcross/.default={4pt/0}
}

%affichage d'un label en radians
\NewDocumentCommand\AffAngleRadian{ s m }{%étoilée en dfrac
	\IfStrEq{#2}{0}%cas où l'argument vaut 0
		{\def\restmp{0}}%
		{%
			\StrDel{#2}{*}[\restmpsansmoins]%
			\StrSubstitute{\restmpsansmoins}{pi}{\pi}[\restmppi]%
			\IfSubStr{#2}{/}%
			{%
				\StrCut{\restmppi}{/}\tmpnum\tmpdenom%
				\IfSubStr{\tmpnum}{-}
				{%
					\StrDel{\tmpnum}{-}[\restmppinum]%
					\IfBooleanTF{#1}
						{\def\restmp{-\dfrac{\restmppinum}{\tmpdenom}}}
						{\def\restmp{-\frac{\restmppinum}{\tmpdenom}}}
				}%
				{%
					\IfBooleanTF{#1}
						{\def\restmp{\dfrac{\tmpnum}{\tmpdenom}}}
						{\def\restmp{\frac{\tmpnum}{\tmpdenom}}}
				}%
			}%
			{%
				\def\restmp{\restmppi}%
			}%
		}%
	\restmp%
}

%axeOx
\defKV[PLaxextkz]{%
	Epaisseur=\def\axexwidth{#1},%
	Police=\def\axexfont{#1},%
	HautGrad=\def\axextickwidth{#1},%
	PosGrad=\def\axexposlabel{#1}
}

\setKVdefault[PLaxextkz]{%
	Epaisseur=1pt,%
	Police=\normalsize\normalfont,%
	PosGrad=below,%
	HautGrad=4pt,%
	AffGrad=true,%
	AffOrigine=true,%
	Annee=false,%
	Dfrac=false,%
	Trigo=false
}

\DeclareDocumentCommand\AxexTikz{ O{} m }{%
	\useKVdefault[PLaxextkz]
	\setKV[PLaxextkz]{#1}% on paramètres les nouvelles clés et on les simplifie
	%récupération des tickwidth H/B
	\IfSubStr{\axextickwidth}{/}
		{\StrCut{\axextickwidth}{/}{\axextickwidthA}{\axextickwidthB}}
		{\def\axextickwidthA{\axextickwidth}\def\axextickwidthB{\axextickwidth}}
	%en fonction de Trigo ou non
	\ifboolKV[PLaxextkz]{Trigo}
		{
			\foreach \x in {#2}{%
				\draw[line width=\axexwidth] ({\x-\axexOx},{\axextickwidthA}) -- ({\x-\axexOx},{-\axextickwidthB})%
				\ifboolKV[PLaxextkz]{AffGrad}%on affiche les graduations
				{%
					node[\axexposlabel,font=\axexfont] {\ifboolKV[PLaxextkz]{Dfrac}{$\AffAngleRadian*{\x}$}{$\AffAngleRadian{\x}$}}
				}%
				{}%
				;}
		}
		{
			\foreach \x in {#2}{%
				\draw[line width=\axexwidth] ({\x-\axexOx},{\axextickwidthA}) -- ({\x-\axexOx},{-\axextickwidthB})%
				\ifboolKV[PLaxextkz]{AffGrad}%on affiche les graduations
				{%
					\ifboolKV[PLaxextkz]{AffOrigine}%si on demande d'afficher l'origine
					{node[\axexposlabel,font=\axexfont] 
						{\ifboolKV[PLaxextkz]{Annee}%
							{\num[group-digits=none]{\x}}%
							{\num[text-family-to-math=true,text-series-to-math=true]{\x}}%
						}
					}
					{\xintifboolexpr{\x==\axexOx}{}{node[\axexposlabel,font=\axexfont] {\ifboolKV[PLaxextkz]{Annee}%
								{\num[group-digits=none]{\x}}%
								{\num[text-family-to-math=true,text-series-to-math=true]{\x}}%
							}
						}
					}
				}
				{}
				;}
		}
	
}

%axeOy
\defKV[PLaxeytkz]{%
	Epaisseur=\def\axeywidth{#1},%
	Police=\def\axeyfont{#1},%
	HautGrad=\def\axeytickwidth{#1},%
	PosGrad=\def\axeyposlabel{#1}
}

\setKVdefault[PLaxeytkz]{%
	Epaisseur=1pt,%
	Police=\normalsize\normalfont,%
	PosGrad=left,%
	HautGrad=4pt,%
	AffGrad=true,%
	AffOrigine=true,%
	Annee=false,%
	Frac=false
}

\DeclareDocumentCommand\AxeyTikz{ O{} m }{%
	\useKVdefault[PLaxeytkz]
	\setKV[PLaxeytkz]{#1}% on paramètres les nouvelles clés et on les simplifie
	\IfSubStr{\axeytickwidth}{/}
	{\StrCut{\axeytickwidth}{/}{\axeytickwidthA}{\axeytickwidthB}}
	{\def\axeytickwidthA{\axeytickwidth}\def\axeytickwidthB{\axeytickwidth}}
	\ifboolKV[PLaxeytkz]{Frac}%
		{%
			\ifboolKV[PLaxeytkz]{AffGrad}%on affiche les graduations
				{%
					\foreach \y in {#2}
						{\draw[line width=\axeywidth] ({\axeytickwidthA},{\y-\axeyOy}) -- ({-\axeytickwidthB},{\y-\axeyOy}) %
						\xintifboolexpr{\y==\axeyOy}{}{node[\axeyposlabel,font=\axeyfont] {\ConversionFraction{\y}}} ;}
				}%
				{%
					\foreach \y in {#2}
						{\draw[line width=\axeywidth] ({\axeytickwidthA},{\y-\axeyOy}) -- ({-\axeytickwidthB},{\y-\axeyOy}) ;}
				}%
		}%
		{%
			\foreach \y in {#2}{%
				\draw[line width=\axeywidth] ({\axeytickwidthA},{\y-\axeyOy}) -- ({-\axeytickwidthB},{\y-\axeyOy})%
				\ifboolKV[PLaxeytkz]{AffGrad}%on affiche les graduations
					{%
						\ifboolKV[PLaxeytkz]{AffOrigine}%si on demande d'afficher l'origine
							{node[\axeyposlabel,font=\axeyfont] 
								{%
									\ifboolKV[PLaxeytkz]{Annee}%
										{\num[group-digits=none]{\y}}%
										{\num[text-family-to-math=true,text-series-to-math=true]{\y}}%
								}%
							}
							{\xintifboolexpr{\y==\axeyOy}{}{node[\axeyposlabel,font=\axeyfont] {\ifboolKV[PLaxeytkz]{Annee}%
								{\num[group-digits=none]{\y}}%
								{\num[text-family-to-math=true,text-series-to-math=true]{\y}}%
							}
						}
						}%
					}%
					{}
				;}
		}%
}

%axes
\defKV[PLaxestkz]{%
	Epaisseur=\def\axeswidth{#1},%
	Police=\def\axesfont{#1},%
	Labelx=\def\axeslabelx{#1},%
	Labely=\def\axeslabely{#1},%
	PosLabelx=\def\axesposlabelx{#1},%
	PosLabely=\def\axesposlabely{#1},%
	EchelleFleche=\def\axesechellefleche{#1},%
	TypeFleche=\def\axestypefleche{#1},%
	AffLabel=\def\axesafflabel{#1},%
	ElargirOx=\def\axeselargx{#1},%
	ElargirOy=\def\axeselargy{#1}
}

\setKVdefault[PLaxestkz]{%
	Epaisseur=1pt,%
	Police=\normalsize\normalfont,%
	Labelx=$x$,%
	Labely=$y$,%
	AffLabel=z,%
	PosLabelx=right,%
	PosLabely=above,%
	EchelleFleche=1,%
	TypeFleche=latex,%
	ElargirOx=0/0.05,%
	ElargirOy=0/0.05
}

\DeclareDocumentCommand\AxesTikz{ O{} }{%
	\useKVdefault[PLaxestkz]
	\setKV[PLaxestkz]{#1}%
	%les petits élargissements
	\IfSubStr{\axeselargx}{/}
		{\StrCut{\axeselargx}{/}{\axeselargxG}{\axeselargxD}}
		{\def\axeselargxG{\axeselargx}\def\axeselargxD{\axeselargx}}
	\def\axesenlargxG{\fpeval{\axeselargxG*(\xmax-\xmin)}}
	\def\axesenlargxD{\fpeval{\axeselargxD*(\xmax-\xmin)}}
	\IfSubStr{\axeselargy}{/}
		{\StrCut{\axeselargy}{/}{\axeselargyG}{\axeselargyD}}
		{\def\axeselargyG{\axeselargy}\def\axeselargyD{\axeselargy}}
	\def\axesenlargyG{\fpeval{\axeselargyG*(\ymax-\ymin)}}
	\def\axesenlargyD{\fpeval{\axeselargyD*(\ymax-\ymin)}}
	%on affiche les deux axes
	\draw[line width=\axeswidth,-{\axestypefleche[scale=\axesechellefleche]}] ({\xmin-\axexOx-\axesenlargxG},0) -- ({\xmax-\axexOx+\axesenlargxD},0) ;
	\draw[line width=\axeswidth,-{\axestypefleche[scale=\axesechellefleche]}] (0,{\ymin-\axeyOy-\axesenlargyG}) -- (0,{\ymax-\axeyOy+\axesenlargyD}) ;
	%les labels éventuels
	\IfSubStr{\axesafflabel}{x}%
		{\draw ({\xmax-\axexOx+\axesenlargxD},0) node[\axesposlabelx,font=\axesfont] {\axeslabelx} ;}
		{}
	\IfSubStr{\axesafflabel}{y}%
		{\draw (0,{\ymax-\axeyOy+\axesenlargyD}) node[\axesposlabely,font=\axesfont] {\axeslabely} ;}
		{}
}

%fenêtre clippée
\newcommand\FenetreTikz{%
	\clip ({\xmin-\axexOx},{\ymin-\axeyOy}) rectangle ({\xmax-\axexOx},{\ymax-\axeyOy}) ;
}

%origine
\defKV[PLaxesorig]{%
	Police=\def\axesorfont{#1},%
	Pos=\def\axesorpos{#1},%
	Decal=\def\axesordecal{#1},%
	Valeur=\def\axesorval{#1}
}

\setKVdefault[PLaxesorig]{%
	Police=\normalsize\normalfont,%
	Pos={below left},%
	Decal=2pt,%
	Valeur=0
}

\DeclareDocumentCommand\OrigineTikz{ O{} }{%
	\useKVdefault[PLaxesorig]%
	\setKV[PLaxesorig]{#1}%
	\draw (0,0) node[\axesorpos=\axesordecal,font=\axesorfont] {\axesorval} ;
}

%grilles
\setKVdefault[PLgrillestkz]{%
	Affp=true,%
	Affs=true
}

\DeclareDocumentCommand\GrilleTikz{ O{} O{thin,lightgray} O{ultra thin,lightgray} }{%
	\useKVdefault[PLgrillestkz]
	\setKV[PLgrillestkz]{#1}%
	\ifboolKV[PLgrillestkz]{Affs}
		{\draw[xstep=\xgrilles,ystep=\ygrilles,#3] ({\xmin-\axexOx},{\ymin-\axeyOy}) grid ({\xmax-\axexOx},{\ymax-\axeyOy});}
		{}
	\ifboolKV[PLgrillestkz]{Affp}
		{\draw[xstep=\xgrille,ystep=\ygrille,#2] ({\xmin-\axexOx},{\ymin-\axeyOy}) grid ({\xmax-\axexOx},{\ymax-\axeyOy});}
		{}
}

%point(s) avec changement origines
\defKV[PLpts]{%
	Taille=\def\ptstaille{#1},%
	Couleur=\def\ptscouleur{#1},%
	Style=\def\ptsstyle{#1}
}

\setKVdefault[PLpts]{%
	Taille=2pt,%
	Couleur=blue,%
	Style=o
}

\newcommand\PLnuagepoints[2][]{%
	\useKVdefault[PLpts]
	\setKV[PLpts]{#1}%
	\setsepchar{§}%
	\readlist\listepointsaffiches{#2}
	\foreachitem\point\in\listepointsaffiches{%
		\StrBetween{\point}{(}{,}[\XPT]
		\StrBetween{\point}{,}{)}[\YPT]
		\IfStrEq{\ptsstyle}{o}%
			{\filldraw[\ptscouleur] ({\XPT-\axexOx},{\YPT-\axeyOy}) circle[radius=\ptstaille] ;}
			{}
		\IfStrEq{\ptsstyle}{x}%
			{\draw[\ptscouleur] ({\XPT-\axexOx},{\YPT-\axeyOy}) pic {PLdotcross=\ptstaille/45} ;}
			{}
		\IfStrEq{\ptsstyle}{+}%
			{\draw[\ptscouleur] ({\XPT-\axexOx},{\YPT-\axeyOy}) pic {PLdotcross=\ptstaille/0} ;}
			{}
	}
}

\newcommand\NuagePointsTikz[3][]{%
	\useKVdefault[PLpts]
	\setKV[PLpts]{#1}% on paramètres les nouvelles clés et on les simplifie
	\def\xliste{#2}
	\def\yliste{#3}
	\readlist*\LX{\xliste}
	\readlist*\LY{\yliste}
	%taille des listes
	\def\LNB{\inteval{\LXlen}}
	\foreach \i in {1,2,...,\LNB} {
		\IfStrEq{\ptsstyle}{o}%
			{
				\IfSubStr{\ptscouleur}{/}
				{\StrCut{\ptscouleur}{/}{\ptscouleurA}{\ptscouleurB}\draw[thick,\ptscouleurA,fill=\ptscouleurB] ({\LX[\i]-\axexOx},{\LY[\i]-\axeyOy}) circle[radius=\ptstaille] ;}
				{\draw[\ptscouleur,fill=\ptscouleur] ({\LX[\i]-\axexOx},{\LY[\i]-\axeyOy}) circle[radius=\ptstaille] ;}
			}
			{}
		\IfStrEq{\ptsstyle}{x}%
			{\draw[\ptscouleur] ({\LX[\i]-\axexOx},{\LY[\i]-\axeyOy}) pic {PLdotcross=\ptstaille/45} ;}
			{}
		\IfStrEq{\ptsstyle}{+}%
			{\draw[\ptscouleur] ({\LX[\i]-\axexOx},{\LY[\i]-\axeyOy}) pic {PLdotcross=\ptstaille/0} ;}
			{}
	}
}

\defKV[PLptmoy]{%
	Police=\def\ptmoyfont{#1},%
	Taille=\def\ptmoytaille{#1},%
	Couleur=\def\ptmoycouleur{#1},%
	Style=\def\ptmoystyle{#1},%
	xg=\def\ptmoyx{#1},%
	yg=\def\ptmoyy{#1},%
	Nom=\def\ptmoynom{#1},%
	Pos=\def\ptmoypos{#1},%
	Decal=\def\ptmoydecal{#1}%
}

\setKVdefault[PLptmoy]{%
	Police=\normalsize\normalfont,%
	Taille=4pt,%
	Couleur=red,%
	Style=x,%
	xg=\LXmoy,%
	yg=\LYmoy,%
	Nom=G,%
	Pos=above,%
	Decal=0pt,%
	AffNom=true
}

\newcommand\PointMoyenTikz[1][]{%
	\useKVdefault[PLptmoy]
	\setKV[PLptmoy]{#1}% on paramètres les nouvelles clés et on les simplifie
	\IfStrEq{\ptmoystyle}{o}%
		{
			\IfSubStr{\ptmoycouleur}{/}
			{\StrCut{\ptmoycouleur}{/}{\ptmoycouleurA}{\ptmoycouleurB}\draw[thick,\ptmoycouleurA,fill=\ptmoycouleurB] ({\ptmoyx-\axexOx},{\ptmoyy-\axeyOy}) circle[radius=\ptmoytaille] ;}
			{\draw[\ptmoycouleur,fill=\ptmoycouleur] ({\ptmoyx-\axexOx},{\ptmoyy-\axeyOy}) circle[radius=\ptmoytaille] ;}
		}
		{}
	\IfStrEq{\ptmoystyle}{x}%
		{\draw[\ptmoycouleur] ({\ptmoyx-\axexOx},{\ptmoyy-\axeyOy}) pic {PLdotcross=\ptmoytaille/45} ;}
		{}
	\IfStrEq{\ptmoystyle}{+}%
		{\draw[\ptmoycouleur] ({\ptmoyx-\axexOx},{\ptmoyy-\axeyOy}) pic {PLdotcross=\ptmoytaille/0} ;}
		{}
	\ifboolKV[PLptmoy]{AffNom}
		{\draw ({\ptmoyx-\axexOx},{\ptmoyy-\axeyOy}) node[\ptmoypos={\ptmoytaille+\ptmoydecal},font=\ptmoyfont] {\ptmoynom} ;}
		{}
	
}

%courbe ?
\newcommand\CourbeTikz[3][]{%
	\setsepchar{:}%
	\readlist\PLdomaine{#3}
	\itemtomacro\PLdomaine[1]\PLDm
	\itemtomacro\PLdomaine[2]\PLDM
	\saveexpandmode\noexpandarg
	\StrSubstitute{#2}{\x}{(\x+\axexOx)}[\fctdecx]
	\restoreexpandmode % restore the previous mode
	\draw[#1] plot[domain={\PLDm-\axexOx}:{\PLDM-\axexOx}] (\x,{\fctdecx-\axeyOy}) ;
}

\setKVdefault[PLsimplewindow]{%
	Axes=true,%
	Grille=true,%
}

\DeclareDocumentCommand\FenetreSimpleTikz{ O{} D(){} D<>{} m D<>{} m }{%
	\useKVdefault[PLsimplewindow]%
	\setKV[PLsimplewindow]{#1}% on paramètres les nouvelles clés et on les simplifie
	\ifboolKV[PLsimplewindow]{Grille}%
		{\GrilleTikz}%
		{}%
	\ifboolKV[PLsimplewindow]{Axes}%
		{\AxesTikz[#2]%
		 \AxexTikz[#3]{#4}
		 \AxeyTikz[#5]{#6}}%
		{}%
}

\NewDocumentCommand\DeclareFonctionTikz{ O{f} m }{%nom_fonction+langage tikz
	\tikzset{declare function={#1(\x)=#2;}}
}

\endinput