本文整理汇总了Python中coilsnake.model.common.blocks.Block类的典型用法代码示例。如果您正苦于以下问题:Python Block类的具体用法?Python Block怎么用?Python Block使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Block类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_from_block
def test_from_block(self):
block = Block()
block.from_list([0x5f, 0x0a])
self.color.from_block(block, 0)
assert_equal(self.color.r, 248)
assert_equal(self.color.g, 144)
assert_equal(self.color.b, 16)
示例2: test_write_2bpp_graphic_to_block
def test_write_2bpp_graphic_to_block():
source = [[2, 1, 2, 3, 2, 1, 2, 1],
[2, 3, 1, 0, 2, 3, 2, 2],
[3, 0, 3, 2, 2, 2, 0, 2],
[1, 3, 3, 0, 2, 0, 2, 3],
[1, 0, 1, 1, 0, 3, 3, 3],
[1, 3, 3, 3, 3, 2, 1, 2],
[2, 2, 3, 1, 2, 2, 1, 0],
[2, 0, 3, 3, 2, 3, 1, 0]]
target = Block()
target.from_list([0] * 16)
assert_equal(16, write_2bpp_graphic_to_block(source=source, target=target, offset=0, x=0, y=0, bit_offset=0))
assert_list_equal(target.to_list(),
[0b01010101,
0b10111010,
0b01100100,
0b11001111,
0b10100000,
0b10111101,
0b11100001,
0b01101011,
0b10110111,
0b00000111,
0b11111010,
0b01111101,
0b00110010,
0b11101100,
0b00110110,
0b10111100])
示例3: test_read_2bpp_graphic_from_block_offset_xy
def test_read_2bpp_graphic_from_block_offset_xy():
source = Block()
source.from_list([0b01010101,
0b10111010,
0b01100100,
0b11001111,
0b10100000,
0b10111101,
0b11100001,
0b01101011,
0b10110111,
0b00000111,
0b11111010,
0b01111101,
0b00110010,
0b11101100,
0b00110110,
0b10111100, 5])
target = [[0 for x in range(10)] for y in range(10)]
assert_equal(16, read_2bpp_graphic_from_block(target=target, source=source, offset=0, x=2, y=1, bit_offset=0))
assert_list_equal(target,
[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 2, 1, 2, 3, 2, 1, 2, 1],
[0, 0, 2, 3, 1, 0, 2, 3, 2, 2],
[0, 0, 3, 0, 3, 2, 2, 2, 0, 2],
[0, 0, 1, 3, 3, 0, 2, 0, 2, 3],
[0, 0, 1, 0, 1, 1, 0, 3, 3, 3],
[0, 0, 1, 3, 3, 3, 3, 2, 1, 2],
[0, 0, 2, 2, 3, 1, 2, 2, 1, 0],
[0, 0, 2, 0, 3, 3, 2, 3, 1, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]])
示例4: test_write_2bpp_graphic_to_block_offset_xy
def test_write_2bpp_graphic_to_block_offset_xy():
source = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 2, 1, 2, 3, 2, 1, 2, 1],
[0, 0, 2, 3, 1, 0, 2, 3, 2, 2],
[0, 0, 3, 0, 3, 2, 2, 2, 0, 2],
[0, 0, 1, 3, 3, 0, 2, 0, 2, 3],
[0, 0, 1, 0, 1, 1, 0, 3, 3, 3],
[0, 0, 1, 3, 3, 3, 3, 2, 1, 2],
[0, 0, 2, 2, 3, 1, 2, 2, 1, 0],
[0, 0, 2, 0, 3, 3, 2, 3, 1, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
target = Block()
target.from_list([0xff] * 18)
assert_equal(16, write_2bpp_graphic_to_block(source=source, target=target, offset=1, x=2, y=1, bit_offset=0))
assert_list_equal(target.to_list(),
[0xff,
0b01010101,
0b10111010,
0b01100100,
0b11001111,
0b10100000,
0b10111101,
0b11100001,
0b01101011,
0b10110111,
0b00000111,
0b11111010,
0b01111101,
0b00110010,
0b11101100,
0b00110110,
0b10111100,
0xff])
示例5: test_read_4bpp_graphic_from_block
def test_read_4bpp_graphic_from_block():
source = Block()
source.from_list([0b01010110,
0b00001011,
0b11001110,
0b10010110,
0b01110001,
0b00111011,
0b00001011,
0b10011110,
0b00011000,
0b00000011,
0b10000001,
0b11101011,
0b00000100,
0b01000101,
0b01010110,
0b10001111,
0b00101100,
0b10110000,
0b01010110,
0b10110010,
0b01010000,
0b11000000,
0b00111000,
0b10010111,
0b00101101,
0b11111100,
0b01111101,
0b11101010,
0b10101111,
0b10110111,
0b01100000,
0b11101110])
target = [[0 for x in range(8)] for y in range(8)]
assert_equal(32, read_4bpp_graphic_from_block(target=target, source=source, offset=0, x=0, y=0, bit_offset=0))
assert_list_equal(target,
[[8, 1, 12, 9, 6, 5, 3, 2],
[11, 5, 8, 14, 1, 7, 15, 0],
[8, 13, 3, 7, 2, 0, 2, 3],
[10, 0, 4, 14, 7, 10, 11, 9],
[8, 8, 12, 9, 13, 12, 2, 6],
[11, 14, 14, 4, 14, 4, 10, 7],
[12, 2, 12, 8, 4, 15, 12, 14],
[10, 13, 12, 1, 10, 11, 11, 2]])
示例6: test_to_block
def test_to_block(self):
block = Block()
block.from_list(range(1, 6))
self.pointer.address = 0xabcdef
self.pointer.to_block(block, 1)
assert_list_equal(block[0:5].to_list(), [1, 0xef, 0xcd, 0xab, 5])
示例7: test_to_block
def test_to_block(self):
block = Block()
block.from_list([0] * 2)
self.color.r = 248
self.color.g = 144
self.color.b = 16
self.color.to_block(block, 0)
assert_list_equal(block.to_list(), [0x5f, 0x0a])
示例8: test_from_block
def test_from_block(self):
table = Table(num_rows=len(self.TABLE_VALUES),
schema=self.TABLE_SCHEMA)
block = Block()
block.from_list(self.BLOCK_DATA)
table.from_block(block, 0)
assert_list_equal(table.values, self.TABLE_VALUES)
示例9: test_to_block
def test_to_block(self):
for test_case in TEST_CASES:
block_size = MapEnemyGroupTableEntry.to_block_size(test_case["value_rep"])
assert_equal(len(test_case["block_rep"]), block_size)
block = Block(size=block_size)
MapEnemyGroupTableEntry.to_block(block, 0, test_case["value_rep"])
assert_list_equal(test_case["block_rep"], block.to_list())
示例10: test_to_block
def test_to_block(self):
block = Block()
block.from_list([0] * len(self.BLOCK_DATA))
table = Table(num_rows=len(self.TABLE_VALUES),
schema=self.TABLE_SCHEMA)
table.values = self.TABLE_VALUES
table.to_block(block, 0)
assert_list_equal(block.to_list(), self.BLOCK_DATA)
示例11: test_from_block
def test_from_block(self):
block = Block()
block.from_list([1, 2, 4, 5, 6])
s = SwirlFrameRow()
s.from_block(block, 0, False)
assert_equal(SwirlFrameRow(x1=1, x2=2, x3=4, x4=5), s)
s.from_block(block, 3, True)
assert_equal(SwirlFrameRow(x1=5, x2=6, x3=0xff, x4=0), s)
示例12: test_from_block
def test_from_block(self):
block = Block()
block.from_list(range(0, 0x100))
self.pointer.from_block(block, 0)
assert_equal(self.pointer.address, 0x020100)
self.pointer.from_block(block, 5)
assert_equal(self.pointer.address, 0x070605)
self.pointer.from_block(block, 0xfd)
assert_equal(self.pointer.address, 0xfffefd)
示例13: test_from_block_repeating_mode_01
def test_from_block_repeating_mode_01(self):
s = SwirlFrame()
block = Block()
block.from_list([1,
0x7f, 1, 2,
97, 3, 4,
0])
s.from_block(block, 0)
assert_equal(len(s.rows), 224)
for row in s.rows[0:0x7f]:
assert_equal(SwirlFrameRow(x1=1, x2=2, x3=0xff, x4=0), row)
for row in s.rows[0x7f:]:
assert_equal(SwirlFrameRow(x1=3, x2=4, x3=0xff, x4=0), row)
示例14: test_standard_text_to_block_with_brackets
def test_standard_text_to_block_with_brackets():
b = Block()
b.from_list([0] * 10)
standard_text_to_block(block=b, offset=0, text="[01 02 03 04]", max_length=10)
assert_list_equal(b.to_list(), [0x01, 0x02, 0x03, 0x04, 0, 0, 0, 0, 0, 0])
b.from_list([0] * 10)
standard_text_to_block(block=b, offset=0, text="[]", max_length=10)
assert_list_equal(b.to_list(), [0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
b.from_list([0] * 10)
standard_text_to_block(block=b, offset=0, text="Te[ab cd ef]st", max_length=10)
assert_list_equal(b.to_list(), [132, 149, 0xab, 0xcd, 0xef, 163, 164, 0, 0, 0])
示例15: test_from_block_repeating_not_mode_01
def test_from_block_repeating_not_mode_01(self):
s = SwirlFrame()
block = Block()
block.from_list([0,
0x7e, 0, 50, 120, 126,
98, 0, 0xff, 0xff, 0,
0])
s.from_block(block, 0)
assert_equal(len(s.rows), 224)
for row in s.rows[0:0x7e]:
assert_equal(SwirlFrameRow(x1=0, x2=50, x3=120, x4=126), row)
for row in s.rows[0x7e:]:
assert_equal(SwirlFrameRow(x1=0, x2=0xff, x3=0xff, x4=0), row)