def to_png(board, square_size=DEFAULT_SQUARE_SIZE):
"""
Serializes the board as a png file.
"""
png_size = (board.size + 1)*square_size
writer = png.Writer(png_size, png_size, greyscale=True, bitdepth=1)
lines = board.scale(square_size)
board.frame_num += 1
frame_name = '{}.png'.format(board.frame_num)
with open(frame_name, 'wb') as frame:
writer.write(frame, lines)
评论列表
文章目录