% !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{article}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[table,svgnames]{xcolor}
\usepackage{amsmath,amssymb}
\usepackage{PixelArtTikz}
\usepackage{fontawesome5}
\usepackage{enumitem}
\usepackage{tabularray}
\usepackage{multicol}
\usepackage{fancyvrb}
\usepackage{fancyhdr}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\lfoot{\sffamily\small [PixelArtTikz]}
\cfoot{\sffamily\small - \thepage{} -}
\rfoot{\hyperlink{matoc}{\small\faArrowAltCircleUp[regular]}}

%\usepackage{hvlogos}
\usepackage{hologo}
\usepackage{xspace}
\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}}
		{\huge \LaTeX} & & & & &\\
		& {\huge \hologo{pdfLaTeX}} & & & & \\
		& & {\huge \hologo{LuaLaTeX}} & & & \\
		& & & {\huge \TikZ} & & \\
		& & & & {\huge \TeXLive} & \\
		& & & & & {\huge \hologo{MiKTeX}} \\
	\end{tblr}
}

\usepackage{hyperref}
\urlstyle{same}
\hypersetup{pdfborder=0 0 0}
\usepackage[margin=1.5cm]{geometry}
\setlength{\parindent}{0pt}
\definecolor{LightGray}{gray}{0.9}

\def\TPversion{0.1.0}
\def\TPdate{23/01/2023}

\usepackage[most]{tcolorbox}
\tcbuselibrary{minted}
\NewTCBListing{PresentationCode}{ O{blue} m }{%
	sharp corners=downhill,enhanced,arc=12pt,skin=bicolor,%
	colback=#1!1!white,colframe=#1!75!black,colbacklower=white,%
	attach boxed title to top right={yshift=-\tcboxedtitleheight},title=Code \LaTeX,%
	boxed title style={%
		colframe=#1!75!black,colback=#1!15!white,%
		,sharp corners=downhill,arc=12pt,%
	},%
	fonttitle=\color{#1!90!black}\itshape\ttfamily\footnotesize,%
	listing engine=minted,minted style=colorful,
	minted language=tex,minted options={tabsize=4,fontsize=\footnotesize,autogobble},
	#2
}

\newcommand\Cle[1]{{\bfseries\sffamily\textlangle #1\textrangle}}

\begin{document}

\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{PixelArtTikz [en]}}\\
				\\
				{\LARGE PixelArts, with Ti\textit{k}Z}, \\
				\\
				{\LARGE with solution and colors.} \\
			\end{tabular}
			
			\medskip
			
			{\small \texttt{Version \TPversion{} -- \TPdate}}
		\end{center}
	\end{tcolorbox}
\end{minipage}
\end{center}

\vspace{0.5cm}

\begin{center}
	\begin{tabular}{c}
	\texttt{Cédric Pierquet}\\
	{\ttfamily c pierquet -- at -- outlook . fr}\\
	\texttt{\url{https://github.com/cpierquet/PixelArtTikz}}
\end{tabular}
\end{center}

\vspace{0.25cm}

{$\blacktriangleright$~~Commands to display PixelArts.}

\smallskip

{$\blacktriangleright$~~Environment to complete the PixelArt.}

\smallskip

\vspace{1cm}

\begin{center}
\begin{filecontents*}[overwrite]{test1.csv}
-,-,-,-,-,-,4,4,4,4,-,-,-,-,-,-
-,-,-,-,4,4,1,1,1,1,4,4,-,-,-,-
-,-,-,4,1,1,1,1,1,1,1,1,4,-,-,-
-,-,4,1,1,1,1,1,1,1,1,1,1,4,-,-
-,-,4,1,1,1,1,1,1,1,1,1,1,4,-,-
-,4,1,9,9,1,1,1,1,1,1,9,9,1,4,-
-,4,9,9,9,9,4,4,4,4,9,9,9,9,4,-
-,4,9,4,9,9,4,4,4,4,9,4,9,9,4,-
-,4,1,9,9,9,4,4,4,4,9,9,9,1,4,-
-,-,4,1,1,9,4,4,4,4,9,1,1,4,-,-
-,-,4,1,1,1,4,4,4,4,1,1,1,4,-,-
-,-,-,4,1,1,1,4,4,1,1,1,4,-,-,-
-,-,4,3,1,1,1,1,1,1,1,1,3,4,-,-
-,4,6,3,1,1,1,1,1,1,1,1,3,6,4,-
-,4,6,6,1,1,1,1,1,1,1,1,6,6,4,-
-,4,6,6,1,1,1,1,1,1,1,1,6,6,4,-
-,4,6,4,1,1,1,4,4,1,1,1,4,6,4,-
2,2,4,2,4,4,4,2,2,4,4,4,2,4,2,2
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
-,-,-,-,-,4,1,1,1,1,4,-,-,-,-,-
-,-,-,-,-,-,4,1,1,4,-,-,-,-,-,-
-,-,-,-,-,-,-,4,4,-,-,-,-,-,-,-
\end{filecontents*}

\PixlArtTikz[Codes=123469,Style=\ttfamily,Unit=0.35]{test1.csv}
~~
\PixlArtTikz[Codes=123469,Symbols={A,B,C,D,E,F},Symb,Style=\ttfamily,Unit=0.35]{test1.csv}
~~
\PixlArtTikz[Codes=123469,Colors={Red,Brown,Yellow,Black,Blue,White},Correction,Unit=0.35]{test1.csv}
\end{center}

\vspace{0.5cm}

%\hfill{}\textit{Merci aux membres du groupe \faFacebook{} du \og Coin \LaTeX{} \fg{} pour leur aide et leurs idées !}

%\hfill{}\textit{Merci à Denis Bitouzé et à Patrick Bideault pour leurs retours et idées !}

\vfill

\hrule

\medskip

\TableauDocumentation

\medskip

\hrule

\medskip

\newpage

\phantomsection
\hypertarget{matoc}{}

\tableofcontents

\newpage

\part{Introduction}

\section{The package PixelArtTikz}

\subsection{Introduction}

The idea is to \textit{propose}, within a Ti\textit{k}Z environment, a macro to generate PixelArt.

Datas are \textit{red} by a \textsf{csv} file, already created and placed into the folder of the \textsf{tex} file, or directly created by \textsf{filecontents}.

\medskip

Some advices about the \textsf{cvs} file :

\begin{itemize}
	\item the \textsf{csv} file must use "," as separator ;
	\item empty cases are coded by "\texttt{-}".
\end{itemize}

\begin{PresentationCode}{listing only}
\begin{filecontents*}{filename.csv}
	A,B,C,D
	A,B,D,C
	B,A,C,D
	B,A,D,C
\end{filecontents*}
\end{PresentationCode}

While compiling, the file \textsf{filename.csv} will be created, and the option \Cle{[overwrite]} will propagate the modifications !

\subsection{Loading of the package, and option}

The \textit{needed} package is here \textsf{csvsimple}, in order to read the \textsf{csv} file.

It's available for \hologo{LaTeX2e} or for \hologo{LaTeX3}. By default, \textsf{PixelArtTikz} loads it for \hologo{LaTeX3}, but an \textit{option} is available to work with \hologo{LaTeX2e}.

\smallskip

The option \Cle{[csvii]} forces the usage of \hologo{LaTeX2e}.

\begin{PresentationCode}{listing only}
\usepackage{PixelArtTikz}                     %package latex3
%which loads
%\RequirePackage{expl3}
%\RequirePackage[l3]{csvsimple}

\usepackage[csvii]{PixelArtTikz}              %package latex2
%which loads
%\RequirePackage[legacy]{csvsimple}
\end{PresentationCode}

\subsection{Used packages}

It's fully copatible with usuals compilations, such as \textsf{latex}, \textsf{pdflatex}, \textsf{lualatex} or \textsf{xelatex}.

\medskip

It loads the packages and libraries :

\begin{itemize}
	\item \texttt{tikz}, \texttt{xintexpr} et \texttt{xinttools};
	\item \texttt{xstring}, \texttt{xparse}, \texttt{simplekv} and \texttt{listofitems}.
\end{itemize}

\pagebreak

\subsection{Macros and environment}

There's two ways to create PixelArt :

\begin{itemize}
	\item by an independent macro ;
	\item by a Ti\textit{k}Z environment in order to put code after.
\end{itemize}

\begin{PresentationCode}{listing only}
%Independent macro
\PixlArtTikz[keys]<options tikz>{file.csv}

%Semi-independent macro, in a tiks environment
\PixlArtTikz*[keys]{file.csv}

%environment
\begin{EnvPixlArtTikz}[keys]<options tikz>{file.csv}
	%tikz code
\end{EnvPixlArtTikz}
\end{PresentationCode}

For the colors, its depending from the loaded packages.

\smallskip

This documentation was compiled with \textsf{xcolor}, with \Cle{[table,svgnames]} options.

%%\section{Petit aparté sur les fichiers csv}
%%
%%\textsf{CSV} désigne un format de fichiers dont le rôle est de présenter des données séparées par des virgules. Il s'agit d'une manière simplifiée d'afficher des données afin de les rendre transmissibles d'un programme à un autre.
%%
%%\smallskip
%%
%%Dans notre cas, le fichier \textsf{csv} contiendra les \textit{codes} qui seront analysés un par un et ligne par ligne pour avoir le rendu par \textit{code}, \textit{symbole} ou \textit{couleur}.
%%
%%\medskip
%%
%%Il \underline{doit} être préparé avec des caractères (codes) \textit{simples} pour que le code de \textsf{PixelArtTikz} puisse fonctionner.
%
\pagebreak

\part{Macros and environment}

\section{Main macro}

\subsection{Example}

The macro \texttt{\textbackslash PixlArtTikz} needs :

\begin{itemize}
	\item the file \textsf{csv} ;
	\item the list (by a string) of codes used in the file \textsf{csv} (eg \texttt{234679} or \texttt{ABCDJK}\ldots);
	\item the list of symbols (if needed) to print in the cases, eg \texttt{25,44,12} or \texttt{AA,AB,AC} ;
	\item the list of colors (for the correction), same order as the codes.
\end{itemize}

We can begin by creating the file \textsf{csv}, directly within the \textsf{tex} code, or with a external file.

\begin{PresentationCode}{}
%creation of the csv
\begin{filecontents*}[overwrite]{base.csv}
	A,B,C,D
	A,B,D,C
	B,A,D,C
	C,A,B,D
\end{filecontents*}
\end{PresentationCode}

\begin{PresentationCode}{}
%instructions and pixelarts
\begin{center}
	\begin{tblr}{colspec={*{4}{Q[1.25cm,c,m]}},hlines,vlines,rows={1.15em}}
		\SetCell[c=4]{c} Instructions & & & \\
		A & B & C & D \\
		45 & 22 & 1 & 7 \\
		Black & Green & Yellow & Red \\
	\end{tblr}
\end{center}

\PixlArtTikz[Codes=ABCD,Style=\large\sffamily,Unit=0.85]{base.csv}
~~
\PixlArtTikz[Codes=ABCD,Symbols={45,22,1,7},Symb,Style=\large\sffamily,Unit=0.85]{base.csv}
~~
\PixlArtTikz[Codes=ABCD,Colors={black,green,yellow,red},Correction,Unit=0.85]{base.csv}
~~
\PixlArtTikz[Codes=ABCD,Colors={black,green,yellow,red},Correction,Border=false,Unit=0.85]{base.csv}
\end{PresentationCode}

\pagebreak

\subsection{Options an keys}

\begin{PresentationCode}{listing only}
\PixlArtTikz[keys]<options tikz>{file.csv}
\end{PresentationCode}

The first argument, \textit{optional} and between \texttt{[...]} proposes the \textsf{keys} :

\begin{itemize}
	\item the key \Cle{Codes} with the \textit{string} of \textit{simple} codes of the \textsf{csv} file ;
	\item the key \Cle{Colors} with the \textit{list} of colors ;
	\item the key \Cle{Symbols} with the \textit{optional list} of alt. symbols for the cases ;
	\item the boolean \Cle{Correction} to color the PixelArt ;\hfill{}default \textsf{false}
	\item the boolean \Cle{Symb} to print the symbols ;\hfill{}default \textsf{false}
	\item the boolean \Cle{Border} to print borders of the cases ;\hfill{}default \textsf{true}
	\item the key \Cle{Style} to specifythe style of the text. \hfill{}default \textsf{\textbackslash scriptsize}
\end{itemize}

The second argument, \textit{optional} and between \texttt{<...>} are options -- in  Ti\textit{k}Z -- to parse to the environment which create the PixelArt.

\medskip

The third argument, \textit{mandatory}, is the filename of the \textsf{csv}.


\begin{PresentationCode}{}
%creation of the csv
\begin{filecontents*}[overwrite]{test1.csv}
	-,-,-,-,-,-,4,4,4,4,-,-,-,-,-,-
	-,-,-,-,4,4,1,1,1,1,4,4,-,-,-,-
	-,-,-,4,1,1,1,1,1,1,1,1,4,-,-,-
	-,-,4,1,1,1,1,1,1,1,1,1,1,4,-,-
	-,-,4,1,1,1,1,1,1,1,1,1,1,4,-,-
	-,4,1,9,9,1,1,1,1,1,1,9,9,1,4,-
	-,4,9,9,9,9,4,4,4,4,9,9,9,9,4,-
	-,4,9,4,9,9,4,4,4,4,9,4,9,9,4,-
	-,4,1,9,9,9,4,4,4,4,9,9,9,1,4,-
	-,-,4,1,1,9,4,4,4,4,9,1,1,4,-,-
	-,-,4,1,1,1,4,4,4,4,1,1,1,4,-,-
	-,-,-,4,1,1,1,4,4,1,1,1,4,-,-,-
	-,-,4,3,1,1,1,1,1,1,1,1,3,4,-,-
	-,4,6,3,1,1,1,1,1,1,1,1,3,6,4,-
	-,4,6,6,1,1,1,1,1,1,1,1,6,6,4,-
	-,4,6,6,1,1,1,1,1,1,1,1,6,6,4,-
	-,4,6,4,1,1,1,4,4,1,1,1,4,6,4,-
	2,2,4,2,4,4,4,2,2,4,4,4,2,4,2,2
	2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
	2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
	-,-,-,-,-,4,1,1,1,1,4,-,-,-,-,-
	-,-,-,-,-,-,4,1,1,4,-,-,-,-,-,-
	-,-,-,-,-,-,-,4,4,-,-,-,-,-,-,-
\end{filecontents*}
\end{PresentationCode}

\begin{PresentationCode}{}
%simple codes
%empty case with -
\PixlArtTikz[Codes=123469,Style=\ttfamily,Unit=0.35]{test1.csv}
~~
\PixlArtTikz[Codes=123469,Colors={Red,Brown,Yellow,Black,Blue,White},Correction,Unit=0.35]{test1.csv}
~~
\PixlArtTikz[Codes=123469,Colors={Red,Brown,Yellow,Black,Blue,White},Correction,Unit=0.35,Border=false]{test1.csv}
\end{PresentationCode}

\pagebreak

In the following example, les \textit{symbols} to print can't be used for the \textit{codes}, so we can use the keys \Cle{Symbols} and \Cle{Symb} to bypass this limitation.

\begin{PresentationCode}{}
%symbols associated to codes

\begin{filecontents*}[overwrite]{cap.csv}
	-,-,-,-,-,-,-,-,D,-,D,-,D,-,-,-,-,-,-,-,-,-
	-,D,D,-,-,-,-,D,D,D,D,D,D,-,-,D,D,D,D,-,-,-
	D,-,-,D,-,D,D,F,F,F,F,F,F,D,D,-,-,-,-,D,-,-
	-,D,-,-,D,F,F,F,-,-,F,F,F,F,F,D,-,D,D,-,-,-
	-,-,D,D,F,F,F,-,F,F,-,F,F,F,F,F,D,D,-,-,-,-
	-,-,-,D,F,F,F,F,F,F,F,F,F,F,F,F,D,-,-,-,-,-
	-,-,-,D,F,J,J,J,J,J,J,J,F,F,F,F,D,-,-,-,-,-
	-,-,-,D,J,-,-,-,J,-,-,-,J,J,F,F,D,-,-,-,-,-
	-,-,-,D,J,-,D,-,J,-,D,-,J,J,B,B,D,-,-,-,-,-
	-,-,-,D,J,-,-,-,J,-,-,-,J,J,B,B,D,-,-,-,-,-
	-,-,-,D,C,J,J,J,J,J,J,J,J,C,C,C,D,-,-,-,-,-
	-,-,-,D,C,C,C,C,C,C,C,C,C,C,C,D,D,D,-,-,-,-
	-,-,-,D,C,C,C,D,D,D,D,D,D,C,D,A,A,A,D,-,-,-
	-,-,-,D,F,C,C,C,C,C,C,C,C,D,A,-,-,-,A,D,-,-
	-,-,-,D,F,C,F,C,C,C,C,F,D,A,-,A,A,A,-,A,D,-
	-,-,D,C,F,F,F,F,C,C,F,D,A,-,A,F,F,F,A,-,A,D
	-,-,D,C,F,F,F,F,F,F,F,D,A,-,A,F,-,F,A,-,A,D
	-,-,D,A,D,-,A,-,A,-,A,D,A,-,A,F,F,F,A,-,A,D
	-,-,-,D,D,-,A,-,A,-,A,-,D,A,-,A,A,A,-,A,D,-
	-,-,-,-,-,D,D,F,D,D,D,D,F,D,A,-,-,-,A,D,-,-
	-,-,-,-,-,-,D,A,D,-,-,D,-,-,D,A,A,A,D,-,-,-
	-,-,-,-,-,-,D,D,D,-,-,D,D,D,D,D,D,D,-,-,-,-
\end{filecontents*}

\PixlArtTikz[Codes=ABCDFJ,Symbols={1,2,3,4,6,10},Symb,Style=\tiny\sffamily,Unit=0.35]{cap.csv}
~~
\PixlArtTikz[Codes=ABCDFJ,Colors={Red,Brown,Yellow,Black,Blue,Gray},Correction,Unit=0.35]{cap.csv}
\end{PresentationCode}

\pagebreak

\subsection{Starred macro}

The starred \textit{étoilée} macro \texttt{\textbackslash PixlArtTikz*} is to be integrated within an environment already created. It cas be usefull to add code after the PixelArt.

\smallskip

In this case :

\begin{itemize}
	\item the \textit{optional} between \texttt{<...>} is useless ;
	\item the key \Cle{Unit} is useless too (uints can be configured in the environment !)
\end{itemize}

\begin{PresentationCode}{}
\begin{center}
	\begin{tikzpicture}[scale=0.5]
		%grid to show positionning
		\draw[very thin,gray,xstep=1,ystep=1] (0,0) grid (17,-24) ;
		\foreach \x in {0,1,...,17} \draw[very thin,gray] (\x,-3pt)--(\x,3pt)%
		node[above,font=\scriptsize\sffamily] {\x} ;
		\foreach \y in {0,-1,...,-24} \draw[very thin,gray] (3pt,\y)--(-3pt,\y)%
		node[left,font=\scriptsize\sffamily] {\y} ;
		%le PixelArt
		\PixlArtTikz*[Codes=123469,Colors={Red,Brown,Yellow,Black,Blue,White},Correction]{test1.csv}
		%added code
		\filldraw[Blue] (14,-1) circle[radius=1] ;
		\filldraw[Yellow] (14,-1) circle[radius=0.8] ;
		\draw[ForestGreen,very thick,<-,>=latex] (15,-1) to[bend left=30] (18,-2)%
		node[right,font=\scriptsize\sffamily] {Code Ti\textit{k}Z} ;
	\end{tikzpicture}
\end{center}
\end{PresentationCode}

\pagebreak

\section{PixelArt environment}

\subsection{Usage}

The package \textsf{PixelArtTikz} proposes an environment to create a PixelArt, and to add code after.

\begin{itemize}
	\item The environment is created within Ti\textit{k}Z and added code is to give in Ti\textit{k}Z !
	\item The added code will be print "above" the PixelArt !
\end{itemize}

\begin{PresentationCode}{listing only}
\begin{EnvPixlArtTikz}[keys]<options tikz>{filename.csv}
	%tikz code(s)
\end{EnvPixlArtTikz}
\end{PresentationCode}

The first argument, \textit{optional} and between \texttt{[...]} proposes the \textsf{keys} :

\begin{itemize}
	\item the key \Cle{Codes} with the \textit{string} of \textit{simple} codes of the \textsf{csv} file ;
	\item the key \Cle{Colors} with the \textit{list} of colors ;
	\item the key \Cle{Symbols} with the \textit{optional list} of alt. symbols for the cases ;
	\item the boolean \Cle{Correction} to color the PixelArt ;\hfill{}default \textsf{false}
	\item the boolean \Cle{Symb} to print the symbols ;\hfill{}default \textsf{false}
	\item the boolean \Cle{Border} to print borders of the cases ;\hfill{}default \textsf{true}
	\item the key \Cle{Style} to specifythe style of the text. \hfill{}default \textsf{\textbackslash scriptsize}
\end{itemize}

The second argument, \textit{optional} and between \texttt{<...>} are options -- in  Ti\textit{k}Z -- to parse to the environment which create the PixelArt.

\medskip

The third argument, \textit{mandatory}, is the filename of the \textsf{csv}.

\subsection{Exemple}

The symbols are at the nodes $(c\,;\,-l)$ where $l$ and $c$ are the row and column  of the data in the \textsf{csv} file.

\begin{PresentationCode}{}
\begin{center}
	\begin{EnvPixlArtTikz}%
			[Codes=123469,Colors={Red,Brown,Yellow,Black,Blue,White},Correction,Unit=0.25]
			{test1.csv}
		\filldraw[Blue] (14,-1) circle[radius=1] ;
		\filldraw[Yellow] (14,-1) circle[radius=0.8] ;
		\draw[ForestGreen,very thick,<-,>=latex] (15,-1) to[bend left=30] (18,-2)%
		node[right,font=\scriptsize\sffamily] {Ti\textit{k}Z code} ;
	\end{EnvPixlArtTikz}
\end{center}
\end{PresentationCode}

\newpage

\part{Historique}

\verb|v0.1.0|~:~~~~Initial version

\end{document}