Wraps a point to be within ptMin and ptMax. Note that max values are exclusive, meaning the return value will always be one less.
ptMin
ptMax
Eg, if a view port is 100x100 pixels, wrapping the point 150,100 yields 50,99.
// Wraps 150,100 to on 0,0 -100,100 rangewrap({x:150,y:100}, {x:100,y:100}); Copy
// Wraps 150,100 to on 0,0 -100,100 rangewrap({x:150,y:100}, {x:100,y:100});
Wrap normalised point:
wrap({x:1.2, y:1.5}); // Yields: {x:0.2, y:0.5} Copy
wrap({x:1.2, y:1.5}); // Yields: {x:0.2, y:0.5}
Point to wrap
Optional
Maximum value, or { x:1, y:1 } by default
{ x:1, y:1 }
Minimum value, or { x:0, y:0 } by default
{ x:0, y:0 }
Wrapped point
Wraps a point to be within
ptMin
andptMax
. Note that max values are exclusive, meaning the return value will always be one less.Eg, if a view port is 100x100 pixels, wrapping the point 150,100 yields 50,99.
Wrap normalised point: