pub fn map<T: Copy + Add<Output = T> + Sub<Output = T> + Mul<Output = T> + Div<Output = T>>(
value: T,
start1: T,
stop1: T,
start2: T,
stop2: T
) -> T
Expand description
Maps a value from one range to another.
Arguments
value
- A value of typeT
representing the value to map.start1
- A value of typeT
representing the start of the input range.stop1
- A value of typeT
representing the end of the input range.start2
- A value of typeT
representing the start of the output range.stop2
- A value of typeT
representing the end of the output range.
Returns
A value of type T
representing the mapped value.
Example
let value = 5;
let start1 = 0;
let stop1 = 10;
let start2 = 0;
let stop2 = 100;
let result = cgl_rs::utils::map(value, start1, stop1, start2, stop2);