texlive[73149] Master/texmf-dist: mpchess (17dec24)

commits+karl at tug.org commits+karl at tug.org
Tue Dec 17 22:11:46 CET 2024


Revision: 73149
          https://tug.org/svn/texlive?view=revision&revision=73149
Author:   karl
Date:     2024-12-17 22:11:46 +0100 (Tue, 17 Dec 2024)
Log Message:
-----------
mpchess (17dec24)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/metapost/mpchess/mpchess-doc-en.pdf
    trunk/Master/texmf-dist/doc/metapost/mpchess/mpchess-doc-en.tex
    trunk/Master/texmf-dist/doc/metapost/mpchess/mpchess-doc-fr.pdf
    trunk/Master/texmf-dist/doc/metapost/mpchess/mpchess-doc-fr.tex
    trunk/Master/texmf-dist/doc/metapost/mpchess/mpchess-preamble.tex
    trunk/Master/texmf-dist/metapost/mpchess/mpchess.mp

Modified: trunk/Master/texmf-dist/doc/metapost/mpchess/mpchess-doc-en.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/metapost/mpchess/mpchess-doc-en.tex
===================================================================
--- trunk/Master/texmf-dist/doc/metapost/mpchess/mpchess-doc-en.tex	2024-12-17 21:11:11 UTC (rev 73148)
+++ trunk/Master/texmf-dist/doc/metapost/mpchess/mpchess-doc-en.tex	2024-12-17 21:11:46 UTC (rev 73149)
@@ -68,7 +68,7 @@
 }
 \vfill
 \begin{center}
-  Version 0.8, 2024, October, 26th \\
+  Version 0.9, 2024, Decembre, 16th \\
   \url{https://gitlab.gutenberg-asso.fr/mchupin/mpchess}
 \end{center}
 %% == Page de garde ====================================================
@@ -86,7 +86,7 @@
 
 
 \begin{center}
-  \url{https://plmlab.math.cnrs.fr/mchupin/mpchess}
+  \url{https://gitlab.gutenberg-asso.fr/mchupin/mpchess}
   \url{https://github.com/chupinmaxime/mpchess}
 \end{center}
 
@@ -686,6 +686,64 @@
 
 \commande|hide_whos_to_move|\index{hide_whos_to_move@\lstinline+hide_whos_to_move+}\smallskip
 
+It is now possible to change the appearance of the marker (since
+version 0.9\footnote{Thanks to Udi Fogiel for fixing a placement bug and
+for suggesting improvements.}. For this purpose, \mpchess provides three styles:
+\lstinline+"triangle"+ (default), \lstinline+"square"+ and \lstinline+"disk"+.
+To select the marker type, use the following command:
+
+\commande|set_marker_type(«string»)|\index{set_marker_type@\lstinline+set_marker_type+}\smallskip
+
+\begin{description}
+  \item[\meta{string}] may be
+\begin{itemize}
+  \item \lstinline+"triangle"+ (default value);
+  \item \lstinline+"square"+;
+\item \lstinline+"disk"+;
+\item \lstinline+"custom"+.
+\end{itemize}
+\end{description}
+
+You can adjust the size (by a factor of the unit dimension) with the following
+command: 
+
+\commande|set_marker_scale(«numeric»)|\index{set_marker_scale@\lstinline+set_marker_scale+}\smallskip
+
+\begin{description}
+  \item[\meta{numeric}:] is a unit dimension factor for enlarging or
+  shrink the mark (default value is \num{0.35}).
+\end{description}
+
+The \lstinline+"custom"+ marker type value lets you define the marker's
+appearance. When this option is called, a
+macro \MP{} \lstinline+custom_maker(expr s,r)+ must be defined. The
+\lstinline+s+ parameter is the scale factor setting: the markers supplied by
+\mpchess are drawings contained in a square of side 1 (\MP{} unit) and scaled
+by \lstinline+s*_chessSquareU+. The \lstinline+r+ parameter is a boolean that
+handles the case where the marker is rotated 180 degrees 
+when placed at the top of the chessboard. 
+
+For example, a \lstinline+custom_marker+ macro reproducing the triangle symbol might be as follows:
+\begin{mpcode}
+def custom_marker(expr s, r)=
+  ((0,0)--(1,0)--(0.5,0.5)--cycle) if r: rotatedaround((0.5, 0.5/3), 180) fi scaled (s*_chessSquareU)
+enddef;
+\end{mpcode}
+
+Only the outline is defined, which will be filled by either white or black.
+
+
+\begin{ExempleMP}
+input mpchess
+beginfig(0);
+set_marker_type("disk");
+set_marker_scale(0.5);
+init_backboard;
+draw backboard;
+init_chessboard;
+draw chessboard;
+endfig;
+\end{ExempleMP}
 \subsection{Draw a Position}
 
 The commands described below allow you to build a position in several ways
@@ -1480,6 +1538,9 @@
 \section{History}
 
 \begin{description}
+\item[v0.9, December 16, 2024:] Correction of a bug in the placement of the
+trait marker (by Udi Fogiel), added different marker features (\lstinline
++"triangle"+, \lstinline+"square"+,\lstinline+"disk"+ and \lstinline+"custom"+). Filling of the white marker. 
 \item[v0.8, October 26, 2024:] Adding \lstinline+"Dotted"+ board theme, and
 \lstinline+"User"+ board theme that allows user to define black and white
 squares.  

Modified: trunk/Master/texmf-dist/doc/metapost/mpchess/mpchess-doc-fr.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/metapost/mpchess/mpchess-doc-fr.tex
===================================================================
--- trunk/Master/texmf-dist/doc/metapost/mpchess/mpchess-doc-fr.tex	2024-12-17 21:11:11 UTC (rev 73148)
+++ trunk/Master/texmf-dist/doc/metapost/mpchess/mpchess-doc-fr.tex	2024-12-17 21:11:46 UTC (rev 73149)
@@ -71,7 +71,7 @@
 }
 \vfill
 \begin{center}
-  Version 0.8, 26 octobre 2024 \\
+  Version 0.9, 16 décembre 2024 \\
   \url{https://gitlab.gutenberg-asso.fr/mchupin/mpchess}
 \end{center}
 %% == Page de garde ====================================================
@@ -89,7 +89,7 @@
 
 
 \begin{center}
-  \url{https://plmlab.math.cnrs.fr/mchupin/mpchess}
+  \url{https://gitlab.gutenberg-asso.fr/mchupin/mpchess}
   \url{https://github.com/chupinmaxime/mpchess}
 \end{center}
 
@@ -669,6 +669,67 @@
 
 \commande|hide_whos_to_move|\index{hide_whos_to_move@\lstinline+hide_whos_to_move+}\smallskip
 
+Il est désormais possible de changer l’apparence du marqueur de trait (depuis la
+version 0.9\footnote{Merci à Udi Fogiel d’avoir corrigé un bug de placement et
+d’avoir proposé des améliorations.}). Pour cela, \mpchess fournit trois styles:
+\lstinline+"triangle"+ (par défaut), \lstinline+"square"+ et \lstinline+"disk"+.
+Pour choisir le type de marquer, on utilisera la commande suivante:
+
+
+\commande|set_marker_type(«string»)|\index{set_marker_type@\lstinline+set_marker_type+}\smallskip
+
+\begin{description}
+  \item[\meta{string}:] peut valoir:
+\begin{itemize}
+  \item \lstinline+"triangle"+ (valeur par défaut) ;
+  \item \lstinline+"square"+;
+\item \lstinline+"disk"+;
+\item \lstinline+"custom"+.
+\end{itemize}
+\end{description}
+
+Vous pouvez ajuster la taille (par un facteur de la dimension d’unité) avec la
+commande suivante:
+
+\commande|set_marker_scale(«numeric»)|\index{set_marker_scale@\lstinline+set_marker_scale+}\smallskip
+
+\begin{description}
+  \item[\meta{numeric}:] est un facteur de la dimension d’unité pour agrandir ou
+  rétrécir le marquer (la valeur par défaut est \num{0.35}).
+\end{description}
+
+La valeur \lstinline+"custom"+ du type de marqueur permet de définir soi même
+l’apparence du marqueur. Lorsque cette option est appelée, il faut définir une
+macro \MP{} \lstinline+custom_maker(expr s,r)+. Le paramètre \lstinline+s+ est
+le réglage du facteur d’échelle : pour les marqueurs fournis par \mpchess, ce
+sont des dessins contenus dans un carré de côté 1 (unité \MP) est mis à
+l’échelle par \lstinline+s*_chessSquareU+. Le paramètre \lstinline+r+ est un
+booléen qui permet de traiter le cas où le marqueur est tourné de 180 degrés
+lorsqu’il est placé en haut de l’échiquier. 
+
+Par exemple, une macro \lstinline+custom_marker+ reproduisant le symbole en
+triangle pourrait être la suivante:
+\begin{mpcode}
+def custom_marker(expr s, r)=
+  ((0,0)--(1,0)--(0.5,0.5)--cycle) if r: rotatedaround((0.5, 0.5/3), 180) fi scaled (s*_chessSquareU)
+enddef;
+\end{mpcode}
+
+On ne définit que le contour qui sera, suivant le cas, colorié en blanc ou en
+noir. 
+
+\begin{ExempleMP}
+input mpchess
+beginfig(0);
+set_marker_type("disk");
+set_marker_scale(0.5);
+init_backboard;
+draw backboard;
+init_chessboard;
+draw chessboard;
+endfig;
+\end{ExempleMP}
+
 \subsection{Dessiner une position}
 
 Les commandes décrites ci-dessous permet de construire une position de plusieurs
@@ -1456,6 +1517,10 @@
 \section{Historique}
 
 \begin{description}
+  \item[v0.9, 16 décembre 2024:] Correction d’un bug de placement de la marque
+  de trait (par Udi Fogiel), ajout de différents marqueur de traits (\lstinline"triangle",
+  \lstinline"square",\lstinline"disk" and \lstinline"custom"). Colloriage du
+  marqueur blanc.
   \item[v0.8, 26 octobre 2024:] Ajout du thème d’échiquier \lstinline+"Dotted"+
   et ajout du thème d’échiquier \lstinline+"User"+ qui permet à l’utilisateur ou
   l’utilisatrice de définir les casses blanches et noires. 

Modified: trunk/Master/texmf-dist/doc/metapost/mpchess/mpchess-preamble.tex
===================================================================
--- trunk/Master/texmf-dist/doc/metapost/mpchess/mpchess-preamble.tex	2024-12-17 21:11:11 UTC (rev 73148)
+++ trunk/Master/texmf-dist/doc/metapost/mpchess/mpchess-preamble.tex	2024-12-17 21:11:46 UTC (rev 73149)
@@ -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,set_board_type,buildUserSquare,_blackSquarePic,_whiteSquarePic},
+  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,buildUserSquare,_blackSquarePic,_whiteSquarePic,set_marker_scale,set_marker_type},
   keywordstyle=\color{darkred},
   classoffset=2,% frame=tb
   morekeywords={backboard,chessboard,chessboard_step},

Modified: trunk/Master/texmf-dist/metapost/mpchess/mpchess.mp
===================================================================
--- trunk/Master/texmf-dist/metapost/mpchess/mpchess.mp	2024-12-17 21:11:11 UTC (rev 73148)
+++ trunk/Master/texmf-dist/metapost/mpchess/mpchess.mp	2024-12-17 21:11:46 UTC (rev 73149)
@@ -2,7 +2,7 @@
 %%                        mpchess.mp                          %%
 %%              draw chessboards with metapost                %%
 %%                    notezik at gmail.com                       %%
-%%                Version 0.8 (octobre   2024)                %%
+%%                Version 0.9 (decembre  2024)                %%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
 % This work may be distributed and/or modified under the conditions of
@@ -12,7 +12,17 @@
 %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
+% Don't load this package twice:
+if known mpchess_version: expandafter endinput; fi;
 
+numeric mpchess_version;string mpchess_date;
+mpchess_version=0.9;
+mpchess_date="2024/12/16";
+% The banner:
+message "******* mpchess " & decimal (mpchess_version) &
+        " (c) Maxime Chupin (" & mpchess_date & ") *******";message "";
+
+
 %input format;
 input hatching;
 %input minim-mp;
@@ -734,10 +744,8 @@
     fi
 enddef;
 
-def _triangle(expr s)=
-    ((0,0)--(1,0)--(0.5,0.5)--cycle) scaled (s*_chessSquareU)
-enddef;
 
+
 color _chess_last_move_color;
 
 _chess_last_move_color:=(0.6078,0.7803,0);
@@ -764,6 +772,72 @@
 enddef;
 
 
+%% markers 
+
+numeric _marker_size;
+
+_marker_size := 0.35;
+
+def set_marker_scale(expr s)=
+    _marker_size:=s;
+enddef;
+
+def _triangle_marker(expr s, r)=
+    ((0,0)--(1,0)--(0.5,0.5)--cycle) if r: rotatedaround((0.5, 0.5/3), 180) fi scaled (s*_chessSquareU)
+enddef;
+
+def _square_marker(expr s, r)=
+    ((0,0)--(1,0)--(1,1)--(0,1)--cycle) scaled (s*_chessSquareU)
+enddef;
+
+
+def _disk_marker(expr s, r)=
+    (fullcircle shifted (0.5,0.5)) scaled (s*_chessSquareU)
+enddef;
+
+string _marker_type;
+
+_marker_type := "triangle";
+
+def _marker(expr s,r)=
+    if(_marker_type="square"):
+        _square_marker(s,r)
+    elseif(_marker_type="disk"):
+        _disk_marker(s,r)
+    elseif(_marker_type="custom"):
+        custom_marker(s,r)
+    else:
+        _triangle_marker(s,r)
+    fi
+enddef;
+
+def set_marker_type(expr s)=
+    _marker_type:=s;
+enddef;
+
+
+vardef _draw_marker(expr c,b)=
+    % c : black or white (color)
+    % b : true or false for placing top (with rotation) or bottom
+    save _height,_width,_pic,_shifted,_margin;
+    picture _pic;
+    pair _shifted;
+    _pic := image(draw _marker(_marker_size,false););
+    _height := abs(ulcorner _pic - llcorner _pic);
+    _width := abs(urcorner _pic-ulcorner _pic);
+    _margin:=0.01*_chessSquareU;
+    if(b): % top rotating
+        _shifted:= (_chessSquareU*_chessSize+_width/2.0+_margin,_chessSquareU*_chessSize);
+    else:
+        _shifted:= (_chessSquareU*_chessSize+_width/2.0+_margin,-_height);
+    fi
+    draw _marker(_marker_size,b) shifted _shifted ;
+    fill _marker(_marker_size,b) shifted _shifted withcolor c;
+enddef;
+
+%%%% end markers
+
+
 vardef _chess_build_chessboard_pic(expr k)=
     save chessboard_pic;
     save shiftPiece;
@@ -786,15 +860,15 @@
     if(_show_whos_to_move):
         if(_chess_view_wb): %white side 
             if(not _white_to_move):
-                fill _triangle(0.3) rotated 180  shifted (_chessSquareU*(_chessSize+0.35),_chessSquareU*(_chessSize)+0.3*_chessSquareU)
+                _draw_marker(black,true);
             else:
-                draw _triangle(0.35)  shifted (_chessSquareU*(_chessSize+0.3),-0.3*_chessSquareU) ;
+                _draw_marker(white,false);
             fi
         else: % black side
             if(_white_to_move):
-                draw _triangle(0.3) rotated 180  shifted (_chessSquareU*(_chessSize+0.35),_chessSquareU*(_chessSize)+0.3*_chessSquareU)
+                _draw_marker(white,true);
             else:
-                fill _triangle(0.35)  shifted (_chessSquareU*(_chessSize+0.3),-0.3*_chessSquareU) ;
+                _draw_marker(black,false);
             fi
         fi
     fi
@@ -1097,4 +1171,4 @@
     else:
        draw _img scaled (_commentScale*_chessSquareU/max(_width,_height)) shifted  ((8+1-_letter)*_chessSquareU-0.15*(_chessSquareU-_width),(8+1-_nbr)*_chessSquareU-0.15*_chessSquareU);
     fi
-enddef;
\ No newline at end of file
+enddef;



More information about the tex-live-commits mailing list.