chess-image-generator
chess-image-generator copied to clipboard
add support for highlighting squares
Adds the ability to highlight squares via generator.highlightSquares(). This is something I wanted for myself, both for highlighting the last move (a common feature in tactics puzzles) and for instructional positions where attention needs to be drawn to specific squares.
No worries if you don't want to merge this, but I figured I'd open a PR in case it seemed generally useful.
const imageGenerator = new ChessImageGenerator();
const fen = "r1bqkbnr/pppp1ppp/2n5/4p3/3PP3/5N2/PPP2PPP/RNBQKB1R w KQkq - 0 1";
imageGenerator.loadFEN(fen);
imageGenerator.highlightSquares(["e4", "e5"]);
imageGenerator.generatePNG("test.png");

This looks like a great addition! I'll be adding this soon once I get the chance to do some testing.
I would love for this change to be added!
Btw, on lichess.org the default highlighting color is rgba(155,199,0,0.41)
rgba(235, 97, 80, 0.8) is what chess.com uses - I'm not married to the particular color though (and it might be nice to be able to customize it).
Sorry for leaving this unchanged! Love the change, looks good to me. This repo needs a revisit to fix some blurriness issues but I think this is great to add for now.