From dfbd36be4341f633cb51d187d3245efbc9d500a8 Mon Sep 17 00:00:00 2001 From: julian laplace Date: Mon, 7 Jul 2025 19:54:02 +0200 Subject: transitions, fix colors, add help --- client/lib/util.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'client/lib/util.js') diff --git a/client/lib/util.js b/client/lib/util.js index 5bf93dc..d0a3914 100644 --- a/client/lib/util.js +++ b/client/lib/util.js @@ -23,10 +23,13 @@ function choice(a) { function mod(n, m) { return n - m * Math.floor(n / m); } -function roundFreq(freq) { - return Math.round(freq * 100); +function roundInterval(interval) { + return Math.round(interval * 10000000); } -const frequencyInRange = (freq) => 20 < freq && freq < 15000; +const intervalInRange = (interval, root) => + 20 < interval * root && interval * root < 15000; +const lerp = (n, a, b) => (b - a) * n + a; +const clamp = (n, a = 0, b = 1) => (n < a ? a : n < b ? n : b); function requestAudioContext(fn) { if (window.location.protocol !== "https:") { @@ -75,7 +78,9 @@ export { choice, mod, browser, - roundFreq, - frequencyInRange, + lerp, + clamp, + roundInterval, + intervalInRange, requestAudioContext, }; -- cgit v1.2.3-70-g09d2