mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-21 20:56:09 +03:00
Fixed "toImage" converters
This commit is contained in:
parent
186e2f8f54
commit
2a5fd0b0f7
@ -608,6 +608,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
|||||||
if (successes) {
|
if (successes) {
|
||||||
if (_this._firstOpen || !_this.preserveViewport) {
|
if (_this._firstOpen || !_this.preserveViewport) {
|
||||||
_this.viewport.goHome( true );
|
_this.viewport.goHome( true );
|
||||||
|
_this.viewport.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
_this._firstOpen = false;
|
_this._firstOpen = false;
|
||||||
|
@ -953,7 +953,10 @@ $.Viewport.prototype = /** @lends OpenSeadragon.Viewport.prototype */{
|
|||||||
//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 );
|
|
||||||
|
var scale = this.homeBounds.width;
|
||||||
|
return new $.Point((viewerX - this.homeBounds.x) * (this.contentSize.x / scale),
|
||||||
|
(viewerY - this.homeBounds.y) * ((this.contentSize.y * this.contentAspectX) / scale));
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -971,7 +974,10 @@ $.Viewport.prototype = /** @lends OpenSeadragon.Viewport.prototype */{
|
|||||||
//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 );
|
|
||||||
|
var scale = this.homeBounds.width;
|
||||||
|
return new $.Point(this.homeBounds.x + ((imageX / this.contentSize.x) * scale),
|
||||||
|
this.homeBounds.y + ((imageY / this.contentSize.y / this.contentAspectX) * scale));
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1003,13 +1009,13 @@ $.Viewport.prototype = /** @lends OpenSeadragon.Viewport.prototype */{
|
|||||||
imageX, imageY
|
imageX, imageY
|
||||||
);
|
);
|
||||||
coordB = this.imageToViewportCoordinates(
|
coordB = this.imageToViewportCoordinates(
|
||||||
pixelWidth, pixelHeight
|
imageX + pixelWidth, imageY + pixelHeight
|
||||||
);
|
);
|
||||||
return new $.Rect(
|
return new $.Rect(
|
||||||
coordA.x,
|
coordA.x,
|
||||||
coordA.y,
|
coordA.y,
|
||||||
coordB.x,
|
coordB.x - coordA.x,
|
||||||
coordB.y
|
coordB.y - coordA.y
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1039,12 +1045,12 @@ $.Viewport.prototype = /** @lends OpenSeadragon.Viewport.prototype */{
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
coordA = this.viewportToImageCoordinates( viewerX, viewerY );
|
coordA = this.viewportToImageCoordinates( viewerX, viewerY );
|
||||||
coordB = this.viewportToImageCoordinates( pointWidth, pointHeight );
|
coordB = this.viewportToImageCoordinates(viewerX + pointWidth, viewerY + pointHeight);
|
||||||
return new $.Rect(
|
return new $.Rect(
|
||||||
coordA.x,
|
coordA.x,
|
||||||
coordA.y,
|
coordA.y,
|
||||||
coordB.x,
|
coordB.x - coordA.x,
|
||||||
coordB.y
|
coordB.y - coordA.y
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1148,7 +1154,8 @@ $.Viewport.prototype = /** @lends OpenSeadragon.Viewport.prototype */{
|
|||||||
viewportToImageZoom: function( viewportZoom ) {
|
viewportToImageZoom: function( viewportZoom ) {
|
||||||
var imageWidth = this.viewer.source.dimensions.x;
|
var imageWidth = this.viewer.source.dimensions.x;
|
||||||
var containerWidth = this._containerInnerSize.x;
|
var containerWidth = this._containerInnerSize.x;
|
||||||
var viewportToImageZoomRatio = containerWidth / imageWidth;
|
var scale = this.homeBounds.width;
|
||||||
|
var viewportToImageZoomRatio = (containerWidth / imageWidth) * scale;
|
||||||
return viewportZoom * viewportToImageZoomRatio;
|
return viewportZoom * viewportToImageZoomRatio;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1166,7 +1173,8 @@ $.Viewport.prototype = /** @lends OpenSeadragon.Viewport.prototype */{
|
|||||||
imageToViewportZoom: function( imageZoom ) {
|
imageToViewportZoom: function( imageZoom ) {
|
||||||
var imageWidth = this.viewer.source.dimensions.x;
|
var imageWidth = this.viewer.source.dimensions.x;
|
||||||
var containerWidth = this._containerInnerSize.x;
|
var containerWidth = this._containerInnerSize.x;
|
||||||
var viewportToImageZoomRatio = imageWidth / containerWidth;
|
var scale = this.homeBounds.width;
|
||||||
|
var viewportToImageZoomRatio = (imageWidth / containerWidth) / scale;
|
||||||
return imageZoom * viewportToImageZoomRatio;
|
return imageZoom * viewportToImageZoomRatio;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
var testInitialOpen = true;
|
var testInitialOpen = true;
|
||||||
var testOverlays = true;
|
var testOverlays = false;
|
||||||
var testMargins = false;
|
var testMargins = false;
|
||||||
var testNavigator = false;
|
var testNavigator = false;
|
||||||
var margins;
|
var margins;
|
||||||
@ -34,6 +34,12 @@
|
|||||||
|
|
||||||
if (testInitialOpen) {
|
if (testInitialOpen) {
|
||||||
config.tileSources = [
|
config.tileSources = [
|
||||||
|
{
|
||||||
|
tileSource: "../../data/testpattern.dzi",
|
||||||
|
x: 4,
|
||||||
|
y: 2,
|
||||||
|
width: 2
|
||||||
|
},
|
||||||
{
|
{
|
||||||
tileSource: "../../data/tall.dzi",
|
tileSource: "../../data/tall.dzi",
|
||||||
x: 1.5,
|
x: 1.5,
|
||||||
|
Loading…
Reference in New Issue
Block a user