mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-22 21:26:10 +03:00
Only use a larger sketch canvas if the viewport get rotated.
This commit is contained in:
parent
33021ac24f
commit
43bb0d7741
@ -317,6 +317,19 @@ $.Drawer.prototype = /** @lends OpenSeadragon.Drawer.prototype */{
|
|||||||
this.sketchCanvas.width = sketchCanvasSize.x;
|
this.sketchCanvas.width = sketchCanvasSize.x;
|
||||||
this.sketchCanvas.height = sketchCanvasSize.y;
|
this.sketchCanvas.height = sketchCanvasSize.y;
|
||||||
this.sketchContext = this.sketchCanvas.getContext( "2d" );
|
this.sketchContext = this.sketchCanvas.getContext( "2d" );
|
||||||
|
|
||||||
|
// If the viewport is not currently rotated, the sketchCanvas
|
||||||
|
// will have the same size as the main canvas. However, if
|
||||||
|
// the viewport get rotated later on, we will need to resize it.
|
||||||
|
if (this.viewport.getRotation() === 0) {
|
||||||
|
var _this = this;
|
||||||
|
this.viewer.addHandler('rotate', function resizeSketchCanvas() {
|
||||||
|
_this.viewer.removeHandler('rotate', resizeSketchCanvas);
|
||||||
|
var sketchCanvasSize = _this._calculateSketchCanvasSize();
|
||||||
|
_this.sketchCanvas.width = sketchCanvasSize.x;
|
||||||
|
_this.sketchCanvas.height = sketchCanvasSize.y;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
context = this.sketchContext;
|
context = this.sketchContext;
|
||||||
}
|
}
|
||||||
@ -555,6 +568,11 @@ $.Drawer.prototype = /** @lends OpenSeadragon.Drawer.prototype */{
|
|||||||
// private
|
// private
|
||||||
_calculateSketchCanvasSize: function() {
|
_calculateSketchCanvasSize: function() {
|
||||||
var canvasSize = this._calculateCanvasSize();
|
var canvasSize = this._calculateCanvasSize();
|
||||||
|
if (this.viewport.getRotation() === 0) {
|
||||||
|
return canvasSize;
|
||||||
|
}
|
||||||
|
// If the viewport is rotated, we need a larger sketch canvas in order
|
||||||
|
// to support edge smoothing.
|
||||||
var sketchCanvasSize = Math.ceil(Math.sqrt(
|
var sketchCanvasSize = Math.ceil(Math.sqrt(
|
||||||
canvasSize.x * canvasSize.x +
|
canvasSize.x * canvasSize.x +
|
||||||
canvasSize.y * canvasSize.y));
|
canvasSize.y * canvasSize.y));
|
||||||
|
Loading…
Reference in New Issue
Block a user