def color_to_rgb(color):
    """Convert hex color code to 8-bit R, G, B values."""
    # Strip out any preceeding pound sign.
    if color is not None:
        color = color.strip('#')
    # Convert to hex then grab component byte values and return them as a tuple.
    try:
        value = int(color, 16)
    except ValueError:
        raise RuntimeError('Expected color value to be in HTML format (like #ff0000) but found: {0}'.format(color))
    return (((value >> 16) & 0xFF, (value >> 8) & 0xFF, value & 0xFF))