code: function(r) {
  
              if (r.containsPoint(this)) {
                  return this;
              }
  
              this.x = min(max(this.x, r.x), r.x + r.width);
              this.y = min(max(this.y, r.y), r.y + r.height);
              return this;
          }
docs: If point lies outside rectangle `r`, return the nearest point on the boundary of rect `r`, otherwise return point itself. (see Squeak Smalltalk, Point>>adhereTo:)