mirror of
https://github.com/openseadragon/openseadragon.git
synced 2025-02-16 14:53:14 +03:00
Merge branch 'master' of https://github.com/openseadragon/openseadragon
This commit is contained in:
commit
576d0eb317
1
.gitignore
vendored
1
.gitignore
vendored
@ -7,3 +7,4 @@ instrumented/
|
|||||||
.idea
|
.idea
|
||||||
/nbproject/private/
|
/nbproject/private/
|
||||||
.directory
|
.directory
|
||||||
|
test/demo/temp
|
||||||
|
@ -11,6 +11,8 @@ OPENSEADRAGON CHANGELOG
|
|||||||
* Improved IIIF options.maxLevel calculation (#1401)
|
* Improved IIIF options.maxLevel calculation (#1401)
|
||||||
* Added canvas-key events, along with the ability to cancel key actions (#1414)
|
* Added canvas-key events, along with the ability to cancel key actions (#1414)
|
||||||
* Added optional zoom in the middle of the image instead of pointer position (#1423)
|
* Added optional zoom in the middle of the image instead of pointer position (#1423)
|
||||||
|
* Now supporting square edge tiles that are padded rather than cropped (#1426)
|
||||||
|
* Fixed an issue causing the simple image tileSource to sometimes show duplicate copies (#1370)
|
||||||
|
|
||||||
2.3.1:
|
2.3.1:
|
||||||
|
|
||||||
|
5862
package-lock.json
generated
Normal file
5862
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
26
src/tile.js
26
src/tile.js
@ -40,7 +40,7 @@
|
|||||||
* @param {Number} level The zoom level this tile belongs to.
|
* @param {Number} level The zoom level this tile belongs to.
|
||||||
* @param {Number} x The vector component 'x'.
|
* @param {Number} x The vector component 'x'.
|
||||||
* @param {Number} y The vector component 'y'.
|
* @param {Number} y The vector component 'y'.
|
||||||
* @param {OpenSeadragon.Point} bounds Where this tile fits, in normalized
|
* @param {OpenSeadragon.Rect} bounds Where this tile fits, in normalized
|
||||||
* coordinates.
|
* coordinates.
|
||||||
* @param {Boolean} exists Is this tile a part of a sparse image? ( Also has
|
* @param {Boolean} exists Is this tile a part of a sparse image? ( Also has
|
||||||
* this tile failed to load? )
|
* this tile failed to load? )
|
||||||
@ -49,8 +49,11 @@
|
|||||||
* is provided directly by the tile source.
|
* is provided directly by the tile source.
|
||||||
* @param {Boolean} loadWithAjax Whether this tile image should be loaded with an AJAX request .
|
* @param {Boolean} loadWithAjax Whether this tile image should be loaded with an AJAX request .
|
||||||
* @param {Object} ajaxHeaders The headers to send with this tile's AJAX request (if applicable).
|
* @param {Object} ajaxHeaders The headers to send with this tile's AJAX request (if applicable).
|
||||||
|
* @param {OpenSeadragon.Rect} sourceBounds The portion of the tile to use as the source of the
|
||||||
|
* drawing operation, in pixels. Note that this only works when drawing with canvas; when drawing
|
||||||
|
* with HTML the entire tile is always used.
|
||||||
*/
|
*/
|
||||||
$.Tile = function(level, x, y, bounds, exists, url, context2D, loadWithAjax, ajaxHeaders) {
|
$.Tile = function(level, x, y, bounds, exists, url, context2D, loadWithAjax, ajaxHeaders, sourceBounds) {
|
||||||
/**
|
/**
|
||||||
* The zoom level this tile belongs to.
|
* The zoom level this tile belongs to.
|
||||||
* @member {Number} level
|
* @member {Number} level
|
||||||
@ -75,6 +78,13 @@ $.Tile = function(level, x, y, bounds, exists, url, context2D, loadWithAjax, aja
|
|||||||
* @memberof OpenSeadragon.Tile#
|
* @memberof OpenSeadragon.Tile#
|
||||||
*/
|
*/
|
||||||
this.bounds = bounds;
|
this.bounds = bounds;
|
||||||
|
/**
|
||||||
|
* The portion of the tile to use as the source of the drawing operation, in pixels. Note that
|
||||||
|
* this only works when drawing with canvas; when drawing with HTML the entire tile is always used.
|
||||||
|
* @member {OpenSeadragon.Rect} sourceBounds
|
||||||
|
* @memberof OpenSeadragon.Tile#
|
||||||
|
*/
|
||||||
|
this.sourceBounds = sourceBounds;
|
||||||
/**
|
/**
|
||||||
* Is this tile a part of a sparse image? Also has this tile failed to load?
|
* Is this tile a part of a sparse image? Also has this tile failed to load?
|
||||||
* @member {Boolean} exists
|
* @member {Boolean} exists
|
||||||
@ -357,12 +367,16 @@ $.Tile.prototype = {
|
|||||||
// changes as we are rendering the image
|
// changes as we are rendering the image
|
||||||
drawingHandler({context: context, tile: this, rendered: rendered});
|
drawingHandler({context: context, tile: this, rendered: rendered});
|
||||||
|
|
||||||
|
if (!this.sourceBounds) { // Just in case
|
||||||
|
this.sourceBounds = new $.Rect(0, 0, rendered.canvas.width, rendered.canvas.height);
|
||||||
|
}
|
||||||
|
|
||||||
context.drawImage(
|
context.drawImage(
|
||||||
rendered.canvas,
|
rendered.canvas,
|
||||||
0,
|
this.sourceBounds.x,
|
||||||
0,
|
this.sourceBounds.y,
|
||||||
rendered.canvas.width,
|
this.sourceBounds.width,
|
||||||
rendered.canvas.height,
|
this.sourceBounds.height,
|
||||||
position.x,
|
position.x,
|
||||||
position.y,
|
position.y,
|
||||||
size.x,
|
size.x,
|
||||||
|
@ -1372,6 +1372,7 @@ function getTile(
|
|||||||
var xMod,
|
var xMod,
|
||||||
yMod,
|
yMod,
|
||||||
bounds,
|
bounds,
|
||||||
|
sourceBounds,
|
||||||
exists,
|
exists,
|
||||||
url,
|
url,
|
||||||
ajaxHeaders,
|
ajaxHeaders,
|
||||||
@ -1389,6 +1390,7 @@ function getTile(
|
|||||||
xMod = ( numTiles.x + ( x % numTiles.x ) ) % numTiles.x;
|
xMod = ( numTiles.x + ( x % numTiles.x ) ) % numTiles.x;
|
||||||
yMod = ( numTiles.y + ( y % numTiles.y ) ) % numTiles.y;
|
yMod = ( numTiles.y + ( y % numTiles.y ) ) % numTiles.y;
|
||||||
bounds = tileSource.getTileBounds( level, xMod, yMod );
|
bounds = tileSource.getTileBounds( level, xMod, yMod );
|
||||||
|
sourceBounds = tileSource.getTileBounds( level, xMod, yMod, true );
|
||||||
exists = tileSource.tileExists( level, xMod, yMod );
|
exists = tileSource.tileExists( level, xMod, yMod );
|
||||||
url = tileSource.getTileUrl( level, xMod, yMod );
|
url = tileSource.getTileUrl( level, xMod, yMod );
|
||||||
|
|
||||||
@ -1418,7 +1420,8 @@ function getTile(
|
|||||||
url,
|
url,
|
||||||
context2D,
|
context2D,
|
||||||
tiledImage.loadTilesWithAjax,
|
tiledImage.loadTilesWithAjax,
|
||||||
ajaxHeaders
|
ajaxHeaders,
|
||||||
|
sourceBounds
|
||||||
);
|
);
|
||||||
|
|
||||||
if (xMod === numTiles.x - 1) {
|
if (xMod === numTiles.x - 1) {
|
||||||
|
@ -360,7 +360,7 @@ $.TileSource.prototype = {
|
|||||||
if (point.x >= 1) {
|
if (point.x >= 1) {
|
||||||
x = this.getNumTiles(level).x - 1;
|
x = this.getNumTiles(level).x - 1;
|
||||||
}
|
}
|
||||||
var EPSILON = 1e-16;
|
var EPSILON = 1e-15;
|
||||||
if (point.y >= 1 / this.aspectRatio - EPSILON) {
|
if (point.y >= 1 / this.aspectRatio - EPSILON) {
|
||||||
y = this.getNumTiles(level).y - 1;
|
y = this.getNumTiles(level).y - 1;
|
||||||
}
|
}
|
||||||
@ -373,8 +373,12 @@ $.TileSource.prototype = {
|
|||||||
* @param {Number} level
|
* @param {Number} level
|
||||||
* @param {Number} x
|
* @param {Number} x
|
||||||
* @param {Number} y
|
* @param {Number} y
|
||||||
|
* @param {Boolean} [isSource=false] Whether to return the source bounds of the tile.
|
||||||
|
* @returns {OpenSeadragon.Rect} Either where this tile fits (in normalized coordinates) or the
|
||||||
|
* portion of the tile to use as the source of the drawing operation (in pixels), depending on
|
||||||
|
* the isSource parameter.
|
||||||
*/
|
*/
|
||||||
getTileBounds: function( level, x, y ) {
|
getTileBounds: function( level, x, y, isSource ) {
|
||||||
var dimensionsScaled = this.dimensions.times( this.getLevelScale( level ) ),
|
var dimensionsScaled = this.dimensions.times( this.getLevelScale( level ) ),
|
||||||
tileWidth = this.getTileWidth(level),
|
tileWidth = this.getTileWidth(level),
|
||||||
tileHeight = this.getTileHeight(level),
|
tileHeight = this.getTileHeight(level),
|
||||||
@ -387,6 +391,12 @@ $.TileSource.prototype = {
|
|||||||
sx = Math.min( sx, dimensionsScaled.x - px );
|
sx = Math.min( sx, dimensionsScaled.x - px );
|
||||||
sy = Math.min( sy, dimensionsScaled.y - py );
|
sy = Math.min( sy, dimensionsScaled.y - py );
|
||||||
|
|
||||||
|
if (isSource) {
|
||||||
|
scale = 1;
|
||||||
|
px = 0;
|
||||||
|
py = 0;
|
||||||
|
}
|
||||||
|
|
||||||
return new $.Rect( px * scale, py * scale, sx * scale, sy * scale );
|
return new $.Rect( px * scale, py * scale, sx * scale, sy * scale );
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -107,6 +107,17 @@
|
|||||||
maxLevel: 0,
|
maxLevel: 0,
|
||||||
});
|
});
|
||||||
assertTileAtPoint(0, new OpenSeadragon.Point(1, 1239 / 4036), new OpenSeadragon.Point(0, 0));
|
assertTileAtPoint(0, new OpenSeadragon.Point(1, 1239 / 4036), new OpenSeadragon.Point(0, 0));
|
||||||
|
|
||||||
|
// Test for issue #1362
|
||||||
|
tileSource = new OpenSeadragon.TileSource({
|
||||||
|
width: 2000,
|
||||||
|
height: 3033,
|
||||||
|
tileWidth: 2000,
|
||||||
|
tileHeight: 3033,
|
||||||
|
tileOverlap: 0,
|
||||||
|
maxLevel: 0,
|
||||||
|
});
|
||||||
|
assertTileAtPoint(0, new OpenSeadragon.Point(1, 3033 / 2000), new OpenSeadragon.Point(0, 0));
|
||||||
});
|
});
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user