Rotating overlays.

This commit is contained in:
Robert Hickman 2013-08-14 13:43:49 -06:00
parent b9583c43ac
commit 6c63710131
2 changed files with 22 additions and 3 deletions

View File

@ -1122,7 +1122,7 @@ function drawOverlay( viewport, overlay, container ){
overlay.bounds.getSize(),
true
);
overlay.drawHTML( container );
overlay.drawHTML( container, viewport );
}
function drawTiles( drawer, lastDrawn ){

View File

@ -171,12 +171,18 @@
* @function
* @param {Element} container
*/
drawHTML: function( container ) {
drawHTML: function( container, viewport ) {
var element = this.element,
style = this.style,
scales = this.scales,
drawerCenter = new $.Point(
viewport.viewer.drawer.canvas.width / 2,
viewport.viewer.drawer.canvas.height / 2
),
degrees = viewport.degrees,
position,
size;
size,
overlayCenter;
if ( element.parentNode != container ) {
//save the source parent for later if we need it
@ -197,6 +203,19 @@
position = position.apply( Math.floor );
size = size.apply( Math.ceil );
// rotate the position of the overlay
if(this.scales){
overlayCenter = new $.Point( size.x / 2, size.y / 2 );
position = position.plus( overlayCenter ).rotate(
degrees,
drawerCenter
).minus( overlayCenter );
size = size.rotate( degrees, new $.Point( 0, 0 ) );
size = new $.Point( Math.abs( size.x ), Math.abs( size.y ) );
}
// call the onDraw callback if there is one to allow, this allows someone to overwrite
// the drawing/positioning/sizing of the overlay
if (this.onDraw) {