You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
490 B
16 lines
490 B
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.createClamp = void 0;
|
|
/**
|
|
* 返回一个 clamp 函数,将输入限定在指定范围之内
|
|
* @param a 范围的第一个端点
|
|
* @param b 范围的第二个端点
|
|
* @returns clamp 函数
|
|
*/
|
|
function createClamp(a, b) {
|
|
const lo = b < a ? b : a;
|
|
const hi = a > b ? a : b;
|
|
return (x) => Math.min(Math.max(lo, x), hi);
|
|
}
|
|
exports.createClamp = createClamp;
|
|
//# sourceMappingURL=clamp.js.map
|