def nmap(value, fr=(0, 1), to=(0, 1)):
    """
    Map a value from a two-value interval into another two-value interval.
    Both intervals are `(0, 1)` by default. Values outside the `fr` interval
    are still mapped proportionately.
    """
    value = (value - fr[0]) / (fr[1] - fr[0])
    return to[0] + value * (to[1] - to[0])