Replace error for non right-angle rotations in Rect.rotate.

This commit is contained in:
Dominik Picheta 2014-08-20 09:21:02 +01:00
parent 1c63c96f04
commit ea80c05a05
3 changed files with 7 additions and 1 deletions

View File

@ -404,6 +404,7 @@ function updateViewport( drawer ) {
viewportBR = rotatedBounds.getBottomRight(); viewportBR = rotatedBounds.getBottomRight();
} }
else if (degrees !== 0) { else if (degrees !== 0) {
// This is just an approximation.
var orthBounds = viewportBounds.rotate(90); var orthBounds = viewportBounds.rotate(90);
viewportBounds.x -= orthBounds.width / 2; viewportBounds.x -= orthBounds.width / 2;
viewportBounds.y -= orthBounds.height / 2; viewportBounds.y -= orthBounds.height / 2;

View File

@ -241,7 +241,7 @@ $.extend( $.Navigator.prototype, $.EventSource.prototype, $.Viewer.prototype, /*
(this.container.clientHeight === 0 ? 1 : this.container.clientHeight) (this.container.clientHeight === 0 ? 1 : this.container.clientHeight)
); );
if ( !containerSize.equals( this.oldContainerSize ) ) { if ( !containerSize.equals( this.oldContainerSize ) ) {
var oldBounds = this.viewport.getBounds().rotate(this.viewport.degrees); var oldBounds = this.viewport.getBounds();
var oldCenter = this.viewport.getCenter(); var oldCenter = this.viewport.getCenter();
this.viewport.resize( containerSize, true ); this.viewport.resize( containerSize, true );
var imageHeight = 1 / this.source.aspectRatio; var imageHeight = 1 / this.source.aspectRatio;

View File

@ -195,6 +195,11 @@ $.Rect.prototype = /** @lends OpenSeadragon.Rect.prototype */{
degrees = ( degrees + 360 ) % 360; degrees = ( degrees + 360 ) % 360;
if (degrees % 90 !== 0)
{
throw new Error('Currently only 0, 90, 180, and 270 degrees are supported.');
}
if( degrees === 0 ){ if( degrees === 0 ){
return new $.Rect( return new $.Rect(
this.x, this.x,