当前位置: 首页>>代码示例>>Python>>正文


Python Matrix.save方法代码示例

本文整理汇总了Python中matrix.Matrix.save方法的典型用法代码示例。如果您正苦于以下问题:Python Matrix.save方法的具体用法?Python Matrix.save怎么用?Python Matrix.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matrix.Matrix的用法示例。


在下文中一共展示了Matrix.save方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_matrix_save

# 需要导入模块: from matrix import Matrix [as 别名]
# 或者: from matrix.Matrix import save [as 别名]
def test_matrix_save():
    m, n = 2, 2
    matrix = Matrix(m, n)
    matrix.colorize(0, 1, 'X')
    matrix.save('/tmp/matrix.bmp')

    with open('/tmp/matrix.bmp') as f:
        assert str(matrix) == f.read()
开发者ID:carlosmaniero,项目名称:matrix,代码行数:10,代码来源:test_matrix.py

示例2: Matrix

# 需要导入模块: from matrix import Matrix [as 别名]
# 或者: from matrix.Matrix import save [as 别名]
import pygame

from pygame.locals import *
from dot import Dot
from matrix import Matrix
from board import Board


# TODO: get image from API
mars_map = Matrix()
mars_map.open()
mars_map.edit()
mars_map.save()

map_pixel = mars_map.size()

pygame.init()

# GLOBAL VARIABLES
MAX_ANTS = 500
speed = 10
tp = 0
ant_lst = []

# pygame CONFIG
screen_size = mars_map.size()
screen = pygame.display.set_mode(screen_size)
clock = pygame.time.Clock()
done = False
run = False
can_change = True
开发者ID:orggue,项目名称:antformars,代码行数:33,代码来源:MAIN.py

示例3: init

# 需要导入模块: from matrix import Matrix [as 别名]
# 或者: from matrix.Matrix import save [as 别名]
class MatrixParser:

    def init(self, m, n):
        m, n = int(m), int(n)
        self.matrix = Matrix(m, n)

    def clean(self):
        self.matrix.clean()

    def colorize(self, x, y, color):
        # Humanaze
        x, y = int(x), int(y)
        x, y = x - 1, y - 1
        self.matrix.colorize(x, y, color)

    def vcolorize(self, x, y1, y2, color):
        x, y1, y2 = int(x), int(y1), int(y2)
        x, y1, y2 = x - 1, y1 - 1, y2 - 1
        self.matrix.vcolorize(x, y1, y2, color)

    def hcolorize(self, x1, x2, y, color):
        y, x1, x2 = int(y), int(x1), int(x2)
        y, x1, x2 = y - 1, x1 - 1, x2 - 1
        self.matrix.hcolorize(y, x1, x2, color)

    def fill(self, x, y, color):
        x, y = int(x), int(y)
        x, y = x - 1, y - 1
        self.matrix.fill(x, y, color)

    def rect(self, x1, y1, x2, y2, color):
        x1, y1, x2, y2 = int(x1), int(y1), int(x2), int(y2)
        x1, y1, x2, y2 = x1 - 1, y1 - 1, x2 - 1, y2 - 1

        self.matrix.rect(x1, y1, x2, y2, color)

    def replace(self, x, y, color):
        x, y = int(x), int(y)
        x, y = x - 1, y - 1
        self.matrix.replace(x, y, color)

    def save(self, name):
        self.matrix.save(name)

    def parse(self, command):
        command, *args = command.split()
        method = self._REGISTER.get(command)

        if method:
            method(self, *args)

    _REGISTER = {
        'I': init,
        'C': clean,
        'L': colorize,
        'V': vcolorize,
        'H': hcolorize,
        'Q': fill,
        'F': replace,
        'K': rect,
        'S': save
    }
开发者ID:carlosmaniero,项目名称:matrix,代码行数:64,代码来源:matrix_parser.py


注:本文中的matrix.Matrix.save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。