MCPcopy Create free account
hub / github.com/microsoft/SandDance / clamper

Function clamper

docs/app/js/sanddance-app.js:127476–127482  ·  view source on GitHub ↗
(a, b)

Source from the content-addressed store, hash-verified

127474 } : (0, _constantJsDefault.default)(isNaN(b) ? NaN : 0.5);
127475}
127476function clamper(a, b) {
127477 var t;
127478 if (a > b) t = a, a = b, b = t;
127479 return function(x) {
127480 return Math.max(a, Math.min(b, x));
127481 };
127482}
127483// normalize(a, b)(x) takes a domain value x in [a,b] and returns the corresponding parameter t in [0,1].
127484// interpolate(a, b)(t) takes a parameter t in [0,1] and returns the corresponding range value x in [a,b].
127485function bimap(domain, range, interpolate) {

Callers 1

rescaleFunction · 0.70

Calls 2

maxMethod · 0.45
minMethod · 0.45

Tested by

no test coverage detected