diff options
author | Karl Berry <karl@freefriends.org> | 2023-07-22 20:18:30 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2023-07-22 20:18:30 +0000 |
commit | 2c38621296bf9859266da2433f18e924e40b2cc9 (patch) | |
tree | d86e7dc5f70c19d07e7cfe68e00228a553b1d06f /Master/texmf-dist/metapost | |
parent | 4ee3602292fd9eae760ab088ab8f5462e6398683 (diff) |
mpchess (22jul23)
git-svn-id: svn://tug.org/texlive/trunk@67704 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/metapost')
-rw-r--r-- | Master/texmf-dist/metapost/mpchess/mpchess-pieces.mp | 18 | ||||
-rw-r--r-- | Master/texmf-dist/metapost/mpchess/mpchess.mp | 82 |
2 files changed, 83 insertions, 17 deletions
diff --git a/Master/texmf-dist/metapost/mpchess/mpchess-pieces.mp b/Master/texmf-dist/metapost/mpchess/mpchess-pieces.mp index 0d6aa5ea248..7a5de31b95f 100644 --- a/Master/texmf-dist/metapost/mpchess/mpchess-pieces.mp +++ b/Master/texmf-dist/metapost/mpchess/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/Master/texmf-dist/metapost/mpchess/mpchess.mp b/Master/texmf-dist/metapost/mpchess/mpchess.mp index d16c8214934..3883ca0bc34 100644 --- a/Master/texmf-dist/metapost/mpchess/mpchess.mp +++ b/Master/texmf-dist/metapost/mpchess/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); |