Image corrections; thanks to Marco Morazan for helping track these down

This commit is contained in:
Danny Yoo 2013-01-30 14:37:47 -07:00
parent 579d977df8
commit 68f76395e9

View File

@ -221,7 +221,7 @@ var isScene = function(x) {
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// SceneImage: primitive-number primitive-number (listof image) -> Scene // SceneImage: primitive-number primitive-number (listof image) -> Scene
var SceneImage = function(width, height, children, withBorder) { var SceneImage = function(width, height, children, withBorder) {
BaseImage.call(this, 0, 0); BaseImage.call(this, Math.floor(width/2), Math.floor(height/2));
this.width = width; this.width = width;
this.height = height; this.height = height;
this.children = children; // arrayof [image, number, number] this.children = children; // arrayof [image, number, number]
@ -545,18 +545,20 @@ OverlayImage.prototype.equals = function(other, aUnionFind) {
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);
var width = img.getWidth();
var height = img.getHeight();
// (w,0) rotation // (w,0) rotation
var x1 = Math.floor(cos * img.getWidth()), var x1 = (cos * width),
y1 = Math.floor(sin * img.getWidth()); y1 = (sin * width);
// (0,h) rotation // (0,h) rotation
var x2 = Math.floor(-sin * img.getHeight()), var x2 = (-sin * height),
y2 = Math.floor( cos * img.getHeight()); y2 = ( cos * height);
// (w,h) rotation // (w,h) rotation
var x3 = Math.floor(cos * img.getWidth() - sin * img.getHeight()), var x3 = (cos * width - sin * height),
y3 = Math.floor(sin * img.getWidth() + cos * img.getHeight()); y3 = (sin * width + cos * height);
var minX = Math.min(0, x1, x2, x3), var minX = Math.min(0, x1, x2, x3),
maxX = Math.max(0, x1, x2, x3), maxX = Math.max(0, x1, x2, x3),
@ -570,13 +572,12 @@ var RotateImage = function(angle, img) {
BaseImage.call(this, BaseImage.call(this,
Math.floor(rotatedWidth / 2), Math.floor(rotatedWidth / 2),
Math.floor(rotatedHeight / 2)); Math.floor(rotatedHeight / 2));
this.img = img; this.img = img;
this.width = rotatedWidth; this.width = Math.floor(rotatedWidth);
this.height = rotatedHeight; this.height = Math.floor(rotatedHeight);
this.angle = angle; this.angle = angle;
this.translateX = -minX; this.translateX = Math.floor(-minX);
this.translateY = -minY; this.translateY = Math.floor(-minY);
}; };
RotateImage.prototype = heir(BaseImage.prototype); RotateImage.prototype = heir(BaseImage.prototype);