% Author.............: C. Pierquet
% licence............: Released under the LaTeX Project Public License v1.3c or later, see http://www.latex-project.org/lppl.txt

\NeedsTeXFormat{LaTeX2e}
\ProvidesExplPackage{customenvs-mathpictos}{2025/10/04}{0.1a}{Pictogrammes Domaines Maths}
%0.1a  Version initiale (LaTeX3)

%%=====Packages utiles et indispensables
\RequirePackage{graphicx}

%%=====Variables LaTeX3
\tl_new:N \l__cemaththeme_bordures_tl
\tl_new:N \l__cemaththeme_fondcouleur_tl
\int_new:N \l__cemaththeme_pageoffset_int
\int_new:N \l__cemaththeme_mainpage_int
\bool_new:N \l__cemaththeme_bg_bool

%%=====Clés avec l3keys
\keys_define:nn { cemaththeme }
{
  bordures         .tl_set:N    = \l__cemaththeme_bordures_tl,
  borders          .tl_set:N    = \l__cemaththeme_bordures_tl,
  bordures         .initial:n   = aucune,
  borders          .initial:n   = none,
  fond             .bool_set:N  = \l__cemaththeme_bg_bool,
  bg               .bool_set:N  = \l__cemaththeme_bg_bool,
  fond             .initial:n   = false,
  bg               .initial:n   = false,
  couleur~fond     .tl_set:N    = \l__cemaththeme_fondcouleur_tl,
  colback          .tl_set:N    = \l__cemaththeme_fondcouleur_tl,
  couleur~fond     .initial:n   = white,
  colback          .initial:n   = white
}

%%=====Fonction auxiliaire pour calculer l'offset
\cs_new:Npn \__cemaththeme_compute_offset:
{
  \str_case:VnF \l__cemaththeme_bordures_tl
  {
    { none }   { \int_set:Nn \l__cemaththeme_pageoffset_int { 4 } }
    { aucune } { \int_set:Nn \l__cemaththeme_pageoffset_int { 4 } }
    { 11 }     { \int_set:Nn \l__cemaththeme_pageoffset_int { 0 } }
    { 10 }     { \int_set:Nn \l__cemaththeme_pageoffset_int { 1 } }
    { 01 }     { \int_set:Nn \l__cemaththeme_pageoffset_int { 2 } }
    { 00 }     { \int_set:Nn \l__cemaththeme_pageoffset_int { 3 } }
  }
  { \int_set:Nn \l__cemaththeme_pageoffset_int { 0 } }
}
\cs_generate_variant:Nn \str_case:nnF { V }

%%=====Macro principale
\NewDocumentCommand \cemaththemeicon { O{height=1cm} m m }
{
  % #1 = options includegraphics
  % #2 = style (clés)
  % #3 = nom du pictogramme
  
  % Réinitialisation et traitement des clés
  \keys_set:nn { cemaththeme } { bordures = aucune , borders = none , fond = false , bg = false , couleur~fond = white , colback = white }
  \keys_set:nn { cemaththeme } { #2 }
  
  % Calcul de l'offset
  \__cemaththeme_compute_offset:
  
  % Calcul de la page principale
  \str_case:enF { #3 }
  {
    %[fr]
    { binomiale }     { \int_set:Nn \l__cemaththeme_mainpage_int { 1 } }
    { convexite }     { \int_set:Nn \l__cemaththeme_mainpage_int { 6 } }
    { fctcube }       { \int_set:Nn \l__cemaththeme_mainpage_int { 11 } }
    { fctcarre }      { \int_set:Nn \l__cemaththeme_mainpage_int { 16 } }
    { variations }    { \int_set:Nn \l__cemaththeme_mainpage_int { 21 } }
    { probas }        { \int_set:Nn \l__cemaththeme_mainpage_int { 26 } }
    { nbderive }      { \int_set:Nn \l__cemaththeme_mainpage_int { 31 } }
    { ensembles }     { \int_set:Nn \l__cemaththeme_mainpage_int { 36 } }
    { lgn }           { \int_set:Nn \l__cemaththeme_mainpage_int { 41 } }
    { equadiff }      { \int_set:Nn \l__cemaththeme_mainpage_int { 46 } }
    { fcttrigo }      { \int_set:Nn \l__cemaththeme_mainpage_int { 51 } }
    { fctaffine }     { \int_set:Nn \l__cemaththeme_mainpage_int { 56 } }
    { integration }   { \int_set:Nn \l__cemaththeme_mainpage_int { 61 } }
    { intervalles }   { \int_set:Nn \l__cemaththeme_mainpage_int { 66 } }
    { limitesfct }    { \int_set:Nn \l__cemaththeme_mainpage_int { 71 } }
    { limitessuite }  { \int_set:Nn \l__cemaththeme_mainpage_int { 76 } }
    { calclitteral }  { \int_set:Nn \l__cemaththeme_mainpage_int { 81 } }
    { fctlog }        { \int_set:Nn \l__cemaththeme_mainpage_int { 86 } }
    { fctinv }        { \int_set:Nn \l__cemaththeme_mainpage_int { 91 } }
    { histogramme }   { \int_set:Nn \l__cemaththeme_mainpage_int { 96 } }
    { defsuites }     { \int_set:Nn \l__cemaththeme_mainpage_int { 101 } }
    { systemes }      { \int_set:Nn \l__cemaththeme_mainpage_int { 106 } }
    { chasles }       { \int_set:Nn \l__cemaththeme_mainpage_int { 111 } }
    { equations }     { \int_set:Nn \l__cemaththeme_mainpage_int { 116 } }
    { espace }        { \int_set:Nn \l__cemaththeme_mainpage_int { 121 } }
    { espaceproj }    { \int_set:Nn \l__cemaththeme_mainpage_int { 126 } }
    { pbgeom }        { \int_set:Nn \l__cemaththeme_mainpage_int { 131 } }
    { espacevect }    { \int_set:Nn \l__cemaththeme_mainpage_int { 136 } }
    { recurrence }    { \int_set:Nn \l__cemaththeme_mainpage_int { 141 } }
    { pourcentages }  { \int_set:Nn \l__cemaththeme_mainpage_int { 146 } }
    { fractions }     { \int_set:Nn \l__cemaththeme_mainpage_int { 151 } }
    { eqbarres }      { \int_set:Nn \l__cemaththeme_mainpage_int { 156 } }
    { scratch }       { \int_set:Nn \l__cemaththeme_mainpage_int { 161 } }
    { python }        { \int_set:Nn \l__cemaththeme_mainpage_int { 166 } }
    { tableur }       { \int_set:Nn \l__cemaththeme_mainpage_int { 171 } }
    { graphes }       { \int_set:Nn \l__cemaththeme_mainpage_int { 176 } }
    { arithm }        { \int_set:Nn \l__cemaththeme_mainpage_int { 181 } }
    { geogebra }      { \int_set:Nn \l__cemaththeme_mainpage_int { 186 } }
    { toilerecur }    { \int_set:Nn \l__cemaththeme_mainpage_int { 191 } }
    { cercletrigo }   { \int_set:Nn \l__cemaththeme_mainpage_int { 196 } }
    { pythagore }     { \int_set:Nn \l__cemaththeme_mainpage_int { 201 } }
    { thales }        { \int_set:Nn \l__cemaththeme_mainpage_int { 206 } }
    { outilsgeom }    { \int_set:Nn \l__cemaththeme_mainpage_int { 211 } }
    { numeration }    { \int_set:Nn \l__cemaththeme_mainpage_int { 216 } }
    { transfo }       { \int_set:Nn \l__cemaththeme_mainpage_int { 221 } }
    { applis }        { \int_set:Nn \l__cemaththeme_mainpage_int { 226 } }
    { booleen }       { \int_set:Nn \l__cemaththeme_mainpage_int { 231 } }
    { fctexpo }       { \int_set:Nn \l__cemaththeme_mainpage_int { 236 } }
    { pdtscal }       { \int_set:Nn \l__cemaththeme_mainpage_int { 241 } }
    { solide }        { \int_set:Nn \l__cemaththeme_mainpage_int { 246 } }
    { algo }          { \int_set:Nn \l__cemaththeme_mainpage_int { 251 } }
    %[en]
    { binom }         { \int_set:Nn \l__cemaththeme_mainpage_int { 1 } }
    { convexity }     { \int_set:Nn \l__cemaththeme_mainpage_int { 6 } }
    { cubicfct }      { \int_set:Nn \l__cemaththeme_mainpage_int { 11 } }
    { quadfct }       { \int_set:Nn \l__cemaththeme_mainpage_int { 16 } }
    %{ variations }    { \int_set:Nn \l__cemaththeme_mainpage_int { 21 } }
    %{ probas }        { \int_set:Nn \l__cemaththeme_mainpage_int { 26 } }
    { derivnb }       { \int_set:Nn \l__cemaththeme_mainpage_int { 31 } }
    { sets }          { \int_set:Nn \l__cemaththeme_mainpage_int { 36 } }
    { lln }           { \int_set:Nn \l__cemaththeme_mainpage_int { 41 } }
    { diffeq }        { \int_set:Nn \l__cemaththeme_mainpage_int { 46 } }
    { trigfct }       { \int_set:Nn \l__cemaththeme_mainpage_int { 51 } }
    { affinfct }      { \int_set:Nn \l__cemaththeme_mainpage_int { 56 } }
    %{ integration }   { \int_set:Nn \l__cemaththeme_mainpage_int { 61 } }
    { intervals }     { \int_set:Nn \l__cemaththeme_mainpage_int { 66 } }
    { fctlim }        { \int_set:Nn \l__cemaththeme_mainpage_int { 71 } }
    { seqlim }        { \int_set:Nn \l__cemaththeme_mainpage_int { 76 } }
    { littcalc }      { \int_set:Nn \l__cemaththeme_mainpage_int { 81 } }
    { logfct }        { \int_set:Nn \l__cemaththeme_mainpage_int { 86 } }
    { invfct }        { \int_set:Nn \l__cemaththeme_mainpage_int { 91 } }
    { histogram }     { \int_set:Nn \l__cemaththeme_mainpage_int { 96 } }
    { seqdef }        { \int_set:Nn \l__cemaththeme_mainpage_int { 101 } }
    { systems }       { \int_set:Nn \l__cemaththeme_mainpage_int { 106 } }
    %{ chasles }       { \int_set:Nn \l__cemaththeme_mainpage_int { 111 } }
    %{ equations }     { \int_set:Nn \l__cemaththeme_mainpage_int { 116 } }
    { space }         { \int_set:Nn \l__cemaththeme_mainpage_int { 121 } }
    { projspac }      { \int_set:Nn \l__cemaththeme_mainpage_int { 126 } }
    { geompb }        { \int_set:Nn \l__cemaththeme_mainpage_int { 131 } }
    { vectspace }     { \int_set:Nn \l__cemaththeme_mainpage_int { 136 } }
    %{ recurrence }    { \int_set:Nn \l__cemaththeme_mainpage_int { 141 } }
    { percentages }   { \int_set:Nn \l__cemaththeme_mainpage_int { 146 } }
    %{ fractions }     { \int_set:Nn \l__cemaththeme_mainpage_int { 151 } }
    { bareq }         { \int_set:Nn \l__cemaththeme_mainpage_int { 156 } }
    %{ scratch }       { \int_set:Nn \l__cemaththeme_mainpage_int { 161 } }
    %{ python }        { \int_set:Nn \l__cemaththeme_mainpage_int { 166 } }
    { spreadsheet }   { \int_set:Nn \l__cemaththeme_mainpage_int { 171 } }
    { graphs }        { \int_set:Nn \l__cemaththeme_mainpage_int { 176 } }
    { arithmetic }    { \int_set:Nn \l__cemaththeme_mainpage_int { 181 } }
    %{ geogebra }      { \int_set:Nn \l__cemaththeme_mainpage_int { 186 } }
    { cabweb }        { \int_set:Nn \l__cemaththeme_mainpage_int { 191 } }
    { trigcircle }    { \int_set:Nn \l__cemaththeme_mainpage_int { 196 } }
    { pythagora }     { \int_set:Nn \l__cemaththeme_mainpage_int { 201 } }
    %{ thales }        { \int_set:Nn \l__cemaththeme_mainpage_int { 206 } }
    { geomtools }     { \int_set:Nn \l__cemaththeme_mainpage_int { 211 } }
    %{ numeration }    { \int_set:Nn \l__cemaththeme_mainpage_int { 216 } }
    { transform }     { \int_set:Nn \l__cemaththeme_mainpage_int { 221 } }
    { applications }  { \int_set:Nn \l__cemaththeme_mainpage_int { 226 } }
    { boolean }       { \int_set:Nn \l__cemaththeme_mainpage_int { 231 } }
    { expfct }        { \int_set:Nn \l__cemaththeme_mainpage_int { 236 } }
    { dotproduct }    { \int_set:Nn \l__cemaththeme_mainpage_int { 241 } }
    { solid }         { \int_set:Nn \l__cemaththeme_mainpage_int { 246 } }
    { algorithm }     { \int_set:Nn \l__cemaththeme_mainpage_int { 251 } }
  }
  { \int_set:Nn \l__cemaththeme_mainpage_int { 1 } }
  
  % Insertion de l'image
  \bool_if:NTF \l__cemaththeme_bg_bool
    {
      {\setlength\fboxsep{0pt}\colorbox{\tl_use:N \l__cemaththeme_fondcouleur_tl}{\includegraphics[page = \int_eval:n { \l__cemaththeme_mainpage_int + \l__cemaththeme_pageoffset_int },#1]{ce-mathpictos-all.pdf}}}
    }
    {
      \includegraphics[page = \int_eval:n { \l__cemaththeme_mainpage_int + \l__cemaththeme_pageoffset_int },#1]{ce-mathpictos-all.pdf}
    }
}

\endinput