當前位置: 首頁>>代碼示例>>Python>>正文


Python Block.from_list方法代碼示例

本文整理匯總了Python中coilsnake.model.common.blocks.Block.from_list方法的典型用法代碼示例。如果您正苦於以下問題:Python Block.from_list方法的具體用法?Python Block.from_list怎麽用?Python Block.from_list使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在coilsnake.model.common.blocks.Block的用法示例。


在下文中一共展示了Block.from_list方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_read_2bpp_graphic_from_block_offset_xy

# 需要導入模塊: from coilsnake.model.common.blocks import Block [as 別名]
# 或者: from coilsnake.model.common.blocks.Block import from_list [as 別名]
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]])
開發者ID:LittleCube13,項目名稱:CoilSnake,代碼行數:33,代碼來源:test_graphics.py

示例2: test_to_block

# 需要導入模塊: from coilsnake.model.common.blocks import Block [as 別名]
# 或者: from coilsnake.model.common.blocks.Block import from_list [as 別名]
    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])
開發者ID:Lyrositor,項目名稱:CoilSnake,代碼行數:9,代碼來源:test_pointers.py

示例3: test_write_2bpp_graphic_to_block

# 需要導入模塊: from coilsnake.model.common.blocks import Block [as 別名]
# 或者: from coilsnake.model.common.blocks.Block import from_list [as 別名]
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])
開發者ID:LittleCube13,項目名稱:CoilSnake,代碼行數:31,代碼來源:test_graphics.py

示例4: test_write_2bpp_graphic_to_block_offset_xy

# 需要導入模塊: from coilsnake.model.common.blocks import Block [as 別名]
# 或者: from coilsnake.model.common.blocks.Block import from_list [as 別名]
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])
開發者ID:LittleCube13,項目名稱:CoilSnake,代碼行數:35,代碼來源:test_graphics.py

示例5: test_read_4bpp_graphic_from_block

# 需要導入模塊: from coilsnake.model.common.blocks import Block [as 別名]
# 或者: from coilsnake.model.common.blocks.Block import from_list [as 別名]
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]])
開發者ID:LittleCube13,項目名稱:CoilSnake,代碼行數:62,代碼來源:test_graphics.py

示例6: test_from_block

# 需要導入模塊: from coilsnake.model.common.blocks import Block [as 別名]
# 或者: from coilsnake.model.common.blocks.Block import from_list [as 別名]
 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)
開發者ID:Lyrositor,項目名稱:CoilSnake,代碼行數:9,代碼來源:test_palettes.py

示例7: test_to_block

# 需要導入模塊: from coilsnake.model.common.blocks import Block [as 別名]
# 或者: from coilsnake.model.common.blocks.Block import from_list [as 別名]
 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])
開發者ID:Lyrositor,項目名稱:CoilSnake,代碼行數:10,代碼來源:test_palettes.py

示例8: test_from_block

# 需要導入模塊: from coilsnake.model.common.blocks import Block [as 別名]
# 或者: from coilsnake.model.common.blocks.Block import from_list [as 別名]
    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)
開發者ID:Lyrositor,項目名稱:CoilSnake,代碼行數:10,代碼來源:test_table.py

示例9: test_to_block

# 需要導入模塊: from coilsnake.model.common.blocks import Block [as 別名]
# 或者: from coilsnake.model.common.blocks.Block import from_list [as 別名]
    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)
開發者ID:Lyrositor,項目名稱:CoilSnake,代碼行數:11,代碼來源:test_table.py

示例10: test_from_block

# 需要導入模塊: from coilsnake.model.common.blocks import Block [as 別名]
# 或者: from coilsnake.model.common.blocks.Block import from_list [as 別名]
    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)
開發者ID:Lyrositor,項目名稱:CoilSnake,代碼行數:12,代碼來源:test_pointers.py

示例11: test_standard_text_to_block

# 需要導入模塊: from coilsnake.model.common.blocks import Block [as 別名]
# 或者: from coilsnake.model.common.blocks.Block import from_list [as 別名]
def test_standard_text_to_block():
    b = Block()

    b.from_list([0] * 10)
    standard_text_to_block(block=b, offset=0, text="Test", max_length=10)
    assert_list_equal(b.to_list(), [132, 149, 163, 164, 0, 0, 0, 0, 0, 0])

    b.from_list([0x66] * 10)
    standard_text_to_block(block=b, offset=0, text="Test", max_length=10)
    assert_list_equal(b.to_list(), [132, 149, 163, 164, 0, 0x66, 0x66, 0x66, 0x66, 0x66])
開發者ID:Silcoish,項目名稱:CoilSnake,代碼行數:12,代碼來源:test_text.py

示例12: test_from_block

# 需要導入模塊: from coilsnake.model.common.blocks import Block [as 別名]
# 或者: from coilsnake.model.common.blocks.Block import from_list [as 別名]
    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)
開發者ID:LittleCube13,項目名稱:CoilSnake,代碼行數:12,代碼來源:test_swirls.py

示例13: test_to_block

# 需要導入模塊: from coilsnake.model.common.blocks import Block [as 別名]
# 或者: from coilsnake.model.common.blocks.Block import from_list [as 別名]
    def test_to_block(self):
        block = Block()

        s = SwirlFrameRow(x1=3, x2=5, x3=55, x4=92)
        block.from_list([33, 33, 33, 33, 33])
        s.to_block(block, 1, False)
        assert_equal([33, 3, 5, 55, 92], block.to_list())

        s = SwirlFrameRow(x1=3, x2=5, x3=0xff, x4=0)
        block.from_list([33, 33, 33, 33, 33])
        s.to_block(block, 2, True)
        assert_equal([33, 33, 3, 5, 33], block.to_list())
開發者ID:LittleCube13,項目名稱:CoilSnake,代碼行數:14,代碼來源:test_swirls.py

示例14: test_from_block_repeating_mode_01

# 需要導入模塊: from coilsnake.model.common.blocks import Block [as 別名]
# 或者: from coilsnake.model.common.blocks.Block import from_list [as 別名]
    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)
開發者ID:LittleCube13,項目名稱:CoilSnake,代碼行數:16,代碼來源:test_swirls.py

示例15: test_from_block_repeating_not_mode_01

# 需要導入模塊: from coilsnake.model.common.blocks import Block [as 別名]
# 或者: from coilsnake.model.common.blocks.Block import from_list [as 別名]
    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)
開發者ID:LittleCube13,項目名稱:CoilSnake,代碼行數:16,代碼來源:test_swirls.py


注:本文中的coilsnake.model.common.blocks.Block.from_list方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。