mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-25 14:46:10 +03:00
Allow tiled image rotation outside the 0 to 360 range
This commit is contained in:
parent
b62d4a7bc1
commit
63a8a2ffa6
@ -500,7 +500,7 @@ $.Drawer.prototype = {
|
|||||||
if ( this.viewport.degrees !== 0 ) {
|
if ( this.viewport.degrees !== 0 ) {
|
||||||
this._offsetForRotation({degrees: this.viewport.degrees});
|
this._offsetForRotation({degrees: this.viewport.degrees});
|
||||||
}
|
}
|
||||||
if (tiledImage.getRotation(true) !== 0) {
|
if (tiledImage.getRotation(true) % 360 !== 0) {
|
||||||
this._offsetForRotation({
|
this._offsetForRotation({
|
||||||
degrees: tiledImage.getRotation(true),
|
degrees: tiledImage.getRotation(true),
|
||||||
point: tiledImage.viewport.pixelFromPointNoRotate(
|
point: tiledImage.viewport.pixelFromPointNoRotate(
|
||||||
@ -569,7 +569,7 @@ $.Drawer.prototype = {
|
|||||||
if ( this.viewport.degrees !== 0 ) {
|
if ( this.viewport.degrees !== 0 ) {
|
||||||
this._restoreRotationChanges();
|
this._restoreRotationChanges();
|
||||||
}
|
}
|
||||||
if (tiledImage.getRotation(true) !== 0) {
|
if (tiledImage.getRotation(true) % 360 !== 0) {
|
||||||
this._restoreRotationChanges();
|
this._restoreRotationChanges();
|
||||||
}
|
}
|
||||||
context.restore();
|
context.restore();
|
||||||
|
@ -132,7 +132,7 @@ $.TiledImage = function( options ) {
|
|||||||
var fitBoundsPlacement = options.fitBoundsPlacement || OpenSeadragon.Placement.CENTER;
|
var fitBoundsPlacement = options.fitBoundsPlacement || OpenSeadragon.Placement.CENTER;
|
||||||
delete options.fitBoundsPlacement;
|
delete options.fitBoundsPlacement;
|
||||||
|
|
||||||
var degrees = $.positiveModulo(options.degrees || 0, 360);
|
var degrees = options.degrees || 0;
|
||||||
delete options.degrees;
|
delete options.degrees;
|
||||||
|
|
||||||
$.extend( true, this, {
|
$.extend( true, this, {
|
||||||
@ -789,7 +789,6 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
|
|||||||
* @fires OpenSeadragon.TiledImage.event:bounds-change
|
* @fires OpenSeadragon.TiledImage.event:bounds-change
|
||||||
*/
|
*/
|
||||||
setRotation: function(degrees, immediately) {
|
setRotation: function(degrees, immediately) {
|
||||||
degrees = $.positiveModulo(degrees, 360);
|
|
||||||
if (this._degreesSpring.target.value === degrees &&
|
if (this._degreesSpring.target.value === degrees &&
|
||||||
this._degreesSpring.isAtTargetValue()) {
|
this._degreesSpring.isAtTargetValue()) {
|
||||||
return;
|
return;
|
||||||
@ -1713,11 +1712,11 @@ function drawTiles( tiledImage, lastDrawn ) {
|
|||||||
|
|
||||||
var zoom = tiledImage.viewport.getZoom(true);
|
var zoom = tiledImage.viewport.getZoom(true);
|
||||||
var imageZoom = tiledImage.viewportToImageZoom(zoom);
|
var imageZoom = tiledImage.viewportToImageZoom(zoom);
|
||||||
// TODO: support tile edge smoothing with tiled image rotation.
|
|
||||||
if (lastDrawn.length > 1 &&
|
if (lastDrawn.length > 1 &&
|
||||||
imageZoom > tiledImage.smoothTileEdgesMinZoom &&
|
imageZoom > tiledImage.smoothTileEdgesMinZoom &&
|
||||||
!tiledImage.iOSDevice &&
|
!tiledImage.iOSDevice &&
|
||||||
tiledImage.getRotation(true) === 0 &&
|
tiledImage.getRotation(true) % 360 === 0 && // TODO: support tile edge smoothing with tiled image rotation.
|
||||||
$.supportsCanvas) {
|
$.supportsCanvas) {
|
||||||
// When zoomed in a lot (>100%) the tile edges are visible.
|
// When zoomed in a lot (>100%) the tile edges are visible.
|
||||||
// So we have to composite them at ~100% and scale them up together.
|
// So we have to composite them at ~100% and scale them up together.
|
||||||
@ -1751,7 +1750,7 @@ function drawTiles( tiledImage, lastDrawn ) {
|
|||||||
useSketch: useSketch
|
useSketch: useSketch
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (tiledImage.getRotation(true) !== 0) {
|
if (tiledImage.getRotation(true) % 360 !== 0) {
|
||||||
tiledImage._drawer._offsetForRotation({
|
tiledImage._drawer._offsetForRotation({
|
||||||
degrees: tiledImage.getRotation(true),
|
degrees: tiledImage.getRotation(true),
|
||||||
point: tiledImage.viewport.pixelFromPointNoRotate(
|
point: tiledImage.viewport.pixelFromPointNoRotate(
|
||||||
@ -1828,7 +1827,7 @@ function drawTiles( tiledImage, lastDrawn ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!sketchScale) {
|
if (!sketchScale) {
|
||||||
if (tiledImage.getRotation(true) !== 0) {
|
if (tiledImage.getRotation(true) % 360 !== 0) {
|
||||||
tiledImage._drawer._restoreRotationChanges(useSketch);
|
tiledImage._drawer._restoreRotationChanges(useSketch);
|
||||||
}
|
}
|
||||||
if (tiledImage.viewport.degrees !== 0) {
|
if (tiledImage.viewport.degrees !== 0) {
|
||||||
@ -1844,7 +1843,7 @@ function drawTiles( tiledImage, lastDrawn ) {
|
|||||||
useSketch: false
|
useSketch: false
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (tiledImage.getRotation(true) !== 0) {
|
if (tiledImage.getRotation(true) % 360 !== 0) {
|
||||||
tiledImage._drawer._offsetForRotation({
|
tiledImage._drawer._offsetForRotation({
|
||||||
degrees: tiledImage.getRotation(true),
|
degrees: tiledImage.getRotation(true),
|
||||||
point: tiledImage.viewport.pixelFromPointNoRotate(
|
point: tiledImage.viewport.pixelFromPointNoRotate(
|
||||||
@ -1861,7 +1860,7 @@ function drawTiles( tiledImage, lastDrawn ) {
|
|||||||
bounds: bounds
|
bounds: bounds
|
||||||
});
|
});
|
||||||
if (sketchScale) {
|
if (sketchScale) {
|
||||||
if (tiledImage.getRotation(true) !== 0) {
|
if (tiledImage.getRotation(true) % 360 !== 0) {
|
||||||
tiledImage._drawer._restoreRotationChanges(false);
|
tiledImage._drawer._restoreRotationChanges(false);
|
||||||
}
|
}
|
||||||
if (tiledImage.viewport.degrees !== 0) {
|
if (tiledImage.viewport.degrees !== 0) {
|
||||||
|
@ -319,10 +319,16 @@
|
|||||||
|
|
||||||
function testDefaultRotation() {
|
function testDefaultRotation() {
|
||||||
var image = viewer.world.getItemAt(0);
|
var image = viewer.world.getItemAt(0);
|
||||||
strictEqual(image.getRotation(), 0, 'image has default rotation');
|
strictEqual(image.getRotation(true), 0, 'image has default current rotation');
|
||||||
|
strictEqual(image.getRotation(false), 0, 'image has default target rotation');
|
||||||
|
|
||||||
image.setRotation(400);
|
image.setRotation(400);
|
||||||
strictEqual(image.getRotation(), 40, 'rotation is set correctly');
|
strictEqual(image.getRotation(true), 0, 'current rotation is not changed');
|
||||||
|
strictEqual(image.getRotation(false), 400, 'target rotation is set correctly');
|
||||||
|
|
||||||
|
image.setRotation(200, true);
|
||||||
|
strictEqual(image.getRotation(true), 200, 'current rotation is set correctly');
|
||||||
|
strictEqual(image.getRotation(false), 200, 'target rotation is set correctly');
|
||||||
|
|
||||||
viewer.addOnceHandler('open', testTileSourceRotation);
|
viewer.addOnceHandler('open', testTileSourceRotation);
|
||||||
viewer.open({
|
viewer.open({
|
||||||
@ -333,7 +339,8 @@
|
|||||||
|
|
||||||
function testTileSourceRotation() {
|
function testTileSourceRotation() {
|
||||||
var image = viewer.world.getItemAt(0);
|
var image = viewer.world.getItemAt(0);
|
||||||
strictEqual(image.getRotation(), 300, 'image has correct rotation');
|
strictEqual(image.getRotation(true), -60, 'image has correct current rotation');
|
||||||
|
strictEqual(image.getRotation(false), -60, 'image has correct target rotation');
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user