mirror of
https://github.com/openseadragon/openseadragon.git
synced 2025-01-31 23:21:42 +03:00
Extract rect calculation
This commit is contained in:
parent
6778533642
commit
50e46b104e
@ -1155,32 +1155,36 @@ function drawTiles( tiledImage, lastDrawn ){
|
|||||||
viewer,
|
viewer,
|
||||||
viewport,
|
viewport,
|
||||||
position,
|
position,
|
||||||
tileSource;
|
tileSource,
|
||||||
|
needsRestore = false;
|
||||||
|
|
||||||
|
// TODO: Move this function
|
||||||
|
var boxToDrawerRectangle = function( box ) {
|
||||||
|
var topLeft = tiledImage.viewport.pixelFromPoint(box.getTopLeft(), true);
|
||||||
|
var size = tiledImage.viewport.deltaPixelsFromPoints(box.getSize(), true);
|
||||||
|
|
||||||
|
return new $.Rect(
|
||||||
|
topLeft.x * $.pixelDensityRatio,
|
||||||
|
topLeft.y * $.pixelDensityRatio,
|
||||||
|
size.x * $.pixelDensityRatio,
|
||||||
|
size.y * $.pixelDensityRatio
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
var needsRestore = false;
|
|
||||||
if ( tiledImage._clip ) {
|
if ( tiledImage._clip ) {
|
||||||
tiledImage._drawer.saveContext();
|
tiledImage._drawer.saveContext();
|
||||||
var box = tiledImage.imageToViewportRectangle(tiledImage._clip, true);
|
var box = tiledImage.imageToViewportRectangle(tiledImage._clip, true);
|
||||||
var topLeft = tiledImage.viewport.pixelFromPoint(box.getTopLeft(), true);
|
var clipRect = boxToDrawerRectangle(box);
|
||||||
var size = tiledImage.viewport.deltaPixelsFromPoints(box.getSize(), true);
|
|
||||||
box = new OpenSeadragon.Rect(topLeft.x * $.pixelDensityRatio,
|
tiledImage._drawer.setClip(clipRect);
|
||||||
topLeft.y * $.pixelDensityRatio,
|
|
||||||
size.x * $.pixelDensityRatio,
|
|
||||||
size.y * $.pixelDensityRatio);
|
|
||||||
tiledImage._drawer.setClip(box);
|
|
||||||
needsRestore = true;
|
needsRestore = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( lastDrawn.length === 0 ) {
|
if ( lastDrawn.length === 0 ) {
|
||||||
tiledImage._drawer.saveContext();
|
tiledImage._drawer.saveContext();
|
||||||
var box = tiledImage.getBounds(true);
|
var placeholderRect = boxToDrawerRectangle( tiledImage.getBounds(true) );
|
||||||
var topLeft = tiledImage.viewport.pixelFromPoint(box.getTopLeft(), true);
|
|
||||||
var size = tiledImage.viewport.deltaPixelsFromPoints(box.getSize(), true);
|
tiledImage._drawer.drawPlaceholder(placeholderRect);
|
||||||
box = new OpenSeadragon.Rect(topLeft.x * $.pixelDensityRatio,
|
|
||||||
topLeft.y * $.pixelDensityRatio,
|
|
||||||
size.x * $.pixelDensityRatio,
|
|
||||||
size.y * $.pixelDensityRatio);
|
|
||||||
tiledImage._drawer.drawPlaceholder(box);
|
|
||||||
needsRestore = true;
|
needsRestore = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user