mirror of
https://github.com/Dr-Blank/Vaani.git
synced 2025-12-06 19:19:28 +00:00
14 lines
368 B
Dart
14 lines
368 B
Dart
|
|
extension InverseLerp on num {
|
||
|
|
/// Returns the fraction of this value between [min] and [max].
|
||
|
|
double inverseLerp(num min, num max) {
|
||
|
|
return (this - min) / (max - min);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
extension Lerp on double {
|
||
|
|
/// Returns the value between [min] and [max] given the fraction [t].
|
||
|
|
double lerp(double min, double max) {
|
||
|
|
return min + ((max - min) * this);
|
||
|
|
}
|
||
|
|
}
|