chess-image-generator icon indicating copy to clipboard operation
chess-image-generator copied to clipboard

add support for highlighting squares

Open schoblaska opened this issue 3 years ago • 1 comments

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");

test

schoblaska avatar Apr 01 '22 20:04 schoblaska

This looks like a great addition! I'll be adding this soon once I get the chance to do some testing.

andyruwruw avatar Apr 05 '22 03:04 andyruwruw

I would love for this change to be added!

Btw, on lichess.org the default highlighting color is rgba(155,199,0,0.41)

jassler avatar Aug 23 '22 10:08 jassler

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).

schoblaska avatar Aug 23 '22 12:08 schoblaska

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.

andyruwruw avatar Aug 29 '22 05:08 andyruwruw