Function ludomath::num::range_map
[−]
[src]
pub fn range_map(
x: f32,
from_start: f32,
from_end: f32,
to_start: f32,
to_end: f32
) -> f32
Maps a value relative to some range to the corresponding value relative to another range.
Computes how far x
is (percentage-wise) from the start to the end
of the range [from_start
, from_end
], and returns the value with
the same percentage in the range [to_start
, to_end
].
Still works if x
is outside the range.