color
¶
Color
¶
Bases: StrEnum
Contains color aliases and converters to go between the various color formats. The color values are defined by the standard Tailwind CSS color theme.
MuJoCo uses a normalized rgba (all color channels clamped between 0 and 1). This enum defines with hex values, but they can be easily transformed with the provided methods (for example: Color.WHITE.rgba).
with_alpha
¶
hex_to_rgba
classmethod
¶
Converts '#RRGGBB' or 'RRGGBB' to normalized [0, 1] RGBA.
Source code in src/mujoco_mojo/utils/color.py
rgba255_to_rgba
classmethod
¶
Converts [0-255, 0-255, 0-255, 0-1] to normalized [0, 1] RGBA.
rgba_to_hex
classmethod
¶
Converts normalized RGBA to '#RRGGBB' (alpha is discarded).
Source code in src/mujoco_mojo/utils/color.py
rgba_to_rgba255
classmethod
¶
Converts normalized RGBA to [0-255, 0-255, 0-255, 0-1].
parse
classmethod
¶
Normalizes arbitrary color input: None/"" -> None (hidden/unset), a member name (case-insensitive) -> its canonical uppercase name, a #rrggbb hex code -> its canonical member name if that exact hex matches one, otherwise its uppercase hex form. Anything else raises ValueError.
Returns a plain str, not a Color, since a caller (e.g. VisualizationSettings's color fields) may need to store an arbitrary hex with no matching member, not just a member name - not every valid return value corresponds to an actual enum member.