% Author : M. Vignal % License : Released under the LaTeX Project Public License v1.3c or later, see http://www.latex-project.org/lppl.txt \ProvidesPackage{RoueQuestions}[2023/07/19 0.0.3 Aide pour générer des roues de questions] \RequirePackage{tikz} \RequirePackage{tkz-euclide} \RequirePackage{simplekv} \RequirePackage{listofitems} \RequirePackage{ifthen} \setKVdefault[roueQuestions]{ Titre = {}, Consigne = {}, Conseil = {Cette partie est encollée et placée sous la consigne de la première roue.}, LineWidth = 2pt, RayonCentral= 6, RayonTotal = 8, BordureCouleur=black, CasesCouleur=white, CentreCouleur=white, Image = {}, ImageOpacite= 0.2, Decoupe = true, DecoupeCouleur=blue, Pliage = true, PliageCouleur=green!30!black, Solution = false, EspaceRoues = -0.5cm } \newcommand{\roueQuestions}[2][]{% \restoreKV[roueQuestions] %paramètres par défaut \setKV[roueQuestions]{#1} % lecture des paramètres passés à la macro et remplacement des valeurs \readlist*\listeequations{#2}% \pgfmathparse{int(\listeequationslen)}\let\nbequations\pgfmathresult% \pgfmathparse{360/\nbequations}\let\angle\pgfmathresult \pgfmathparse{\useKV[roueQuestions]{RayonCentral}}\let\RayonCentral\pgfmathresult \pgfmathparse{\useKV[roueQuestions]{RayonTotal}}\let\RayonTotal\pgfmathresult \pgfmathparse{(2*\RayonCentral+\RayonTotal)/3}\let\RayonTexte\pgfmathresult \pgfmathparse{(4*\RayonCentral)/3}\let\LargeurTexte\pgfmathresult \edef\LineWidth{\useKV[roueQuestions]{LineWidth}} \edef\Image{\useKV[roueQuestions]{Image}} \pgfmathparse{\useKV[roueQuestions]{ImageOpacite}}\let\ImageOpacite\pgfmathresult \edef\DecoupeCouleur{\useKV[roueQuestions]{DecoupeCouleur}} \edef\PliageCouleur{\useKV[roueQuestions]{PliageCouleur}} \edef\CasesCouleur{\useKV[roueQuestions]{CasesCouleur}} \edef\CentreCouleur{\useKV[roueQuestions]{CentreCouleur}} \edef\BordureCouleur{\useKV[roueQuestions]{BordureCouleur}} % \ifboolKV[roueQuestions]{Solution}{% \vspace{\useKV[roueQuestions]{EspaceRoues}} }{} % \begin{tikzpicture}[remember picture] \foreach \n in {1,...,\nbequations}{% %pour masquer ce qui dépasse du scope \filldraw[\CentreCouleur] (0,0) -- (\angle*\n:\RayonCentral) -- (\angle*\n+\angle:\RayonCentral) -- cycle; } %scope \begin{scope} \clip (0,0) circle (\RayonCentral); \ifthenelse{\equal{\Image}{}}{}{% c{}{ %\filldraw[blue] (-7,-7) rectangle (7,7); %ajout image \ifboolKV[roueQuestions]{Solution}{}{\node[opacity=\ImageOpacite] (centre) at(0,0) {\includegraphics[]{\Image}};} } } \end{scope} \foreach \n in {1,...,\nbequations}{% %pour masquer ce qui dépasse du scope \filldraw[\CasesCouleur] (\angle*\n-\angle:\RayonCentral) -- (\angle*\n-\angle:\RayonTotal) -- (\angle*\n:\RayonTotal) -- (\angle*\n:\RayonCentral) -- cycle; } \foreach \n in {1,...,\nbequations}{% \ifboolKV[roueQuestions]{Decoupe}{% \edef\couleurExt{\DecoupeCouleur} }{% \edef\couleurExt{\BordureCouleur} } \ifboolKV[roueQuestions]{Pliage}{% \edef\couleurPli{\PliageCouleur} }{% \edef\couleurPli{\BordureCouleur} } % intérieur vers extérieur \ifboolKV[roueQuestions]{Solution}{% \draw[line width={\useKV[roueQuestions]{LineWidth}}] (\angle*\n:\RayonCentral) -- (\angle*\n:\RayonTotal) ; }{% \draw[\couleurExt,line width={\useKV[roueQuestions]{LineWidth}},dashed] (\angle*\n:\RayonCentral) -- (\angle*\n:\RayonTotal) ; } % intérieur \ifboolKV[roueQuestions]{Solution}{\draw[line width={\useKV[roueQuestions]{LineWidth}}] (\angle*\n:\RayonCentral) -- (\angle*\n+\angle:\RayonCentral) ; }{\draw[\couleurPli,line width={\useKV[roueQuestions]{LineWidth}}] (\angle*\n:\RayonCentral) -- (\angle*\n+\angle:\RayonCentral) ; } % extérieur \draw[\couleurExt, line width={\useKV[roueQuestions]{LineWidth}}] (\angle*\n:\RayonTotal) -- (\angle*\n+\angle:\RayonTotal) ; % texte de l'onglet % angle de rotation du texte = 180 - \angle/2 \tkzDefPoint(\angle*\n:\RayonCentral){A\n} \tkzDefPoint(\angle*\n+\angle:\RayonCentral){B\n} \tkzDefPoint(\angle*\n:\RayonTotal){C\n} \tkzDefPoint(\angle*\n+\angle:\RayonTotal){D\n} \tkzDefMidPoint(A\n,B\n) \tkzGetPoint{M\n} \tkzDefMidPoint(C\n,D\n) \tkzGetPoint{N\n} \tkzDefMidPoint(M\n,N\n) \tkzGetPoint{P\n} % \tkzDrawPoints(A\n,B\n,M\n,C\n,D\n,N\n,P\n) \tkzLabelPoints(A\n,B\n,M\n,C\n,D\n,N\n,P\n) % \pgfmathparse{270 + \angle*\n - \angle/2}\let\angleTexte\pgfmathresult % \node[rotate=\angleTexte] at (\angle*\n-\angle/2:\RayonTexte) {\listeequations[\n]}; \pgfmathparse{\angle*\n + \angle/2-90}\let\angleTexte\pgfmathresult \tkzLabelPoint[centered](P\n){\rotatebox{\angleTexte}{\listeequations[\n]}} % } \node at(0,2*\RayonCentral/3) {\textbf{\useKV[roueQuestions]{Titre}}}; \node[text width=\LargeurTexte cm,text justified] at(0,0) {\ifboolKV[roueQuestions]{Solution}{\useKV[roueQuestions]{Conseil}}{\useKV[roueQuestions]{Consigne}}}; \end{tikzpicture} } \newcommand{\rouesQuestions}[3][]{% \roueQuestions[#1]{#2} \begin{flushright} \roueQuestions[#1,Solution]{#3} \end{flushright} }