Colorize text with hex code.

    :param text: the text you want to paint
    :param color: a hex color or rgb color
    :param background: decide to colorize background

    ::

        colorize('hello', 'ff0000')
        colorize('hello', '#ff0000')
        colorize('hello', (255, 0, 0))

def colorize(text, color, background=False):
    """
    Colorize text with hex code.

    :param text: the text you want to paint
    :param color: a hex color or rgb color
    :param background: decide to colorize background

    ::

        colorize('hello', 'ff0000')
        colorize('hello', '#ff0000')
        colorize('hello', (255, 0, 0))

    """

    if color in _styles:
        c = Color(text)
        c.styles = [_styles.index(color) + 1]
        return c

    c = Color(text)
    if background:
        c.bgcolor = _color2ansi(color)
    else:
        c.fgcolor = _color2ansi(color)
    return c