Wraps floating point numbers to be within a range (default: 0..1). Use wrapInteger if you want to wrap integer values.
This logic makes sense for some things like rotation angle.
If you just want to lock values to a range without wrapping, consider clamp.
wrap(1.2); // 0.2wrap(2); // 1.0wrap(-0.2); // 0.8 Copy
wrap(1.2); // 0.2wrap(2); // 1.0wrap(-0.2); // 0.8
A range can be provided too:
wrap(30, 20, 50); // 30wrap(60, 20, 50); // 30 Copy
wrap(30, 20, 50); // 30wrap(60, 20, 50); // 30
Wraps floating point numbers to be within a range (default: 0..1). Use wrapInteger if you want to wrap integer values.
This logic makes sense for some things like rotation angle.
If you just want to lock values to a range without wrapping, consider clamp.
A range can be provided too: