Skip to content

Rgba32

Represents a single color as packed 32-bit RGBA. Accepts NumPy arrays of shape (3,) or (4,), sequences of 3 or 4 numbers, or an existing Rgba32 instance. This datatype is used for vertex/point colors and color parameters across the Telekinesis ecosystem.

Field

Required

FieldTypeDescription
rgbaRgba32LikeSingle color: (3,) or (4,) array or list (dtype uint8), packed int, or Rgba32.

Optional

None.

Methods

MethodDescription
to_numpy()Returns a NumPy array of shape (3,) (RGB) or (4,) (RGBA), dtype uint8. Elements are [R, G, B] or [R, G, B, A] in 0–255.

Example

From the datatypes examples:

python
from datatypes import datatypes
from loguru import logger
import numpy as np

# ------------------------------------------------
# 1. Create Rgba32 instances
# ------------------------------------------------
red = datatypes.Rgba32([255, 0, 0, 255])
green = datatypes.Rgba32([0, 255, 0, 255])
blue = datatypes.Rgba32([0, 0, 255, 255])

# ------------------------------------------------
# 2. Access via to_numpy and int conversion
# ------------------------------------------------
logger.info("Rgba32 red to_numpy={}", red.to_numpy())
logger.info("Rgba32 green to_numpy={}", green.to_numpy())
logger.info("Rgba32 blue to_numpy={}", blue.to_numpy())
logger.info("Rgba32 int(red)={}", int(red))

# ------------------------------------------------
# 3. Use Rgba32 with Points3D
# ------------------------------------------------
positions = np.array(
    [[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [2.0, 0.0, 0.0]], dtype=np.float32
)
points_3d = datatypes.Points3D(positions=positions, colors=[red, green, blue])
logger.info("Points3D with Rgba32 to_numpy positions shape={}", points_3d.to_numpy("positions").shape)
logger.info("Points3D with Rgba32 to_numpy colors shape={}", points_3d.to_numpy("colors").shape if points_3d.to_numpy("colors") is not None else None)