From 4b487170104a577ebafbab9f53e4f7b2f758f72c Mon Sep 17 00:00:00 2001 From: Antoine Vandecreme Date: Tue, 25 Oct 2016 21:41:42 +0200 Subject: [PATCH] Rollback sketchCanvas scaling when tiled image rotated --- src/drawer.js | 4 +--- src/tiledimage.js | 16 ++-------------- src/world.js | 10 ---------- 3 files changed, 3 insertions(+), 27 deletions(-) diff --git a/src/drawer.js b/src/drawer.js index 9440c280..73772a88 100644 --- a/src/drawer.js +++ b/src/drawer.js @@ -323,7 +323,6 @@ $.Drawer.prototype = { this.sketchCanvas.height = sketchCanvasSize.y; this.sketchContext = this.sketchCanvas.getContext( "2d" ); - // FIXME: should check if any tiled image get rotated as well. // 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. @@ -621,8 +620,7 @@ $.Drawer.prototype = { // private _calculateSketchCanvasSize: function() { var canvasSize = this._calculateCanvasSize(); - if (this.viewport.getRotation() === 0 && - !this.viewer.world._hasRotatedItem()) { + if (this.viewport.getRotation() === 0) { return canvasSize; } // If the viewport is rotated, we need a larger sketch canvas in order diff --git a/src/tiledimage.js b/src/tiledimage.js index c6659c77..ca6b8eeb 100644 --- a/src/tiledimage.js +++ b/src/tiledimage.js @@ -550,20 +550,8 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag }, // private - // Convert rectangle in tiled image coordinates to viewport coordinates. - _tiledImageToViewportRectangle: function(rect) { - var scale = this._scaleSpring.current.value; - return new $.Rect( - rect.x * scale + this._xSpring.current.value, - rect.y * scale + this._ySpring.current.value, - rect.width * scale, - rect.height * scale, - rect.degrees) - .rotate(this.getRotation(), this._getRotationPoint(true)); - }, - - // private - // Convert rectangle in viewport coordinates to tiled image coordinates. + // Convert rectangle in viewport coordinates to this tiled image point + // coordinates (x in [0, 1] and y in [0, aspectRatio]) _viewportToTiledImageRectangle: function(rect) { var scale = this._scaleSpring.current.value; rect = rect.rotate(-this.getRotation(), this._getRotationPoint(true)); diff --git a/src/world.js b/src/world.js index ad6285d9..e68590b3 100644 --- a/src/world.js +++ b/src/world.js @@ -436,16 +436,6 @@ $.extend( $.World.prototype, $.EventSource.prototype, /** @lends OpenSeadragon.W * @property {?Object} userData - Arbitrary subscriber-defined object. */ this.raiseEvent( 'remove-item', { item: item } ); - }, - - // private - _hasRotatedItem: function() { - for (var i = 0; i < this._items.length; i++) { - if (this._items[i].getRotation() !== 0) { - return true; - } - } - return false; } });