movis.ops.tile#

movis.ops.tile(layers: Sequence[BasicLayer], rows: int, cols: int, size: tuple[int, int] | None = None) Composition[source]#

Tile layers into a single composition.

Args:
layers:

Layers to tile. Note that the order of the layers is row-major. For example, if layers is [a, b, c, d] and rows and cols are both 2, the composition will be: [[a, b], [c, d]].

rows:

Number of rows.

cols:

Number of columns.

size:

Size of each layer. Note that tile assumes that all layers have the same size. If None, the size of the layer is estimated.

Note

The layer resolution specified in size does not have to be the actual layer resolution. For example, if size is specified to be larger than the actual layer size, each layer is placed in the center of each tile.

Returns:

Composition with all layers tiled. The size is (cols * w, rows * h), where w and h are the width and height of each layer, respectively.

Examples:
>>> import movis as mv
>>> import numpy as np
>>> layer1 = mv.layer.Image(np.zeros((100, 100, 4), dtype=np.uint8), duration=1.0)
>>> layer2 = mv.layer.Image(np.zeros((100, 100, 4), dtype=np.uint8), duration=1.0)
>>> composition = mv.tile([layer1, layer2], rows=1, cols=2)  # tile 1x2
>>> composition.duration
1.0
>>> composition.size
(200, 100)