incorpoating the rotation fix that we did for wescheme

This commit is contained in:
Danny Yoo 2011-08-19 16:28:51 -04:00
parent 195cc8ab86
commit 177b94bd98

View File

@ -504,7 +504,7 @@ OverlayImage.prototype.equals = function(other, aUnionFind) {
// based on http://stackoverflow.com/questions/3276467/adjusting-div-width-and-height-after-rotated // based on http://stackoverflow.com/questions/3276467/adjusting-div-width-and-height-after-rotated
var RotateImage = function(angle, img) { var RotateImage = function(angle, img) {
var sin = Math.sin(angle * Math.PI / 180), var sin = Math.sin(angle * Math.PI / 180),
cos = Math.cos(angle * Math.PI / 180); cos = Math.cos(angle * Math.PI / 180);
// (w,0) rotation // (w,0) rotation
var x1 = Math.floor(cos * img.getWidth()), var x1 = Math.floor(cos * img.getWidth()),
@ -548,15 +548,14 @@ RotateImage.prototype.render = function(ctx, x, y) {
var sin = Math.sin(this.angle * Math.PI / 180), var sin = Math.sin(this.angle * Math.PI / 180),
cos = Math.cos(this.angle * Math.PI / 180), cos = Math.cos(this.angle * Math.PI / 180),
r = Math.sqrt(x*x + y*y); r = Math.sqrt(x*x + y*y);
x = Math.ceil(cos * r);
y = -Math.floor(sin * r);
ctx.save(); ctx.save();
ctx.translate(this.translateX, this.translateY); ctx.translate(x + this.translateX, y + this.translateY);
ctx.rotate(this.angle * Math.PI / 180); ctx.rotate(this.angle * Math.PI / 180);
this.img.render(ctx, x, y); this.img.render(ctx, 0, 0);
ctx.restore(); ctx.restore();
}; };
RotateImage.prototype.equals = function(other, aUnionFind) { RotateImage.prototype.equals = function(other, aUnionFind) {
return ( other instanceof RotateImage && return ( other instanceof RotateImage &&
this.pinholeX == other.pinholeX && this.pinholeX == other.pinholeX &&