The minimum value of the range.
The maximum value of the range.
The value to wrap around the range.
wrap(0, 3, 0); // => 0
wrap(0, 3, 1); // => 1
wrap(0, 3, 2); // => 2
wrap(0, 3, 3); // => 0 (wraps back to the start)
wrap(0, 3, -1); // => 2 (wraps from below to the end)
wrap(0, 3, -2); // => 1
wrap(0, 3, -3); // => 0
Wrap a value around a specified range. When the value exceeds the
max
, it wraps back tomin
, and when it's belowmin
, it wraps around tomax
.