chess.svg module renders SVG Tiny images (mostly for IPython/Jupyter
Notebook integration). The piece images by
Colin M.L. Burnett are triple
licensed under the GFDL, BSD and GPL.
Renders the given
chess.Pieceas an SVG image.
>>> import chess >>> import chess.svg >>> >>> from IPython.display import SVG >>> >>> SVG(chess.svg.piece(chess.Piece.from_symbol("R")))
board(board=None, squares=None, flipped=False, coordinates=True, lastmove=None, check=None, arrows=(), size=None, style=None)¶
Renders a board with pieces and/or selected squares as an SVG image.
- board – A
chess.BaseBoardfor a chessboard with pieces or
None(the default) for a chessboard without pieces.
- squares – A
chess.SquareSetwith selected squares.
- flipped – Pass
Trueto flip the board.
- coordinates – Pass
Falseto disable coordinates in the margin.
- lastmove – A
chess.Moveto be highlighted.
- check – A square to be marked as check.
- arrows – A list of
[chess.svg.Arrow(chess.E2, chess.E4)]or a list of tuples like
[(chess.E2, chess.E4)]. An arrow from a square pointing to the same square is drawn as a circle, like
- size – The size of the image in pixels (e.g.,
400for a 400 by 400 board) or
None(the default) for no size limit.
- style – A CSS stylesheet to include in the SVG image.
>>> import chess >>> import chess.svg >>> >>> from IPython.display import SVG >>> >>> board = chess.Board("8/8/8/8/4N3/8/8/8 w - - 0 1") >>> squares = board.attacks(chess.E4) >>> SVG(chess.svg.board(board=board, squares=squares))
- board – A