mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-25 06:36:11 +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 ) {
|
||||
this._offsetForRotation({degrees: this.viewport.degrees});
|
||||
}
|
||||
if (tiledImage.getRotation(true) !== 0) {
|
||||
if (tiledImage.getRotation(true) % 360 !== 0) {
|
||||
this._offsetForRotation({
|
||||
degrees: tiledImage.getRotation(true),
|
||||
point: tiledImage.viewport.pixelFromPointNoRotate(
|
||||
@ -569,7 +569,7 @@ $.Drawer.prototype = {
|
||||
if ( this.viewport.degrees !== 0 ) {
|
||||
this._restoreRotationChanges();
|
||||
}
|
||||
if (tiledImage.getRotation(true) !== 0) {
|
||||
if (tiledImage.getRotation(true) % 360 !== 0) {
|
||||
this._restoreRotationChanges();
|
||||
}
|
||||
context.restore();
|
||||
|
@ -132,7 +132,7 @@ $.TiledImage = function( options ) {
|
||||
var fitBoundsPlacement = options.fitBoundsPlacement || OpenSeadragon.Placement.CENTER;
|
||||
delete options.fitBoundsPlacement;
|
||||
|
||||
var degrees = $.positiveModulo(options.degrees || 0, 360);
|
||||
var degrees = options.degrees || 0;
|
||||
delete options.degrees;
|
||||
|
||||
$.extend( true, this, {
|
||||
@ -789,7 +789,6 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
|
||||
* @fires OpenSeadragon.TiledImage.event:bounds-change
|
||||
*/
|
||||
setRotation: function(degrees, immediately) {
|
||||
degrees = $.positiveModulo(degrees, 360);
|
||||
if (this._degreesSpring.target.value === degrees &&
|
||||
this._degreesSpring.isAtTargetValue()) {
|
||||
return;
|
||||
@ -1713,11 +1712,11 @@ function drawTiles( tiledImage, lastDrawn ) {
|
||||
|
||||
var zoom = tiledImage.viewport.getZoom(true);
|
||||
var imageZoom = tiledImage.viewportToImageZoom(zoom);
|
||||
// TODO: support tile edge smoothing with tiled image rotation.
|
||||
|
||||
if (lastDrawn.length > 1 &&
|
||||
imageZoom > tiledImage.smoothTileEdgesMinZoom &&
|
||||
!tiledImage.iOSDevice &&
|
||||
tiledImage.getRotation(true) === 0 &&
|
||||
tiledImage.getRotation(true) % 360 === 0 && // TODO: support tile edge smoothing with tiled image rotation.
|
||||
$.supportsCanvas) {
|
||||
// When zoomed in a lot (>100%) the tile edges are visible.
|
||||
// So we have to composite them at ~100% and scale them up together.
|
||||
@ -1751,7 +1750,7 @@ function drawTiles( tiledImage, lastDrawn ) {
|
||||
useSketch: useSketch
|
||||
});
|
||||
}
|
||||
if (tiledImage.getRotation(true) !== 0) {
|
||||
if (tiledImage.getRotation(true) % 360 !== 0) {
|
||||
tiledImage._drawer._offsetForRotation({
|
||||
degrees: tiledImage.getRotation(true),
|
||||
point: tiledImage.viewport.pixelFromPointNoRotate(
|
||||
@ -1828,7 +1827,7 @@ function drawTiles( tiledImage, lastDrawn ) {
|
||||
}
|
||||
|
||||
if (!sketchScale) {
|
||||
if (tiledImage.getRotation(true) !== 0) {
|
||||
if (tiledImage.getRotation(true) % 360 !== 0) {
|
||||
tiledImage._drawer._restoreRotationChanges(useSketch);
|
||||
}
|
||||
if (tiledImage.viewport.degrees !== 0) {
|
||||
@ -1844,7 +1843,7 @@ function drawTiles( tiledImage, lastDrawn ) {
|
||||
useSketch: false
|
||||
});
|
||||
}
|
||||
if (tiledImage.getRotation(true) !== 0) {
|
||||
if (tiledImage.getRotation(true) % 360 !== 0) {
|
||||
tiledImage._drawer._offsetForRotation({
|
||||
degrees: tiledImage.getRotation(true),
|
||||
point: tiledImage.viewport.pixelFromPointNoRotate(
|
||||
@ -1861,7 +1860,7 @@ function drawTiles( tiledImage, lastDrawn ) {
|
||||
bounds: bounds
|
||||
});
|
||||
if (sketchScale) {
|
||||
if (tiledImage.getRotation(true) !== 0) {
|
||||
if (tiledImage.getRotation(true) % 360 !== 0) {
|
||||
tiledImage._drawer._restoreRotationChanges(false);
|
||||
}
|
||||
if (tiledImage.viewport.degrees !== 0) {
|
||||
|
@ -319,10 +319,16 @@
|
||||
|
||||
function testDefaultRotation() {
|
||||
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);
|
||||
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.open({
|
||||
@ -333,7 +339,8 @@
|
||||
|
||||
function testTileSourceRotation() {
|
||||
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();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user