rgb_to_hex
- compas.utilities.rgb_to_hex(rgb, g=None, b=None)[source]
Convert an RGB color specification to HEX.
Deprecated since version 1.14: Use
Color
instead.- Parameters
rgb (int or float | [int, int, int] | [float, float, float]) – A full RGB color specification, or an integer or a float representing the value of the red component.
g (int | float, optional) – The green component. This parameter is ignored if rgb is a full color specification.
b (int | float, optional) – The blue component. This parameter is ignored if rgb is a full color specification.
- Returns
str – The corresponding HEX color.
Examples
>>> rgb_to_hex((255, 0.0, 0.0)) '#ff0000' >>> rgb_to_hex((255, 0, 0)) '#ff0000' >>> rgb_to_hex((1.0, 0, 0)) '#ff0000' >>> rgb_to_hex((1, 0, 0)) '#010000'