- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 210
 
Closed
Labels
Description
Now that the lerp function has been implemented into pygame.math I thought it would also be a good idea to add the invlerp and remap functions.
def inv_lerp(a: float, b: float, v: float) -> float:
    return (v - a) / (b - a)
def remap(i_min: float, i_max: float, o_min: float, o_max: float, v: float) -> float:
    t = inv_lerp(i_min, i_max, v)
    return lerp(o_min, o_max, t)inv_lerp is opposite of lerp and remap utilizes both to map a value from an input range to an output range. Very useful if you want to remap things like colors or percents etc.