images.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:conway 作者: avyfain 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号