Fixed test errors

This commit is contained in:
Ian Gilman 2018-04-02 11:09:23 -07:00
parent 7ba516b30a
commit 02a397638c
2 changed files with 12 additions and 7 deletions

View File

@ -367,16 +367,21 @@ $.Tile.prototype = {
// changes as we are rendering the image
drawingHandler({context: context, tile: this, rendered: rendered});
if (!this.sourceBounds) { // Just in case
this.sourceBounds = new $.Rect(0, 0, rendered.canvas.width, rendered.canvas.height);
var sourceWidth, sourceHeight;
if (this.sourceBounds) {
sourceWidth = Math.min(this.sourceBounds.width, rendered.canvas.width);
sourceHeight = Math.min(this.sourceBounds.height, rendered.canvas.height);
} else {
sourceWidth = rendered.canvas.width;
sourceHeight = rendered.canvas.height;
}
context.drawImage(
rendered.canvas,
this.sourceBounds.x,
this.sourceBounds.y,
this.sourceBounds.width,
this.sourceBounds.height,
0,
0,
sourceWidth,
sourceHeight,
position.x,
position.y,
size.x,

View File

@ -392,7 +392,7 @@ $.TileSource.prototype = {
sy = Math.min( sy, dimensionsScaled.y - py );
if (isSource) {
return new $.Rect(0, 0, Math.floor(sx), Math.floor(sy));
return new $.Rect(0, 0, sx, sy);
}
return new $.Rect( px * scale, py * scale, sx * scale, sy * scale );