This commit is contained in:
eewing
2026-02-17 14:10:16 -06:00
parent 2bca5834c5
commit cf73cd3b4c
11246 changed files with 1690552 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
export function linearScale(domain, range, clamp = true) {
const [d0, d1] = domain;
const [r0, r1] = range;
const slope = (r1 - r0) / (d1 - d0);
return (x) => {
const result = r0 + slope * (x - d0);
if (!clamp)
return result;
if (result > Math.max(r0, r1))
return Math.max(r0, r1);
if (result < Math.min(r0, r1))
return Math.min(r0, r1);
return result;
};
}