batgrl.texture_tools#

Tools for graphics.

Module Attributes

Interpolation

Interpolation methods for resizing graphic gadgets.

Functions

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[, ...])

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[tuple[int, int, Literal[4]], dtype[uint8]], dest: ndarray[tuple[int, int, Literal[4]], 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:
sourceRGBA_2D

The texture to composite.

destRGBA_2D

The texture on which the source is painted.

posPointlike, 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[tuple[int, int, Literal[4]], dtype[uint8]]#

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

Parameters:
pathPath

Path to image.

Returns:
RGBA_2D

An uint8 RGBA array of the image.

batgrl.texture_tools.resize_texture(texture: ndarray[tuple[int, int, Literal[4]], dtype[uint8]], size: Sizelike, interpolation: Literal['nearest', 'linear', 'cubic', 'area', 'lanczos'] = 'linear', out: ndarray[tuple[int, int, Literal[4]], dtype[uint8]] | None = None) ndarray[tuple[int, int, Literal[4]], dtype[uint8]]#

Resize texture.

Parameters:
textureRGBA_2D

An RGBA texture to resize.

sizeSizelike

The new size of the texture.

interpolationInterpolation, default: “linear”

Interpolation used when resizing texture.

outRGBA_2D | None, default: None

Optional output array. If None, a new array is created.

Returns:
RGBA_2D

A new uint8 RGBA array.