mini_arcade_core.backend.utils ============================== .. py:module:: mini_arcade_core.backend.utils .. autoapi-nested-parse:: Configuration and utility functions for the mini arcade native backend. Functions --------- .. autoapisummary:: mini_arcade_core.backend.utils.alpha_to_u8 mini_arcade_core.backend.utils.rgba mini_arcade_core.backend.utils.validate_file_exists Module Contents --------------- .. py:function:: alpha_to_u8(alpha: mini_arcade_core.backend.types.Alpha | None) -> int Convert an alpha value to an 8-bit integer (0-255). :param alpha: Alpha value as float [0.0, 1.0] or int [0, 255], or None for opaque. :type alpha: Optional[Union[float, int]] :return: Alpha as an integer in the range 0-255. :rtype: int :raises TypeError: If alpha is a bool. :raises ValueError: If alpha is out of range. .. py:function:: rgba(color: mini_arcade_core.backend.types.Color) -> mini_arcade_core.backend.types.ColorRGBA Convert a color tuple to RGBA format. :param color: Color as (r,g,b) or (r,g,b,a). :type color: Color :return: Color as (r,g,b,a) with alpha as 0-255 integer. :rtype: ColorRGBA .. py:function:: validate_file_exists(path: str) -> str Validate that a file exists at the given path. :param path: Path to the file. :type path: str :return: The original path if the file exists. :rtype: str :raises FileNotFoundError: If the file does not exist.