diff options
author | Karl Berry <karl@freefriends.org> | 2024-08-18 19:48:14 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2024-08-18 19:48:14 +0000 |
commit | 828eadc9127f2d0fd299cadec49c70bee4dce585 (patch) | |
tree | 4b6d361eca15eb1103faf5c50e0862c940a0cf9d /Master | |
parent | 7297d02f1daa6e2343666f905e7bec874553ad7d (diff) |
wordle (18aug24)
git-svn-id: svn://tug.org/texlive/trunk@72059 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r-- | Master/texmf-dist/doc/latex/wordle/README.md | 41 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/wordle/wordle-doc-en.pdf | bin | 284036 -> 266174 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/wordle/wordle-doc-en.tex | 1323 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/wordle/wordle-doc-fr.pdf | bin | 279989 -> 264372 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/wordle/wordle-doc-fr.tex | 1153 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/wordle/wordle.sty | 864 |
6 files changed, 2309 insertions, 1072 deletions
diff --git a/Master/texmf-dist/doc/latex/wordle/README.md b/Master/texmf-dist/doc/latex/wordle/README.md index f1977a1ae76..fdfd9968701 100644 --- a/Master/texmf-dist/doc/latex/wordle/README.md +++ b/Master/texmf-dist/doc/latex/wordle/README.md @@ -1,8 +1,33 @@ -wordle is a package to work with Wordle game. ------------------------------------------------------------ -wordle est un package pour travailler avec le jeu du sutom. ------------------------------------------------------------ -Author : Cédric Pierquet -email : cpierquet@outlook.fr -Licence : Released under the LaTeX Project Public License v1.3c or later, see http://www.latex-project.org/lppl.txt -Source : https://tex.stackexchange.com/questions/659860/wordle-like-colored-letter-boxes-in-latex
\ No newline at end of file +![v![]()ersion](https://img.shields.io/github/v/tag/AndrewMathas/wordle?color=success&label=version) +<a href="http://www.latex-project.org/lppl.txt"><img src="https://img.shields.io/badge/license-LPPLv1.3c-blueviolet.svg"></a> +<a href="https://www.latex-project.org/"><img src="https://img.shields.io/badge/latex-20B2AA?logo=Latex"></a> + +# Wordle + +A stupidly feature-rich LaTeX package for typesetting **Wordle** puzzles. This package provides a stupidly feature-rich way of creating Wordle puzzles in LaTeX, which [Wikipedia](https://en.wikipedia.org/wiki/Wordle) describes as a hugely popular web-based word game created and developed by Welsh software engineer Josh Wardle. + +This package provides the `wordle` environment, which uses the syntax: + +```tex +% \usepackage{wordle} +\begin{wordle}{ANVIL} + CRANE + NATAL + ANVIL +\end{wordle} +``` + +Ce package fournit un moyen stupidement riche en fonctionnalités de créer des puzzles **Wordle** en LaTeX, que [Wikipedia](https://en.wikipedia.org/wiki/Wordle) décrit comme comme un jeu de lettres en ligne extrêmement populaire, créé et développé par l'ingénieur logiciel gallois Josh Wardle. + +```tex +% \usepackage{wordle} +\begin{GrilleSutom}{REBUS} + ABRIS + ROUTE + REBUS +\end{GrilleSutom} +``` + +### Authors +Andrew Mathas and Cédric Pierquet + diff --git a/Master/texmf-dist/doc/latex/wordle/wordle-doc-en.pdf b/Master/texmf-dist/doc/latex/wordle/wordle-doc-en.pdf Binary files differindex aadb07f54b0..7845bc31b5f 100644 --- a/Master/texmf-dist/doc/latex/wordle/wordle-doc-en.pdf +++ b/Master/texmf-dist/doc/latex/wordle/wordle-doc-en.pdf diff --git a/Master/texmf-dist/doc/latex/wordle/wordle-doc-en.tex b/Master/texmf-dist/doc/latex/wordle/wordle-doc-en.tex index 06352f5ad5f..a638ed94962 100644 --- a/Master/texmf-dist/doc/latex/wordle/wordle-doc-en.tex +++ b/Master/texmf-dist/doc/latex/wordle/wordle-doc-en.tex @@ -1,426 +1,921 @@ -% !TeX TXS-program:compile = txs:///arara -% arara: pdflatex: {shell: yes, synctex: no, interaction: batchmode} -% arara: pdflatex: {shell: yes, synctex: no, interaction: batchmode} if found('log', '(undefined references|Please rerun|Rerun to get)') - -\documentclass[english,a4paper,11pt]{article} -\usepackage[margin=2cm,includefoot]{geometry} -\def\TPversion{0.1.1} -\def\TPdate{03/09/2023} -\usepackage{amssymb,amsfonts,amsmath} -\usepackage[utf8]{inputenc} -%\usepackage[T1]{fontenc} +% !TeX TS-program = pdflatex + +\documentclass[svgnames]{report} \usepackage{wordle} -\usepackage{awesomebox} -\usepackage{fontawesome5} -\usepackage{footnote} -\makesavenoteenv{tabular} +\usepackage{manfnt} \usepackage{enumitem} -\usepackage{tabularray} -\usepackage{fancyvrb} -\usepackage{fancyhdr} -\fancyhf{} -\renewcommand{\headrulewidth}{0pt} -\lfoot{\sffamily\small [wordle]} -\cfoot{\sffamily\small - \thepage{} -} -\rfoot{\hyperlink{matoc}{\small\faArrowAltCircleUp[regular]}} - -%\usepackage{hvlogos} -\usepackage{xspace} -\usepackage{hologo} -\providecommand\tikzlogo{Ti\textit{k}Z} -\providecommand\TeXLive{\TeX{}Live\xspace} -\providecommand\PSTricks{\textsf{PSTricks}\xspace} -\let\pstricks\PSTricks -\let\TikZ\tikzlogo -\newcommand\TableauDocumentation{% - \begin{tblr}{width=\linewidth,colspec={X[c]X[c]X[c]X[c]X[c]X[c]},cells={font=\sffamily}} - {\LARGE \LaTeX} & & & & &\\ - & {\LARGE \hologo{pdfLaTeX}} & & & & \\ - & & {\LARGE \hologo{LuaLaTeX}} & & & \\ - & & & {\LARGE \TikZ} & & \\ - & & & & {\LARGE \TeXLive} & \\ - & & & & & {\LARGE \hologo{MiKTeX}} \\ - \end{tblr} +\setlist[description]{font=\sffamily\bfseries\color{ForestGreen},labelwidth=\textwidth} +\usepackage{booktabs} +\usepackage[a4paper,margin=18mm]{geometry} +\synctex=1 +\parindent=0pt +\parskip=2mm + +\usepackage{cmap} % fix search and cut-and-paste in Acrobat +\setcounter{secnumdepth}{0} + +\usepackage{listings}\lstset{language=[LaTeX]TeX,framerule=2pt} +\lstset{language=[LaTeX]TeX, + texcsstyle=*\bfseries\color{Peru}, + backgroundcolor=\color{Ivory}, + numbers=none, + breaklines=true, + keywordstyle=\color{Sienna}, + commentstyle=\color{BurlyWood}, + tabsize=2, + morekeywords={Wordle,wordle,GrilleSutom}, + resetmargins=true, } - -\usepackage{hyperref} -\urlstyle{same} -\hypersetup{pdfborder=0 0 0} -\setlength{\parindent}{0pt} -\definecolor{LightGray}{gray}{0.9} - -\usepackage{babel} -%\AddThinSpaceBeforeFootnotes -%\FrenchFootnotes - -\usepackage{listings} - -\usepackage{newverbs} -\newverbcommand{\motcletex}{\color{cyan!75!black}}{} -\newverbcommand{\packagetex}{\color{violet!75!black}}{} - -\usepackage[most]{tcolorbox} -\tcbuselibrary{listingsutf8} -\newtcblisting{DemoCode}[1][]{% - enhanced,width=0.95\linewidth,center,% - bicolor,size=title,% - colback=cyan!2!white,% - colbacklower=cyan!1!white,% - colframe=cyan!75!black,% - listing options={% - breaklines=true,% - breakatwhitespace=true,% - style=tcblatex,basicstyle=\small\ttfamily,% - tabsize=4,% - commentstyle={\itshape\color{gray}}, - keywordstyle={\color{blue}},% - classoffset=0,% - keywords={},% - alsoletter={-},% - keywordstyle={\color{blue}},% - classoffset=1,% - alsoletter={-},% - morekeywords={center,justify},% - keywordstyle={\color{violet}},% - classoffset=2,% - alsoletter={-},% - morekeywords={WordleGrid},% - keywordstyle={\color{green!50!black}},% - classoffset=3,% - morekeywords={Colors,Rounded,Unit,Font,ColorLetters,Letters,Style,Thickness,BorderColor},% - keywordstyle={\color{orange}} - },% - #1 +% hyperref links to ctan +\newcommand\ctan[1]{\href{https://www.ctan.org/pkg/#1}{\texttt{#1}}} + +\newcommand\Section[1]{\subsection{\textcolor{DarkGreen}{#1}}} + +\ExplSyntaxOn +\NewDocumentCommand\option{ omo }{% + \IfNoValueTF{#1}{\textsf{#2}} + {% + \textbf{\textcolor{Crimson}{#2}} + \str_if_empty:nF {#1}{~(default:~\textcolor{DarkRed}{#1})}% + \IfNoValueF{#3}{\hfill\textcolor{Gray}{[accepts:~#3]}}% + }% + \index{#2}% +} +\ExplSyntaxOff + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\usepackage{imakeidx} +\indexsetup{level=\section*, toclevel=section, noclearpage} +\makeindex[intoc,columns=3] + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\usepackage[skins,listings]{tcolorbox} +\usetikzlibrary{backgrounds, shapes.geometric} % for tikz={framed,...} + +\DeclareTotalTCBox\keyword{ O{} v }{ + fontupper=\sffamily, + nobeforeafter, + skin=tile, + verbatim, + on line, + tcbox raise base, + top=0pt,bottom=0pt,left=0mm,right=0mm, + colback=OldLace, + colupper=ForestGreen, + #1} +{#2} + +\lstdefinestyle{tikz}{style=tcblatex, + classoffset=0, + texcsstyle=*\color{DarkGoldenrod},% + deletetexcs={begin, end}, + moretexcs={,% + node, + draw, + true, + false + },% + classoffset=1, + keywordstyle=\color{ForestGreen},% + morekeywords={wordle,GrilleSutom}, + classoffset=2, + keywordstyle=\color{Crimson},% + morekeywords={ + absent, + align, + border, + borders, + case, + color, + colors, + colour, + colours, + correct, + empty, + font, + frame, + frames, + letters, + lower, + name, + natural, + noalign, + noletters, + params, + present, + rounded, + rows, + scale, + sensitive, + separation, + shape, + shapes, + size, + strict, + style, + style, + text, + thickness, + tikz, + tile, + upper, + }, + classoffset=3, + keywordstyle=\color{DarkOrange},% + morekeywords={ + hard, + standard, + sutom, + } } -\tcbset{vignettes/.style={% - nobeforeafter,box align=base,boxsep=0pt,enhanced,sharp corners=all,rounded corners=southeast,% - boxrule=0.75pt,left=7pt,right=1pt,top=0pt,bottom=0.25pt,% - } +\DeclareTCBListing{example}{ !O{} }{% + skin=bicolor, + colframe=MediumSeaGreen, + colbacklower=OldLace, + colback=LawnGreen!20, + lefthand width=50mm, + listing style=tikz, + sidebyside, + sidebyside align=center, + sidebyside gap=4mm, + text and listing, + text outside listing, + boxsep = 0pt, + #1 } -\tcbset{vignetteMaJ/.style={% - fontupper={\vphantom{pf}\footnotesize\ttfamily}, - vignettes,colframe=purple!50!black,coltitle=white,colback=purple!10,% - overlay={\begin{tcbclipinterior}% - \fill[fill=purple!75]($(interior.south west)$) rectangle node[rotate=90]{\tiny \sffamily{\textcolor{black}{\scalebox{0.66}[0.66]{\textbf{MàJ}}}}} ($(interior.north west)+(5pt,0pt)$);% - \end{tcbclipinterior}} - } +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +\makeatletter +\author{Andrew Mathas and Cédric Pierquet} +\usepackage{tikz} +\usetikzlibrary{shadows.blur} +\tikzset{shadowed/.style={blur shadow={shadow blur steps=5}, + bottom color=ForestGreen!30, + draw=MediumSeaGreen!70, + shade, + font=\normalfont\Huge\bfseries\scshape, + rounded corners=8pt, + top color=SeaGreen, + }, + boxes/.style={draw=SeaGreen, + fill=Cornsilk, + font=\sffamily\small, + inner sep=5pt, + rectangle, + rounded corners=8pt, + text=DarkGreen, + } +} +\newcommand\Wordle{% + \begin{tikzpicture}[remember picture,overlay] + \node[yshift=-3cm] at (current page.north west) + {\begin{tikzpicture}[remember picture, overlay] + \draw[shadowed](30mm,0) rectangle node[white]{wordle} (\paperwidth-30mm,16mm); + \node[anchor=west,boxes] at (4cm,0cm) {\@author}; + \node[anchor=east,boxes] at (\paperwidth-4cm,0) {Version \wordle@version}; + \end{tikzpicture} + }; + \end{tikzpicture} + \vspace*{20mm} } -\newcommand\Cle[1]{{\small\sffamily\textlangle \textcolor{orange}{#1}\textrangle}} -\newcommand\cmaj[1]{\tcbox[vignetteMaJ]{#1}\xspace} +\def\@oddfoot{\textsc{Wordle} --- \wordle@version~(released~\wordle@release)\hfill\thepage} + +\usepackage[colorlinks=true,linkcolor=blue,urlcolor=MediumBlue]{hyperref} +\hypersetup{ + pdfcreator={ Generated by pdfLaTeX }, + pdfinfo={ + Author ={ Andrew Mathas and Cédric Pierquet}, + Keywords={ wordle }, + License ={ LaTeX Project Public License v1.3c or later }, + Subject ={ LaTeXing Wordle puzzles }, + Title ={ Wordle - \wordle@version } + }, +} +\makeatother \begin{document} -\setlength{\aweboxleftmargin}{0.07\linewidth} -\setlength{\aweboxcontentwidth}{0.93\linewidth} -\setlength{\aweboxvskip}{8pt} - -\pagestyle{fancy} - -\thispagestyle{empty} - -\vspace{2cm} - -\begin{center} - \begin{minipage}{0.75\linewidth} - \begin{tcolorbox}[colframe=yellow,colback=yellow!15] - \begin{center} - \begin{tabular}{c} - {\Huge \texttt{wordle} [en]}\\ - \\ - {\LARGE Grids of Wordle,} \\ - \\ - {\LARGE made with \textsf{Ti\textit{k}Z}.} \\ - \end{tabular} - - \bigskip - - {\small \texttt{Version \TPversion{} -- \TPdate}} - \end{center} - \end{tcolorbox} -\end{minipage} -\end{center} - -\begin{center} - \begin{tabular}{c} - \texttt{Cédric Pierquet}\\ - {\ttfamily c pierquet -- at -- outlook . fr}\\ - \texttt{\url{https://github.com/cpierquet/wordle}} -\end{tabular} -\end{center} - -\vspace{0.25cm} - -{$\blacktriangleright$~~Create Wordle grids Wordle/Sutom\footnotemark\footnotetext{\url{https://en.wikipedia.org/wiki/Wordle}}.} - -\vspace{0.25cm} - -{$\blacktriangleright$~~Specify colors and font\footnotemark\footnotetext{Ideas from \url{ttps://tex.stackexchange.com/questions/659860/wordle-like-colored-letter-boxes-in-latex}}. - -\vspace{0.5cm} - -\begin{center} -\begin{WordleGrid}{CRAZE} - GRAIL TRACK CRAMP CRABS CRAZY CRAZE -\end{WordleGrid} -\end{center} - -\begin{center} -\begin{WordleGrid}[Rounded=0,Colors={lightgray,orange,teal},Style=alt,Unit=0.5,Letters=false]{LADLE} - FLAIL LAPEL LADLE -\end{WordleGrid} -% -\hspace{5mm} -% -\begin{WordleGrid}[Rounded=0,Colors={lightgray,orange,teal},Style=alt,Unit=0.5]{LADLE} - FLAIL LAPEL LADLE -\end{WordleGrid} -\end{center} - -\vspace{0.25cm} - -%\hfill{}\textit{Merci à Denis Bitouzé et à Gilles Le Bourhis pour leurs retours et idées !} - -\smallskip - -\vfill - -\hrule - -\medskip - -\TableauDocumentation - -\medskip - -\hrule - -\vspace*{1cm} - -\newpage - -\phantomsection -\hypertarget{matoc}{} - -\tableofcontents - -\vfill - -\section{History} - -\verb|v0.1.1|~:~~~~Bugfix with english version. - -\verb|v0.1.0|~:~~~~Initial version. - -\newpage - -\section{The wordle package} - -\subsection{The game} - -\begin{noteblock} -Wordle is a web-based word game created and developed by Welsh software engineer Josh Wardle. Players have six attempts to guess a five-letter word, with feedback given for each guess in the form of colored tiles indicating when letters match or occupy the correct position. - -Every day, a five-letter word is chosen which players aim to guess within six tries. After every guess, each letter is marked as either green, yellow or gray: green indicates that letter is correct and in the correct position, yellow means it is in the answer but not in the right position, while gray indicates it is not in the answer at all. Multiple instances of the same letter in a guess, such as the "o"s in "robot", will be colored green or yellow only if the letter also appears multiple times in the answer; otherwise, excess repeating letters will be colored gray. - -\smallskip - -\hfill{\scriptsize \url{https://en.wikipedia.org/wiki/Wordle}} -\end{noteblock} - -\subsection{The package} - -\begin{noteblock} -This package can display, in a \textsf{tex} file, a wordle grid (with \TikZ{} and within a \motcletex!minipage!), with ability : - -\begin{itemize} - \item to change dimensions and colors ; - \item to pick style for misplaced letters ; - \item to change borders and corners ; - \item to print or not the letters. -\end{itemize} - -It's possible to "play" with other words than five-letter words ! -\end{noteblock} - -\begin{importantblock} -Most of source code, in \hologo{LaTeX3}, is given by thread from \texttt{tex.stackexchange}, proposed by user \textsf{3141592653589793238}. -\end{importantblock} - -\subsection{Loading of the package, used packages} - -\begin{importantblock} -The package \packagetex!wordle! loads within the preamble. - -There's no option, and \packagetex!xcolor! isn't loaded. -\end{importantblock} - -\begin{DemoCode}[listing only] -\documentclass{article} -\usepackage{wordle} - -\end{DemoCode} - -\begin{noteblock} -\packagetex!wordle! loads the following packages and libraries : - -\begin{itemize} - \item \packagetex!tikz!; - \item \packagetex!simplekv! ; - \item \packagetex!xstring!. -\end{itemize} - -It’s mostly compatible with \textsf{latex}, \textsf{pdflatex}, \textsf{lualatex} or \textsf{xelatex} compilation ! -\end{noteblock} - -\vfill~ - -\pagebreak - -\section{WordleGrid environment} - -\subsection{Environment} - -\begin{cautionblock} -The environment to display a Wordle grid is \packagetex!WordleGrid!. - -It works with keys, between \texttt{[...]} and needs to know : - -\begin{itemize} - \item the good word ; - \item the different guesses. -\end{itemize} - -The code create the grid and the colors ! -\end{cautionblock} - -\begin{DemoCode}[listing only] -\begin{WordleGrid}[keys]{good word} - guess n°1 - guess n°2 - guess n°3 -\end{WordleGrid} -\end{DemoCode} - -\begin{noteblock} -the grid is created with a \motcletex!minipage!, with automatic width and spacings ! -\end{noteblock} - -\begin{DemoCode}[] -%default output -\begin{WordleGrid}{REBUS} - ARISE - ROUTE - RULES - REBUS -\end{WordleGrid} -\end{DemoCode} - -\subsection{Keys and options} - -\begin{tipblock} -The first argument, mandatory and between \texttt{[...]}, proposes the following \Cle{keys} : - -\begin{itemize} - \item \Cle{Colors} : = colors of the boxes \Cle{back,misplaced,good} ; - - \hfill{}default : \Cle{WordleBack,WordleBad,WordleGood},% - \item \Cle{Rounded} := arc for corners, in mm ; \hfill{}default : \Cle{0.1} - \item \Cle{Unit} := width of cases, in cm ; \hfill{}default : \Cle{1} - \item \Cle{Font} := font for letters ; \hfill{}default : \Cle{\textbackslash LARGE\textbackslash bfseries\textbackslash sffamily} - \item \Cle{ColorLetters} := color for letters ; \hfill{}default : \Cle{white} - \item \Cle{BorderColor} := color fot the border ; \hfill{}default : \Cle{white} - \item \Cle{Letters} := boolean to print letters ; \hfill{}default : \Cle{true} - \item \Cle{Style} := style within \Cle{default / other} to change the style ; \hfill{}default : \Cle{default} - \item \Cle{Thick} := thickness of the borders, in mm. \hfill{}default : \Cle{0.25} -\end{itemize} -\vspace*{-\baselineskip}\leavevmode -\end{tipblock} - -\begin{tipblock} -The second argument, optional and between \texttt{\{...\}} is the correct word. - -\smallskip - -Different guesses are given within the body of the environment (line by line or space separated). -\end{tipblock} - -\subsection{Examples} - -\begin{DemoCode}[] -\begin{WordleGrid}{BURGH} - ABATE - HERBS - BURLY - BURGH -\end{WordleGrid} -% -\hspace{5mm} -% -\begin{WordleGrid}[Style=alt]{BURGH} - ABATE HERBS BURLY BURGH -\end{WordleGrid} -\end{DemoCode} - -\begin{DemoCode}[] -\begin{WordleGrid} - [Thickness=0.3,BorderColor=black,% - Colors={lightgray,orange,teal}]{BURGH} - ABATE - HERBS - BURLY - BURGH -\end{WordleGrid} -% -\hspace{5mm} -% -\begin{WordleGrid} - [Rounded=0,Thickness=0.3,BorderColor=black,% - Colors={lightgray,orange,teal}]{BURGH} - ABATE - HERBS - BURLY - BURGH -\end{WordleGrid} -\end{DemoCode} - -\begin{DemoCode}[] -\begin{WordleGrid}[Unit=2,Font=\Huge\ttfamily,ColorLetters=black]{BURGH} - ABATE - HERBS - BURLY - BURGH -\end{WordleGrid} -\end{DemoCode} - -\begin{DemoCode}[] -\begin{WordleGrid}% - [Unit=0.75,Rounded=0,Colors={cyan,orange,violet},Letters=false]{BURGH} - ABATE - HERBS - BURLY - BURGH -\end{WordleGrid} -\hspace{5mm} -\begin{WordleGrid}% - [Unit=0.75,Rounded=0,Colors={cyan,orange,violet},Style=alt] - {BURGH} - ABATE - HERBS - BURLY - BURGH -\end{WordleGrid} -\hspace{5mm} -\begin{WordleGrid}% - [Unit=0.75,Rounded=0,Colors={cyan,orange,violet},Style=alt,Letters=false] - {BURGH} - ABATE - HERBS - BURLY - BURGH -\end{WordleGrid} -\end{DemoCode} - -\end{document}
\ No newline at end of file + \Wordle + + This package provides a stupidly feature-rich way of creating + \keyword{Wordle} puzzles in \LaTeX, which + \href{https://en.wikipedia.org/wiki/Wordle}{Wikipedia} describes as a + hugely popular web-based word game created and developed by Welsh + software engineer Josh Wardle. This package is an enhanced version of + one of the solutions to a question asked by \textcolor{FireBrick}{valerio\_new} + on + \href{https://tex.stackexchange.com/questions/659860/wordle-like-colored-letter-boxes-in-latex/660056#660056}{tex.stackexchange.com}. + + This package provides the \keyword{wordle} environment, which uses the + syntax: + + \begin{tcblisting}{ + listing only, + skin=bicolor, + colframe=MediumSeaGreen, + colbacklower=OldLace, + colback=LawnGreen!20, + listing style=tikz, + boxsep = 0pt, + } + % \usepackage{wordle} + \begin{wordle}[wordle settings]{solution}[optional tikz commands] + guess1 guess2 ... + \end{wordle} + \end{tcblisting} + \index{environment!wordle} + \index{wordle} + + and the \keyword{GrilleSutom} environment, for \keyword{Sutom}, the French version of + the games: + + \begin{tcblisting}{ + listing only, + skin=bicolor, + colframe=MediumSeaGreen, + colbacklower=OldLace, + colback=LawnGreen!20, + listing style=tikz, + boxsep = 0pt, + } + % \usepackage{wordle} + \begin{GrilleSutom}[sutom settings]{solution}[optional TikZ commands] + guess1 guess2 ... + \end{GrilleSutom} + \end{tcblisting} + \index{environment!GrilleSutom} + \index{GrilleSutom} + \index{sutom} + + The words in the puzzle can be entered on a single lines, or on separate + lines. Here are some examples: + + \begin{example} + \begin{wordle}{ANVIL} + % English version of sutom (wordle) + CRANE + NATAL + ANVIL + \end{wordle} + \end{example} + + \begin{example} + % French version of wordle (sutom) + \begin{GrilleSutom}{REBUS} + ABRIS + ROUTE + REBUS + \end{GrilleSutom} + \end{example} + + As in the online puzzles, the \keyword{wordle} environment + automatically colours the letter tiles + \keyword[colback=WordleCorrect,colupper=White]{green} + when the letter is in the same position as the solution, and as + \keyword[colback=WordlePresent,colupper=White]{gold} when + the letter is in the solution but it is not in the correct position. + Similarly, \keyword{GrilleSutom} colours the correct letters + \keyword[colback=WordleSutomCorrect,colupper=White]{red} + and the present letters + \keyword[colback=WordleSutomPresent,colupper=White]{gold}. + As described below, these colours can be changed to suit your tastes. + + The number of letters in the puzzle is determined by the solution, + being constrained only by the page width. + + \begin{example} + \begin{wordle}[rows=4]{orange} + normal + orders + orange + \end{wordle} + \end{example} + + The letters in the puzzle can be entered in upper case, lower case, or + mixed case. By default, the case of the letters is ignored when + determining the colours of the letter tiles. + + As described below, the \keyword{wordle} and \keyword{GrilleSutom} + environments accept an array of different options that change the + colours, fonts, and shapes of the tile. In addition, you can the case + sensitivity of the environments, add extra rows to the puzzle, disable + special formatting of the \textit{letter tiles}. These options are + given as a comma separated list key-value pairs. They can be set + locally, using the optional argument of the \keyword|wordle| + environment, or they can be set globally (more accurately, in the + current \LaTeX\ group) using the \keyword{\WordleSetup} command + \index{\textbackslash WordleSetup}, or as global package options, via + \keyword{\usepackage[options]{wordle}}. The order of the options does + not matter, except that later options take precedence over earlier + ones, with the exception of \option{tikz} and \option{tile style} keys + which are always applied last. + + The \keyword{wordle} puzzles are drawn using \ctan{TikZ}, with each + letter in the puzzle sitting inside a \ctan{TikZ} node. Many of the + options control the settings of these nodes. + + The descriptions of the options below are grouped according to their + function. + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + \Section{Wordle styles} + + The \option{style} key can be used to change many characteristics of + the tiles in a \keyword{wordle} puzzle, including their colours, the + fonts and so on. The more common settings can be setting using the + \option{style} keyword. \textit{The style should always be set first + because, otherwise, the style settings may override earlier settings.} + + The following styles are supported: + + \textcolor{DarkOrange}{sutom} + \index{style!sutom} + \index{sutom} + + \begin{example} + \begin{wordle}[style=sutom]{ANVIL} + CRANE + NATAL + ANVIL + \end{wordle} + \end{example} + + The \textcolor{DarkOrange}{sutom} style is the default + style for the \keyword{GrilleSutom} environment. + + \textcolor{DarkOrange}{standard} + \index{style!standard} + + \begin{example} + \begin{wordle}[style=standard]{ANVIL} + CRANE + NATAL + ANVIL + \end{wordle} + \end{example} + + The \textcolor{DarkOrange}{standard} style is the default style for the + \keyword{wordle} environment. + + \textcolor{DarkOrange}{hard} + \index{style!hard} + + \begin{example} + \begin{wordle}[style=hard]{ANVIL} + CRANE + NATAL + ANVIL + \end{wordle} + \end{example} + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + \Section{Options for the individual styles of the letter tiles} + + There are four types of letter tiles in \keyword{wordle}: + \option{absent}, \option{present}, \option{correct} and + \option{empty}, corresponding to letters not in the solution, + incorrectly placed letters, correctly placed letters, and empty + tiles, respectively. The options in this section can be used to set + the text, tile and border colours, shapes, and frames of these tiles. + + The letter tiles in a \keyword{wordle} environment are typeset inside + a \ctan{TikZ} \keyword{\node}. The options below control the different + style settings of these nodes. + + \option[--]{colours}[comma separated list of valid colours] + + The \option{colours} option is a short-hand for specifying the colours + of the \option{absent}, \option{present}, \option{correct} and + \option{empty} tiles, in that order. Later colours can be omitted but + the colours should be given in this order, from left to right. + If only one colour is given then this colour is applied to all tiles. + + \begin{example} + \begin{wordle}[colours={LightGray,Orange,Teal}]{cellar} + pounds + taylor + cellar + \end{wordle} + \end{example} + + The colours can also be set individually using \option{absent colour}, + \option{present colour}, \option{correct colour} and \option{empty + colour}. To support north American dialects, is also possible to use + \option{colors}, \option{absent color}, \option{present color}, + \option{correct color} and \option{empty color}. + + \begin{example} + \begin{wordle}[absent colour=DarkGray,present color=Salmon, + correct color=SeaGreen]{cellar} + pounds + taylor + cellar + \end{wordle} + \end{example} + + \option[white]{borders}[comma separated list of valid colours] + + Similar to the \option{colours} option, this is a short-hand for the + setting border colour of the \option{absent}, \option{present}, + \option{correct} and \option{empty} tiles, in that order. + If only one colour is given then this colour is applied to all tiles. + + \begin{example} + \begin{wordle}[borders={red, orange,blue}]{ANVIL} + CRANE + NATAL + ANVIL + \end{wordle} + \end{example} + + You can set the border borders of the individual tiles using + \option{absent border}, \option{present border}, \option{correct + border} and \option{empty border} + + \option[false]{frames}[comma separated list of true/false] + + This is a short-hand for adding a rectangular frame around the + \option{absent}, \option{present}, \option{correct} and \option{empty} + tiles, in that order, with the same background colour as the + \option{absent} file. This is only useful for non-square tiles. + + \begin{example} + \begin{wordle}[frames={false,true,true}, shapes=circle]{ANVIL} + CRANE + NATAL + ANVIL + \end{wordle} + \end{example} + + You can set the frames of the individual tiles using + \option{absent frame}, \option{present frame}, + \option{correct frame} and \option{empty~frame}. + + \option[rectangle]{shapes}[comma separated list of TikZ shapes] + + Similar to the \option{colours} option, this is a short-hand for the + setting shape colour of the \option{absent}, \option{present}, + \option{correct} and \option{empty} tiles, in that order. + + \begin{example} + \begin{wordle}[shapes={circle, rectangle, circle}]{ANVIL} + CRANE + NATAL + ANVIL + \end{wordle} + \end{example} + + You can set the shape shapes of the individual tiles using + \option{absent shape}, \option{present shape}, + \option{correct shape} and \option{empty shape} + You can use the shapes provided by the \ctan{TikZ} + \texttt{shapes.geometric} package, including \texttt{diamond}, + \texttt{ellipse}, \texttt{trapezium} and \texttt{star}; see + section~71.2 of the \ctan{TikZ} manual. + + \begin{example} + % \usepackage{shapes.geometric} + \begin{wordle}[shapes={diamond, ellipse, star}]{LADLE} + FLAIL + LAPEL + * + LADLE + LOVER + \end{wordle} + \end{example} + + \option[white]{text}[comma separated list of valid colours] + + This is a short-hand for the setting the text colours of the + \option{absent}, \option{present}, \option{correct} and \option{empty} + tiles, in that order. + + \begin{example} + \begin{wordle}[text={red, orange,blue}]{ANVIL} + CRANE + NATAL + ANVIL + \end{wordle} + \end{example} + + You can set the text borders of the individual tiles using + \option{absent text}, \option{present border}, \option{correct + text} and \option{empty border} + + + \Section{Common tile characteristics} + + The following options apply to all tiles. + + \option[]{noalign} (default) \qquad + \option[]{align} + + The options tweak the vertical alignment of the letters in each row of + the puzzle. This is only likely to be useful if you have lower case + letters in your puzzle. + + \begin{example} + \begin{wordle}[align]{agony} + groan + angry + agony + \end{wordle} + \end{example} + + \begin{example} + \begin{wordle}[noalign]{agony} % the default + groan + angry + agony + \end{wordle} + \end{example} + + \option[\textbackslash Large\textbackslash bfseries\textbackslash sffamily]{font} + [LaTeX font specification] + + Sets the font used by all \keyword{wordle} letters. Any valid sequence + of \LaTeX\ font commands can be used. + + \begin{example} + \begin{wordle}[font=\large\sffamily]{ANVIL} + CRANE + NATAL + ANVIL + \end{wordle} + \end{example} + + \option[1mm]{rounded}[a length] + + Set TikZ \texttt{rounded corners} key for the \keyword{wordle} letter tiles. + + \begin{example} + \begin{wordle}[rounded=2mm]{ANVIL} + CRANE + NATAL + ANVIL + \end{wordle} + \end{example} + + \option[0.5mm]{separation}[a length] + + Sets the separation distance between the \keyword{wordle} letter + tiles. + + \begin{example} + \begin{wordle}[separation=2mm, borders=black]{ANVIL} + CRANE + NATAL + ANVIL + \end{wordle} + \end{example} + + \option[1]{scale}[a number] + + The \option{scale} option rescales the \keyword{wordle} environment. + The \option{scale} alters the dimensions sets by the \option{rounded}, + \option{separation} \option{size} and \option{thickness} options. If + you change the scale, then you will almost certainly want + to change font size font as well, which you can do using the + \option{font} option: + + \begin{example} + \begin{wordle}[scale=1.5, font=\huge\bfseries]{SIZE} + HELP + WISE + SIZE + \end{wordle} + \end{example} + + \option[8mm]{size}[a length] + + The \option{size} option sets the size of the \keyword{wordle} letter + tiles. Unlike the \option{scale} option, \option{size} only changes + the dimensions of the letter tiles. + + \begin{example} + \begin{wordle}[size=10mm, font=\huge\bfseries]{LADLE} + FLAIL LAPEL * LADLE + \end{wordle} + \end{example} + + \option[0.25mm]{thickness}[a length] + + Sets the border thickness of the \keyword{wordle} letter tiles. By + default, the borders of the tiles are white, which makes this setting + hard to see, so the following example changes the border to red. + + \begin{example} + \begin{wordle}[thickness=1mm, borders=red]{LADLE} + FLAIL + LAPEL + LADLE + \end{wordle} + \end{example} + + \option[--]{tile style}[comma separated list of TikZ style keys] + + A comma-separated list of \ctan{Tikz} node keys that are appended to + the style of the \ctan{TikZ} node that contains each of the + \keyword{wordle} letters. Some of the options given above can be set + directly using the \option{tile style} option. When using the + \option{tile style}, be careful not to break the special formatting of + letters provided by the \keyword{wordle} environment.\par + + With most of the \keyword{wordle} options, the latter options take + precedence, however, the \option{tile style} option is applied last, + so it overrides any competing options. + + % TODO: Fix this because it looks like this style is being applied + % twice because the PDF file shows a rotation of 90 = 2*45... + \begin{example} + \begin{wordle}[tile style={rotate=45}]{ANVIL} + CRANE + NATAL + ANVIL + \end{wordle} + \end{example} + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + \Section{Extra rows and columns} + + By default, all of the words in a \keyword{wordle} puzzle are assumed + to have the same number of letters as the solution, and the number of + rows in the puzzle is number of words given in the environment. The + options below give more control over the number of rows and columns in + the puzzle. + + \option[]{letters} (default)\qquad + \option[]{noletters} + + By default, the letters in the puzzle are printed. You can hide the + letters from the puzzle, while still keeping the \keyword{wordle} tile + colouring, using \option{noletters}. + + \begin{example} + \begin{wordle}[letters]{CRAZE} % the default + TRACE + CREAM + CRAZE + \end{wordle} + \end{example} + + \begin{example} + \begin{wordle}[noletters]{CRAZE} + TRACE + CREAM + CRAZE + \end{wordle} + \end{example} + + \option[false]{strict}[true/false/--] + + By default, the \keyword{wordle} environment does not check that each + word in the puzzle has the same length as the solution, so missing + and extra letters receive no special processing. + + \begin{example} + \begin{wordle}[strict=false]{CRAZE} % the default + GRAIL + CRAMPS + CRAM + CRABS + \end{wordle} + \end{example} + + The \option{strict} option enforces the word length in the puzzle by + marking missing letters as incorrect and striking out extra letters. + + \begin{example} + \begin{wordle}[strict]{CRAZE} + GRAIL + CRAMPS + CRAM + CRABS + \end{wordle} + \end{example} + + \option[--]{rows} + + By default, a \keyword{wordle} environment displays the words + in the puzzle environment with one word per row. You can add extra + (blank) rows to the puzzle with the \option{rows} option. + + \begin{example} + \begin{wordle}[rows=4]{ANVIL} + CRANE + NATAL + ANVIL + \end{wordle} + \end{example} + + The \option{rows} option only adds extra rows to the puzzle if they + are needed. This option does not prevent ``extra'' rows from + appearing. + + \begin{example} + \begin{wordle}[rows=2]{ANVIL} + CRANE + NATAL + ANVIL + \end{wordle} + \end{example} + + + \option[]{*} + + You can disable the special colouring of letter tiles in a + \keyword{wordle} puzzle by adding an asterisk,~\option{*}, as a + \textit{word}, into the puzzle. + + \begin{example} + \begin{wordle}{ANVIL} + CRANE + NATAL + * % disable wordle colouring + ANNUL + ANVIL + \end{wordle} + \end{example} + + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + \Section{Case sensitivity} + \index{case~sensitive} + \index{case~sensitive!lower case} + \index{case~sensitive!natural case} + \index{case~sensitive!upper case} + + By default, the letters are printed in upper and lower case, exactly + as typed, and the letter comparisons are not case sensitive. + + \option[false]{case~sensitive} + + By default the \keyword{wordle} puzzles are not case sensitive, but + you can make them case sensitive using this option. Note that + \keyword{case sensitive} is the same as \keyword{case sensitive=true} + (and the default option is the same as + \keyword{case sensitive=false}). + + \begin{example} + \begin{wordle}[case sensitive=false]{youth} % the default + North + South + Youth + \end{wordle} + \end{example} + + Here is a case sensitive version of this puzzle. + + \begin{example} + \begin{wordle}[case sensitive]{youth} + North + South + Youth + \end{wordle} + \end{example} + + As this puzzle is case sensitive, the \keyword{Y} on the last line is + not marked as being correct because it does not match the \keyword{y} + in the solution. + + \option[]{natural case} (default) \qquad + \option[]{lower case} \qquad + \option[]{upper case} + + The \option{lower case} and \option{upper case} options force all + letters in the puzzle to be in lower or upper case, respectively. + + \begin{example} + \begin{wordle}[lower case]{YOUTH} + North + South + Youth + \end{wordle} + \end{example} + + \begin{example} + \begin{wordle}[upper case]{youth} + North + South + Youth + \end{wordle} + \end{example} + + As these examples show, both of these options disable the case + sensitivity of the tests for colouring the \keyword{wordle} tiles; + that is, they set \option{case sensitive=false}. To balance the + \option{lower case} and \option{upper case} options, the + \option{natural case} option makes the \keyword{wordle} environment + restores the default behaviour, which respects the case of the letters + as typed into the environment. The \option{natural case} option does + not change the \option{case sensitive} setting. + + \begin{example} + \begin{wordle}[natural case]{youth} % the default + North + South + youth + \end{wordle} + \end{example} + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + \Section{Adding \ctan{TikZ} code} + + The \keyword{wordle} environment is a fancy wrapper around a + \keyword{tikzpicture} environment, with some code under the hood that + automatically colours the letter tiles according to how well they + match the solution. The options in this section describe how to access + the underlying \ctan{TikZ} layer. + + \option[]{tikz}[TikZ commands] + + The \option{tikz} option passes \ctan{TikZ} keys to the underlying + \keyword{tikzpicture} environment. The \option{tikz} option is almost + the same as using a \keyword{\tikzset{...}} command before the + \keyword{wordle} environment except that it is applied to the + \keyword{tikpicture} environment, which contains the \keyword{wordle} + puzzle, such that the \option{tikz} keys are applied \textit{after} + all of options above and \textit{before} \option{tile style} is + applied. + + \begin{example} + % \usetikzlibrary{backgrounds} + \begin{wordle}[ + tikz={framed, + background rectangle/.style={ + double,ultra thick, draw=SteelBlue + } + }]{youth} + North South youth + \end{wordle} + \end{example} + + As this example indicates, it is advisable to enclose complicated + \ctan{TikZ} settings inside braces. + + \option[W]{name} + + All of the tiles in a \keyword{wordle} puzzle are given node names of + the form $\langle$\textsf{name}$\rangle$-$\mathsf{r}$-$\mathsf{c}$, + for the tile in row~$\mathsf{r}$ and column~$\mathsf{c}$. By default, + the prefix \textsf{name} is \texttt{W}. Within reason, the + \option{name} prefix can be changed to anything you like using the + \option{name} option. + + One way to use the named nodes for the letter tiles is with + \ctan{TikZ} \texttt{overlay} and \texttt{remember picture} keys: + + \begin{example} + \begin{wordle}[tikz={remember picture}]{CRAZE} + TRACE + CREAM + CRAZE + \end{wordle} + \end{example} + + This makes it possible, for example, to draw arrows to tiles in a + \keyword{wordle} puzzle: + + \begin{example} + \tikz[remember picture]\draw[overlay, very thick, opacity=0.5,->,red](0,0)node{No M!} to [out=90, in=180](W-2-5); + \end{example} + + A second use of the tile node names is in conjunction with \ctan{TikZ} + commands that can be added to a \keyword{wordle} puzzle using the + second optional argument to the environment. As with the \option{tikz} + option, it is advisable to enclose complicated \ctan{TikZ} commands + inside braces. + + \begin{example} + \begin{wordle}[name=M, + tikz={arr/.style={Red,ultra thick,->}} + ]{MACAW} + [{ + \draw[arr](M-1-3.south)--(M-3-2.north)--(M-4-2.north); + \draw[arr](M-1-1.south)--(M-3-5)--(M-4-3.north east); + }] + CRANE HOTLY BASIC MACAW + \end{wordle} + \end{example} + + In practice, we are not convinced that anyone will find a real use for this! + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + \Section{The package code} + + The \keyword{wordle} package is a \LaTeX3 package. There are many + comments in the code explaining how the code works. The automatic + colouring of the letter tiles is a fun exercise in \LaTeX3 + programming, which was motivated by a + \href{https://tex.stackexchange.com/questions/659860/wordle-like-colored-letter-boxes-in-latex/660056#660056}{tex.stackexchange.com} post. + + Bug reports and feature requests can be made on \href{https://github.com/AndrewMathas/Wordle}{github}. + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + \printindex + +\end{document} diff --git a/Master/texmf-dist/doc/latex/wordle/wordle-doc-fr.pdf b/Master/texmf-dist/doc/latex/wordle/wordle-doc-fr.pdf Binary files differindex 3277ca9a99c..09d306b0f30 100644 --- a/Master/texmf-dist/doc/latex/wordle/wordle-doc-fr.pdf +++ b/Master/texmf-dist/doc/latex/wordle/wordle-doc-fr.pdf diff --git a/Master/texmf-dist/doc/latex/wordle/wordle-doc-fr.tex b/Master/texmf-dist/doc/latex/wordle/wordle-doc-fr.tex index f365cbb4598..039bc7a1583 100644 --- a/Master/texmf-dist/doc/latex/wordle/wordle-doc-fr.tex +++ b/Master/texmf-dist/doc/latex/wordle/wordle-doc-fr.tex @@ -1,422 +1,767 @@ -% !TeX TXS-program:compile = txs:///arara -% arara: pdflatex: {shell: yes, synctex: no, interaction: batchmode} -% arara: pdflatex: {shell: yes, synctex: no, interaction: batchmode} if found('log', '(undefined references|Please rerun|Rerun to get)') - -\documentclass[french,a4paper,11pt]{article} -\usepackage[margin=2cm,includefoot]{geometry} -\def\TPversion{0.1.1} -\def\TPdate{3 septembre 2023} -\usepackage{amssymb,amsfonts,amsmath} +% !TeX TS-program = pdflatex + +\documentclass[svgnames]{report} \usepackage[utf8]{inputenc} -%\usepackage[T1]{fontenc} \usepackage{wordle} -\usepackage{awesomebox} -\usepackage{fontawesome5} -\usepackage{footnote} -\makesavenoteenv{tabular} +\usepackage{manfnt} \usepackage{enumitem} -\usepackage{tabularray} -\usepackage{fancyvrb} -\usepackage{fancyhdr} -\fancyhf{} -\renewcommand{\headrulewidth}{0pt} -\lfoot{\sffamily\small [wordle]} -\cfoot{\sffamily\small - \thepage{} -} -\rfoot{\hyperlink{matoc}{\small\faArrowAltCircleUp[regular]}} - -%\usepackage{hvlogos} -\usepackage{hologo} -\providecommand\tikzlogo{Ti\textit{k}Z} -\providecommand\TeXLive{\TeX{}Live\xspace} -\providecommand\PSTricks{\textsf{PSTricks}\xspace} -\let\pstricks\PSTricks -\let\TikZ\tikzlogo -\newcommand\TableauDocumentation{% - \begin{tblr}{width=\linewidth,colspec={X[c]X[c]X[c]X[c]X[c]X[c]},cells={font=\sffamily}} - {\LARGE \LaTeX} & & & & &\\ - & {\LARGE \hologo{pdfLaTeX}} & & & & \\ - & & {\LARGE \hologo{LuaLaTeX}} & & & \\ - & & & {\LARGE \TikZ} & & \\ - & & & & {\LARGE \TeXLive} & \\ - & & & & & {\LARGE \hologo{MiKTeX}} \\ - \end{tblr} +\setlist[description]{font=\sffamily\bfseries\color{ForestGreen},labelwidth=\textwidth} +\usepackage{booktabs} +\usepackage[a4paper,margin=18mm]{geometry} +\synctex=1 +\parindent=0pt +\parskip=2mm + +\usepackage{cmap} % fix search and cut-and-paste in Acrobat +\setcounter{secnumdepth}{0} + +\usepackage{listings}\lstset{language=[LaTeX]TeX,framerule=2pt} +\lstset{language=[LaTeX]TeX, + texcsstyle=*\bfseries\color{Peru}, + backgroundcolor=\color{Ivory}, + numbers=none, + breaklines=true, + keywordstyle=\color{Sienna}, + commentstyle=\color{BurlyWood}, + tabsize=2, + morekeywords={Wordle,wordle,GrilleSutom}, + resetmargins=true, } - -\usepackage{hyperref} -\urlstyle{same} -\hypersetup{pdfborder=0 0 0} -\setlength{\parindent}{0pt} -\definecolor{LightGray}{gray}{0.9} - -\usepackage{babel} -\AddThinSpaceBeforeFootnotes -\FrenchFootnotes - -\usepackage{listings} - -\usepackage{newverbs} -\newverbcommand{\motcletex}{\color{cyan!75!black}}{} -\newverbcommand{\packagetex}{\color{violet!75!black}}{} - -\usepackage[most]{tcolorbox} -\tcbuselibrary{listingsutf8} -\newtcblisting{DemoCode}[1][]{% - enhanced,width=0.95\linewidth,center,% - bicolor,size=title,% - colback=cyan!2!white,% - colbacklower=cyan!1!white,% - colframe=cyan!75!black,% - listing options={% - breaklines=true,% - breakatwhitespace=true,% - style=tcblatex,basicstyle=\small\ttfamily,% - tabsize=4,% - commentstyle={\itshape\color{gray}}, - keywordstyle={\color{blue}},% - classoffset=0,% - keywords={},% - alsoletter={-},% - keywordstyle={\color{blue}},% - classoffset=1,% - alsoletter={-},% - morekeywords={center,justify},% - keywordstyle={\color{violet}},% - classoffset=2,% - alsoletter={-},% - morekeywords={GrilleSutom},% - keywordstyle={\color{green!50!black}},% - classoffset=3,% - morekeywords={Couleurs,Arrondi,Unite,Police,CouleurLettres,Lettres,Style,Epaisseur,CouleurBordure},% - keywordstyle={\color{orange}} - },% - #1 +% hyperref links to ctan +\newcommand\ctan[1]{\href{https://www.ctan.org/pkg/#1}{\texttt{#1}}} + +\newcommand\Section[1]{\subsection{\textcolor{DarkGreen}{#1}}} + +\ExplSyntaxOn +\NewDocumentCommand\option{ omo }{% + \IfNoValueTF{#1}{\textsf{#2}} + {% + \textbf{\textcolor{Crimson}{#2}} + \str_if_empty:nF {#1}{~(défaut~:~\textcolor{DarkRed}{#1})}% + \IfNoValueF{#3}{\hfill\textcolor{Gray}{[accepte~:~#3]}}% + }% + \index{#2}% +} +\ExplSyntaxOff + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\usepackage{imakeidx} +\indexsetup{level=\section*, toclevel=section, noclearpage} +\makeindex[intoc,columns=3] + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\usepackage[skins,listings]{tcolorbox} +\usetikzlibrary{backgrounds, shapes.geometric} % for tikz={framed,...} + +\DeclareTotalTCBox\keyword{ O{} v }{ + fontupper=\sffamily, + nobeforeafter, + skin=tile, + verbatim, + on line, + tcbox raise base, + top=0pt,bottom=0pt,left=0mm,right=0mm, + colback=OldLace, + colupper=ForestGreen, + #1} +{#2} + +\lstdefinestyle{tikz}{style=tcblatex, + classoffset=0, + texcsstyle=*\color{DarkGoldenrod},% + deletetexcs={begin, end}, + moretexcs={,% + node, + draw, + true, + false + },% + classoffset=1, + keywordstyle=\color{ForestGreen},% + morekeywords={wordle,GrilleSutom}, + classoffset=2, + keywordstyle=\color{Crimson},% + morekeywords={ + absent, + Strict, + Taille, + Lignes, + Epaisseur, + align, + border, + borders, + Bords, + Cadres, + Style, + Formes, + Separation, + case, + Police, + Arrondi, + Echelle, + NonLettres, + color, + Couleurs, + CouleurBordures, + CouleurLettres, + bordure, + couleur, + colours, + correct, + vide, + font, + frame, + frames, + letters, + lower, + params, + name, + natural, + noalign, + noletters, + present, + rounded, + rows, + scale, + sensitive, + separation, + shape, + shapes, + size, + strict, + style, + style, + text, + thickness, + tikz, + tile, + upper, + }, + classoffset=3, + keywordstyle=\color{DarkOrange},% + morekeywords={ + hard, + standard, + sutom, + } } -\tcbset{vignettes/.style={% - nobeforeafter,box align=base,boxsep=0pt,enhanced,sharp corners=all,rounded corners=southeast,% - boxrule=0.75pt,left=7pt,right=1pt,top=0pt,bottom=0.25pt,% - } +\DeclareTCBListing{example}{ !O{} }{% + skin=bicolor, + colframe=MediumSeaGreen, + colbacklower=OldLace, + colback=LawnGreen!20, + lefthand width=50mm, + listing style=tikz, + sidebyside, + sidebyside align=center, + sidebyside gap=4mm, + text and listing, + text outside listing, + boxsep = 0pt, + #1 } -\tcbset{vignetteMaJ/.style={% - fontupper={\vphantom{pf}\footnotesize\ttfamily}, - vignettes,colframe=purple!50!black,coltitle=white,colback=purple!10,% - overlay={\begin{tcbclipinterior}% - \fill[fill=purple!75]($(interior.south west)$) rectangle node[rotate=90]{\tiny \sffamily{\textcolor{black}{\scalebox{0.66}[0.66]{\textbf{MàJ}}}}} ($(interior.north west)+(5pt,0pt)$);% - \end{tcbclipinterior}} - } +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +\makeatletter +\author{Andrew Mathas \&\ Cédric Pierquet} +\usepackage{tikz} +\usetikzlibrary{shadows.blur} +\tikzset{shadowed/.style={blur shadow={shadow blur steps=5}, + bottom color=ForestGreen!30, + draw=MediumSeaGreen!70, + shade, + font=\normalfont\Huge\bfseries\scshape, + rounded corners=8pt, + top color=SeaGreen, + }, + boxes/.style={draw=SeaGreen, + fill=Cornsilk, + font=\sffamily\small, + inner sep=5pt, + rectangle, + rounded corners=8pt, + text=DarkGreen, + } +} +\newcommand\Wordle{% + \begin{tikzpicture}[remember picture,overlay] + \node[yshift=-3cm] at (current page.north west) + {\begin{tikzpicture}[remember picture, overlay] + \draw[shadowed](30mm,0) rectangle node[white]{wordle} (\paperwidth-30mm,16mm); + \node[anchor=west,boxes] at (4cm,0cm) {\@author}; + \node[anchor=east,boxes] at (\paperwidth-4cm,0) {Version \wordle@version}; + \end{tikzpicture} + }; + \end{tikzpicture} + \vspace*{20mm} } -\newcommand\Cle[1]{{\small\sffamily\textlangle \textcolor{orange}{#1}\textrangle}} -\newcommand\cmaj[1]{\tcbox[vignetteMaJ]{#1}\xspace} +\def\@oddfoot{\textsc{Wordle} --- \wordle@version~(version~du~\wordle@release)\hfill\thepage} + +\usepackage[colorlinks=true,linkcolor=blue,urlcolor=MediumBlue]{hyperref} +\hypersetup{ + pdfcreator={ Generated by pdfLaTeX }, + pdfinfo={ + Author ={ Andrew Mathas et Cédric Pierquet }, + Keywords={ wordle }, + License ={ LaTeX Project Public License v1.3c or later }, + Subject ={ LaTeXing Wordle puzzles }, + Title ={ Wordle - \wordle@version } + }, +} +\makeatother \begin{document} -\setlength{\aweboxleftmargin}{0.07\linewidth} -\setlength{\aweboxcontentwidth}{0.93\linewidth} -\setlength{\aweboxvskip}{8pt} - -\pagestyle{fancy} - -\thispagestyle{empty} - -\vspace{2cm} - -\begin{center} - \begin{minipage}{0.75\linewidth} - \begin{tcolorbox}[colframe=yellow,colback=yellow!15] - \begin{center} - \begin{tabular}{c} - {\Huge \texttt{wordle} [fr]}\\ - \\ - {\LARGE Des grilles de Wordle (Sutom),} \\ - \\ - {\LARGE avec \textsf{Ti\textit{k}Z}.} \\ - \end{tabular} - - \bigskip - - {\small \texttt{Version \TPversion{} -- \TPdate}} - \end{center} - \end{tcolorbox} -\end{minipage} -\end{center} - -\begin{center} - \begin{tabular}{c} - \texttt{Cédric Pierquet}\\ - {\ttfamily c pierquet -- at -- outlook . fr}\\ - \texttt{\url{https://github.com/cpierquet/wordle}} -\end{tabular} -\end{center} - -\vspace{0.25cm} - -{$\blacktriangleright$~~Créer des grilles de Wordle/Sutom\footnotemark\footnotetext{\url{https://fr.wikipedia.org/wiki/Wordle}}.} - -\vspace{0.25cm} - -{$\blacktriangleright$~~Gestion des couleurs, de la taille\footnotemark\footnotetext{Idées venant de \url{ttps://tex.stackexchange.com/questions/659860/wordle-like-colored-letter-boxes-in-latex}}. - -\vspace{1cm} - -\begin{center} -\begin{GrilleSutom}{LUCIOLE} - LAPINES - LUMIERE - LOURDES - LUCIOLE -\end{GrilleSutom} -\end{center} - -\medskip - -\begin{center} -\begin{GrilleSutom}[Arrondi=0,Couleurs={lightgray,orange,teal},Style=alt,Unite=0.5,Lettres=false]{REBUS} - ABRIS - ROUTE - RUDES - REBUS -\end{GrilleSutom} -% -\hspace{5mm} -% -\begin{GrilleSutom}[Arrondi=0,Couleurs={lightgray,orange,teal},Style=alt,Unite=0.5]{REBUS} - ABRIS - ROUTE - RUDES - REBUS -\end{GrilleSutom} -\end{center} - -\vspace{0.5cm} - -%\hfill{}\textit{Merci à Denis Bitouzé et à Gilles Le Bourhis pour leurs retours et idées !} - -\smallskip - -\vfill - -\hrule - -\medskip + \Wordle + + Ce package fournit un moyen \textit{stupidement} riche en fonctionnalités de créer des puzzles \keyword{Wordle} en \LaTeX, que \href{https://en.wikipedia.org/wiki/Wordle}{Wikipedia} décrit comme + comme un jeu de lettres en ligne extrêmement populaire, créé et développé par l'ingénieur logiciel gallois Josh Wardle. Ce paquet + est une version améliorée d'une des solutions à une question posée par \textcolor{FireBrick}{valerio\_new} sur \href{https://tex.stackexchange.com/questions/659860/wordle-like-colored-letter-boxes-in-latex/660056#660056}{tex.stackexchange.com}. + + Ce paquet fournit l'environnement \keyword{GrilleSutom}, qui utilise la syntaxe : + + \begin{tcblisting}{ + listing only, + skin=bicolor, + colframe=MediumSeaGreen, + colbacklower=OldLace, + colback=LawnGreen!20, + listing style=tikz, + boxsep = 0pt, + } + % \usepackage{wordle} + \begin{GrilleSutom}[params sutom]{solution}[commandes tikz optionnelles] + essai1 essai2 ... + \end{GrilleSutom} + \end{tcblisting} + \index{environnement!GrilleSutom} + \index{GrilleSutom} + \index{sutom} + + et l'environnement \keyword{wordle}, pour la version anglaise du jeu : + + \begin{tcblisting}{ + listing only, + skin=bicolor, + colframe=MediumSeaGreen, + colbacklower=OldLace, + colback=LawnGreen!20, + listing style=tikz, + boxsep = 0pt, + } + % \usepackage{wordle} + \begin{wordle}[params wordle]{solution}[commandes tikz optionnelles] + essai1 essai2 ... + \end{wordle} + \end{tcblisting} + \index{environnement!wordle} + \index{wordle} + + Les mots du puzzle peuvent être saisis sur une seule ligne ou sur des lignes séparées. Voici quelques exemples : + + \begin{example} + %Version fr du wordle (sutom) + \begin{GrilleSutom}{REBUS} + ABRIS + ROUTE + REBUS + \end{GrilleSutom} + \end{example} + + \begin{example} + % Version en du sutom (wordle) + \begin{wordle}{SUTOM} + SAUCE + SAUTS + SUTOM + \end{wordle} + \end{example} + + Comme pour les puzzles en ligne, l'environnement \keyword{GrilleSutom} + colore automatiquement les lettres en + \keyword[colback=WordleSutomCorrect,colupper=White]{rouge} + lorsque la lettre se trouve dans la même position que la solution, et en + \keyword[colback=WordlePresent,colupper=White]{or} lorsque la lettre est dans la solution mais qu'elle n'est pas bien placée. + De même, \keyword{GrilleSutom} colore les lettres correctes en + \keyword[colback=WordleCorrect,colupper=White]{vert} + et les lettres actuelles en + \keyword[colback=WordleCorrect,colupper=White]{or}. + Comme décrites ci-dessous, ces couleurs peuvent être modifiées en fonction de vos goûts. + + Le nombre de lettres du puzzle est déterminé par la solution, et n'est limité que par la largeur de la page. + + \begin{example} + \begin{GrilleSutom}[Lignes=4]{orange} + normal + ordres + orange + \end{GrilleSutom} + \end{example} + + Les lettres du puzzle peuvent être saisies en majuscules, en minuscules ou en mélange de majuscules et de minuscules. Par défaut, la casse des lettres est ignorée lors de la détermination des couleurs des cases de lettres. + + Comme décrit ci-dessous, les environnements \keyword{wordle} et \keyword{GrilleSutom} acceptent une liste d'options différentes qui modifient les couleurs, les polices et les formes de la tuile. De plus, vous pouvez modifier la sensibilité à la casse des environnements, ajouter des lignes supplémentaires au puzzle, désactiver la mise en forme spéciale des \textit{cases de lettres}. Ces options sont données sous la forme d'une liste séparée par des virgules de paires \texttt{clé-valeur}. Elles peuvent être définies localement, en utilisant l'argument optionnel de l'environnement \keyword|wordle|, ou globalement (plus précisément, dans le groupe \LaTeX\ actuel) en utilisant la commande \keyword{\ParamsSutom} \index{\textbackslash ParamsSutom}, ou comme options globales du package, via \keyword{\usepackage[options]{wordle}}. L'ordre des options n'a pas d'importance, sauf que les options ultérieures ont priorité sur les options précédentes, à l'exception des clés \option{tikz} et \option{tile style} qui sont toujours appliquées en dernier. + + Les puzzles \keyword{wordle} sont dessinés à l'aide de \ctan{TikZ}, chaque lettre du puzzle étant placée à l'intérieur d'un nœud \ctan{TikZ}. De nombreuses options contrôlent les paramètres de ces nœuds. Les descriptions des options ci-dessous sont regroupées en fonction de leur fonction. + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + \Section{Styles Wordle} + + La clé \option{Style} peut être utilisée pour modifier de nombreuses caractéristiques des cases dans un puzzle \keyword{wordle}, y compris leurs couleurs, les polices et ainsi de suite. Les paramètres les plus courants peuvent être définis à l'aide du mot-clé \option{style}. \textit{Le style doit toujours être défini en premier car, sinon, les paramètres de style peuvent remplacer les paramètres précédents.} + + Les styles suivants sont pris en charge : + + \textcolor{DarkOrange}{sutom} + \index{Style!sutom} + \index{sutom} + + \begin{example} + \begin{GrilleSutom}[Style=sutom]{REBUS} + ABRIS + ROUTE + REBUS + \end{GrilleSutom} + \end{example} + + En plus de définir les couleurs des cases, les cadres et les formes, le style \textsf{sutom} définit également la taille des cases à 8 mm. Le style \textsf{sutom} est le style par défaut pour l'environnement \keyword{GrilleSutom}. + + \textcolor{DarkOrange}{standard} + \index{style!standard} + + \begin{example} + \begin{GrilleSutom}[Style=standard]{REBUS} + ABRIS + ROUTE + REBUS + \end{GrilleSutom} + \end{example} + + Le style \textcolor{DarkOrange}{standard} est le style par défaut pour l'environnement \keyword{wordle}. + + \textcolor{DarkOrange}{hard} + \index{style!hard} + + \begin{example} + \begin{GrilleSutom}[Style=hard]{REBUS} + ABRIS + ROUTE + REBUS + \end{GrilleSutom} + \end{example} + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + \Section{Options pour les styles individuels des cases de lettres} + + Il existe quatre types de cases de lettres dans \keyword{wordle} : + \option{absent}, \option{present}, \option{correct} et + \option{vide}, correspondant respectivement aux lettres qui ne sont pas dans la solution, + aux lettres mal placées, aux lettres correctement placées et aux cases vides. Les options de cette section peuvent être utilisées pour + définir les couleurs du texte, des cases et des bordures, les formes et les cadres de ces cases. + + Les cases de lettres dans un environnement \keyword{wordle} sont composées à l'intérieur + d'un \keyword{\node} \ctan{TikZ}. Les options ci-dessous contrôlent les + différents paramètres de style de ces nœuds. + + \option[--]{Couleurs}[liste de couleurs valides séparées par des virgules] + + L'option \option{Couleurs} est un raccourci pour spécifier les + couleurs des cases \option{absent}, \option{present}, \option{correct} et + \option{vide}, dans cet ordre. Les couleurs suivantes peuvent être omises, mais + les couleurs doivent être données dans cet ordre, de gauche à droite. + Si une seule couleur est donnée, cette couleur est appliquée à toutes les cases. + + \begin{example} + \begin{GrilleSutom}[Couleurs={LightGray,Orange,Teal}]{cellar} + pounds + taylor + cellar + \end{GrilleSutom} + \end{example} + + Les couleurs peuvent également être définies individuellement à l'aide de \option{couleur absent}, \option{couleur present}, \option{couleur correct} et \option{couleur vide}. + + \begin{example} + \begin{GrilleSutom}[couleur absent=DarkGray,couleur present=Salmon, + couleur correct=SeaGreen]{cellar} + pounds + taylor + cellar + \end{GrilleSutom} + \end{example} + + \option[white]{CouleurBordures}[liste de couleurs valides séparées par des virgules] + + de manière similaire à l'option \option{Couleurs}, il s'agit d'un raccourci pour le paramétrage des couleurs des bordures des cases \option{absent}, \option{present}, + \option{correct} et \option{vide}, dans cet ordre. + + Si une seule couleur est donnée, elle est appliquée à toutes les cases. -\TableauDocumentation + \begin{example} + \begin{GrilleSutom}[CouleurBordures={red,orange,blue}]{REBUS} + ABRIS + ROUTE + REBUS + \end{GrilleSutom} + \end{example} + + Les bordures pour les cases individuelles peuvent être paramétrer via + \option{bordure absent}, \option{bordure present}, \option{bordure correct} et \option{bordure vide}. + + \option[false]{Cadres}[liste de booléens true/false séparées par des virgules] + + Il s'agit d'un raccourci pour ajouter un cadre autour des cases \option{absent}, \option{present}, \option{correct} et \option{vide}, dans cet ordre, avec la même couleur que \option{absent}. C'est utile uniquement pour les cases non carrée. + + \begin{example} + \begin{GrilleSutom}[Cadres={false,true,true},Formes=circle]{REBUS} + ABRIS + ROUTE + REBUS + \end{GrilleSutom} + \end{example} + + Les cadres pour les cases individuelles peuvent être paramétrer via \option{cadre absent}, \option{cadre present}, + \option{cadre correct} and \option{cadre vide}. + + \option[rectangle]{Formes}[liste de formes TikZ séparées par des virgules] + + De même que pour l'option \option{Couleurs}, c'est un raccourci pour paramétrer les formes des cases \option{absent}, \option{present}, + \option{correct} et \option{vide}, dans cet ordre. + + \begin{example} + \begin{GrilleSutom}[Formes={circle, rectangle, circle}]{REBUS} + ABRIS + ROUTE + REBUS + \end{GrilleSutom} + \end{example} + + Les formes individuelles peuvent être paramétrer via \option{forme absent}, \option{forme present}, + \option{forme correct} et \option{forme vide}. + + Les formes proposés par le package \ctan{TikZ} + \texttt{shapes.geometric}, incluant \texttt{diamond}, + \texttt{ellipse}, \texttt{trapezium} et \texttt{star} (voir section~71.2 du manuel \ctan{TikZ}). + + \begin{example} + % \usepackage{shapes.geometric} + \begin{GrilleSutom}[Formes={diamond,ellipse,star}]{LADLE} + FLAIL + LAPEL + * + LADLE + LOVER + \end{GrilleSutom} + \end{example} + + \option[white]{CouleurLettres}[liste de couleurs valides séparées par des virgules] + + Il s'agir d'un raccourci pour paramétrer la couleur des lettres des cases \option{absent}, \option{present}, \option{correct} et \option{vide}, dans cet ordre. + + \begin{example} + \begin{GrilleSutom}[CouleurLettres={red,orange,blue}]{REBUS} + ABRIS + ROUTE + REBUS + \end{GrilleSutom} + \end{example} + + Les cases individuelles peuvent être paramétrer via \option{coultxt absent}, \option{coultxt present}, \option{coultxt correct} et \option{coultxt vide}. + + + \Section{Caractéristiques communes des cases} + + Les options suivantes s'appliquent à toutes les cases. + + \option[]{nonalign} (default) \qquad + \option[]{align} -\medskip + Cette option s'occupe de l'alignement vertical des lettres. C'est utile essentiellement lors de l'utilisation de minuscules. -\hrule + \begin{example} + \begin{GrilleSutom}[align]{agony} + groan + angry + agony + \end{GrilleSutom} + \end{example} -\vspace*{1cm} - -\newpage - -\phantomsection -\hypertarget{matoc}{} - -\tableofcontents - -\vfill - -\section{Historique} - -\verb|v0.1.0|~:~~~~Correction d'un bug avec la version anglaise. - -\verb|v0.1.0|~:~~~~Version initiale. - -\newpage - -\section{Le package wordle} - -\subsection{Le principe du jeu} - -\begin{noteblock} -Wordle est un jeu de lettres en ligne gratuit développé en 2021 par Josh Wardle. Ce jeu est une adaptation directe du jeu télévisé américain Lingo (Motus en France) qui propose de faire deviner un mot par plusieurs tentatives, en indiquant pour chacune d'entre-elles la position des lettres bien placées et mal placées. - -Le but du jeu est de deviner un mot spécifique de cinq lettres en un maximum de six tentatives, en tapant des lettres sur un écran de six lignes de cinq cases chacune. La personne qui joue inscrit sur la première ligne un mot de cinq lettres de son choix et entre sa proposition. Après chaque proposition, les lettres apparaissent en couleurs : le fond gris représente les lettres qui ne se trouvent pas dans le mot recherché, le fond jaune représente les lettres qui se trouvent ailleurs dans le mot, et le fond vert représente les lettres qui se trouvent à la bonne place dans le mot à trouver. - -\smallskip - -\hfill{\scriptsize \url{https://fr.wikipedia.org/wiki/Wordle}} -\end{noteblock} - -\subsection{Le package} - -\begin{noteblock} -Le package propose de quoi afficher, dans son document \LaTeX, une grille de Wordle (ou de Sutom) à l'aide de \TikZ{} et d'une \motcletex!minipage!, avec la possibilité : - -\begin{itemize} - \item de spécifier les dimensions, la couleur ; - \item de choisir le style des lettres mal placées ; - \item de personnaliser les bordure et les coins ; - \item d'afficher ou non les lettres. -\end{itemize} - -Contrairement au jeu \og initial \fg, il est possible de travailler avec des mots de longueur différente de 5 ! -\end{noteblock} - -\begin{importantblock} -Une bonne partie du code, en \hologo{LaTeX3}, est issu d'un fil sur \texttt{tex.stackexchange}, et proposé par l'internaute \textsf{3141592653589793238}. -\end{importantblock} - -\subsection{Chargement du package, packages utilisés} - -\begin{importantblock} -Le package se charge, de manière classique, dans le préambule. - -Il n'existe pas d'option pour le package, et \packagetex!xcolor! n'est pas chargé. -\end{importantblock} - -\begin{DemoCode}[listing only] -\documentclass{article} -\usepackage{wordle} + \begin{example} + \begin{GrilleSutom}{agony} % nonalign par defaut + groan + angry + agony + \end{GrilleSutom} + \end{example} + + \option[\textbackslash Large\textbackslash bfseries\textbackslash sffamily]{Police} + [Police \LaTeX] -\end{DemoCode} - -\begin{noteblock} -\packagetex!wordle! charge les packages suivants : - -\begin{itemize} - \item \packagetex!tikz!; - \item \packagetex!simplekv! ; - \item \packagetex!xstring!. -\end{itemize} - -Il est compatible avec les compilations usuelles en \textsf{latex}, \textsf{pdflatex}, \textsf{lualatex} ou \textsf{xelatex}. -\end{noteblock} - -\vfill~ - -\pagebreak - -\section{Environnement GrilleSutom} - -\subsection{Fonctionnement global} - -\begin{cautionblock} -L'environnement dédié à la création de la grille du Sutom est \packagetex!GrilleSutom!. - -Il fonctionne avec un système de clés, entre \texttt{[...]}, et nécessite de préciser : - -\begin{itemize} - \item le bon mot ; - \item les différentes propositions. -\end{itemize} - -Le code se charge de mettre en forme (grâce à une \motcletex!minipage!) la grille et les différentes couleurs d'aide. -\end{cautionblock} - -\begin{DemoCode}[listing only] -\begin{GrilleSutom}[clés]{mot à trouver} - proposition n°1 - proposition n°2 - proposition n°3 -\end{GrilleSutom} -\end{DemoCode} - -\begin{noteblock} -Comme indiqué dans l'introduction, la grille est créée à l'aide d'un environnement \motcletex!minipage!, avec gestion automatique de la largeur et des espacements. -\end{noteblock} - -\begin{DemoCode}[] -%sortie par défaut -\begin{GrilleSutom}{SUTOM} - SAUCE - SAUTS - SUTOM -\end{GrilleSutom} -\end{DemoCode} - -\subsection{Clés et options} - -\begin{tipblock} -Le premier argument, optionnel et entre \texttt{[...]}, propose les \Cle{clés} suivantes : - -\begin{itemize} - \item \Cle{Couleurs} : = couleur des cases, sous la forme \Cle{fond,mal placée,bien placée} ; - - \hfill{}défaut : \Cle{cyan!75!black,yellow,red},% - \item \Cle{Arrondi} := arrondi des coins, en mm ; \hfill{}défaut : \Cle{0.1} - \item \Cle{Unite} := largeur des cases, en cm ; \hfill{}défaut : \Cle{1} - \item \Cle{Police} := police des lettres ; \hfill{}défaut : \Cle{\textbackslash LARGE\textbackslash bfseries\textbackslash sffamily} - \item \Cle{CouleurLettres} := couleur des lettres ; \hfill{}défaut : \Cle{white} - \item \Cle{CouleurBordure} := couleur de la bordure des cases ; \hfill{}défaut : \Cle{white} - \item \Cle{Lettres} := booléen pour afficher les lettre ; \hfill{}défaut : \Cle{true} - \item \Cle{Style} := style parmi \Cle{rond / autre} pour changer le style ; \hfill{}défaut : \Cle{rond} - \item \Cle{Epaisseur} := épaisseur des traits, en mm. \hfill{}défaut : \Cle{0.25} -\end{itemize} -\vspace*{-\baselineskip}\leavevmode -\end{tipblock} - -\begin{tipblock} -Le second argument, obligatoire et entre \texttt{\{...\}} correspond au mot correct à trouver. - -\smallskip - -Les différentes propositions sont à donner (ligne par ligne ou séparées par des espaces) dans le corps de l'environnement. -\end{tipblock} - -\subsection{Exemples} - -\begin{DemoCode}[] -\begin{GrilleSutom}{BOURDON} - BALEINE - BOURBON - BROMURE - BOURDON -\end{GrilleSutom} -% -\hspace{5mm} -% -\begin{GrilleSutom}[Style=alt]{BOURDON} - BALEINE BOURBON BROMURE BOURDON -\end{GrilleSutom} -\end{DemoCode} - -\begin{DemoCode}[] -\begin{GrilleSutom} - [Style=alt,Epaisseur=0.3,CouleurBordure=black,% - Couleurs={lightgray,orange,teal}]% - {BOURDON} - BALEINE BOURBON BROMURE BOURDON -\end{GrilleSutom} -% -\hspace{5mm} -% -\begin{GrilleSutom} - [Arrondi=0,Epaisseur=0.3,CouleurBordure=black,% - Couleurs={lightgray,orange,teal}]% - {BOURDON} - BALEINE BOURBON BROMURE BOURDON -\end{GrilleSutom} -\end{DemoCode} - -\begin{DemoCode}[] -\begin{GrilleSutom}[Unite=2,Police=\Huge\ttfamily,CouleurLettres=black]{BOURDON} - BALEINE - BOURBON - BROMURE - BOURDON -\end{GrilleSutom} -\end{DemoCode} - -\begin{DemoCode}[] -\begin{GrilleSutom}% - [Unite=0.75,Arrondi=0,Couleurs={cyan,orange,violet},% - Style=alt,Lettres=false]{REBUS} - ABRIS - ROUTE - RUDES - REBUS -\end{GrilleSutom} -\hspace{5mm} -\begin{GrilleSutom}% - [Unite=0.75,Arrondi=0,Couleurs={cyan,orange,violet},Style=alt]{REBUS} - ABRIS - ROUTE - RUDES - REBUS -\end{GrilleSutom} -\end{DemoCode} - -\end{document}
\ No newline at end of file + Cela permet de paramétrer la police de toutes les lettres. Toute commande valide est acceptée. + + \begin{example} + \begin{GrilleSutom}[Police=\large\ttfamily]{REBUS} + ABRIS + ROUTE + REBUS + \end{GrilleSutom} + \end{example} + + \option[1mm]{Arrondi}[une longueur] + + Cela permet de paramétrer le paramètres \texttt{rounded corners} (de TikZ) pour les cases \keyword{wordle}. + + \begin{example} + \begin{GrilleSutom}[Arrondi=2.5mm]{REBUS} + ABRIS + ROUTE + REBUS + \end{GrilleSutom} + \end{example} + + \option[0.5mm]{Separation}[une longueur] + + Cela permet de paramétrer la séparation entre les cases du \keyword{wordle}. + + \begin{example} + \begin{GrilleSutom}[Separation=2mm,CouleurBordures=black]{REBUS} + ABRIS + ROUTE + REBUS + \end{GrilleSutom} + \end{example} + + \option[1]{Echelle}[un nombre] + + L'option \option{Echelle} applique un facteur à l'environnement \keyword{wordle}. + Cette option modifie les dimensions définies par les options \option{Arrondi}, + \option{Separation}, \option{Taille} et \option{Epaisseur}. Si vous changez l'échelle, vous voudrez également changer la police de caractères via \option{Police} : + + \begin{example} + \begin{GrilleSutom}[Echelle=1.5,Police=\huge\bfseries]{SIZE} + HELP + WISE + SIZE + \end{GrilleSutom} + \end{example} + + \option[8mm]{Taille}[une longueur] + + L'option \option{Taille} définit la taille des cases. Contrairement à l'option \option{Echelle}, \option{Taille} change uniquement la dimension des cases. + + \begin{example} + \begin{GrilleSutom}[Taille=10mm,Police=\huge\bfseries]{REPU} + ABRI ROUE * REPU + \end{GrilleSutom} + \end{example} + + \option[0.25mm]{Epaisseur}[une longueur]• + + Cela permet de paramétrer la taille des bordures des cases. Par défaut la couleur est blanche, donc pour illustrer cette option elle sera paramétrer en rouge. + + \begin{example} + \begin{GrilleSutom}[Epaisseur=0.75mm,CouleurBordures=red]{LADLE} + FLAIL + LAPEL + LADLE + \end{GrilleSutom} + \end{example} + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + \Section{Lignes et colonnes supplémentaires} + + Par défaut, le nombre de lignes et de colonnes de la grille est fixée par les mots donnés. + + \option[]{Lettres} (défaut)\qquad + \option[]{NonLettres} + + Par dafut, les lettres sont affichées, mais l'option \option{NonLettres} peuvent être cachées. + + \begin{example} + \begin{GrilleSutom}{CRAZE} % the default + TRACE + CREAM + CRAZE + \end{GrilleSutom} + \end{example} + + \begin{example} + \begin{GrilleSutom}[NonLettres]{CRAZE} + TRACE + CREAM + CRAZE + \end{GrilleSutom} + \end{example} + + \option[false]{Strict}[true/false/--] + + Par défaut, l'environnement ne vérifie pas si tous les mots sont la même taille, donc les lettres \textit{en trop} n'ont pas de style particulier. + + \begin{example} + \begin{GrilleSutom}[Strict=false]{CRAZE} % par defaut + GRAIL + CRAMPS + CRAM + CRABS + \end{GrilleSutom} + \end{example} + + L'option booléenne \option{Strict} force un style particulier des lettre \textit{en trop}. + + \begin{example} + \begin{GrilleSutom}[Strict]{CRAZE} + GRAIL + CRAMPS + CRAM + CRABS + \end{GrilleSutom} + \end{example} + + \option[--]{Lignes} + + Par défaut, l'environnement \keyword{wordle} affiche le nombre de lignes en adéquation avec le nombre de mots donnés. L'option \option{Lignes} permet de modifier le nombre de lignes (évenuellement vides). + + \begin{example} + \begin{GrilleSutom}[Lignes=4]{ANVIL} + CRANE + NATAL + ANVIL + \end{GrilleSutom} + \end{example} + + \begin{example} + \begin{GrilleSutom}[Lignes=2]{ANVIL} + CRANE + NATAL + ANVIL + \end{GrilleSutom} + \end{example} + + \option[]{*} + + Le style des case peut être annulé en ajoutant un astérisque,~\option{*}, en tant que mot. + + \begin{example} + \begin{GrilleSutom}{ANVIL} + CRANE + NATAL + * % annule la mise en forme + ANNUL + ANVIL + \end{GrilleSutom} + \end{example} + + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + \Section{Sensibilité à la casse} + \index{case~sensitive} + \index{case~sensitive!lower case} + \index{case~sensitive!natural case} + \index{case~sensitive!upper case} + + Par défaut, les lettres peuvent être écrites en majuscule ou en minuscule, comme saisies par l'utilisateur. + + L'option (voir doc en anglais) \option{case~sensitive} permet de spécifier un paramétrage de la casse. + + \begin{example} + \begin{GrilleSutom}[case sensitive=false]{youth} % par defaut + North + South + Youth + \end{GrilleSutom} + \end{example} + + \begin{example} + \begin{GrilleSutom}[case sensitive]{youth} + North + South + Youth + \end{GrilleSutom} + \end{example} + + Les options \textit{fines} \option{natural case} (défaut), \option{lower case}et \option{upper case} permettent de travailler plus finement sur la casse des lettres correctes et/ou mal placées. + + \begin{example} + \begin{GrilleSutom}[lower case]{YOUTH} + North + South + Youth + \end{GrilleSutom} + \end{example} + + \begin{example} + \begin{GrilleSutom}[upper case]{youth} + North + South + Youth + \end{GrilleSutom} + \end{example} + + \begin{example} + \begin{GrilleSutom}[natural case]{youth} % par defaut + North + South + youth + \end{GrilleSutom} + \end{example} + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + \Section{Style \ctan{TikZ} complémentaire} + + \option[]{tikz}[commandes TikZ] + + \begin{example} + % \usetikzlibrary{backgrounds} + \begin{GrilleSutom}[ + tikz={framed, + background rectangle/.style={ + double,ultra thick, draw=SteelBlue + } + }]{youth} + North South youth + \end{GrilleSutom} + \end{example} + + \pagebreak + + \option[W]{Nom} + + \begin{example} + \begin{GrilleSutom}[tikz={remember picture}]{CRAZE} + TRACE + CREAM + CRAZE + \end{GrilleSutom} + \end{example} + + \begin{example} + \tikz[remember picture]\draw[overlay, very thick, opacity=0.5,->,red](0,0)node{Pas de M !!!} to [out=90, in=180](W-2-5); + \end{example} + + \begin{example} + \begin{GrilleSutom}[name=M, + tikz={arr/.style={red,ultra thick,->}} + ]{MACAW} + [{ + \draw[arr](M-1-3.south)--(M-3-2.north)--(M-4-2.north); + \draw[arr](M-1-1.south)--(M-3-5)--(M-4-3.north east); + }] + CRANE HOTLY BASIC MACAW + \end{GrilleSutom} + \end{example} + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + \Section{Le code} + + Le package \keyword{wordle} est écrit en \LaTeX3. Beaucoup de commentaires permettent d'expliciter le fonctionnement du code. La coloration automatique des cases est un exercice amusant en \LaTeX3, motivépar un message issu de + \href{https://tex.stackexchange.com/questions/659860/wordle-like-colored-letter-boxes-in-latex/660056#660056}{tex.stackexchange.com}. + + Le dépôt \href{https://github.com/AndrewMathas/Wordle}{github.com/AndrewMathas/Wordle} est disponible pour signaler tout bug. + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + \printindex + +\end{document} diff --git a/Master/texmf-dist/tex/latex/wordle/wordle.sty b/Master/texmf-dist/tex/latex/wordle/wordle.sty index 4df1801ba02..a463f22837e 100644 --- a/Master/texmf-dist/tex/latex/wordle/wordle.sty +++ b/Master/texmf-dist/tex/latex/wordle/wordle.sty @@ -1,298 +1,670 @@ -% Author.........: C. Pierquet -% licence........: Released under the LaTeX Project Public License v1.3c or later, see http://www.latex-project.org/lppl.txtf -% Inspiration....: https://tex.stackexchange.com/questions/659860/wordle-like-colored-letter-boxes-in-latex +% --------------------------------------------------------------- +% wordle --- A latex package for typesetting wordle puzzles +% +% E-mail: andrew.mathas@gmail.com and cpierquet@outlook.fr +% Released under the LaTeX Project Public License v1.3c or later +% See http://www.latex-project.org/lppl.txt +% ---------------------------------------------------------------- \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{wordle}[2023/09/03 v0.1.1 Wordle grid] -% 0.1.1 Coorection d'un bug sur la version anglaise -% 0.1.0 Version initiale + quelques modèles -%------Packages utiles +% Package version +\def\wordle@version{0.3.0} +\def\wordle@release{2024-08-18} + +\providecommand\DeclareRelease[3]{} +\providecommand\DeclareCurrentRelease[2]{} +\DeclareRelease{\wordle@version}{\wordle@release}{wordle.sty} +\DeclareCurrentRelease{}{\wordle@release} + +\ProvidesExplPackage{wordle} {\wordle@release} {\wordle@version} + {A latex package for typesetting wordle puzzles} + +% ---------------------------------------------------------------- +% Required packages +%\RequirePackage{xcolor} \RequirePackage{tikz} -\RequirePackage{simplekv} -\RequirePackage{xstring} -%commandes utiles -\usepackage{expl3} -\ExplSyntaxOn +% ---------------------------------------------------------------- +% predefined tile colours + +% from https://www.nytimes.com/games/wordle +\definecolor{WordleAbsent} {HTML} {797D7F} +\definecolor{WordlePresent} {HTML} {F7DA21} +\definecolor{WordleCorrect} {HTML} {6AAB64} +\definecolor{WordleEmpty} {HTML} {F5F5DC} + +\definecolor{WordleHardPresent} {HTML} {95BEFA} +\definecolor{WordleHardCorrect} {HTML} {FB9B00} + +% from https://sutom.nocle.fr/# +\definecolor{WordleSutomAbsent} {HTML} {0077B7} +\definecolor{WordleSutomPresent} {HTML} {FFBB00} +\definecolor{WordleSutomCorrect} {HTML} {EB2152} + +% ---------------------------------------------------------------- +% package variables + +\bool_new:N \l__wordle_case_sensitive_bool % case sensitive mode (false by default) +\bool_new:N \l__wordle_strict_bool % strict mode (false by default) + +\dim_new:N \l__wordle_grid_dim +\dim_new:N \l__wordle_rounded_dim +\dim_new:N \l__wordle_sep_dim +\dim_new:N \l__wordle_size_dim +\dim_new:N \l__wordle_thickness_dim + +\int_new:N \l__wordle_rows_int -%boite en [fr] -\cs_new:Npn \l__sutom_boite_lettre:nn #1#2#3 +\fp_new:N \l__wordle_scale_fp + +\tl_new:N \l__wordle_align_tl +\tl_new:N \l__wordle_depth_tl +\tl_new:N \l__wordle_font_tl +\tl_new:N \l__wordle_name_tl +\tl_new:N \l__wordle_style_tl +\tl_new:N \l__wordle_tikz_tl +\tl_new:N \l__wordle_tile_style_tl + +\tl_new:N \l__wordle_present_border_tl +\tl_new:N \l__wordle_present_colour_tl +\tl_new:N \l__wordle_present_frame_tl +\tl_new:N \l__wordle_present_shape_tl +\tl_new:N \l__wordle_present_text_tl + +\tl_new:N \l__wordle_correct_border_tl +\tl_new:N \l__wordle_correct_colour_tl +\tl_new:N \l__wordle_correct_frame_tl +\tl_new:N \l__wordle_correct_shape_tl +\tl_new:N \l__wordle_correct_text_tl + +\tl_new:N \l__wordle_empty_border_tl +\tl_new:N \l__wordle_empty_colour_tl +\tl_new:N \l__wordle_empty_frame_tl +\tl_new:N \l__wordle_empty_shape_tl +\tl_new:N \l__wordle_empty_text_tl + +\tl_new:N \l__wordle_absent_border_tl +\tl_new:N \l__wordle_absent_colour_tl +\tl_new:N \l__wordle_absent_frame_tl +\tl_new:N \l__wordle_absent_shape_tl +\tl_new:N \l__wordle_absent_text_tl + + +% ---------------------------------------------------------------- +% Assign up to four style attributes from comma separated list to absent, +% present, correct, empty, respectively. If there is only one entry in +% the list then everything is set equal to that entry +\cs_new_nopar:Npn \__wordle_set_style:nn #1#2 { - \ifboolKV[SUTOM]{Lettres}% - {% - \tikz \draw[rounded~corners=\fpeval{#3*\SutomUnit}cm,draw=\SutomBorder,line~width=\SutomWidth~mm,fill=#1] (0,0) rectangle++ (\SutomUnit,\SutomUnit) node[midway,font=\SutomFonte,text=\SutomFonteColor,scale=\SutomUnit] {#2} ; - }% - {% - \tikz \draw[rounded~corners=\fpeval{#3*\SutomUnit}cm,draw=\SutomBorder,line~width=\SutomWidth~mm,fill=#1] (0,0) rectangle++ (\SutomUnit,\SutomUnit) ; - }% + \seq_set_split:Nnn \l_tmpa_seq {,} {#2} + \int_compare:nNnTF {\seq_count:N \l_tmpa_seq} = {1} + { + \tl_set:co {l__wordle_absent_#1_tl} {#2} + \tl_set:co {l__wordle_present_#1_tl} {#2} + \tl_set:co {l__wordle_correct_#1_tl} {#2} + \tl_set:co {l__wordle_empty_#1_tl} {#2} + } + { + \seq_pop_left:NNT \l_tmpa_seq \l_tmpa_tl { \tl_set:co {l__wordle_absent_#1_tl} {\l_tmpa_tl} } + \seq_pop_left:NNT \l_tmpa_seq \l_tmpa_tl { \tl_set:co {l__wordle_present_#1_tl} {\l_tmpa_tl} } + \seq_pop_left:NNT \l_tmpa_seq \l_tmpa_tl { \tl_set:co {l__wordle_correct_#1_tl} {\l_tmpa_tl} } + \seq_pop_left:NNT \l_tmpa_seq \l_tmpa_tl { \tl_set:co {l__wordle_empty_#1_tl} {\l_tmpa_tl} } + } } -\cs_new:Npn \l__sutom_boite_lettre_rond:nn #1#2#3#4 +% apply the wordle styles +\cs_new_nopar:Npn \__wordle_apply_style:n #1 { + \str_case:enF { #1 } + { + {hard} + { + \__wordle_set_style:nn {border} {white} + \__wordle_set_style:nn {colour} {WordleAbsent,WordleHardPresent,WordleHardCorrect,WordleEmpty} + \__wordle_set_style:nn {frame} {false} + \__wordle_set_style:nn {shape} {rectangle} + \__wordle_set_style:nn {text} {white,white,white,black} + } + + {alt} + { % alt appears in the English version of Cedric's manual for sutom + \__wordle_set_style:nn {border} {white} + \__wordle_set_style:nn {colour} {WordleSutomAbsent,WordleSutomPresent,WordleSutomCorrect,WordleEmpty} + \__wordle_set_style:nn {frame} {false,true,false,false} + \__wordle_set_style:nn {shape} {rectangle,circle,rectangle,circle} + \__wordle_set_style:nn {text} {white,white,white,black} + \tl_set:Nn \l_wordle_font_tl {\LARGE\bfseries\sffamily} + + } + + {sutom} + { + \__wordle_set_style:nn {border} {white} + \__wordle_set_style:nn {colour} {WordleSutomAbsent,WordleSutomPresent,WordleSutomCorrect,WordleEmpty} + \__wordle_set_style:nn {frame} {false,true,false,false} + \__wordle_set_style:nn {shape} {rectangle,circle,rectangle,circle} + \__wordle_set_style:nn {text} {white,white,white,black} + \tl_set:Nn \l_wordle_font_tl {\LARGE\bfseries\sffamily} + } + } + { + % default style + \__wordle_set_style:nn {border} {white} + \__wordle_set_style:nn {colour} {WordleAbsent,WordlePresent,WordleCorrect,WordleEmpty} + \__wordle_set_style:nn {frame} {false} + \__wordle_set_style:nn {shape} {rectangle} + \__wordle_set_style:nn {text} {white,white,white,black} + } +} + +% rescale dimensions +\cs_new_nopar:Npn \__wordle_rescale:n #1 { - \IfStrEq{\SutomStyle}{rond} - {% - \tikz {\draw[rounded~corners=\fpeval{#4*\SutomUnit}cm,draw=\SutomBorder,line~width=\SutomWidth~mm,fill=#1] (0,0) rectangle++ (\SutomUnit,\SutomUnit) ; - \ifboolKV[SUTOM]{Lettres}% - {% - \draw[line~width=\SutomWidth~mm,draw=#2,fill=#2] ({0.5*\SutomUnit},{0.5*\SutomUnit}) circle[radius=\fpeval{0.5*\SutomUnit-0.1*\SutomWidth}] node[font=\SutomFonte,text=\SutomFonteColor,scale=\SutomUnit] {#3} ; - }% - {% - \draw[line~width=\SutomWidth~mm,draw=#2,fill=#2] ({0.5*\SutomUnit},{0.5*\SutomUnit}) circle[radius=\fpeval{0.5*\SutomUnit-0.1*\SutomWidth}]; - }% - }% - }% - {% - \ifboolKV[SUTOM]{Lettres}% - {% - \tikz \draw[rounded~corners=\fpeval{#4*\SutomUnit}cm,line~width=0\SutomWidth~mm,draw=\SutomBorder,fill=#2] (0,0) rectangle++ (\SutomUnit,\SutomUnit) node[midway,font=\SutomFonte,text=\SutomFonteColor,scale=\SutomUnit] {#3} ; - }% - {% - \tikz \draw[rounded~corners=\fpeval{#4*\SutomUnit}cm,line~width=\SutomWidth~mm,draw=\SutomBorder,fill=#2] (0,0) rectangle++ (\SutomUnit,\SutomUnit) ; - }% - }% + \fp_set:Nn \l__wordle_scale_fp {#1} + \dim_set:Nn \l__wordle_rounded_dim { \fp_eval:n {#1*\dim_to_decimal_in_mm:n {\l__wordle_rounded_dim }}mm } + \dim_set:Nn \l__wordle_sep_dim { \fp_eval:n {#1*\dim_to_decimal_in_mm:n {\l__wordle_sep_dim }}mm } + \dim_set:Nn \l__wordle_size_dim { \fp_eval:n {#1*\dim_to_decimal_in_mm:n {\l__wordle_size_dim }}mm } + \dim_set:Nn \l__wordle_thickness_dim { \fp_eval:n {#1*\dim_to_decimal_in_mm:n {\l__wordle_thickness_dim}}mm } } -%boite en [en] -\cs_new:Npn \l__wordle_boite_lettre:nn #1#2#3 + +% ---------------------------------------------------------------- +% just in case we're running an old version of latex +\providecommand \IfFormatAtLeastTF { \@ifl@t@r \fmtversion } + +\IfFormatAtLeastTF { 2022-06-01 } + { \ProcessKeyOptions [ wordle ] } + { + \RequirePackage { l3keys2e } + \ProcessKeysOptions { wordle } + } + +% ---------------------------------------------------------------- +% Define keys for the package options and their defaults + +\keys_define:nn { wordle } { - \ifboolKV[WORDLE]{Letters}% - {% - \tikz \draw[rounded~corners=\fpeval{#3*\SutomUnit}cm,draw=\SutomBorder,line~width=\SutomWidth~mm,fill=#1] (0,0) rectangle++ (\SutomUnit,\SutomUnit) node[midway,font=\SutomFonte,text=\SutomFonteColor,scale=\SutomUnit] {#2} ; - }% - {% - \tikz \draw[rounded~corners=\fpeval{#3*\SutomUnit}cm,draw=\SutomBorder,line~width=\SutomWidth~mm,fill=#1] (0,0) rectangle++ (\SutomUnit,\SutomUnit) ; - }% + % apply puzzle styles: sets colours of absent, present, correct and empty tiles + style .code:n = { + \seq_set_from_clist:Nn \l_tmpa_seq {#1} + \seq_map_inline:Nn \l_tmpa_seq { \__wordle_apply_style:n { \str_lowercase:n{##1}} } + }, + Style .meta:n = { style = #1 }, + style .initial:n = standard, + + % specifying tile colours and shapes + borders .code:n = { \__wordle_set_style:nn {border} {#1} }, + BorderColor .code:n = { \__wordle_set_style:nn {border} {#1} }, + CouleurBordures.code:n = { \__wordle_set_style:nn {border} {#1} }, + + Couleurs .code:n = { \__wordle_set_style:nn {colour} {#1} }, + colours .code:n = { \__wordle_set_style:nn {colour} {#1} }, + + frames .code:n = { \__wordle_set_style:nn {frame} {#1} }, + Cadres .code:n = { \__wordle_set_style:nn {frame} {#1} }, + frames .default:n = true, + shapes .code:n = { \__wordle_set_style:nn {shape} {#1} }, + Formes .code:n = { \__wordle_set_style:nn {shape} {#1} }, + + % text colour + text .code:n = { \__wordle_set_style:nn {text} {#1} }, + CouleurLettres .code:n = { \__wordle_set_style:nn {text} {#1} }, + + % align letters in puzzle + align .code:n = { + \tl_set:Nn \l__wordle_align_tl {\vphantom{azertyuiopqsdfghjklmwxcvbnAZERTYUIOPQSDFGHJKLMWXCVBN}} + \tl_set:Nn \l__wordle_depth_tl {text~depth=0pt} + }, + noalign .code:n = { + \tl_set:Nn \l__wordle_align_tl {} + \tl_set:Nn \l__wordle_depth_tl {} + }, + nonalign .meta:n = { noalign }, + align .initial:n = {true}, + + absent .tl_set:N = \l__wordle_absent_colour_tl, + absent~color .tl_set:N = \l__wordle_absent_colour_tl, + couleur~absent .tl_set:N = \l__wordle_absent_colour_tl, + absent~colour .tl_set:N = \l__wordle_absent_colour_tl, + bordure~absent .tl_set:N = \l__wordle_absent_border_tl, + absent~border .tl_set:N = \l__wordle_absent_border_tl, + absent~frame .tl_set:N = \l__wordle_absent_frame_tl, + cadre~absent .tl_set:N = \l__wordle_absent_frame_tl, + absent~frame .default:n = true, + absent~shape .tl_set:N = \l__wordle_absent_shape_tl, + forme~absent .tl_set:N = \l__wordle_absent_shape_tl, + absent~text .tl_set:N = \l__wordle_absent_text_tl, + coultxt~absent .tl_set:N = \l__wordle_absent_text_tl, + + correct .tl_set:N = \l__wordle_correct_colour_tl, + correct~color .tl_set:N = \l__wordle_correct_colour_tl, + correct~colour .tl_set:N = \l__wordle_correct_colour_tl, + couleur~correct.tl_set:N = \l__wordle_correct_colour_tl, + correct~border .tl_set:N = \l__wordle_correct_border_tl, + bordure~correct.tl_set:N = \l__wordle_correct_border_tl, + correct~frame .tl_set:N = \l__wordle_correct_frame_tl, + cadre~correct .tl_set:N = \l__wordle_correct_frame_tl, + correct~frame .default:n = true, + correct~shape .tl_set:N = \l__wordle_correct_shape_tl, + forme~correct .tl_set:N = \l__wordle_correct_shape_tl, + correct~text .tl_set:N = \l__wordle_correct_text_tl, + coultxt~correct.tl_set:N = \l__wordle_correct_text_tl, + + empty .tl_set:N = \l__wordle_empty_colour_tl, + couleur~vide .tl_set:N = \l__wordle_empty_colour_tl, + empty~color .tl_set:N = \l__wordle_empty_colour_tl, + empty~colour .tl_set:N = \l__wordle_empty_colour_tl, + empty~border .tl_set:N = \l__wordle_empty_border_tl, + bordure~vide .tl_set:N = \l__wordle_empty_border_tl, + empty~frame .tl_set:N = \l__wordle_empty_frame_tl, + cadre~vide .tl_set:N = \l__wordle_empty_frame_tl, + empty~frame .default:n = true, + empty~shape .tl_set:N = \l__wordle_empty_shape_tl, + forme~vide .tl_set:N = \l__wordle_empty_shape_tl, + empty~text .tl_set:N = \l__wordle_empty_text_tl, + coultxt~vide. tl_set:N = \l__wordle_empty_text_tl, + + present .tl_set:N = \l__wordle_present_colour_tl, + couleur~present.tl_set:N = \l__wordle_present_colour_tl, + present~color .tl_set:N = \l__wordle_present_colour_tl, + present~colour .tl_set:N = \l__wordle_present_colour_tl, + present~border .tl_set:N = \l__wordle_present_border_tl, + bordure~present.tl_set:N = \l__wordle_present_border_tl, + present~frame .tl_set:N = \l__wordle_present_frame_tl, + cadre~present .tl_set:N = \l__wordle_present_frame_tl, + present~frame .default:n = true, + present~shape .tl_set:N = \l__wordle_present_shape_tl, + forme~present .tl_set:N = \l__wordle_present_shape_tl, + present~text .tl_set:N = \l__wordle_present_text_tl, + coultxt~present.tl_set:N = \l__wordle_present_text_tl, + + % text font + font .tl_set:N = \l__wordle_font_tl, + Fonte .tl_set:N = \l__wordle_font_tl, + Police .tl_set:N = \l__wordle_font_tl, + font .initial:n = \Large\bfseries\sffamily, + + % tile size + size .dim_set:N = \l__wordle_size_dim, + Taille .dim_set:N = \l__wordle_size_dim, + size .initial:n = 8mm, + + % thickness of tile border + thickness .dim_set:N = \l__wordle_thickness_dim, + Epaisseur .dim_set:N = \l__wordle_thickness_dim, + Thick .code:n = {\dim_set:Nn \l__wordle_thickness_dim {#1mm}}, + thickness .initial:n = 0.25mm, + + % rounded-corner = # + rounded .dim_set:N = \l__wordle_rounded_dim, + Arrondi .dim_set:N = \l__wordle_rounded_dim, + rounded .default:n = 4pt, + Rounded .code:n = {\dim_set:Nn \l__wordle_rounded_dim {#1mm}}, + rounded .initial:n = 1mm, + + % separation between tiles + separation .dim_set:N = \l__wordle_sep_dim, + Separation .dim_set:N = \l__wordle_sep_dim, + separation .initial:n = 0.5mm, + + % rescale tiles + scale .code:n = { \__wordle_rescale:n {#1} }, + Echelle .code:n = { \__wordle_rescale:n {#1} }, + scale .initial:n = 1, + Unit .code:n = { \__wordle_rescale:n {#1} }, + Unite .code:n = { \__wordle_rescale:n {#1} }, + + % letter case + case~sensitive .bool_set:N = \l__wordle_case_sensitive_bool, + case~sensitive .default:n = true, + case~sensitive .initial:n = false, + + % letter visibility + letters .code:n = {\cs_set_eq:NN \__wordle_letter:n \__wordle_letter_natural:n}, + Lettres .code:n = {\cs_set_eq:NN \__wordle_letter:n \__wordle_letter_natural:n}, + noletters .code:n = {\cs_set_eq:NN \__wordle_letter:n \__wordle_letter_none:n}, + NonLettres .code:n = {\cs_set_eq:NN \__wordle_letter:n \__wordle_letter_none:n}, + letters .initial:n = true, + + % forced letter case + natural~case .code:n = { + \cs_set_eq:NN \__wordle_letter:n \__wordle_letter_natural:n + }, + lower~case .code:n = { + \cs_set_eq:NN \__wordle_letter:n \__wordle_letter_lower:n + \bool_set_false:N \l__wordle_case_sensitive_bool + }, + upper~case .code:n = { + \cs_set_eq:NN \__wordle_letter:n \__wordle_letter_upper:n + \bool_set_false:N \l__wordle_case_sensitive_bool + }, + + % puzzle specs: rows and columns + rows .int_set:N = \l__wordle_rows_int, + Lignes .int_set:N = \l__wordle_rows_int, + rows .initial:n = 0, + + strict .bool_set:N = \l__wordle_strict_bool, + Strict .bool_set:N = \l__wordle_strict_bool, + strict .default:n = true, + strict .initial:n = false, + + % tikz settings + tile~style .tl_set:N = \l__wordle_tile_style_tl, + Style~case .tl_set:N = \l__wordle_tile_style_tl, + tile~style .initial:n = , + + name .tl_set:N = \l__wordle_name_tl, + Nom .tl_set:N = \l__wordle_name_tl, + name .initial:n = W, + tikz .tl_set:N = \l__wordle_tikz_tl, + tikz .initial:n = , +} + +% user settings +\NewDocumentCommand\WordleSetup{ m }{ \keys_set:nn { wordle } {#1} } +\NewDocumentCommand\ParamsSutom{ m }{ \keys_set:nn { wordle } {#1} } + +% ---------------------------------------------------------------- +% Define TikZ Wordle styles for the letters. Using tikz styles both +% ensures consistency and has the added advantage of taking care of +% expansion issues with the tile settings +\tikzset{/Wordle/.is~family, /Wordle, + tile/.style = { + /tikz, % change back to using tikz keys + inner~sep = \l__wordle_sep_dim, + minimum~height = \l__wordle_size_dim, + minimum~size = \l__wordle_size_dim, + rounded~corners= \l__wordle_rounded_dim, + line~width = \l__wordle_thickness_dim, + font = \l__wordle_font_tl, + % scale = \fp_to_decimal:N \l__wordle_scale_fp, + text = \tl_use:c {l__wordle_#1_text_tl}, + fill = \tl_use:c {l__wordle_#1_colour_tl}, + shape = \tl_use:c {l__wordle_#1_shape_tl}, + }, + frame/.style = { + /Wordle/tile=#1, + /tikz, % change back to using tikz keys + draw = \tl_use:c{l__wordle_#1_border_tl}, + minimum~size = {\l__wordle_size_dim+\l__wordle_thickness_dim}, + fill = \tl_use:c {l__wordle_#1_colour_tl}, + shape = rectangle, + }, } -\cs_new:Npn \l__wordle_boite_lettre_rond:nn #1#2#3#4 +% apply a TikZ setting +\cs_new_nopar:Npn \__wordle_tikzset:n #1 { \exp_args:Nx \tikzset{#1} } + +% ---------------------------------------------------------------- +% preprocessing of the wordle letters +\cs_new_nopar:Npn \__wordle_letter_none:n #1 {} +\cs_new_nopar:Npn \__wordle_letter_natural:n #1 {#1} +\cs_new_nopar:Npn \__wordle_letter_lower:n #1 { \str_lowercase:n {#1} } +\cs_new_nopar:Npn \__wordle_letter_upper:n #1 { \str_uppercase:n {#1} } + +% by default wordle letters are not processed +\cs_set_eq:NN \__wordle_letter:n \__wordle_letter_natural:n + +% Print a letter in a box as a node. There is slightly different behaviour +% depending on whether the tile is frames or we are in strict mode. The way +% that the entry is printed depends is controlled by \__wordle_letter:n. +\cs_new_nopar:Npn \wordle__boxed_letter:nn #1#2 { - \IfStrEq{\SutomStyle}{default} - {% - \ifboolKV[WORDLE]{Letters}% - {% - \tikz \draw[rounded~corners=\fpeval{#4*\SutomUnit}cm,line~width=\SutomWidth~mm,draw=\SutomBorder,fill=#2] (0,0) rectangle++ (\SutomUnit,\SutomUnit) node[midway,font=\SutomFonte,text=\SutomFonteColor,scale=\SutomUnit] {#3} ; - }% - {% - \tikz \draw[rounded~corners=\fpeval{#4*\SutomUnit}cm,line~width=\SutomWidth~mm,draw=\SutomBorder,fill=#2] (0,0) rectangle++ (\SutomUnit,\SutomUnit) ; - }% - }% - {% - \tikz {\draw[rounded~corners=\fpeval{#4*\SutomUnit}cm,draw=\SutomBorder,line~width=\SutomWidth~mm,fill=#1] (0,0) rectangle++ (\SutomUnit,\SutomUnit) ; - \ifboolKV[WORDLE]{Letters}% - {% - \draw[line~width=\SutomWidth~mm,draw=#2,fill=#2] ({0.5*\SutomUnit},{0.5*\SutomUnit}) circle[radius=\fpeval{0.5*\SutomUnit-0.1*\SutomWidth}] node[font=\SutomFonte,text=\SutomFonteColor,scale=\SutomUnit] {#3} ; - }% - {% - \draw[line~width=\SutomWidth~mm,draw=#2,fill=#2] ({0.5*\SutomUnit},{0.5*\SutomUnit}) circle[radius=\fpeval{0.5*\SutomUnit-0.1*\SutomWidth}]; - }% - }% - }% + % determine the node name, which takes the form <W>-<row>-<col> + \tl_set:No \l_tmpa_tl + { + \l__wordle_name_tl-\int_eval:n{1+\l__wordle_row_index_int}-\int_use:N\l__wordle_letter_index_int + } + + % the construction of the node depends on whether the tile is framed + \tl_if_eq:cnTF {l__wordle_#1_frame_tl} {true} + { + % draw the frame + \node[/Wordle/frame=absent] % frame use the absent fill colour + at ({\l__wordle_letter_index_int*\l__wordle_grid_dim},{-\l__wordle_row_index_int*\l__wordle_grid_dim}){}; + % draw the tile + \node[/Wordle/tile=#1] + (\l_tmpa_tl) at ({\l__wordle_letter_index_int*\l__wordle_grid_dim}, + {-\l__wordle_row_index_int*\l__wordle_grid_dim}) + { \l__wordle_align_tl\__wordle_letter:n {#2} }; + } + { + % draw the tile, with a border + \node[/Wordle/frame=#1, /Wordle/tile=#1] + (\l_tmpa_tl) at ({\l__wordle_letter_index_int*\l__wordle_grid_dim}, + {-\l__wordle_row_index_int*\l__wordle_grid_dim}) + { \l__wordle_align_tl\__wordle_letter:n {#2} }; + } + + % if strict then put a slash through any extra letters + \bool_if:NT \l__wordle_strict_bool + { + \int_compare:nNnT {\l__wordle_letter_index_int} > {\seq_count:N \l__wordle_answer_seq } + { + \draw[red,ultra~thick] (\tl_use:N\l_tmpa_tl.south~west)--(\tl_use:N\l_tmpa_tl.north~east); + } + } } -\seq_new:N \l_wordle_seq % the answer -\prop_new:N \l_wordle_prop % count letters in wordle -\seq_new:N \l_words_seq % list of all words -\prop_new:N \l_word_prop % count letters in word -\int_new:N \l_letter_int % index of current letter in word +\seq_new:N \l__wordle_answer_seq % the answer +\prop_new:N \l__wordle_answer_counts_prop % count letters in wordle +\seq_new:N \l__wordle_solution_seq % list of all words +\prop_new:N \l__wordle_word_counts_prop % count letters in word +\int_new:N \l__wordle_letter_index_int % index of current letter in word +\int_new:N \l__wordle_row_index_int % TikZ row index in solution -% a conditional for nonnegative prop counter in \l_word_prop -\prg_new_protected_conditional:Npnn \if_wordle_letter_nonnegative:n #1 {TF} +% a conditional for non-negative prop counter in \l__wordle_word_counts_prop +\prg_new_protected_conditional:Npnn \if__wordle_letter_nonnegative:n #1 {TF} { - \prop_if_in:NnTF \l_word_prop {#1} - { % letter in in prop - \prop_get:NnN \l_word_prop {#1} \l_tmpa_tl - \int_compare:nNnTF {\l_tmpa_tl} < {0} - {\prg_return_false:} {\prg_return_true:} - } - {\prg_return_false:} + \prop_if_in:NnTF \l__wordle_word_counts_prop {#1} + { % letter in in prop + \prop_get:NnN \l__wordle_word_counts_prop {#1} \l_tmpa_tl + \int_compare:nNnTF {\l_tmpa_tl} < {0} + {\prg_return_false:} {\prg_return_true:} + } + {\prg_return_false:} } +\cs_generate_variant:Nn \str_if_eq:nVTF {xVTF} + % a conditional for comparing letters -\prg_new_protected_conditional:Npnn \if_wordle_letters_agree:n #1 {T, TF} +\prg_new_protected_conditional:Npnn \if__wordle_letters_agree:n #1 {T, TF} { - \str_set:Nx \l_tmpa_str {\seq_item:Nn \l_wordle_seq {\l_letter_int}} - \str_if_eq:nVTF {#1} \l_tmpa_str {\prg_return_true:} {\prg_return_false:} + \str_set:Nx \l_tmpa_str + {\seq_item:Nn \l__wordle_answer_seq {\l__wordle_letter_index_int}} + + + \bool_if:NTF \l__wordle_case_sensitive_bool + {\str_if_eq:nVTF {#1} \l_tmpa_str {\prg_return_true:} {\prg_return_false:}} + {\str_if_eq:xVTF {\str_uppercase:n{#1}} \l_tmpa_str {\prg_return_true:} {\prg_return_false:}} } % add #3 to <prop=#1>.#2 -\cs_new_protected:Npn \wordle__add_to_prop_counter:Nnn #1#2#3 +\cs_new_nopar:Npn \wordle__add_to_prop_counter:Nnn #1#2#3 { - \prop_put_if_new:Nnn #1 {#2} {0} - \prop_pop:NnN #1 {#2} \l_tmp_a - \prop_put:Nnx #1 {#2} {\int_eval:n {#3+\l_tmp_a}} + \prop_put_if_new:Nnn #1 {#2} {0} + \prop_pop:NnN #1 {#2} \l_tmp_a + \prop_put:Nnx #1 {#2} {\int_eval:n {#3+\l_tmp_a}} } -% make \l_wordle_prop<x> = #x's in wordle_seq -\cs_new_protected:Npn \count_letters_in_wordle:n #1 +% make \l__wordle_answer_counts_prop<x> = #x's in wordle_seq +\cs_new_nopar:Npn \wordle__count_letters_in_answer:n #1 { - \wordle__add_to_prop_counter:Nnn \l_wordle_prop {#1} {1}% + \wordle__add_to_prop_counter:Nnn \l__wordle_answer_counts_prop {#1} {1} } % first run: subtract correct matches from letter counts -\cs_new:Npn \count_letters_in_word:n #1 +\cs_new_nopar:Npn \wordle__count_letters_in_word:n #1 { - \int_incr:N \l_letter_int - \if_wordle_letters_agree:nT {#1} - { \wordle__add_to_prop_counter:Nnn \l_word_prop {#1} {-1} }% + \int_incr:N \l__wordle_letter_index_int + \if__wordle_letters_agree:nT {#1} + { \wordle__add_to_prop_counter:Nnn \l__wordle_word_counts_prop {#1} {-1} } } -%commande [fr] % on the second run we print a coloured wordle word -\cs_new:Npn \write_letters_in_word:n #1 +\cs_new_nopar:Npn \wordle__write_letters_in_word:n #1 { - \int_incr:N \l_letter_int - \if_wordle_letters_agree:nTF {#1} - { \l__sutom_boite_lettre:nn {\SutomBienPlacee}{#1}{\SutomRounded} } - { - % subtract 1 from the prop counter - \wordle__add_to_prop_counter:Nnn \l_word_prop {#1} {-1} - % if the counter is non-negative this is a pseudo match - \if_wordle_letter_nonnegative:nTF {#1} - { \l__sutom_boite_lettre_rond:nn {\SutomCoulFond}{\SutomCoulMalPlacee}{#1}{\SutomRounded} } - { \l__sutom_boite_lettre:nn {\SutomCoulFond}{#1}{\SutomRounded} } - }% + \int_incr:N \l__wordle_letter_index_int + \if__wordle_letters_agree:nTF {#1} + { \wordle__boxed_letter:nn {correct} {#1} } + { + % subtract 1 from the prop counter + \wordle__add_to_prop_counter:Nnn \l__wordle_word_counts_prop {#1} {-1} + % if the counter is non-negative this is a pseudo match + \if__wordle_letter_nonnegative:nTF {#1} + { \wordle__boxed_letter:nn {present} {#1} } + { \wordle__boxed_letter:nn {absent} {#1} } + } } -%commande [en] -% on the second run we print a coloured wordle word -\cs_new:Npn \write_letters_in_wordle:n #1 +\cs_generate_variant:Nn \seq_set_split:Nnn {Nnx} +\cs_generate_variant:Nn \cs_set_nopar:Nn {NV} + +% typeset the word "#1", colouring letters using the wordle convention +\cs_new_nopar:Npn \wordle__mark_word:n #1 { - \int_incr:N \l_letter_int - \if_wordle_letters_agree:nTF {#1} - { \l__wordle_boite_lettre:nn {\SutomBienPlacee}{#1}{\SutomRounded} } - { - % subtract 1 from the prop counter - \wordle__add_to_prop_counter:Nnn \l_word_prop {#1} {-1} - % if the counter is non-negative this is a pseudo match - \if_wordle_letter_nonnegative:nTF {#1} - { \l__wordle_boite_lettre_rond:nn {\SutomCoulFond}{\SutomCoulMalPlacee}{#1}{\SutomRounded} } - { \l__wordle_boite_lettre:nn {\SutomCoulFond}{#1}{\SutomRounded} } - }% -} + \str_if_eq:nnTF {#1} {*} + { + \cs_set_eq:NN \wordle__process_word:n \wordle__empty_word:n + } + { + \prop_set_eq:NN \l__wordle_word_counts_prop \l__wordle_answer_counts_prop + \tl_map_function:nN {#1} \wordle__count_letters_in_word:n + \int_zero:N \l__wordle_letter_index_int + \tl_map_function:nN {#1} \wordle__write_letters_in_word:n -%clés [fr] -\defKV[SUTOM]{% - Couleurs=\def\SutomCouleurs{#1},% - Arrondi=\def\SutomRounded{#1},% - Unite=\def\SutomUnit{#1},% - Police=\def\SutomFonte{#1},% - CouleurLettres=\def\SutomFonteColor{#1},% - Style=\def\SutomStyle{#1},% - Epaisseur=\def\SutomWidth{#1},% - CouleurBordure=\def\SutomBorder{#1} -} + % if strict then check lengths + \bool_if:NT \l__wordle_strict_bool + { + \int_while_do:nNnn {\l__wordle_letter_index_int} < {\seq_count:N\l__wordle_answer_seq} + { + \int_incr:N \l__wordle_letter_index_int + \wordle__boxed_letter:nn {absent} {\c_space_tl} + } + } -\setKVdefault[SUTOM]{% - Couleurs={cyan!75!black,yellow,red},% - Arrondi=0.1,% - Unite=1,% - Police=\LARGE\bfseries\sffamily,% - CouleurLettres=white,% - Lettres=true,% - Style=rond,% - Epaisseur=0.25,% - CouleurBordure=white + % increment the row index + \int_incr:N \l__wordle_row_index_int + } } -%environnement [fr] -\NewDocumentEnvironment{GrilleSutom}{ O{} m b }% -{% - \restoreKV[SUTOM]% - \setKV[SUTOM]{#1}% - \StrBefore{\SutomCouleurs}{,}[\SutomCoulFond]% - \StrBetween[1,2]{\SutomCouleurs}{,}{,}[\SutomCoulMalPlacee]% - \StrBehind[2]{\SutomCouleurs}{,}[\SutomBienPlacee]% - \StrLen{#2}[\SutomNbLettres]% - \def\SutomLarg{\fpeval{1.01*\SutomUnit*\SutomNbLettres}}% - \begin{minipage}{\SutomLarg~cm} - \lineskip=0pt% - \parindent=0pt% - % split the answer into letters - \seq_set_split:Nnn \l_wordle_seq {} {#2} - % we need to count the number of times each letter appears in \l_wordle_seq - \prop_clear:N \l_wordle_prop - \tl_map_function:nN {#2} \count_letters_in_wordle:n - % split the solution into words - \regex_split:nnN {\s} {#3} \l_words_seq - % process the words - \seq_map_inline:Nn \l_words_seq - { - \int_zero:N \l_letter_int - \prop_set_eq:NN \l_word_prop \l_wordle_prop - \tl_map_function:nN {##1} \count_letters_in_word:n - \int_zero:N \l_letter_int - \tl_map_function:nN {##1} \write_letters_in_word:n - \par - } -}% -{% - \end{minipage}% +% typeset the word "#1" by putting boxes around each letter +\cs_new_nopar:Npn \wordle__empty_word:n #1 +{ + \tl_map_inline:nn {#1} + { + \int_incr:N \l__wordle_letter_index_int + \wordle__boxed_letter:nn {empty} {##1} + } + % if strict then check lengths + \bool_if:NT \l__wordle_strict_bool + { + \int_while_do:nNnn {\l__wordle_ltter_index_int} < {\seq_count:N\l__wordle_answer_seq} + { + \int_incr:N \l__wordle_letter_index_int + \wordle__boxed_letter:nn {empty} {\c_space_tl} + } + } + \int_incr:N \l__wordle_row_index_int } -%clés [en] -\definecolor{WordleBack}{HTML}{797D7F} -\definecolor{WordleBad}{HTML}{CAB557} -\definecolor{WordleGood}{HTML}{6AAB64} - -\defKV[WORDLE]{% - Colors=\def\SutomCouleurs{#1},% - Rounded=\def\SutomRounded{#1},% - Unit=\def\SutomUnit{#1},% - Fonte=\def\SutomFonte{#1},% - ColorLetters=\def\SutomFonteColor{#1},% - Style=\def\SutomStyle{#1},% - Thickness=\def\SutomWidth{#1},% - BorderColor=\def\SutomBorder{#1} -} +\cs_set_eq:NN \wordle__process_word:n \wordle__mark_word:n -\setKVdefault[WORDLE]{% - Colors={WordleBack,WordleBad,WordleGood},% - Rounded=0.1,% - Unit=1,% - Fonte=\LARGE\bfseries\sffamily,% - CouleurLettres=white,% - Letters=true,% - Style=default,% - Thick=0.25,% - BorderColor=white -} +\NewDocumentEnvironment{wordle}{ O{} m O{} b } +{ + % apply wordle environment options + \WordleSetup{#1} + \begin{tikzpicture} -%environnement [en] -\NewDocumentEnvironment{WordleGrid}{ O{} m b } -{% - \restoreKV[WORDLE]% - \setKV[WORDLE]{#1}% - \StrBefore{\SutomCouleurs}{,}[\SutomCoulFond]% - \StrBetween[1,2]{\SutomCouleurs}{,}{,}[\SutomCoulMalPlacee]% - \StrBehind[2]{\SutomCouleurs}{,}[\SutomBienPlacee]% - \StrLen{#2}[\SutomNbLettres]% - \def\SutomLarg{\fpeval{1.01*\SutomUnit*\SutomNbLettres}}% - \begin{minipage}{\SutomLarg~cm} - \parindent=0pt - \lineskip=0pt - % split the answer into letters - \seq_set_split:Nnn \l_wordle_seq {} {#2} - % we need to count the number of times each letter appears in \l_wordle_seq - \prop_clear:N \l_wordle_prop - \tl_map_function:nN {#2} \count_letters_in_wordle:n - % split the solution into words - \regex_split:nnN {\s} {#3} \l_words_seq - % process the words - \seq_map_inline:Nn \l_words_seq - { - \int_zero:N \l_letter_int - \prop_set_eq:NN \l_word_prop \l_wordle_prop - \tl_map_function:nN {##1} \count_letters_in_word:n - \int_zero:N \l_letter_int - \tl_map_function:nN {##1} \write_letters_in_wordle:n - \par - } -}% -{% - \end{minipage}% -} + % apply any tikz settings -- we need to some expansion trickery to do this + \__wordle_tikzset:n {\l__wordle_tikz_tl} + \__wordle_tikzset:n {/Wordle/tile/.append~style={\l__wordle_depth_tl,\l__wordle_tile_style_tl}} + + % set grid dimension = box size + separation + \dim_set:Nn \l__wordle_grid_dim {\l__wordle_size_dim+\l__wordle_sep_dim} + + % split the answer into letters + \bool_if:NTF \l__wordle_case_sensitive_bool + { \seq_set_split:Nnn \l__wordle_answer_seq {} {#2} } + { \seq_set_split:Nnx \l__wordle_answer_seq {} {\str_uppercase:n {#2}} } + + % count the number of times letters appear in \l__wordle_answer_seq + \prop_clear:N \l__wordle_answer_counts_prop + \tl_map_function:nN {#2} \wordle__count_letters_in_answer:n + + % split the solution into words + \regex_split:nnN {\s} {#4} \l__wordle_solution_seq + + % process the words + \int_zero:N \l__wordle_row_index_int + \seq_map_inline:Nn \l__wordle_solution_seq + { + \int_zero:N \l__wordle_letter_index_int + \wordle__process_word:n {##1} + } + + % if required, add extra required blank rows + \int_while_do:nNnn {\l__wordle_row_index_int} < {\l__wordle_rows_int} + { + \int_zero:N \l__wordle_letter_index_int + \int_while_do:nNnn {\l__wordle_letter_index_int} < {\seq_count:N\l__wordle_answer_seq} + { + \int_incr:N \l__wordle_letter_index_int + \wordle__boxed_letter:nn {empty} {\c_space_tl} + } + \int_incr:N \l__wordle_row_index_int + } + + % finally, execute the optional TikZ commands + #3 + + \end{tikzpicture} +}{} + +% wrapper environment for Gridwordle +\NewDocumentEnvironment{GridWordle}{ O{} m O{} b } + { + \begin{wordle}[#1]{#2}[#3]#4]\end{wordle} + } + {} + +% wrapper environment for GrilleSutom +\NewDocumentEnvironment{GrilleSutom}{ O{} m O{} b } + { + \begin{wordle}[style=sutom,#1]{#2}[#3]#4\end{wordle} + } + {} -\ExplSyntaxOff +\endinput -\endinput
\ No newline at end of file +% ---------------------------------------------------------------- +% CHANGE LOG +% +% Version 0.3 - \wordle@release +% - merged AM & CP packages, adding styles and streamlining options, french keys +% +% Version 0.2 - \wordle@release +% - added documentation and cleaned some of the options +% +% Version 0.1 - 2022-10-01 +% - initial version +% +% ---------------------------------------------------------------- +% +% Copyright (C) 2022-3 by Andrew Mathas <andrew.mathas@gmail.com> +% and Cédric Pierquet cpierquet@outlook.fr +% +% This work may be distributed and/or modified under the +% conditions of the LaTeX Project Public License (LPPL), either +% version 1.3c of this license or (at your option) any later +% version. The latest version of this license is in the file: +% +% http://www.latex-project.org/lppl.txt +% +% This work is "maintained" (as per LPPL maintenance status) by +% Andrew Mathas. +% +% This work consists of the files: +% wordle.sty +% wordle.tex |