16 lines
366 B
JavaScript
16 lines
366 B
JavaScript
"use strict";
|
|
|
|
function normalise(value, { min : input_min, max: input_max }, { min : output_min, max: output_max }) {
|
|
return (
|
|
((value - input_min) / (input_max - input_min)) * (output_max - output_min)
|
|
) + output_min
|
|
}
|
|
|
|
function clamp(value, min, max) {
|
|
if(value > max) return max;
|
|
if(value < min) return min;
|
|
return value;
|
|
}
|
|
|
|
|
|
export { normalise, clamp };
|