Skip to main content

remap

Function remap 

pub fn remap(
    value: f64,
    istart: f64,
    istop: f64,
    ostart: f64,
    ostop: f64,
) -> f64
Expand description

Maps a value from range [istart, istop] to [ostart, ostop]. See also [method lerp] and [method inverse_lerp]. If value is outside [istart, istop], then the resulting value will also be outside [ostart, ostop]. If this is not desired, use [method clamp] on the result of this function.

remap(75, 0, 100, -1, 1) # Returns 0.5

For complex use cases where multiple ranges are needed, consider using Curve or Gradient instead.

Note: If istart == istop, the return value is undefined (most likely NaN, INF, or -INF).