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