Exemplo n.º 1
0
 def pieceFactory(self, piece: chess.Piece, square: int):
     result = ChessPieceWidget(
         self.getTile(square),
         imageDir + imageStyleDir + imageDict[piece.symbol()],
         self.boardWidget)
     addToDictList(self.pieceDict, piece, result)
     self.widgetToAdd.add_widget(result)
def piece(piece: chess.Piece, size: Optional[int] = None) -> str:
    """
    Renders the given :class:`chess.Piece` as an SVG image.
    >>> import chess
    >>> import chess.svg
    >>>
    >>> chess.svg.piece(chess.Piece.from_symbol("R"))  # doctest: +SKIP
    .. image:: ../docs/wR.svg
    """
    svg = _svg(SQUARE_SIZE, size)
    svg.append(ET.fromstring(PIECES[piece.symbol()]))
    return SvgWrapper(ET.tostring(svg).decode("utf-8"))
Exemplo n.º 3
0
def piece_char(piece: chess.Piece):
    if piece is None:
        return chr(0).encode()
    return piece.symbol().encode()
Exemplo n.º 4
0
 def piece_texture(self, piece: chess.Piece):
     return self.atlas[piece.symbol()]