chessboardjs icon indicating copy to clipboard operation
chessboardjs copied to clipboard

Change Piece color at runtime

Open Astrydax opened this issue 4 years ago • 1 comments

It seems that the piece images are only loaded at startup through a config. Would it be possible to allow choosing the images at runtime and not just startup?

Astrydax avatar Dec 15 '20 07:12 Astrydax

You can accomplish this by using a function for the piece theme configuration instead of a string. I did it like so:

getPiece(piece) {
    return 'images/pieces/' + this.chosen_theme + '/' + piece + '.png'
}

Replace chosen_theme with whatever variable holds the pieces theme you want.

Then in your board config you set pieceTheme to the getPiece function.

blunket avatar Jan 05 '21 21:01 blunket

Please close issue

Astrydax avatar Nov 21 '22 17:11 Astrydax