batgrl.texture_tools#

Tools for graphics.

Module Attributes

Interpolation

Interpolation methods for resizing graphic gadgets.

Functions

_composite(dest, rgb, a[, alpha])

Composite an rgb texture or color onto dest.

composite(source, dest[, pos, mask_mode])

Composite source texture onto destination texture at given position.

read_texture(path)

Return a uint8 RGBA numpy array from a path to an image.

resize_texture(texture, size[, interpolation])

Resize texture.

batgrl.texture_tools.Interpolation#

Interpolation methods for resizing graphic gadgets.

alias of Literal[‘nearest’, ‘linear’, ‘cubic’, ‘area’, ‘lanczos’]

batgrl.texture_tools.composite(source: ndarray[Any, dtype[uint8]], dest: ndarray[Any, dtype[uint8]], pos: Point = (0, 0), mask_mode: bool = False) None#

Composite source texture onto destination texture at given position.

If mask_mode is true, source alpha values less than 255 are ignored.

Parameters:
sourceNDArray[np.uint8]

The texture to composite.

destNDArray[np.uint8]

The texture on which the source is painted.

posPoint, default: Point(0, 0)

Position of the source on the destination.

mask_modebool, default: False

Whether to ignore alpha values less than 255.

batgrl.texture_tools.read_texture(path: Path) ndarray[Any, dtype[uint8]]#

Return a uint8 RGBA numpy array from a path to an image.

Parameters:
pathPath

Path to image.

Returns:
NDArray[np.uint8]

An uint8 RGBA array of the image.

batgrl.texture_tools.resize_texture(texture: ndarray[Any, dtype[uint8]], size: Size, interpolation: Literal['nearest', 'linear', 'cubic', 'area', 'lanczos'] = 'linear') ndarray[Any, dtype[uint8]]#

Resize texture.

Parameters:
textureNDArray[np.uint8]

An RGBA texture to resize.

sizeSize

The new size of the texture.

interpolationInterpolation, default: “linear”

Interpolation used when resizing texture.

Returns:
NDArray[np.uint8]

A new uint8 RGBA array.