summaryrefslogtreecommitdiff
path: root/graphics/pgf/contrib/scrabble/tex/Scrabble.sty
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/pgf/contrib/scrabble/tex/Scrabble.sty')
-rw-r--r--graphics/pgf/contrib/scrabble/tex/Scrabble.sty388
1 files changed, 388 insertions, 0 deletions
diff --git a/graphics/pgf/contrib/scrabble/tex/Scrabble.sty b/graphics/pgf/contrib/scrabble/tex/Scrabble.sty
new file mode 100644
index 0000000000..23ccca5fb2
--- /dev/null
+++ b/graphics/pgf/contrib/scrabble/tex/Scrabble.sty
@@ -0,0 +1,388 @@
+% Author : C. Pierquet
+% licence : Released under the LaTeX Project Public License v1.3c or later, see http://www.latex-project.org/lppl.txtf
+% Copyright : Scrabble, TradeMark by Hasbro or Mattel
+% Inspiration : Mark Wibrow in https://tex.stackexchange.com/questions/194780/tikz-drawing-a-rectangle-with-spikes-on-borders
+
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{Scrabble}[2023/01/06 v0.1.1 Scrabble]
+% 0.1.1 Option [fr] pour franciser les commandes
+% 0.1 Version initiale
+
+%------Option
+\newif\if@fr \@frfalse
+\DeclareOption{fr}{\@frtrue}
+\DeclareOption*{}%si option inconnue ;-)
+\ProcessOptions\relax
+
+%------Packages utiles
+\RequirePackage{tikz}
+\RequirePackage{pgf,pgffor}
+\RequirePackage{xstring}
+\RequirePackage{xparse}
+\RequirePackage{simplekv}
+%librairies tikz
+\usetikzlibrary{calc,shapes.geometric}
+
+\if@fr %les commandes francisées
+%score par lettre
+%idées de https://tex.stackexchange.com/questions/194780/tikz-drawing-a-rectangle-with-spikes-on-borders
+\newcommand\lettrescorescrabble[2][FR]{%avec gestion du Joker par *
+ \IfStrEq{#2}{*}%
+ {}%
+ {%
+ \def\tmp{#2}%
+ \expandafter\count\expandafter0\expandafter`#2\relax\advance\count0 by-65\relax%
+ \IfStrEq{#1}{FR}%
+ {\ifcase\count0\relax1\or3\or3\or2\or1\or4\or2\or4\or1\or8\or10\or1\or1\or1\or1\or3\or8\or1\or1\or1\or1\or4\or10\or10\or10\or10\else\fi}{}%
+ \IfStrEq{#1}{EN}%
+ {\ifcase\count0\relax1\or3\or3\or2\or1\or4\or2\or4\or1\or8\or5\or1\or3\or1\or1\or3\or10\or1\or1\or1\or1\or4\or4\or8\or4\or10\else\fi}{}%
+ \IfStrEq{#1}{DE}%
+ {\ifcase\count0\relax1\or3\or4\or1\or1\or2\or2\or2\or2\or1\or6\or4\or2\or3\or2\or4\or10\or1\or1\or1\or1\or6\or3\or8\or10\or3\else\fi}{}%
+ \IfStrEq{#1}{ES}%
+ {\ifcase\count0\relax1\or3\or3\or2\or1\or4\or2\or4\or1\or8\or0\or1\or3\or1\or1\or3\or5\or1\or1\or1\or1\or4\or0\or8\or4\or10\else\fi}{}%
+ }%
+}
+
+%commandes localisées des cases
+\newcommand\SCRBMCT[1][FR]{%
+ \IfStrEq{#1}{FR}{MOT\\COMPTE\\TRIPLE}{}%
+ \IfStrEq{#1}{EN}{TRIPLE\\WORD\\SCORE}{}%
+ \IfStrEq{#1}{DE}{\scalebox{2}[2]{3W}}{}%
+ \IfStrEq{#1}{ES}{TRIPLE\\TANTO\\DE\\PALABRA}{}%
+}
+\newcommand\SCRBMCD[1][FR]{%
+ \IfStrEq{#1}{FR}{MOT\\COMPTE\\DOUBLE}{}%
+ \IfStrEq{#1}{EN}{DOUBLE\\WORD\\SCORE}{}%
+ \IfStrEq{#1}{DE}{\scalebox{2}[2]{2W}}{}%
+ \IfStrEq{#1}{ES}{DOBLE\\TANTO\\DE\\PALABRA}{}%
+}
+\newcommand\SCRBLCT[1][FR]{%
+ \IfStrEq{#1}{FR}{LETTRE\\COMPTE\\TRIPLE}{}%
+ \IfStrEq{#1}{EN}{TRIPLE\\LETTER\\SCORE}{}%
+ \IfStrEq{#1}{DE}{\scalebox{2}[2]{3B}}{}%
+ \IfStrEq{#1}{ES}{TRIPLE\\TANTO\\DE\\LETRA}{}%
+}
+\newcommand\SCRBLCD[1][FR]{%
+ \IfStrEq{#1}{FR}{LETTRE\\COMPTE\\DOUBLE}{}%
+ \IfStrEq{#1}{EN}{DOUBLE\\LETTER\\SCORE}{}%
+ \IfStrEq{#1}{DE}{\scalebox{2}[2]{2B}}{}%
+ \IfStrEq{#1}{ES}{DOBLE\\TANTO\\DE\\LETRA}{}%
+}
+
+%styles case + jetons
+%idées de https://tex.stackexchange.com/questions/194780/tikz-drawing-a-rectangle-with-spikes-on-borders
+\tikzset{
+ scorelettre/.style={
+ font=\sffamily\bfseries\tiny,align=center,scale=0.95,draw=none,fill=none
+ },
+ pics/.cd,
+ pointes/.style args={#1#2#3}{
+ code={
+ \fill [#3,scale=0.5*0.9] (-1,1) {\foreach \i in {0,1,2,3}{%
+ [rotate=-\i*90] -- (-#1*#2,1) {\foreach \j in {1,...,#1} {-- ++(#2,#2) -- ++(#2,-#2)} -- (1,1)}}} -- cycle;
+ }
+ },
+ casecentrale/.style={
+ code={
+ \path pic {pointes={2}{0.15}{red!25}};
+ \node [star,fill,star point ratio=2.35] {};%
+ }
+ },
+ jeton/.style={
+ code={
+ \node[fill=yellow!40,minimum size=0.9 cm,rounded corners=\fpeval{\PLSCRBBLEechelle*0.15} cm,font=\Large\sffamily\bfseries] (JETON) {\IfStrEq{#1}{*}{}{#1}};%
+ \node[inner sep=2pt,font=\sffamily\scriptsize,anchor=south east] at (JETON.south east) { \lettrescorescrabble[\PLSCRBBLElangue]{#1} };%
+ }
+ },
+ placemotH/.style={
+ code={
+ \foreach \l [count=\x from 0] in {#1} {\path ({\x-1},-1) pic {jeton={\l}};}
+ }
+ },
+ placemotV/.style={
+ code={
+ \foreach \l [count=\y from 0] in {#1} {\path (-1,-{\y-1}) pic {jeton={\l}};}
+ }
+ },
+ motcomptetriple/.style={
+ code={
+ \path pic {pointes={3}{0.15}{red!75}};%
+ \ifboolKV[PLSCRABBLETIKZ]{Labels}%
+ {\node [scorelettre] { \SCRBMCT[\PLSCRBBLElangue] };}{}
+ }
+ },
+ motcomptedouble/.style={
+ code={
+ \path pic {pointes={2}{0.15}{red!25}};%
+ \ifboolKV[PLSCRABBLETIKZ]{Labels}%
+ {\node [scorelettre] { \SCRBMCD[\PLSCRBBLElangue] };}
+ {}%
+ }
+ },
+ lettrecomptetriple/.style={
+ code={
+ \path pic {pointes={3}{0.15}{blue!50!cyan!75}};%
+ \ifboolKV[PLSCRABBLETIKZ]{Labels}%
+ {\node [scorelettre] { \SCRBLCT[\PLSCRBBLElangue] };}{}
+ }
+ },
+ lettrecomptedouble/.style={
+ code={
+ \path pic {pointes={2}{0.15}{blue!50!cyan!50}};%
+ \ifboolKV[PLSCRABBLETIKZ]{Labels}%
+ {\node [scorelettre] { \SCRBLCD[\PLSCRBBLElangue] };}{}
+ }
+ }
+}
+
+%commande pour placer un mot
+\newcommand\ScrabblePlaceMot[3][H]{%
+ \IfStrEq{#1}{H}%
+ {\path (#3) pic {placemotH={#2}};}
+ {\path (#3) pic {placemotV={#2}};}
+}
+
+%clés
+\defKV[PLSCRABBLETIKZ]{%
+ Echelle=\xdef\PLSCRBBLEechelle{#1}
+}
+\setKVdefault[PLSCRABBLETIKZ]{%
+ Echelle=1,%
+ Cadre=true,%
+ Labels=true,%
+ Aide=false
+}
+
+%commandes génériques autonomes pour plateau
+\NewDocumentCommand\PlateauScrabble{ D<>{FR} O{} }{%1=lng,2=options
+ \xdef\PLSCRBBLElangue{#1}
+ \useKVdefault[PLSCRABBLETIKZ]
+ \setKV[PLSCRABBLETIKZ]{#2}
+ \begin{tikzpicture}[scale=\PLSCRBBLEechelle,every node/.style={scale=\PLSCRBBLEechelle}]
+ %plateau
+ \fill[gray!25] (-.5,-.5) rectangle ++(15,15);
+ \draw[white,line width=\fpeval{\PLSCRBBLEechelle*0.1} cm, shift={(-.5,-.5)}] grid (15,15);
+ \foreach \scrcase in{(\x,\y),(\y,14-\x),(14-\x,14-\y),(14-\y,\x)}{%
+ \foreach \x/\y in {0/0,7/0}{\path \scrcase pic {motcomptetriple};}
+ \foreach \x/\y in {1/1,2/2,3/3,4/4}{\path \scrcase pic {motcomptedouble};}
+ \foreach \x/\y in {1/5,5/1,5/5}{\path \scrcase pic {lettrecomptetriple};}
+ \foreach \x/\y in {3/0,0/3,2/6,6/2,6/6}{\path \scrcase pic {lettrecomptedouble};}
+ }
+ \path (7,7) pic {casecentrale};
+ \ifboolKV[PLSCRABBLETIKZ]{Cadre}{\draw[line width=\fpeval{\PLSCRBBLEechelle*0.075} cm] (-0.6,-0.6) rectangle (14.6,14.6) ;}{}
+ \end{tikzpicture}%
+}
+
+%environnement pour plateau, pour placer des mots
+\NewDocumentEnvironment{EnvScrabble}{ D<>{FR} O{} }%1=LANG,2=options
+{
+ \xdef\PLSCRBBLElangue{#1}
+ \useKVdefault[PLSCRABBLETIKZ]
+ \setKV[PLSCRABBLETIKZ]{#2}
+ \begin{tikzpicture}[scale=\PLSCRBBLEechelle,every node/.style={scale=\PLSCRBBLEechelle}]
+ %plateau
+ \fill[gray!25] (-.5,-.5) rectangle ++(15,15);
+ \draw[white,line width=\fpeval{\PLSCRBBLEechelle*0.1} cm, shift={(-.5,-.5)}] grid (15,15);
+ \foreach \scrcase in{(\x,\y),(\y,14-\x),(14-\x,14-\y),(14-\y,\x)}{%cases spéciales
+ \foreach \x/\y in {0/0,7/0} {\path \scrcase pic {motcomptetriple};}
+ \foreach \x/\y in {1/1,2/2,3/3,4/4} {\path \scrcase pic {motcomptedouble};}
+ \foreach \x/\y in {1/5,5/1,5/5} {\path \scrcase pic {lettrecomptetriple};}
+ \foreach \x/\y in {3/0,0/3,2/6,6/2,6/6} {\path \scrcase pic {lettrecomptedouble};}
+ }
+ \path (7,7) pic {casecentrale};
+ \ifboolKV[PLSCRABBLETIKZ]{Cadre}
+ {\draw[line width=\fpeval{\PLSCRBBLEechelle*0.075} cm] (-0.6,-0.6) rectangle (14.6,14.6) ;}%
+ {}
+ \ifboolKV[PLSCRABBLETIKZ]{Aide}
+ {%
+ \foreach \numberscr in {1,2,...,15}
+ {\draw[gray] ({\numberscr-1},-0.65) node[below,font=\sffamily] {\numberscr};\draw[gray] (-0.65,{\numberscr-1}) node[left,font=\sffamily] {\numberscr};}
+ }%
+ {}
+}
+{
+ \end{tikzpicture}%
+}
+\else %les commandes "anglaises"
+%score par lettre
+%idées de https://tex.stackexchange.com/questions/194780/tikz-drawing-a-rectangle-with-spikes-on-borders
+\newcommand\lettrescorescrabble[2][EN]{%avec gestion du Joker par *
+ \IfStrEq{#2}{*}%
+ {}%
+ {%
+ \def\tmp{#2}%
+ \expandafter\count\expandafter0\expandafter`#2\relax\advance\count0 by-65\relax%
+ \IfStrEq{#1}{FR}%
+ {\ifcase\count0\relax1\or3\or3\or2\or1\or4\or2\or4\or1\or8\or10\or1\or1\or1\or1\or3\or8\or1\or1\or1\or1\or4\or10\or10\or10\or10\else\fi}{}%
+ \IfStrEq{#1}{EN}%
+ {\ifcase\count0\relax1\or3\or3\or2\or1\or4\or2\or4\or1\or8\or5\or1\or3\or1\or1\or3\or10\or1\or1\or1\or1\or4\or4\or8\or4\or10\else\fi}{}%
+ \IfStrEq{#1}{GE}%
+ {\ifcase\count0\relax1\or3\or4\or1\or1\or2\or2\or2\or2\or1\or6\or4\or2\or3\or2\or4\or10\or1\or1\or1\or1\or6\or3\or8\or10\or3\else\fi}{}%
+ \IfStrEq{#1}{SP}%
+ {\ifcase\count0\relax1\or3\or3\or2\or1\or4\or2\or4\or1\or8\or0\or1\or3\or1\or1\or3\or5\or1\or1\or1\or1\or4\or0\or8\or4\or10\else\fi}{}%
+ }%
+}
+
+%commandes localisées des cases
+\newcommand\SCRBMCT[1][EN]{%
+ \IfStrEq{#1}{FR}{MOT\\COMPTE\\TRIPLE}{}%
+ \IfStrEq{#1}{EN}{TRIPLE\\WORD\\SCORE}{}%
+ \IfStrEq{#1}{GE}{\scalebox{2}[2]{3W}}{}%
+ \IfStrEq{#1}{SP}{TRIPLE\\TANTO\\DE\\PALABRA}{}%
+}
+\newcommand\SCRBMCD[1][EN]{%
+ \IfStrEq{#1}{FR}{MOT\\COMPTE\\DOUBLE}{}%
+ \IfStrEq{#1}{EN}{DOUBLE\\WORD\\SCORE}{}%
+ \IfStrEq{#1}{GE}{\scalebox{2}[2]{2W}}{}%
+ \IfStrEq{#1}{SP}{DOBLE\\TANTO\\DE\\PALABRA}{}%
+}
+\newcommand\SCRBLCT[1][EN]{%
+ \IfStrEq{#1}{FR}{LETTRE\\COMPTE\\TRIPLE}{}%
+ \IfStrEq{#1}{EN}{TRIPLE\\LETTER\\SCORE}{}%
+ \IfStrEq{#1}{GE}{\scalebox{2}[2]{3B}}{}%
+ \IfStrEq{#1}{SP}{TRIPLE\\TANTO\\DE\\LETRA}{}%
+}
+\newcommand\SCRBLCD[1][EN]{%
+ \IfStrEq{#1}{FR}{LETTRE\\COMPTE\\DOUBLE}{}%
+ \IfStrEq{#1}{EN}{DOUBLE\\LETTER\\SCORE}{}%
+ \IfStrEq{#1}{GE}{\scalebox{2}[2]{2B}}{}%
+ \IfStrEq{#1}{SP}{DOBLE\\TANTO\\DE\\LETRA}{}%
+}
+
+%styles case + jetons
+%idées de https://tex.stackexchange.com/questions/194780/tikz-drawing-a-rectangle-with-spikes-on-borders
+\tikzset{
+ scorelettre/.style={
+ font=\sffamily\bfseries\tiny,align=center,scale=0.95,draw=none,fill=none
+ },
+ pics/.cd,
+ pointes/.style args={#1#2#3}{
+ code={
+ \fill [#3,scale=0.5*0.9] (-1,1) {\foreach \i in {0,1,2,3}{%
+ [rotate=-\i*90] -- (-#1*#2,1) {\foreach \j in {1,...,#1} {-- ++(#2,#2) -- ++(#2,-#2)} -- (1,1)}}} -- cycle;
+ }
+ },
+ casecentrale/.style={
+ code={
+ \path pic {pointes={2}{0.15}{red!25}};
+ \node [star,fill,star point ratio=2.35] {};%
+ }
+ },
+ jeton/.style={
+ code={
+ \node[fill=yellow!40,minimum size=0.9 cm,rounded corners=\fpeval{\PLSCRBBLEechelle*0.15} cm,font=\Large\sffamily\bfseries] (JETON) {\IfStrEq{#1}{*}{}{#1}};%
+ \node[inner sep=2pt,font=\sffamily\scriptsize,anchor=south east] at (JETON.south east) { \lettrescorescrabble[\PLSCRBBLElangue]{#1} };%
+ }
+ },
+ placemotH/.style={
+ code={
+ \foreach \l [count=\x from 0] in {#1} {\path ({\x-1},-1) pic {jeton={\l}};}
+ }
+ },
+ placemotV/.style={
+ code={
+ \foreach \l [count=\y from 0] in {#1} {\path (-1,-{\y-1}) pic {jeton={\l}};}
+ }
+ },
+ motcomptetriple/.style={
+ code={
+ \path pic {pointes={3}{0.15}{red!75}};%
+ \ifboolKV[PLSCRABBLETIKZ]{Labels}%
+ {\node [scorelettre] { \SCRBMCT[\PLSCRBBLElangue] };}{}
+ }
+ },
+ motcomptedouble/.style={
+ code={
+ \path pic {pointes={2}{0.15}{red!25}};%
+ \ifboolKV[PLSCRABBLETIKZ]{Labels}%
+ {\node [scorelettre] { \SCRBMCD[\PLSCRBBLElangue] };}
+ {}%
+ }
+ },
+ lettrecomptetriple/.style={
+ code={
+ \path pic {pointes={3}{0.15}{blue!50!cyan!75}};%
+ \ifboolKV[PLSCRABBLETIKZ]{Labels}%
+ {\node [scorelettre] { \SCRBLCT[\PLSCRBBLElangue] };}{}
+ }
+ },
+ lettrecomptedouble/.style={
+ code={
+ \path pic {pointes={2}{0.15}{blue!50!cyan!50}};%
+ \ifboolKV[PLSCRABBLETIKZ]{Labels}%
+ {\node [scorelettre] { \SCRBLCD[\PLSCRBBLElangue] };}{}
+ }
+ }
+}
+
+%commande pour placer un mot
+\newcommand\ScrabblePutWord[3][H]{%
+ \IfStrEq{#1}{H}%
+ {\path (#3) pic {placemotH={#2}};}
+ {\path (#3) pic {placemotV={#2}};}
+}
+
+%clés
+\defKV[PLSCRABBLETIKZ]{%
+ Scale=\xdef\PLSCRBBLEechelle{#1}
+}
+\setKVdefault[PLSCRABBLETIKZ]{%
+ Scale=1,%
+ Border=true,%
+ Labels=true,%
+ Help=false
+}
+
+%commandes génériques autonomes pour plateau
+\NewDocumentCommand\ScrabbleBoard{ D<>{EN} O{} }{%1=lng,2=options
+ \xdef\PLSCRBBLElangue{#1}
+ \useKVdefault[PLSCRABBLETIKZ]
+ \setKV[PLSCRABBLETIKZ]{#2}
+ \begin{tikzpicture}[scale=\PLSCRBBLEechelle,every node/.style={scale=\PLSCRBBLEechelle}]
+ %plateau
+ \fill[gray!25] (-.5,-.5) rectangle ++(15,15);
+ \draw[white,line width=\fpeval{\PLSCRBBLEechelle*0.1} cm, shift={(-.5,-.5)}] grid (15,15);
+ \foreach \scrcase in{(\x,\y),(\y,14-\x),(14-\x,14-\y),(14-\y,\x)}{%
+ \foreach \x/\y in {0/0,7/0}{\path \scrcase pic {motcomptetriple};}
+ \foreach \x/\y in {1/1,2/2,3/3,4/4}{\path \scrcase pic {motcomptedouble};}
+ \foreach \x/\y in {1/5,5/1,5/5}{\path \scrcase pic {lettrecomptetriple};}
+ \foreach \x/\y in {3/0,0/3,2/6,6/2,6/6}{\path \scrcase pic {lettrecomptedouble};}
+ }
+ \path (7,7) pic {casecentrale};
+ \ifboolKV[PLSCRABBLETIKZ]{Border}{\draw[line width=\fpeval{\PLSCRBBLEechelle*0.075} cm] (-0.6,-0.6) rectangle (14.6,14.6) ;}{}
+ \end{tikzpicture}%
+}
+
+%environnement pour plateau, pour placer des mots
+\NewDocumentEnvironment{EnvScrabble}{ D<>{EN} O{} }%1=LANG,2=options
+{
+ \xdef\PLSCRBBLElangue{#1}
+ \useKVdefault[PLSCRABBLETIKZ]
+ \setKV[PLSCRABBLETIKZ]{#2}
+ \begin{tikzpicture}[scale=\PLSCRBBLEechelle,every node/.style={scale=\PLSCRBBLEechelle}]
+ %plateau
+ \fill[gray!25] (-.5,-.5) rectangle ++(15,15);
+ \draw[white,line width=\fpeval{\PLSCRBBLEechelle*0.1} cm, shift={(-.5,-.5)}] grid (15,15);
+ \foreach \scrcase in{(\x,\y),(\y,14-\x),(14-\x,14-\y),(14-\y,\x)}{%cases spéciales
+ \foreach \x/\y in {0/0,7/0} {\path \scrcase pic {motcomptetriple};}
+ \foreach \x/\y in {1/1,2/2,3/3,4/4} {\path \scrcase pic {motcomptedouble};}
+ \foreach \x/\y in {1/5,5/1,5/5} {\path \scrcase pic {lettrecomptetriple};}
+ \foreach \x/\y in {3/0,0/3,2/6,6/2,6/6} {\path \scrcase pic {lettrecomptedouble};}
+ }
+ \path (7,7) pic {casecentrale};
+ \ifboolKV[PLSCRABBLETIKZ]{Border}
+ {\draw[line width=\fpeval{\PLSCRBBLEechelle*0.075} cm] (-0.6,-0.6) rectangle (14.6,14.6) ;}%
+ {}
+ \ifboolKV[PLSCRABBLETIKZ]{Help}
+ {%
+ \foreach \numberscr in {1,2,...,15}
+ {\draw[gray] ({\numberscr-1},-0.65) node[below,font=\sffamily] {\numberscr};\draw[gray] (-0.65,{\numberscr-1}) node[left,font=\sffamily] {\numberscr};}
+ }%
+ {}
+}
+{
+ \end{tikzpicture}%
+}
+\fi
+
+\endinput \ No newline at end of file