[pmwiki-users] A side=black option for the (:chessboard:) markup in Cookbook/ChessMarkup.
Olivier K
olivier at vvma.net
Thu Sep 1 02:42:27 CDT 2011
Hello,
A few days ago, I discovered Cookbook/ChessMarkup. It is really
powerful and easy to use. :-)
I was looking for a way to flip the board, that is to see the board
from blacks' side, and therefore I tried this, in chess.php:
## Now generate the table from the 8x8 board
$FmtV['$SquareWidth'] = $width / 8;
$FmtV['$SquareHeight'] = $height / 8;
for($i=0; $i<64; $i++) {
if ($i%8 == 0) $out[] = "<tr>";
$FmtV['$PieceImg'] = $ChessPieces[$board{$i}];
$FmtV['$PieceName'] = $board{$i};
# K # next 3 lines added.
# if (isset($args['side'])) # Not necessary ?
if ($args['side'] == 'black')
{ $FmtV['$PieceImg'] = $ChessPieces[$board{63-$i}]; $FmtV['$PieceName'] = $board{63-$i}; }
It is quick&dirty I confess, but now if I use
(:chessboard side=black:)
I see the board from blacks' side. In order to actually flip the
board, I use this modified chess.php with Hans Bracker's
Cookbook/Toggle recipe with something like:
(:toggle blancs noirs show="flip" hide="flip":)
>>id=blancs<<
(:chessboard align=center:)
>><<
>>id=noirs<<
(:chessboard align=center side=black :)
>><<
There is a bug: It did *not* improve my gaming skills one bit. ;-)
Best regards,
--
Olivier K
More information about the pmwiki-users
mailing list