Converts an RGB color to its hexadecimal string representation.
The function takes an RGB color object and converts its red, green, blue, and optional alpha components
into a hexadecimal color string. The output is always in 6-character format (RRGGBB) or 8-character format (RRGGBBAA)
if an alpha value is provided and not equal to 1.
The RGB values are normalized to fit the 0-255 integer range and clamped to ensure they remain valid.
The alpha value, if present, is normalized to the 0-255 range before being included in the hexadecimal format.
An object representing the RGB color components. The object should contain r, g, and b properties in normalized ranges (0.0 to 1.0) and an optional alpha property in the same range.
Returns string
The hexadecimal string representation of the RGB color.
Converts an RGB color to its hexadecimal string representation.
The function takes an RGB color object and converts its red, green, blue, and optional alpha components into a hexadecimal color string. The output is always in 6-character format (RRGGBB) or 8-character format (RRGGBBAA) if an alpha value is provided and not equal to 1.
The RGB values are normalized to fit the 0-255 integer range and clamped to ensure they remain valid. The alpha value, if present, is normalized to the 0-255 range before being included in the hexadecimal format.