Texture

类位于 Infernux.core

描述

纹理资源。

description

构造函数

签名 描述
Texture.__init__(native: TextureData) → None Wrap an existing C++ TextureData.

constructors

属性

名称 类型 描述
native TextureData The underlying C++ TextureData object. (只读)
width int 纹理宽度(像素)。 (只读)
height int 纹理高度(像素)。 (只读)
channels int Number of color channels (e.g. (只读)
name str 纹理名称。 (只读)
guid str 纹理的全局唯一标识符。 (只读)
source_path str The file path the texture was loaded from. (只读)
size Tuple[int, int] (width, height) tuple. (只读)

properties

公共方法

方法 描述
pixels_as_bytes() → bytes Get raw pixel data as bytes (row-major, RGBA or RGB).
pixels_as_list() → list Get pixel data as a flat list of integers [0-255].
to_numpy() → 'numpy.ndarray' Convert pixel data to a NumPy array (H, W, C), dtype uint8.

public_methods

静态方法

方法 描述
static Texture.load(file_path: str) → Optional[Texture] 从文件路径加载纹理。
static Texture.from_memory(data: bytes, width: int, height: int, channels: int = ..., name: str = ...) → Optional[Texture] Create a texture from raw pixel data in memory.
static Texture.solid_color(width: int, height: int, r: int = ..., g: int = ..., b: int = ..., a: int = ...) → Optional[Texture] Create a solid color texture.
static Texture.checkerboard(width: int, height: int, cell_size: int = ...) → Optional[Texture] Create a checkerboard pattern texture.
static Texture.from_native(native: TextureData) → Texture Wrap an existing C++ TextureData.

static_methods

运算符

方法 返回值
__repr__() → str str

operators

示例

example

# TODO: Add example for Texture

另请参阅

see_also