mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-25 22:56:11 +03:00
Add viewportToImageRectangle method and add support to pass a point to viewportToImageCoordinates and imageToViewportCoordinates
This commit is contained in:
parent
7f88bf78b6
commit
bfa76e471b
@ -726,6 +726,10 @@ $.Viewport.prototype = {
|
|||||||
* system to image coordinate system
|
* system to image coordinate system
|
||||||
*/
|
*/
|
||||||
viewportToImageCoordinates: function(viewerX, viewerY) {
|
viewportToImageCoordinates: function(viewerX, viewerY) {
|
||||||
|
if ( arguments.length == 1 ) {
|
||||||
|
//they passed a point instead of individual components
|
||||||
|
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);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -734,6 +738,10 @@ $.Viewport.prototype = {
|
|||||||
* Seajax viewer coordinate system
|
* Seajax viewer coordinate system
|
||||||
*/
|
*/
|
||||||
imageToViewportCoordinates: function( imageX, imageY ) {
|
imageToViewportCoordinates: function( imageX, imageY ) {
|
||||||
|
if ( arguments.length == 1 ) {
|
||||||
|
//they passed a point instead of individual components
|
||||||
|
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);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -763,6 +771,29 @@ $.Viewport.prototype = {
|
|||||||
coordB.x,
|
coordB.x,
|
||||||
coordB.y
|
coordB.y
|
||||||
);
|
);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Translates from a rectangle which describes a portion of
|
||||||
|
* the viewport in point coordinates to image rectangle coordinates.
|
||||||
|
*/
|
||||||
|
viewportToImageRectangle: function( viewerX, viewerY, pointWidth, pointHeight ) {
|
||||||
|
var coordA,
|
||||||
|
coordB,
|
||||||
|
rect;
|
||||||
|
if ( arguments.length == 1 ) {
|
||||||
|
//they passed a rectangle instead of individual components
|
||||||
|
rect = viewerX;
|
||||||
|
return this.viewportToImageRectangle(rect.x, rect.y, rect.width, rect.height);
|
||||||
|
}
|
||||||
|
coordA = this.viewportToImageCoordinates(viewerX, viewerY);
|
||||||
|
coordB = this.viewportToImageCoordinates(pointWidth, pointHeight);
|
||||||
|
return new $.Rect(
|
||||||
|
coordA.x,
|
||||||
|
coordA.y,
|
||||||
|
coordB.x,
|
||||||
|
coordB.y
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user