diff --git a/source/code/hippie/app.js b/source/code/hippie/app.js index 81d2494..d5f077f 100644 --- a/source/code/hippie/app.js +++ b/source/code/hippie/app.js @@ -523,6 +523,22 @@ function capitalizeFirstLetter(text) { return text.charAt(0).toUpperCase() + text.slice(1); } +function mapRange(value, inMin, inMax, outMin, outMax, reverse = false, clamp = false) { + let min = outMin; + let max = outMax; + + if (reverse) { + [min, max] = [max, min]; + } + + const mapped = (value - inMin) * (max - min) / (inMax - inMin) + min; + + if (clamp) { + return Math.max(Math.min(min, max), Math.min(Math.max(min, max), mapped)); + } + return mapped; +} + // CONCEPTS // NOTE: Benutzt private Zuweisungen