Class pyglet.image.TextureGrid

        AbstractImage --+        
                        |        
                  Texture --+    
                            |    
                TextureRegion --+
                                |
AbstractImageSequence --+       |
                        |       |
          TextureSequence --+   |
                            |   |
       UniformTextureSequence --+
                                |
                               TextureGrid

A texture containing a regular grid of texture regions.

To construct, create an ImageGrid first:

image_grid = ImageGrid(...)
texture_grid = TextureGrid(image_grid)

The texture grid can be accessed as a single texture, or as a sequence of TextureRegion. When accessing as a sequence, you can specify integer indexes, in which the images are arranged in rows from the bottom-left to the top-right:

# assume the texture_grid is 3x3:
current_texture = texture_grid[3] # get the middle-left image

You can also specify tuples in the sequence methods, which are addressed as row, column:

# equivalent to the previous example:
current_texture = texture_grid[1, 0]

When using tuples in a slice, the returned sequence is over the rectangular region defined by the slice:

# returns center, center-right, center-top, top-right images in that
# order:
images = texture_grid[(1,1):]
# equivalent to
images = texture_grid[(1,1):(3,3)]

Methods

  __init__(self, grid)
  get(self, row, column)
AbstractImage __getitem__(self, index)
Retrieve a (list of) image.
  __setitem__(self, index, value)
Replace one or more images in the sequence.
  __len__(self)
Iterator __iter__(self)
Iterate over the images in sequence.
  __del__(self) (Inherited from pyglet.image.TextureRegion)
  __repr__(self) (Inherited from pyglet.image.AbstractImage)
  blit(self, x, y, z=0, width=None, height=None)
Draw this image to the active framebuffers.
(Inherited from pyglet.image.Texture)
  blit_into(self, source, x, y, z)
Draw source on this image.
(Inherited from pyglet.image.TextureRegion)
  blit_to_texture(self, target, level, x, y, z=0)
Draw this image on the currently bound texture at target.
(Inherited from pyglet.image.AbstractImage)
Texture create(cls, width, height, internalformat=6408, rectangle=False, force_rectangle=False)
Create an empty Texture.
(Inherited from pyglet.image.Texture)
Texture create_for_size(cls, target, min_width, min_height, internalformat=None)
Create a Texture with dimensions at least min_width, min_height.
(Inherited from pyglet.image.Texture)
  delete(self)
Delete the texture from video memory.
(Inherited from pyglet.image.Texture)
Animation get_animation(self, period, loop=True)
Create an animation over this image sequence for the given constant framerate.
(Inherited from pyglet.image.AbstractImageSequence)
ImageData get_image_data(self)
Get the image data of this texture.
(Inherited from pyglet.image.TextureRegion)
Texture get_mipmapped_texture(self)
Retrieve a Texture instance with all mipmap levels filled in.
(Inherited from pyglet.image.AbstractImage)
AbstractImage get_region(self, x, y, width, height)
Retrieve a rectangular region of this image.
(Inherited from pyglet.image.TextureRegion)
Texture get_texture(self, rectangle=False, force_rectangle=False)
A Texture view of this image.
(Inherited from pyglet.image.Texture)
TextureSequence get_texture_sequence(self)
Get a TextureSequence.
(Inherited from pyglet.image.TextureSequence)
TextureRegion get_transform(self, flip_x=False, flip_y=False, rotate=0)
Create a copy of this image applying a simple transformation.
(Inherited from pyglet.image.Texture)
  save(self, filename=None, file=None, encoder=None)
Save this image to a file.
(Inherited from pyglet.image.AbstractImage)

Properties

ImageData image_data
An ImageData view of this texture.
(Inherited from pyglet.image.Texture)
Texture mipmapped_texture
A Texture view of this image.
(Inherited from pyglet.image.AbstractImage)
Texture texture
Get a Texture view of this image.
(Inherited from pyglet.image.AbstractImage)
TextureSequence texture_sequence
Access this image sequence as a texture sequence.
(Inherited from pyglet.image.AbstractImageSequence)

Instance Variables

int anchor_x = 0
X coordinate of anchor, relative to left edge of image data
(Inherited from pyglet.image.AbstractImage)
int anchor_y = 0
Y coordinate of anchor, relative to bottom edge of image data
(Inherited from pyglet.image.AbstractImage)
int height
Height of image
(Inherited from pyglet.image.AbstractImage)
int level = 0
The mipmap level of this texture.
(Inherited from pyglet.image.Texture)
class (subclass of TextureRegion) region_class
Class to use when constructing regions of this texture.
(Inherited from pyglet.image.Texture)
int target
The GL texture target (e.g., GL_TEXTURE_2D).
(Inherited from pyglet.image.Texture)
tuple tex_coords = (0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0...
12-tuple of float, named (u1, v1, r1, u2, v2, r2, ...).
(Inherited from pyglet.image.Texture)
int width
Width of image
(Inherited from pyglet.image.AbstractImage)

Class Variables

  items = ()
  rows = 1
  columns = 1
int item_width = 0
Width of each texture in the sequence.
int item_height = 0
Height of each texture in the sequence.
  images = 1 (Inherited from pyglet.image.Texture)
  tex_coords_order = (0, 1, 2, 3) (Inherited from pyglet.image.Texture)
  x = 0 (Inherited from pyglet.image.Texture)
  y = 0 (Inherited from pyglet.image.Texture)
  z = 0 (Inherited from pyglet.image.Texture)

Method Details

__init__

(Constructor) __init__(self, grid)
Overrides:
TextureRegion.__init__

__getitem__

(Indexing operator) __getitem__(self, index)
Retrieve a (list of) image.
Returns: AbstractImage
Overrides:
AbstractImageSequence.__getitem__

__setitem__

(Index assignment operator) __setitem__(self, index, value)
Replace one or more images in the sequence.
Overrides:
AbstractImageSequence.__setitem__

__len__

(Length operator) __len__(self)
Overrides:
AbstractImageSequence.__len__

__iter__

__iter__(self)
Iterate over the images in sequence.
Returns: Iterator
Overrides:
AbstractImageSequence.__iter__

Since: pyglet 1.1