color_to_rgb

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

Convert a HEX or RGB color to RGB.

Deprecated since version 1.14: Use compas.colors.Color instead.

Parameters
  • color (str | [int, int, int] | [float, float, float]) – The color.

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

Returns

tuple[int, int, int] | tuple[float, float, float] – If normalize is True, the RGB color with 0-1 float components. If normalize is False, the RGB color with 0-255 integer components.

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)