def int_from_rgb(rgb):
    """Return an int in the range [0, 0xffffff] converted from an RGB tuple."""
    return (round(rgb[0] * 0xff) << 16) + \
        (round(rgb[1] * 0xff) << 8) + \
        round(rgb[2] * 0xff)