Wraps a point to be within ptMin and ptMax. 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.

// Wraps 150,100 to on 0,0 -100,100 range
wrap({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}
  • Parameters

    • pt: Point

      Point to wrap

    • OptionalptMax: Point

      Maximum value, or { x:1, y:1 } by default

    • OptionalptMin: Point

      Minimum value, or { x:0, y:0 } by default

    Returns Point

    Wrapped point