map-number
Version:
processing/p5.js map like function, including floating point numbers support
3 lines (2 loc) • 694 B
JavaScript
var n,t;n=this,t=function(n){function t(n,t,e,o,r){return(n-t)*(r-o)/(e-t)+o}function e(n,t){return(e,o,r,f,i)=>t(n(e,o,r,f,i))}const o=e(t,Math.ceil);function r(n,t,e,o,r){return f=>n(f,t,e,o,r)}const f=e(t,Math.floor);function i(n,e,o,r,f){const i=t(n,e,o,r,f);let c=r,u=f;if(u<c){const n=c;c=u,u=n}return i>u?u:i<c?c:i}const c=e(t,Math.round);n.ceil=o,n.clamp=i,n.compile=r,n.create=r,n.floor=f,n.limit=i,n.map=t,n.round=c,n.transform=e,n.transformed=e,n.wrap=r},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((n="undefined"!=typeof globalThis?globalThis:n||self).mapNum={});
//# sourceMappingURL=map.min.js.map