Function withinRange

Returns true if two points are within a specified range on both axes.

Provide a point for the range to set different x/y range, or pass a number to use the same range for both axis.

Note this simply compares x,y values it does not calcuate distance.

withinRange({x:100,y:100}, {x:101, y:101}, 1); // True
withinRange({x:100,y:100}, {x:105, y:101}, {x:5, y:1}); // True
withinRange({x:100,y:100}, {x:105, y:105}, {x:5, y:1}); // False - y axis too far
  • Parameters

    Returns boolean