Add comments and fix indentation

This commit is contained in:
Antoine Vandecreme 2013-09-04 14:13:25 -04:00
parent bfa76e471b
commit 63af5a69ac

View File

@ -722,33 +722,54 @@ $.Viewport.prototype = {
}, },
/** /**
* Translates from Seajax viewer coordinate * Translates from Seajax viewer coordinate system to image coordinate system.
* system to image coordinate system * This method can be called either by passing X,Y coordinates or an
* OpenSeadragon.Point
* @function
* @param {OpenSeadragon.Point} viewerX the point in viewport coordinate system.
* @param {Number} viewerX X coordinate in viewport coordinate system.
* @param {Number} viewerY Y coordinate in viewport coordinate system.
* @return {OpenSeadragon.Point} a point representing the coordinates in the image.
*/ */
viewportToImageCoordinates: function(viewerX, viewerY) { viewportToImageCoordinates: function( viewerX, viewerY ) {
if ( arguments.length == 1 ) { if ( arguments.length == 1 ) {
//they passed a point instead of individual components //they passed a point instead of individual components
return this.viewportToImageCoordinates(viewerX.x, viewerX.y); return this.viewportToImageCoordinates( viewerX.x, viewerX.y );
} }
return new $.Point(viewerX * this.contentSize.x, viewerY * this.contentSize.y * this.contentAspectX); return new $.Point( viewerX * this.contentSize.x, viewerY * this.contentSize.y * this.contentAspectX );
}, },
/** /**
* Translates from image coordinate system to * Translates from image coordinate system to Seajax viewer coordinate system
* Seajax viewer coordinate system * This method can be called either by passing X,Y coordinates or an
* OpenSeadragon.Point
* @function
* @param {OpenSeadragon.Point} imageX the point in image coordinate system.
* @param {Number} imageX X coordinate in image coordinate system.
* @param {Number} imageY Y coordinate in image coordinate system.
* @return {OpenSeadragon.Point} a point representing the coordinates in the viewport.
*/ */
imageToViewportCoordinates: function( imageX, imageY ) { imageToViewportCoordinates: function( imageX, imageY ) {
if ( arguments.length == 1 ) { if ( arguments.length == 1 ) {
//they passed a point instead of individual components //they passed a point instead of individual components
return this.imageToViewportCoordinates(imageX.x, imageX.y); return this.imageToViewportCoordinates( imageX.x, imageX.y );
} }
return new $.Point( imageX / this.contentSize.x, imageY / this.contentSize.y / this.contentAspectX); return new $.Point( imageX / this.contentSize.x, imageY / this.contentSize.y / this.contentAspectX );
}, },
/** /**
* Translates from a rectangle which describes a portion of * Translates from a rectangle which describes a portion of the image in
* the image in pixel coordinates to OpenSeadragon viewport * pixel coordinates to OpenSeadragon viewport rectangle coordinates.
* rectangle coordinates. * This method can be called either by passing X,Y,width,height or an
* OpenSeadragon.Rect
* @function
* @param {OpenSeadragon.Rect} imageX the rectangle in image coordinate system.
* @param {Number} imageX the X coordinate of the top left corner of the rectangle
* in image coordinate system.
* @param {Number} imageY the Y coordinate of the top left corner of the rectangle
* in image coordinate system.
* @param {Number} pixelWidth the width in pixel of the rectangle.
* @param {Number} pixelHeight the height in pixel of the rectangle.
*/ */
imageToViewportRectangle: function( imageX, imageY, pixelWidth, pixelHeight ) { imageToViewportRectangle: function( imageX, imageY, pixelWidth, pixelHeight ) {
var coordA, var coordA,
@ -757,7 +778,9 @@ $.Viewport.prototype = {
if( arguments.length == 1 ) { if( arguments.length == 1 ) {
//they passed a rectangle instead of individual components //they passed a rectangle instead of individual components
rect = imageX; rect = imageX;
return this.imageToViewportRectangle(rect.x, rect.y, rect.width, rect.height); return this.imageToViewportRectangle(
rect.x, rect.y, rect.width, rect.height
);
} }
coordA = this.imageToViewportCoordinates( coordA = this.imageToViewportCoordinates(
imageX, imageY imageX, imageY
@ -776,6 +799,16 @@ $.Viewport.prototype = {
/** /**
* Translates from a rectangle which describes a portion of * Translates from a rectangle which describes a portion of
* the viewport in point coordinates to image rectangle coordinates. * the viewport in point coordinates to image rectangle coordinates.
* This method can be called either by passing X,Y,width,height or an
* OpenSeadragon.Rect
* @function
* @param {OpenSeadragon.Rect} viewerX the rectangle in viewport coordinate system.
* @param {Number} viewerX the X coordinate of the top left corner of the rectangle
* in viewport coordinate system.
* @param {Number} imageY the Y coordinate of the top left corner of the rectangle
* in viewport coordinate system.
* @param {Number} pointWidth the width of the rectangle in viewport coordinate system.
* @param {Number} pointHeight the height of the rectangle in viewport coordinate system.
*/ */
viewportToImageRectangle: function( viewerX, viewerY, pointWidth, pointHeight ) { viewportToImageRectangle: function( viewerX, viewerY, pointWidth, pointHeight ) {
var coordA, var coordA,
@ -784,10 +817,12 @@ $.Viewport.prototype = {
if ( arguments.length == 1 ) { if ( arguments.length == 1 ) {
//they passed a rectangle instead of individual components //they passed a rectangle instead of individual components
rect = viewerX; rect = viewerX;
return this.viewportToImageRectangle(rect.x, rect.y, rect.width, rect.height); return this.viewportToImageRectangle(
rect.x, rect.y, rect.width, rect.height
);
} }
coordA = this.viewportToImageCoordinates(viewerX, viewerY); coordA = this.viewportToImageCoordinates( viewerX, viewerY );
coordB = this.viewportToImageCoordinates(pointWidth, pointHeight); coordB = this.viewportToImageCoordinates( pointWidth, pointHeight );
return new $.Rect( return new $.Rect(
coordA.x, coordA.x,
coordA.y, coordA.y,