forked from jossmac/interpolate-range
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbundle.js
More file actions
1 lines (1 loc) · 1.1 KB
/
bundle.js
File metadata and controls
1 lines (1 loc) · 1.1 KB
1
"use strict";function clamp(t,r,e){var n=e,o=Math.min(t,r),a=Math.max(t,r);return n<o&&(n=o),a<n&&(n=a),n}function linearStep(t,r,e,n){return n?clamp(t,r,e):e}Object.defineProperty(exports,"__esModule",{value:!0});var slicedToArray=function(t,r){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return function(t,r){var e=[],n=!0,o=!1,a=void 0;try{for(var i,u=t[Symbol.iterator]();!(n=(i=u.next()).done)&&(e.push(i.value),!r||e.length!==r);n=!0);}catch(t){o=!0,a=t}finally{try{!n&&u.return&&u.return()}finally{if(o)throw a}}return e}(t,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")};function interpolate(t){var r=slicedToArray(t.inputRange,2),e=r[0],n=r[1],o=slicedToArray(t.outputRange,2),a=o[0],i=o[1],u=t.clamp,p=t.fn,l=void 0===p?linearStep:p,c=(i-a)/(n-e);return function(t){return l(a,i,(t-e)*c+a,u)}}function smoothStep(t,r,e){var n=clamp(t,r,(e-t)/(r-t));return n*n*(3-2*n)}function smootherStep(t,r,e){var n=clamp(t,r,(e-t)/(r-t));return n*n*n*(n*(6*n-15)+10)}exports.default=interpolate,exports.clamp=clamp,exports.smoothStep=smoothStep,exports.smootherStep=smootherStep;