code: function(imageX, imageY, pixelWidth, pixelHeight, current) {
          var rect = imageX;
          if (rect instanceof $.Rect) {
              //they passed a rect instead of individual components
              current = imageY;
          } else {
              rect = new $.Rect(imageX, imageY, pixelWidth, pixelHeight);
          }
  
          var coordA = this.imageToViewportCoordinates(rect.getTopLeft(), current);
          var coordB = this._imageToViewportDelta(rect.width, rect.height, current);
  
          return new $.Rect(
              coordA.x,
              coordA.y,
              coordB.x,
              coordB.y,
              rect.degrees + this.getRotation(current)
          );
      }
docs: Translates from a rectangle which describes a portion of the image in
  pixel coordinates to OpenSeadragon viewport rectangle coordinates.
  This method can be called either by passing X,Y,width,height or an {@link OpenSeadragon.Rect}.
  @param {Number|OpenSeadragon.Rect} imageX - The left coordinate or rectangle in image coordinate system.
  @param {Number} [imageY] - The top coordinate in image coordinate system.
  @param {Number} [pixelWidth] - The width in pixel of the rectangle.
  @param {Number} [pixelHeight] - The height in pixel of the rectangle.
  @param {Boolean} [current=false] - Pass true to use the current location; false for target location.
  @return {OpenSeadragon.Rect} A rect representing the coordinates in the viewport.