color_to_rgb

compas.utilities.color_to_rgb(color, normalize=False)[source]

Convert a HEX or RGB color to RGB.

Parameters
  • color (str or tuple or float) – The color.

  • normalize (bool, optional) – If true, normalize the resulting RGB color components.

Returns

tuple – The corresponding RGB color specification.

Examples

>>> color_to_rgb('#ff0000')
(255, 0, 0)
>>> color_to_rgb('#ff0000', normalize=True)
(1.0, 0.0, 0.0)
>>> color_to_rgb(1.0, normalize=True)
(1.0, 0.0, 0.0)
>>> color_to_rgb(1.0)
(255, 0, 0)
>>> color_to_rgb((255, 0, 0))
(255, 0, 0)
>>> color_to_rgb((255, 0, 0), normalize=True)
(1.0, 0.0, 0.0)