mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-25 22:56:11 +03:00
Test for clip feature
This commit is contained in:
parent
c27f68640f
commit
e433863f09
@ -1163,10 +1163,10 @@ function drawTiles( tiledImage, lastDrawn ){
|
||||
var box = tiledImage.imageToViewportRectangle(tiledImage._clip, true);
|
||||
var topLeft = tiledImage.viewport.pixelFromPoint(box.getTopLeft(), true);
|
||||
var size = tiledImage.viewport.deltaPixelsFromPoints(box.getSize(), true);
|
||||
box = new OpenSeadragon.Rect(Math.round(topLeft.x * $.pixelDensityRatio),
|
||||
Math.round(topLeft.y * $.pixelDensityRatio),
|
||||
Math.round(size.x * $.pixelDensityRatio),
|
||||
Math.round(size.y * $.pixelDensityRatio));
|
||||
box = new OpenSeadragon.Rect(topLeft.x * $.pixelDensityRatio,
|
||||
topLeft.y * $.pixelDensityRatio,
|
||||
size.x * $.pixelDensityRatio,
|
||||
size.y * $.pixelDensityRatio);
|
||||
tiledImage._drawer.setClip(box);
|
||||
usedClip = true;
|
||||
}
|
||||
|
@ -191,4 +191,33 @@
|
||||
viewer.open('/test/data/testpattern.dzi');
|
||||
});
|
||||
|
||||
// ----------
|
||||
asyncTest('clip', function() {
|
||||
var clip = new OpenSeadragon.Rect(100, 100, 800, 800);
|
||||
|
||||
viewer.addHandler('open', function() {
|
||||
var image = viewer.world.getItemAt(0);
|
||||
propEqual(image.getClip(), clip, 'image has correct clip');
|
||||
|
||||
image.setClip(null);
|
||||
equal(image.getClip(), null, 'clip is cleared');
|
||||
|
||||
image.setClip(clip);
|
||||
propEqual(image.getClip(), clip, 'clip is set correctly');
|
||||
|
||||
Util.spyOnce(viewer.drawer, 'setClip', function(rect) {
|
||||
ok(true, 'drawer.setClip is called');
|
||||
var pixelRatio = viewer.viewport.getContainerSize().x / image.getContentSize().x;
|
||||
var canvasClip = clip.times(pixelRatio * OpenSeadragon.pixelDensityRatio);
|
||||
propEqual(rect, canvasClip, 'clipping to correct rect');
|
||||
start();
|
||||
});
|
||||
});
|
||||
|
||||
viewer.open({
|
||||
tileSource: '/test/data/testpattern.dzi',
|
||||
clip: clip
|
||||
});
|
||||
});
|
||||
|
||||
})();
|
||||
|
Loading…
Reference in New Issue
Block a user