mini_arcade_core.backend.utils

Configuration and utility functions for the mini arcade native backend.

Functions

alpha_to_u8(→ int)

Convert an alpha value to an 8-bit integer (0-255).

rgba(→ mini_arcade_core.backend.types.ColorRGBA)

Convert a color tuple to RGBA format.

validate_file_exists(→ str)

Validate that a file exists at the given path.

Module Contents

mini_arcade_core.backend.utils.alpha_to_u8(alpha: mini_arcade_core.backend.types.Alpha | None) int[source]

Convert an alpha value to an 8-bit integer (0-255).

Parameters:

alpha (Optional[Union[float, int]]) – Alpha value as float [0.0, 1.0] or int [0, 255], or None for opaque.

Returns:

Alpha as an integer in the range 0-255.

Return type:

int

Raises:
  • TypeError – If alpha is a bool.

  • ValueError – If alpha is out of range.

mini_arcade_core.backend.utils.rgba(color: mini_arcade_core.backend.types.Color) mini_arcade_core.backend.types.ColorRGBA[source]

Convert a color tuple to RGBA format.

Parameters:

color (Color) – Color as (r,g,b) or (r,g,b,a).

Returns:

Color as (r,g,b,a) with alpha as 0-255 integer.

Return type:

ColorRGBA

mini_arcade_core.backend.utils.validate_file_exists(path: str) str[source]

Validate that a file exists at the given path.

Parameters:

path (str) – Path to the file.

Returns:

The original path if the file exists.

Return type:

str

Raises:

FileNotFoundError – If the file does not exist.