(self, id, tile_width=1, tile_height=1)
return result
Retrieves the graphics data for a sprite.

        The return value is a list of bytearrays, where each bytearray
        represents a row of pixels. Each value is a color value for a
        pixel (0-15).

        By default, this returns a sprite consisting of the tile with
        the given PICO-8 tile ID, an 8x8 pixel region. You can request
        multiple tiles in a single sprite using the tile_width and
        tile_height arguments. The complete sprite is calculated from
        the 16 tile x 16 tile spritesheet with the tile of the given
        ID in the upper left corner, similar to the PICO-8 spr
        function. If the given width or height extend off the edge of
        the spritesheet, the extraneous space is filled with zeroes.

        PICO-8 tile IDs start with 0 in the upper left corner, and
        increase left to right, then top to bottom, in the 16 tile x
        16 tile spritesheet.

        Args:
          id: The PICO-8 tile ID that is the upper-left corner of the requested
            sprite.
          tile_width: The width of the requested sprite, as a number of tiles.
            Must be 1 or greater.
          tile_height: The height of the requested sprite, as a number of
            tiles. Must be 1 or greater.

        Returns:
          A list of bytearrays, one bytearray per row, where each cell
          is a color from 0 (transparent/black) to 15 (peach). (See
          the color constants defined in the gfx module.)
Retrieves the graphics data for a sprite.
Retrieves the graphics data for a sprite .
def get_sprite(self, id, tile_width=1, tile_height=1):
        """Retrieves the graphics data for a sprite.

        The return value is a list of bytearrays, where each bytearray
        represents a row of pixels. Each value is a color value for a
        pixel (0-15).

        By default, this returns a sprite consisting of the tile with
        the given PICO-8 tile ID, an 8x8 pixel region. You can request
        multiple tiles in a single sprite using the tile_width and
        tile_height arguments. The complete sprite is calculated from
        the 16 tile x 16 tile spritesheet with the tile of the given
        ID in the upper left corner, similar to the PICO-8 spr
        function. If the given width or height extend off the edge of
        the spritesheet, the extraneous space is filled with zeroes.

        PICO-8 tile IDs start with 0 in the upper left corner, and
        increase left to right, then top to bottom, in the 16 tile x
        16 tile spritesheet.

        Args:
          id: The PICO-8 tile ID that is the upper-left corner of the requested
            sprite.
          tile_width: The width of the requested sprite, as a number of tiles.
            Must be 1 or greater.
          tile_height: The height of the requested sprite, as a number of
            tiles. Must be 1 or greater.

        Returns:
          A list of bytearrays, one bytearray per row, where each cell
          is a color from 0 (transparent/black) to 15 (peach). (See
          the color constants defined in the gfx module.)
        """
        assert 0 <= id <= 255
        assert 1 <= tile_width
        assert 1 <= tile_height
        first_tile_row = id // 16
        first_tile_col = id % 16
        result = []
        for ty in range(first_tile_row, first_tile_row + tile_height):
            for y_offset in range(8):
                row = bytearray()
                for tx in range(first_tile_col, first_tile_col + tile_width):
                    if tx > 15 or ty > 15:
                        row.extend([0] * 8)
                    else:
                        for x_offset in range(8):
                            data_loc = (ty * 64 * 8 +
                                        y_offset * 64 +
                                        tx * 4 +
                                        x_offset // 2)
                            b = self._data[data_loc]
                            if x_offset % 2 == 0:
                                row.append(b & 0x0f)
                            else:
                                row.append((b & 0xf0) >> 4)
                result.append(row)
        return result
def get_sprite ( self , id , tile_width = 1 , tile_height = 1 ) : assert 0 <= id <= 255 assert 1 <= tile_width assert 1 <= tile_height first_tile_row = id // 16 first_tile_col = id % 16 result = [ ] for ty in range ( first_tile_row , first_tile_row + tile_height ) : for y_offset in range ( 8 ) : row = bytearray ( ) for tx in range ( first_tile_col , first_tile_col + tile_width ) : if tx > 15 or ty > 15 : row . extend ( [ 0 ] * 8 ) else : for x_offset in range ( 8 ) : data_loc = ( ty * 64 * 8 + y_offset * 64 + tx * 4 + x_offset // 2 ) b = self . _data [ data_loc ] if x_offset % 2 == 0 : row . append ( b & 0x0f ) else : row . append ( ( b & 0xf0 ) >> 4 ) result . append ( row ) return result