Пример #1
0
def save(file, model, position=None, flip=False):
    """Export the current position into a .png file"""

    show_cords = conf.get("showCords")
    boardview = BoardView(model)
    padding = int(SQUARE / 4) if show_cords else 0

    width = SQUARE * 8 + padding * 2
    height = SQUARE * 8 + padding * 2

    surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)
    context = cairo.Context(surface)

    boardview.shown = position
    boardview.square = 0 + padding, 0 + padding, SQUARE * 8, SQUARE

    if flip:
        boardview._rotation = math.pi
        boardview.matrix = cairo.Matrix.init_rotate(math.pi)

    boardview.matrix, boardview.invmatrix = matrixAround(
        boardview.matrix, width / 2.0, height / 2.0)
    context.transform(boardview.matrix)

    boardview.drawBoard(context, None)
    boardview.drawPieces(context, None)

    if show_cords:
        boardview.drawCords(context, None)

    surface.write_to_png(file.name)
Пример #2
0
def save(file, model, position=None):
    """Export the current position into a .png file"""

    boardview = BoardView(model)
    padding = int(SQUARE / 4) if boardview.show_cords else 0

    surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, SQUARE * 8 + padding * 2,
                                 SQUARE * 8 + padding * 2)
    context = cairo.Context(surface)

    boardview.shown = position
    boardview.square = 0 + padding, 0 + padding, SQUARE * 8, SQUARE

    boardview.drawBoard(context, None)
    boardview.drawPieces(context, None)

    if boardview.show_cords:
        boardview.drawCords(context, None)

    surface.write_to_png(file.name)
Пример #3
0
def save(file, model, position=None):
    """Export the current position into a .png file"""

    boardview = BoardView(model)
    padding = int(SQUARE / 4) if boardview.show_cords else 0

    surface = cairo.ImageSurface(cairo.FORMAT_ARGB32,
                                 SQUARE * 8 + padding * 2, SQUARE * 8 + padding * 2)
    context = cairo.Context(surface)

    boardview.shown = position
    boardview.square = 0 + padding, 0 + padding, SQUARE * 8, SQUARE

    boardview.drawBoard(context, None)
    boardview.drawPieces(context, None)

    if boardview.show_cords:
        boardview.drawCords(context, None)

    surface.write_to_png(file.name)