Skip to main content

Math

Most typical JavaScript Math function are supported. Please file an issue if we missed one.

Math.map

Maps a value between two ranges.

const ratio = 0.5 // [0, 1]
const percent = Math.map(ratio, 0, 1, 0, 100)

Math.constrain

Constrains a value between two values.

const v = -0.1 // [0, 1]
const c = Math.constrain(v, 0, 1)