SVG rendering

This module renders SVGs (mostly for IPython integration). Piece images are copyright Colin M.L. Burnett and triple licensed under GFDL & BSD & GPL.

chess.svg.piece(piece, size=None)

Renders the given chess.Piece as an SVG.

>>> import chess
>>> import chess.svg
>>> chess.svg.piece(chess.Piece.from_symbol("R"))  
chess.svg.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.

  • board – A chess.BaseBoard for a chessboard with pieces or None (the default) for a chessboard without pieces.
  • squares – A chess.SquareSet with selected squares.
  • flipped – Pass True to flip the board.
  • coordinates – Pass False to disable coordinates in the margin.
  • lastmove – A chess.Move to be highlighted.
  • check – A square to be marked as check.
  • arrows – A list of Arrow objects like [chess.svg.Arrow(chess.E2, chess.E4)]. Arrows from a square to the same square are drawn as circles.
  • size – Limit the SVG size by setting width and height of the image.
  • style – CSS to use instead of the default stylesheet.
>>> import chess
>>> import chess.svg
>>> board = chess.Board("8/8/8/8/4N3/8/8/8 w - - 0 1")
>>> squares = board.attacks(chess.E4)
>>> chess.svg.board(board=board, squares=squares)