RGBtoHex

grizli.utils.RGBtoHex(vals, rgbtype=1)[source]

Converts RGB values in a variety of formats to Hex values.

Parameters:
vals : tuple

An RGB/RGBA tuple

rgb_type : int
Valid valus are:
  • 1 = Inputs are in the range 0 to 1
  • 256 = Inputs are in the range 0 to 255
Returns:
hextstr : str

A hex string in the form ‘#RRGGBB’ or ‘#RRGGBBAA’

References

(credit: Rychard @ https://stackoverflow.com/a/48288173)