def rgb2hex(r, g, b, normalized=False):
    """ Converts RGB to HEX color """

    # Check if RGB triplett is normalized to unity
    if normalized:
        r, g, b = r * 255.0, g * 255.0, b * 255.0

    return '#%02X%02X%02X' % (r, g, b)