mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-25 06:36:11 +03:00
Add TileSource.getTileAtPoint test
This commit is contained in:
parent
6370a6bafa
commit
b162f197ea
@ -217,7 +217,7 @@
|
|||||||
var firstImage = viewer.world.getItemAt(0);
|
var firstImage = viewer.world.getItemAt(0);
|
||||||
firstImage.addHandler('fully-loaded-change', function() {
|
firstImage.addHandler('fully-loaded-change', function() {
|
||||||
var imageData = viewer.drawer.context.getImageData(0, 0,
|
var imageData = viewer.drawer.context.getImageData(0, 0,
|
||||||
500 * OpenSeadragon.pixelDensityRatio, 500 * density);
|
500 * density, 500 * density);
|
||||||
|
|
||||||
// Pixel 250,250 will be in the hole of the A
|
// Pixel 250,250 will be in the hole of the A
|
||||||
var expectedVal = getPixelValue(imageData, 250 * density, 250 * density);
|
var expectedVal = getPixelValue(imageData, 250 * density, 250 * density);
|
||||||
|
@ -48,4 +48,43 @@
|
|||||||
Util.testDeprecation(source, 'getTileSize');
|
Util.testDeprecation(source, 'getTileSize');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('getTileAtPoint', function() {
|
||||||
|
var tileSource = new OpenSeadragon.TileSource({
|
||||||
|
width: 1500,
|
||||||
|
height: 1000,
|
||||||
|
tileWidth: 200,
|
||||||
|
tileHeight: 150,
|
||||||
|
tileOverlap: 1,
|
||||||
|
});
|
||||||
|
|
||||||
|
equal(tileSource.maxLevel, 11, "The max level should be 11.");
|
||||||
|
|
||||||
|
function assertTileAtPoint(level, position, expected) {
|
||||||
|
var actual = tileSource.getTileAtPoint(level, position);
|
||||||
|
ok(actual.equals(expected), "The tile at level " + level +
|
||||||
|
", position " + position.toString() +
|
||||||
|
" should be tile " + expected.toString() +
|
||||||
|
" got " + actual.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
assertTileAtPoint(11, new OpenSeadragon.Point(0, 0), new OpenSeadragon.Point(0, 0));
|
||||||
|
assertTileAtPoint(11, new OpenSeadragon.Point(0.5, 0.5), new OpenSeadragon.Point(3, 5));
|
||||||
|
assertTileAtPoint(11, new OpenSeadragon.Point(1, 10 / 15), new OpenSeadragon.Point(7, 6));
|
||||||
|
|
||||||
|
assertTileAtPoint(10, new OpenSeadragon.Point(0, 0), new OpenSeadragon.Point(0, 0));
|
||||||
|
assertTileAtPoint(10, new OpenSeadragon.Point(0.5, 0.5), new OpenSeadragon.Point(1, 2));
|
||||||
|
assertTileAtPoint(10, new OpenSeadragon.Point(1, 10 / 15), new OpenSeadragon.Point(3, 3));
|
||||||
|
|
||||||
|
assertTileAtPoint(9, new OpenSeadragon.Point(0, 0), new OpenSeadragon.Point(0, 0));
|
||||||
|
assertTileAtPoint(9, new OpenSeadragon.Point(0.5, 0.5), new OpenSeadragon.Point(0, 1));
|
||||||
|
assertTileAtPoint(9, new OpenSeadragon.Point(1, 10 / 15), new OpenSeadragon.Point(1, 1));
|
||||||
|
|
||||||
|
// For all other levels, there is only one tile.
|
||||||
|
for (var level = 8; level >= 0; level--) {
|
||||||
|
assertTileAtPoint(level, new OpenSeadragon.Point(0, 0), new OpenSeadragon.Point(0, 0));
|
||||||
|
assertTileAtPoint(level, new OpenSeadragon.Point(0.5, 0.5), new OpenSeadragon.Point(0, 0));
|
||||||
|
assertTileAtPoint(level, new OpenSeadragon.Point(1, 10 / 15), new OpenSeadragon.Point(0, 0));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
Loading…
Reference in New Issue
Block a user