shaack / cm-chessboard

A JavaScript chessboard without dependencies. Rendered in SVG, coded in ES6. Views FEN, handles move input, animated, responsive, expandable
MIT License
215 stars 66 forks source link

Support for alternatives when loading custom chess pieces (PNGs, individual SVGs) #90

Open vesper8 opened 1 year ago

vesper8 commented 1 year ago

I would like to use the pieces from these chess sets: https://commons.wikimedia.org/wiki/Category:SVG_chess_pieces/Maurizio_Monge

I've been trying to make it work with the way you've set up your SVG sprite that includes all pieces in one file.. and I'm having a very hard time. I've found two other dozen sets of chess SVGs (here:https://github.com/supertorpe/chessendgametraining/tree/master/src/assets/pieces) that I would love to play with and possibly use but making it work with your format is very difficult.

It would have been lovely if you added support for alternatives when using custom piece sets.. such as allowing us to pass individual svgs or individual pngs.

Or some kind of converter script that accepts the individual SVGs and resizes them and constructs the sprite SVG in the format usable by cm-chessboard.

I know it's a shot in the dark and asking for a lot.. but figured it doesn't hurt to ask. In its current form.. it's just rather hard to work with any other custom set.

If you have tips on how to go about it, such as a handy tool to use, that adds to your comment here https://github.com/shaack/cm-chessboard/issues/26#issuecomment-778783131, I'd love to hear it.

Many thanks

vesper8 commented 1 year ago

Being able to assign individual SVGs for each of the black and white pieces would be such a game changer! CM-Chessboard is already a very popular library but being restricted to only a few chess pieces styles I think is holding it back from becoming the de facto JS chessboard! Don't you agree @shaack ?

shaack commented 1 year ago

I don't think that individual pieces sets for b and w would be necessary. But adding more sets is easy, there are many in the lichess repository which can be integrated.

vesper8 commented 1 year ago

I would still love to see this kind of support added. Currently adding more sets is not what I would call easy as you must take 10+ individual SVGs and build a single SVG sprite which to an SVG expert might not be so hard but because of issues with scale, coordinates translation in the SVG paths, and the difficulty in perfectly aligning the pieces on the SVG sprite.. in the best case scenario where the individual SVGs follow a standard, as perhaps in the case of Lichess, this may be not that hard, but when wanting to use other sets such as the ones I link to in my first post, it's very hard indeed.