We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Constrain a number within a minimum and a maximum value.
Similar: constrain, normalize, remap, lerp.
function constrain(x, min, max) // x: a number // min: minimum value // max: maximum value
const xmath = require('extra-math'); xmath.constrain(20, 0, 50); // → 20 xmath.constrain(-10, 0, 100); // → 0 xmath.constrain(120, 0, 100); // → 100