From 8e64fc98a1773bc22a0f010f106d56a028e48597 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Sun, 23 Jul 2023 03:01:14 +0000 Subject: CTAN sync 202307230301 --- .../contrib/macros/mpchess/doc/mpchess-doc-en.pdf | Bin 862646 -> 1000703 bytes .../contrib/macros/mpchess/doc/mpchess-doc-en.tex | 109 ++++++++++++++++++--- .../contrib/macros/mpchess/doc/mpchess-doc-fr.pdf | Bin 867272 -> 1005336 bytes .../contrib/macros/mpchess/doc/mpchess-doc-fr.tex | 103 ++++++++++++++++--- .../macros/mpchess/doc/mpchess-preamble.tex | 2 +- .../contrib/macros/mpchess/fonts/mpchessfont.ttf | Bin 38292 -> 38292 bytes .../macros/mpchess/metapost/mpchess-pieces.mp | 18 ++-- .../contrib/macros/mpchess/metapost/mpchess.mp | 82 ++++++++++++++-- 8 files changed, 272 insertions(+), 42 deletions(-) (limited to 'graphics/metapost') diff --git a/graphics/metapost/contrib/macros/mpchess/doc/mpchess-doc-en.pdf b/graphics/metapost/contrib/macros/mpchess/doc/mpchess-doc-en.pdf index 421fa6b060..741544029e 100644 Binary files a/graphics/metapost/contrib/macros/mpchess/doc/mpchess-doc-en.pdf and b/graphics/metapost/contrib/macros/mpchess/doc/mpchess-doc-en.pdf differ diff --git a/graphics/metapost/contrib/macros/mpchess/doc/mpchess-doc-en.tex b/graphics/metapost/contrib/macros/mpchess/doc/mpchess-doc-en.tex index bcc74e5003..5ad5abdb1a 100644 --- a/graphics/metapost/contrib/macros/mpchess/doc/mpchess-doc-en.tex +++ b/graphics/metapost/contrib/macros/mpchess/doc/mpchess-doc-en.tex @@ -68,7 +68,7 @@ } \vfill \begin{center} - Version 0.6, 2023, April, 26th \\ + Version 0.7, 2023, July, 20th \\ \url{https://plmlab.math.cnrs.fr/mchupin/mpchess} \end{center} %% == Page de garde ==================================================== @@ -293,12 +293,15 @@ command: \item[\meta{string}] can be: \begin{itemize} \item \lstinline+"BlueLichess"+ (default); -\item \lstinline+"BrownLichess"+ ; +\item \lstinline+"BrownLichess"+; +\item \lstinline+"GreenLichess"+; +\item \lstinline+"PinkPyramidalLichess"+; +\item \lstinline+"Wood"+; \item or \lstinline+"Classical"+. \end{itemize} \end{description} -The following examples show the results obtained from each theme: +The following example shows the results obtained from \lstinline+"BrownLichess"+: \begin{ExempleMP} input mpchess beginfig(0); @@ -307,21 +310,65 @@ init_backboard; draw backboard; endfig; \end{ExempleMP} -\begin{ExempleMP} -input mpchess -beginfig(0); -set_color_theme("Classical"); -init_backboard; -draw backboard; -endfig; -\end{ExempleMP} -The two color themes provided borrow the colors of the Lichess themes. +The table~\ref{tab:color} shows the different results of the different themes. + +\begin{table} + \centering +\begin{tabular}{cc} + +\lstinline+"GreenLichess"+ theme&\lstinline+"Classical"+ theme\\ +\begin{mplibcode} + input mpchess + beginfig(0); + init_chessboard; + set_backboard_width(4cm); + set_color_theme("GreenLichess"); + init_backboard; + draw backboard; + endfig; +\end{mplibcode} +&\begin{mplibcode} + input mpchess + beginfig(0); + init_chessboard; + set_backboard_width(4cm); + set_color_theme("Classical"); + init_backboard; + draw backboard; + endfig; +\end{mplibcode}\\ +\lstinline+"PinkPyramidalLichess"+ theme& \lstinline+"Wood"+ theme\\ +\begin{mplibcode} + input mpchess + beginfig(0); + init_chessboard; + set_backboard_width(4cm); + set_color_theme("PinkPyramidalLichess"); + init_backboard; + draw backboard; + endfig; +\end{mplibcode}& +\begin{mplibcode} + input mpchess + beginfig(0); + init_chessboard; + set_backboard_width(4cm); + set_color_theme("Wood"); + init_backboard; + draw backboard; + endfig; +\end{mplibcode}\\ +\end{tabular} +\caption{The different color themes provided by \mpchess.}\label{tab:color} +\end{table} + \subsubsection{Configuring a Personal Color Theme} -A color theme is really just the definition of two colors. +\paragraph{Colors.} +A color theme is the definition of two colors. These can be defined with the following commands\footnote{Attention, in version 0.6, \lstinline+set_white_color+ became \lstinline+set_white_squares_color+ and \lstinline+set_black_color+ became @@ -341,6 +388,40 @@ init_backboard; draw backboard; endfig; \end{ExempleMP} + +\paragraph{Color Types.} + +To choose a type, you can use the following command: + +\commande|set_board_type(«string»)|\index{set_board_type@\lstinline+set_board_type+}\smallskip + + +Three types of coloring are available: + +\begin{description} + \item[\meta{string}] can be: +\begin{itemize} +\item \lstinline+"flat"+, simple flat coloring (default); +\item \lstinline+"pyramidal"+, Lichess \emph{pyramidal} coloring; +\item \lstinline+"wood"+, wood imitation. +\end{itemize} +\end{description} + +Here is an example coupling color and type definitions. + +\begin{ExempleMP} +input mpchess +beginfig(0); +set_white_squares_color((0.9,0.8,0.8)); +set_black_squares_color((0.7,0.6,0.6)); +set_board_type("wood"); +init_backboard; +draw backboard; +endfig; +\end{ExempleMP} + + + \subsection{Display Coordinates} You may have noticed in the various examples that by default, the coordinates are, as on the Lichess site, written in small letters inside the boxes. @@ -1367,6 +1448,8 @@ endfig; \section{History} \begin{description} +\item[v0.7, juillet 2023:] Black knight adjustment, adding color board themes (\lstinline+GreenLichess+, \lstinline+PinkPyramidalLichess+, +\lstinline+Wood+ with color type (\lstinline+set_board_type+). \item[v0.6, April 26, 2023:] Fixed bugs concerning castling management, and moves ambiguities in \textsc{pgn} format. Changed \lstinline+set_white_color+ to diff --git a/graphics/metapost/contrib/macros/mpchess/doc/mpchess-doc-fr.pdf b/graphics/metapost/contrib/macros/mpchess/doc/mpchess-doc-fr.pdf index fd467b6595..bcca5a85f9 100644 Binary files a/graphics/metapost/contrib/macros/mpchess/doc/mpchess-doc-fr.pdf and b/graphics/metapost/contrib/macros/mpchess/doc/mpchess-doc-fr.pdf differ diff --git a/graphics/metapost/contrib/macros/mpchess/doc/mpchess-doc-fr.tex b/graphics/metapost/contrib/macros/mpchess/doc/mpchess-doc-fr.tex index 2ee8714da4..db6a5f8b86 100644 --- a/graphics/metapost/contrib/macros/mpchess/doc/mpchess-doc-fr.tex +++ b/graphics/metapost/contrib/macros/mpchess/doc/mpchess-doc-fr.tex @@ -71,7 +71,7 @@ } \vfill \begin{center} - Version 0.6, 26 avril 2023 \\ + Version 0.7, 20 juillet 2023 \\ \url{https://plmlab.math.cnrs.fr/mchupin/mpchess} \end{center} %% == Page de garde ==================================================== @@ -289,6 +289,9 @@ Plusieurs thèmes de couleurs sont accessibles. Pour choisir un thème de couleu \begin{itemize} \item \lstinline+"BlueLichess"+ (thème par défaut); \item \lstinline+"BrownLichess"+ ; +\item \lstinline+"GreenLichess"+; +\item \lstinline+"PinkPyramidalLichess"+; +\item \lstinline+"Wood"+; \item ou \lstinline+"Classical"+. \end{itemize} \end{description} @@ -302,20 +305,64 @@ init_backboard; draw backboard; endfig; \end{ExempleMP} -\begin{ExempleMP} -input mpchess -beginfig(0); -set_color_theme("Classical"); -init_backboard; -draw backboard; -endfig; -\end{ExempleMP} -Les deux thèmes colorés fournis empruntent les couleurs des thèmes de Lichess. +Le tableau~\ref{tab:color} montre les résultats des différents thèmes fournis +par \mpchess. + +\begin{table} + \centering +\begin{tabular}{cc} + +Thème \lstinline+"GreenLichess"+&Thème \lstinline+"Classical"+\\ +\begin{mplibcode} + input mpchess + beginfig(0); + init_chessboard; + set_backboard_width(4cm); + set_color_theme("GreenLichess"); + init_backboard; + draw backboard; + endfig; +\end{mplibcode} +&\begin{mplibcode} + input mpchess + beginfig(0); + init_chessboard; + set_backboard_width(4cm); + set_color_theme("Classical"); + init_backboard; + draw backboard; + endfig; +\end{mplibcode}\\ +Thème \lstinline+"PinkPyramidalLichess"+&Thème \lstinline+"Wood"+\\ +\begin{mplibcode} + input mpchess + beginfig(0); + init_chessboard; + set_backboard_width(4cm); + set_color_theme("PinkPyramidalLichess"); + init_backboard; + draw backboard; + endfig; +\end{mplibcode}& +\begin{mplibcode} + input mpchess + beginfig(0); + init_chessboard; + set_backboard_width(4cm); + set_color_theme("Wood"); + init_backboard; + draw backboard; + endfig; +\end{mplibcode}\\ +\end{tabular} +\caption{Les différents thèmes de couleur fournis par \mpchess.}\label{tab:color} +\end{table} \subsubsection{Configuration d’un thème personnel} -Un thème de couleur est en réalité simplement la définition de deux couleurs. +\paragraph{Couleurs.} +Un thème de couleur conciste en la définition de deux couleurs. Celles-ci peuvent se définir avec les commandes suivantes \footnote{Attention, lors du passage à la version 0.6, \lstinline+set_white_color+ est devenu \lstinline+set_white_squares_color+ et \lstinline+set_black_color+ est devenu @@ -335,6 +382,37 @@ init_backboard; draw backboard; endfig; \end{ExempleMP} + +\paragraph{Type de coloriage.} + + +On peut choisir un type de coloriage avec la commande suivante: + +\commande|set_board_type(«string»)|\index{set_board_type@\lstinline+set_board_type+}\smallskip + +Les trois types de coloriage fournis par \mpchess{} se choisissent avec +\begin{description} + \item[\meta{string}] qui peut valoir: +\begin{itemize} +\item \lstinline+"flat"+, coloriage à plat (défaut); +\item \lstinline+"pyramidal"+, coloriage \emph{pyramidal} à la Lichess; +\item \lstinline+"wood"+, imitation bois. +\end{itemize} +\end{description} + +Voici un exemple de paramétrage de couleur et de type de coloriage. + +\begin{ExempleMP} +input mpchess +beginfig(0); +set_white_squares_color((0.9,0.8,0.8)); +set_black_squares_color((0.7,0.6,0.6)); +set_board_type("wood"); +init_backboard; +draw backboard; +endfig; +\end{ExempleMP} + \subsection{Affichage des coordonnées} Vous avez pu constater dans les divers exemples que par défaut, les coordonnées @@ -1346,6 +1424,9 @@ endfig; \section{Historique} \begin{description} +\item[v0.7, juillet 2023:] Ajustement du cavalier noir, ajout de thèmes +d'échiquier (\lstinline+GreenLichess+, \lstinline+PinkPyramidalLichess+, +\lstinline+Wood+ avec des types de coloriage (\lstinline+set_board_type+). \item[v0.6, avril 2023:] Corrections de bugs concernant la gestion des roques, et des ambiguïtés de pièces pour les déplacements sous format \textsc{pgn}. Changement de \lstinline+set_white_color+ en diff --git a/graphics/metapost/contrib/macros/mpchess/doc/mpchess-preamble.tex b/graphics/metapost/contrib/macros/mpchess/doc/mpchess-preamble.tex index 62e5ad2413..6a7f11d747 100644 --- a/graphics/metapost/contrib/macros/mpchess/doc/mpchess-preamble.tex +++ b/graphics/metapost/contrib/macros/mpchess/doc/mpchess-preamble.tex @@ -97,7 +97,7 @@ set_no_coords,set_white_view,set_black_view, set_white_player,set_black_player,set_pieces_theme,set_players_side,init_chessboard,set_empty_chessboard,add_white_pieces,add_black_pieces,clear_areas,clear_files,clear_ranks,clear_squares,build_chessboard_from_fen,build_chessboards_from_pgn,clear_chessboard, color_square,draw_arrows,draw_circles,draw_comment,draw_crosses,get_halfmove_number,get_totalmove_number, - reset_mpchess,set_black_to_move,set_last_move_color,set_comment_color,set_white_to_move,set_whos_to_move,show_last_move,unset_whos_to_move,set_arrow_width,clip_chessboard,build_chessboard_from_fen_file,build_chessboard_from_pgn_file,draw_black_main_lines,draw_black_main_lines_step,draw_white_main_lines,draw_white_main_lines_step,set_main_lines_color,set_possible_moves_color,show_possible_moves,show_possible_moves_step,hide_coordinates,hide_whos_to_move,set_black_squares_color,set_coordinates_font,set_coordinates_position,set_white_squares_color,show_coordinates,show_whos_to_move}, + reset_mpchess,set_black_to_move,set_last_move_color,set_comment_color,set_white_to_move,set_whos_to_move,show_last_move,unset_whos_to_move,set_arrow_width,clip_chessboard,build_chessboard_from_fen_file,build_chessboard_from_pgn_file,draw_black_main_lines,draw_black_main_lines_step,draw_white_main_lines,draw_white_main_lines_step,set_main_lines_color,set_possible_moves_color,show_possible_moves,show_possible_moves_step,hide_coordinates,hide_whos_to_move,set_black_squares_color,set_coordinates_font,set_coordinates_position,set_white_squares_color,show_coordinates,show_whos_to_move,set_board_type}, keywordstyle=\color{darkred}, classoffset=2,% frame=tb morekeywords={backboard,chessboard,chessboard_step}, diff --git a/graphics/metapost/contrib/macros/mpchess/fonts/mpchessfont.ttf b/graphics/metapost/contrib/macros/mpchess/fonts/mpchessfont.ttf index 11f0bef692..000d741430 100644 Binary files a/graphics/metapost/contrib/macros/mpchess/fonts/mpchessfont.ttf and b/graphics/metapost/contrib/macros/mpchess/fonts/mpchessfont.ttf differ diff --git a/graphics/metapost/contrib/macros/mpchess/metapost/mpchess-pieces.mp b/graphics/metapost/contrib/macros/mpchess/metapost/mpchess-pieces.mp index 0d6aa5ea24..7a5de31b95 100644 --- a/graphics/metapost/contrib/macros/mpchess/metapost/mpchess-pieces.mp +++ b/graphics/metapost/contrib/macros/mpchess/metapost/mpchess-pieces.mp @@ -51,14 +51,14 @@ linejoin := mitered; fill (19.250000,7.917970)..controls (22.527300,7.917970) and (22.671900,5.488280)..(22.671900,3.679690) --(5.632810,3.679690)..controls (5.632810,5.519530) and (5.777340,7.917970)..(9.054690,7.917970) --cycle; -fill (19.257799,9.101560)--(9.082030,9.101560)..controls (9.218750,12.449200) and (13.515600,14.226600)..(13.710900,15.843800) - ..controls (13.906300,17.457001) and (13.031300,17.875000)..(13.031300,17.875000) - ..controls (13.031300,17.875000) and (12.433600,15.933600)..(11.668000,15.535200) - ..controls (10.902300,15.136700) and (9.125000,14.765600)..(9.125000,14.765600) - ..controls (9.125000,14.765600) and (7.875000,13.789100)..(7.140630,13.855500) - ..controls (6.406250,13.925800) and (5.773440,15.449200)..(5.773440,15.449200) - --(8.273440,18.898399)--(9.539060,21.347700)--(10.734400,22.476601) - --(11.246100,24.136700)--(12.683600,22.675800)..controls (20.597700,22.675800) and (22.316401,13.824200)..(19.257799,9.101560) +fill (18.890600,9.101560)--(9.410160,9.101560)..controls (9.539060,12.566400) and (13.539100,14.410200)..(13.722700,16.085899) + ..controls (13.906300,17.757799) and (13.089800,18.187500)..(13.089800,18.187500) + ..controls (13.089800,18.187500) and (12.531300,16.175800)..(11.820300,15.765600) + ..controls (11.109400,15.355500) and (9.449220,14.968800)..(9.449220,14.968800) + ..controls (9.449220,14.968800) and (8.289060,13.957000)..(7.601560,14.027300) + ..controls (6.917970,14.097700) and (6.332030,15.675800)..(6.332030,15.675800) + --(8.656250,19.253901)--(9.835940,21.785200)--(10.949200,22.957001) + --(11.425800,24.675800)--(12.765600,23.164101)..controls (20.140600,23.164101) and (21.738300,13.992200)..(18.890600,9.101560) --cycle; ); @@ -363,4 +363,4 @@ draw (19.609400,21.625000)--(17.171900,22.253901)--(16.644501,21.011700) --(8.683590,21.382799)..controls (8.683590,21.382799) and (8.660160,17.046900)..(9.914060,17.070299) --(18.378901,17.070299)..controls (19.628901,17.070299) and (19.609400,21.625000)..(19.609400,21.625000) --cycle; -); \ No newline at end of file +); diff --git a/graphics/metapost/contrib/macros/mpchess/metapost/mpchess.mp b/graphics/metapost/contrib/macros/mpchess/metapost/mpchess.mp index d16c821493..3883ca0bc3 100644 --- a/graphics/metapost/contrib/macros/mpchess/metapost/mpchess.mp +++ b/graphics/metapost/contrib/macros/mpchess/metapost/mpchess.mp @@ -1,8 +1,8 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% mpchess.mp %% %% draw chessboards with metapost %% -%% chupin@ceremade.dauphine.fr %% -%% Version 0.6 (avril 2023) %% +%% notezik@gmail.com %% +%% Version 0.7 (juillet 2023) %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % This work may be distributed and/or modified under the conditions of @@ -21,6 +21,7 @@ input mpchess-skak; % piece of skak package input mpchess-chessboard; input mpchess-pgn; input mpchess-fen; +input fiziko; if not known mplib: input latexmp fi; @@ -198,13 +199,54 @@ picture _blackSquarePic, _whiteSquarePic; picture _blackSquareColoredPic, _whiteSquareColoredPic; picture _blackSquareClassicalPic, _whiteSquareClassicalPic; +def _wood_draw(expr N,d,p,c,_SquareUnit)= + save _up_wood,_down_wood; + path _up_wood,_down_wood; + fill unitsquare scaled _SquareUnit withcolor c; + for i=1 upto N-1: + _up_wood:=(i/N+uniformdeviate(d),0.0+0.5p/_SquareUnit)*_SquareUnit--(i/N,0.0+0.5p/_SquareUnit)*_SquareUnit--(i/N,0.5)*_SquareUnit--(i/N+uniformdeviate(d),0.7+uniformdeviate(.3)-p/_SquareUnit)*_SquareUnit--cycle; + fill _up_wood withcolor ((0.9+uniformdeviate + .25)[white,c]); + _down_wood:=((i-1)/N+uniformdeviate(d)+0.5/N,1.0-0.5p/_SquareUnit)*_SquareUnit--((i-1)/N+0.5/N,1.0-0.5p/_SquareUnit)*_SquareUnit--((i-1)/N+0.5/N,0.5)*_SquareUnit--((i-1)/N+uniformdeviate(d)+0.5/N,0.3-uniformdeviate(.3)+p/_SquareUnit)*_SquareUnit--cycle; + fill _down_wood withcolor ((0.9+uniformdeviate + .25)[white,c]); + endfor; +enddef; + def _buildColoredSquare(expr _SquareUnit,_BlackColor,_WhiteColor)= - _blackSquarePic:=image( - fill unitsquare scaled _SquareUnit withcolor _BlackColor; - ); - _whiteSquarePic:=image( - fill unitsquare scaled _SquareUnit withcolor _WhiteColor; - ); + if(_chess_board_type="flat"): + _blackSquarePic:=image( + fill unitsquare scaled _SquareUnit withcolor _BlackColor; + ); + _whiteSquarePic:=image( + fill unitsquare scaled _SquareUnit withcolor _WhiteColor; + ); + elseif(_chess_board_type="pyramidal"): + _blackSquarePic:=image( + fill unitsquare scaled _SquareUnit withcolor _BlackColor; + fill (1,0)--(1,1)--(0.5,0.5)--cycle scaled _SquareUnit withcolor + 0.97[black,_BlackColor]; + fill (0,1)--(0,0)--(0.5,0.5)--cycle scaled _SquareUnit withcolor + 0.97[white,_BlackColor]; + ); + _whiteSquarePic:=image( + fill unitsquare scaled _SquareUnit withcolor _WhiteColor; + fill (1,0)--(1,1)--(0.5,0.5)--cycle scaled _SquareUnit withcolor + 0.97[black,_WhiteColor]; + fill (0,1)--(0,0)--(0.5,0.5)--cycle scaled _SquareUnit withcolor + 0.97[white,_WhiteColor]; + ); + elseif(_chess_board_type="wood"): + _N_wood:=20; + _deviate_wood:=0.02; + _pencile_wood:=0.7pt; + path _up_wood,_down_wood,_q,_p; + _blackSquarePic:=image( + _wood_draw(_N_wood,_deviate_wood,_pencile_wood,_BlackColor,_SquareUnit); + ); + _whiteSquarePic:=image(_wood_draw(_N_wood,_deviate_wood,_pencile_wood,_WhiteColor,_SquareUnit); + ); + fi enddef; def _buildClassicalSquare(expr _SquareUnit)= @@ -223,11 +265,25 @@ _whiteSquarePic:=_whiteSquareColoredPic; def set_color_theme(expr t)= _chessTheme := t; if(t="BlueLichess"): + _chess_board_type:="flat"; _blackColorSquare:=(0.549,0.6353,0.6784); _whiteColorSquare:=(0.8706,0.8912,0.902); elseif(t="BrownLichess"): + _chess_board_type:="flat"; _blackColorSquare:=(0.709803922,0.5333,0.3882); _whiteColorSquare:=(0.941176471,0.850980392,0.709803922); + elseif(t="GreenLichess"): + _chess_board_type:="flat"; + _blackColorSquare:=(0.5255,0.651,0.4); + _whiteColorSquare:=(1.0,1.0,0.8666); + elseif(t="PinkPyramidalLichess"): + _chess_board_type:="pyramidal"; + _blackColorSquare:=(0.949,0.451,0.451); + _whiteColorSquare:=(0.9294,0.9333,0.73333); + elseif(t="Wood"): + _chess_board_type:="wood"; + _blackColorSquare:=(0.4902,0.3569,0.2118); + _whiteColorSquare:=(0.8039,0.7843,0.7725); elseif(t="Classical"): _blackColorSquare:=black; _whiteColorSquare:=black; @@ -490,6 +546,16 @@ enddef; picture backboard; +string _chess_board_type; % define flat color or "pyramidal" like lichess + +% default value flat +_chess_board_type:="flat"; + +vardef set_board_type(expr s) = + _chess_board_type:=s; +enddef; + + def init_backboard = _chessSquareU:=_chessWidth/_chessSize; _init_piece(_chessSquareU); -- cgit v1.2.3