src/rectangle.js
function(degrees, pivot) {
        degrees = $.positiveModulo(degrees, 360);
        if (degrees === 0) {
            return this.clone();
        }

        pivot = pivot || this.getCenter();
        var newTopLeft = this.getTopLeft().rotate(degrees, pivot);
        var newTopRight = this.getTopRight().rotate(degrees, pivot);

        var diff = newTopRight.minus(newTopLeft);
        // Handle floating point error
        diff = diff.apply(function(x) {
            var EPSILON = 1e-15;
            return Math.abs(x) < EPSILON ? 0 : x;
        });
        var radians = Math.atan(diff.y / diff.x);
        if (diff.x < 0) {
            radians += Math.PI;
        } else if (diff.y < 0) {
            radians += 2 * Math.PI;
        }
        return new $.Rect(
            newTopLeft.x,
            newTopLeft.y,
            this.width,
            this.height,
            radians / Math.PI * 180);
    }
function(degrees, pivot) {
        degrees = $.positiveModulo(degrees, 360);
        if (degrees === 0) {
            return this.clone();
        }

        pivot = pivot || this.getCenter();
        var newTopLeft = this.getTopLeft().rotate(degrees, pivot);
        var newTopRight = this.getTopRight().rotate(degrees, pivot);

        var diff = newTopRight.minus(newTopLeft);
        // Handle floating point error
        diff = diff.apply(function(x) {
            var EPSILON = 1e-15;
            return Math.abs(x) < EPSILON ? 0 : x;
        });
        var radians = Math.atan(diff.y / diff.x);
        if (diff.x < 0) {
            radians += Math.PI;
        } else if (diff.y < 0) {
            radians += 2 * Math.PI;
        }
        return new $.Rect(
            newTopLeft.x,
            newTopLeft.y,
            this.width,
            this.height,
            radians / Math.PI * 180);
    }
function ( degrees , pivot ) { degrees = $ . positiveModulo ( degrees , 360 ) ; if ( degrees === 0 ) { return this . clone ( ) ; } pivot = pivot || this . getCenter ( ) ; var newTopLeft = this . getTopLeft ( ) . rotate ( degrees , pivot ) ; var newTopRight = this . getTopRight ( ) . rotate ( degrees , pivot ) ; var diff = newTopRight . minus ( newTopLeft ) ; // Handle floating point error diff = diff . apply ( function ( x ) { var EPSILON = 1e-15 ; return Math . abs ( x ) < EPSILON ? 0 : x ; } ) ; var radians = Math . atan ( diff . y / diff . x ) ; if ( diff . x < 0 ) { radians += Math . PI ; } else if ( diff . y < 0 ) { radians += 2 * Math . PI ; } return new $ . Rect ( newTopLeft . x , newTopLeft . y , this . width , this . height , radians / Math . PI * 180 ) ; }
Rotates a rectangle around a point.
@function
@param {Number} degrees The angle in degrees to rotate.
@param {OpenSeadragon.Point} [pivot] The point about which to rotate.
Defaults to the center of the rectangle.
@return {OpenSeadragon.Rect}
Rotates a rectangle around a point .