function pointInRect(p, rect, tolerance) {
  tolerance = tolerance || 0;

  return p.x > rect.x - tolerance &&
         p.y > rect.y - tolerance &&
         p.x < rect.x + rect.width + tolerance &&
         p.y < rect.y + rect.height + tolerance;
}
Returns true if the point p is inside the rectangle rect

@param {Point} p
@param {Rect} rect
@param {number} tolerance

@return {boolean}