boltz_data.draw.color#

Color utilities for visualization.

Functions

as_hex_color(color, /)

Convert any color format to a hex string.

as_rgb_float_color(color, /)

Convert any color format to a float RGB numpy array in range [0, 1].

as_rgb_int_color(color, /)

Convert any color format to an integer RGB numpy array in range [0, 255].

darken(color, amount)

Darken a color by the specified amount.

boltz_data.draw.color.as_hex_color(color, /)[source]#

Convert any color format to a hex string.

Parameters:

color (str | Sequence[int] | Sequence[float] | ndarray[tuple[int, ...], dtype[float32]] | ndarray[tuple[int, ...], dtype[uint8]]) – Color in any supported format: - CSS color name (e.g., “red”, “blue”) - Hex string (e.g., “#ff0000”, “ff0000”) - Integer sequence [0-255, 0-255, 0-255] - Float sequence [0.0-1.0, 0.0-1.0, 0.0-1.0] - Numpy array (int or float)

Return type:

str

Returns:

Hex color string with leading #.

Raises:

ValueError – If color format is invalid.

boltz_data.draw.color.as_rgb_float_color(color, /)[source]#

Convert any color format to a float RGB numpy array in range [0, 1].

Parameters:

color (str | Sequence[int] | Sequence[float] | ndarray[tuple[int, ...], dtype[float32]] | ndarray[tuple[int, ...], dtype[uint8]]) – Color in any supported format.

Return type:

ndarray[tuple[int, ...], dtype[float32]]

Returns:

Numpy array of shape (3,) with float values in range [0, 1].

Raises:

ValueError – If color format is invalid.

boltz_data.draw.color.as_rgb_int_color(color, /)[source]#

Convert any color format to an integer RGB numpy array in range [0, 255].

Parameters:

color (str | Sequence[int] | Sequence[float] | ndarray[tuple[int, ...], dtype[float32]] | ndarray[tuple[int, ...], dtype[uint8]]) – Color in any supported format.

Return type:

ndarray[tuple[int, ...], dtype[uint8]]

Returns:

Numpy array of shape (3,) with uint8 values in range [0, 255].

Raises:

ValueError – If color format is invalid.

boltz_data.draw.color.darken(color, amount)[source]#

Darken a color by the specified amount.

Returns the color in the same format as the input.

Parameters:
Return type:

str | Sequence[int] | Sequence[float] | ndarray[tuple[int, ...], dtype[float32]] | ndarray[tuple[int, ...], dtype[uint8]]

Returns:

Darkened color in the same format as input.