diff --git a/packages/canvas/canvas-extract/src/CanvasExtract.js b/packages/canvas/canvas-extract/src/CanvasExtract.js index 58dfcbc..5b791cb 100644 --- a/packages/canvas/canvas-extract/src/CanvasExtract.js +++ b/packages/canvas/canvas-extract/src/CanvasExtract.js @@ -105,8 +105,8 @@ frame.height = this.renderer.height; } - const width = frame.width * resolution; - const height = frame.height * resolution; + const width = Math.floor(frame.width * resolution); + const height = Math.floor(frame.height * resolution); const canvasBuffer = new CanvasRenderTarget(width, height, 1); const canvasData = context.getImageData(frame.x * resolution, frame.y * resolution, width, height); diff --git a/packages/canvas/canvas-extract/src/CanvasExtract.js b/packages/canvas/canvas-extract/src/CanvasExtract.js index 58dfcbc..5b791cb 100644 --- a/packages/canvas/canvas-extract/src/CanvasExtract.js +++ b/packages/canvas/canvas-extract/src/CanvasExtract.js @@ -105,8 +105,8 @@ frame.height = this.renderer.height; } - const width = frame.width * resolution; - const height = frame.height * resolution; + const width = Math.floor(frame.width * resolution); + const height = Math.floor(frame.height * resolution); const canvasBuffer = new CanvasRenderTarget(width, height, 1); const canvasData = context.getImageData(frame.x * resolution, frame.y * resolution, width, height); diff --git a/packages/canvas/canvas-sprite/src/CanvasSpriteRenderer.js b/packages/canvas/canvas-sprite/src/CanvasSpriteRenderer.js index 225beb0..c61c338 100644 --- a/packages/canvas/canvas-sprite/src/CanvasSpriteRenderer.js +++ b/packages/canvas/canvas-sprite/src/CanvasSpriteRenderer.js @@ -162,12 +162,12 @@ sprite._tintedCanvas, 0, 0, - width * resolution, - height * resolution, - dx * renderer.resolution, - dy * renderer.resolution, - width * renderer.resolution, - height * renderer.resolution + Math.floor(width * resolution), + Math.floor(height * resolution), + Math.floor(dx * renderer.resolution), + Math.floor(dy * renderer.resolution), + Math.floor(width * renderer.resolution), + Math.floor(height * renderer.resolution) ); } else @@ -176,12 +176,12 @@ source, texture._frame.x * resolution, texture._frame.y * resolution, - width * resolution, - height * resolution, - dx * renderer.resolution, - dy * renderer.resolution, - width * renderer.resolution, - height * renderer.resolution + Math.floor(width * resolution), + Math.floor(height * resolution), + Math.floor(dx * renderer.resolution), + Math.floor(dy * renderer.resolution), + Math.floor(width * renderer.resolution), + Math.floor(height * renderer.resolution) ); } diff --git a/packages/canvas/canvas-extract/src/CanvasExtract.js b/packages/canvas/canvas-extract/src/CanvasExtract.js index 58dfcbc..5b791cb 100644 --- a/packages/canvas/canvas-extract/src/CanvasExtract.js +++ b/packages/canvas/canvas-extract/src/CanvasExtract.js @@ -105,8 +105,8 @@ frame.height = this.renderer.height; } - const width = frame.width * resolution; - const height = frame.height * resolution; + const width = Math.floor(frame.width * resolution); + const height = Math.floor(frame.height * resolution); const canvasBuffer = new CanvasRenderTarget(width, height, 1); const canvasData = context.getImageData(frame.x * resolution, frame.y * resolution, width, height); diff --git a/packages/canvas/canvas-sprite/src/CanvasSpriteRenderer.js b/packages/canvas/canvas-sprite/src/CanvasSpriteRenderer.js index 225beb0..c61c338 100644 --- a/packages/canvas/canvas-sprite/src/CanvasSpriteRenderer.js +++ b/packages/canvas/canvas-sprite/src/CanvasSpriteRenderer.js @@ -162,12 +162,12 @@ sprite._tintedCanvas, 0, 0, - width * resolution, - height * resolution, - dx * renderer.resolution, - dy * renderer.resolution, - width * renderer.resolution, - height * renderer.resolution + Math.floor(width * resolution), + Math.floor(height * resolution), + Math.floor(dx * renderer.resolution), + Math.floor(dy * renderer.resolution), + Math.floor(width * renderer.resolution), + Math.floor(height * renderer.resolution) ); } else @@ -176,12 +176,12 @@ source, texture._frame.x * resolution, texture._frame.y * resolution, - width * resolution, - height * resolution, - dx * renderer.resolution, - dy * renderer.resolution, - width * renderer.resolution, - height * renderer.resolution + Math.floor(width * resolution), + Math.floor(height * resolution), + Math.floor(dx * renderer.resolution), + Math.floor(dy * renderer.resolution), + Math.floor(width * renderer.resolution), + Math.floor(height * renderer.resolution) ); } diff --git a/packages/core/src/textures/BaseTexture.js b/packages/core/src/textures/BaseTexture.js index d1167ae..5f2228d 100644 --- a/packages/core/src/textures/BaseTexture.js +++ b/packages/core/src/textures/BaseTexture.js @@ -303,7 +303,7 @@ */ get realWidth() { - return this.width * this.resolution; + return Math.ceil(this.width * this.resolution); } /** @@ -314,7 +314,7 @@ */ get realHeight() { - return this.height * this.resolution; + return Math.ceil(this.height * this.resolution); } /** @@ -378,8 +378,8 @@ setRealSize(realWidth, realHeight, resolution) { this.resolution = resolution || this.resolution; - this.width = realWidth / this.resolution; - this.height = realHeight / this.resolution; + this.width = Math.ceil(realWidth / this.resolution); + this.height = Math.ceil(realHeight / this.resolution); this._refreshPOT(); this.update(); @@ -415,8 +415,8 @@ if (this.valid) { - this.width = this.width * oldResolution / resolution; - this.height = this.height * oldResolution / resolution; + this.width = Math.ceil(this.width * oldResolution / resolution); + this.height = Math.ceil(this.height * oldResolution / resolution); this.emit('update', this); } diff --git a/packages/canvas/canvas-extract/src/CanvasExtract.js b/packages/canvas/canvas-extract/src/CanvasExtract.js index 58dfcbc..5b791cb 100644 --- a/packages/canvas/canvas-extract/src/CanvasExtract.js +++ b/packages/canvas/canvas-extract/src/CanvasExtract.js @@ -105,8 +105,8 @@ frame.height = this.renderer.height; } - const width = frame.width * resolution; - const height = frame.height * resolution; + const width = Math.floor(frame.width * resolution); + const height = Math.floor(frame.height * resolution); const canvasBuffer = new CanvasRenderTarget(width, height, 1); const canvasData = context.getImageData(frame.x * resolution, frame.y * resolution, width, height); diff --git a/packages/canvas/canvas-sprite/src/CanvasSpriteRenderer.js b/packages/canvas/canvas-sprite/src/CanvasSpriteRenderer.js index 225beb0..c61c338 100644 --- a/packages/canvas/canvas-sprite/src/CanvasSpriteRenderer.js +++ b/packages/canvas/canvas-sprite/src/CanvasSpriteRenderer.js @@ -162,12 +162,12 @@ sprite._tintedCanvas, 0, 0, - width * resolution, - height * resolution, - dx * renderer.resolution, - dy * renderer.resolution, - width * renderer.resolution, - height * renderer.resolution + Math.floor(width * resolution), + Math.floor(height * resolution), + Math.floor(dx * renderer.resolution), + Math.floor(dy * renderer.resolution), + Math.floor(width * renderer.resolution), + Math.floor(height * renderer.resolution) ); } else @@ -176,12 +176,12 @@ source, texture._frame.x * resolution, texture._frame.y * resolution, - width * resolution, - height * resolution, - dx * renderer.resolution, - dy * renderer.resolution, - width * renderer.resolution, - height * renderer.resolution + Math.floor(width * resolution), + Math.floor(height * resolution), + Math.floor(dx * renderer.resolution), + Math.floor(dy * renderer.resolution), + Math.floor(width * renderer.resolution), + Math.floor(height * renderer.resolution) ); } diff --git a/packages/core/src/textures/BaseTexture.js b/packages/core/src/textures/BaseTexture.js index d1167ae..5f2228d 100644 --- a/packages/core/src/textures/BaseTexture.js +++ b/packages/core/src/textures/BaseTexture.js @@ -303,7 +303,7 @@ */ get realWidth() { - return this.width * this.resolution; + return Math.ceil(this.width * this.resolution); } /** @@ -314,7 +314,7 @@ */ get realHeight() { - return this.height * this.resolution; + return Math.ceil(this.height * this.resolution); } /** @@ -378,8 +378,8 @@ setRealSize(realWidth, realHeight, resolution) { this.resolution = resolution || this.resolution; - this.width = realWidth / this.resolution; - this.height = realHeight / this.resolution; + this.width = Math.ceil(realWidth / this.resolution); + this.height = Math.ceil(realHeight / this.resolution); this._refreshPOT(); this.update(); @@ -415,8 +415,8 @@ if (this.valid) { - this.width = this.width * oldResolution / resolution; - this.height = this.height * oldResolution / resolution; + this.width = Math.ceil(this.width * oldResolution / resolution); + this.height = Math.ceil(this.height * oldResolution / resolution); this.emit('update', this); } diff --git a/packages/extract/src/Extract.js b/packages/extract/src/Extract.js index 986d158..d8d4890 100644 --- a/packages/extract/src/Extract.js +++ b/packages/extract/src/Extract.js @@ -113,8 +113,8 @@ renderer.renderTexture.bind(null); } - const width = frame.width * resolution; - const height = frame.height * resolution; + const width = Math.floor(frame.width * resolution); + const height = Math.floor(frame.height * resolution); const canvasBuffer = new CanvasRenderTarget(width, height, 1); diff --git a/packages/canvas/canvas-extract/src/CanvasExtract.js b/packages/canvas/canvas-extract/src/CanvasExtract.js index 58dfcbc..5b791cb 100644 --- a/packages/canvas/canvas-extract/src/CanvasExtract.js +++ b/packages/canvas/canvas-extract/src/CanvasExtract.js @@ -105,8 +105,8 @@ frame.height = this.renderer.height; } - const width = frame.width * resolution; - const height = frame.height * resolution; + const width = Math.floor(frame.width * resolution); + const height = Math.floor(frame.height * resolution); const canvasBuffer = new CanvasRenderTarget(width, height, 1); const canvasData = context.getImageData(frame.x * resolution, frame.y * resolution, width, height); diff --git a/packages/canvas/canvas-sprite/src/CanvasSpriteRenderer.js b/packages/canvas/canvas-sprite/src/CanvasSpriteRenderer.js index 225beb0..c61c338 100644 --- a/packages/canvas/canvas-sprite/src/CanvasSpriteRenderer.js +++ b/packages/canvas/canvas-sprite/src/CanvasSpriteRenderer.js @@ -162,12 +162,12 @@ sprite._tintedCanvas, 0, 0, - width * resolution, - height * resolution, - dx * renderer.resolution, - dy * renderer.resolution, - width * renderer.resolution, - height * renderer.resolution + Math.floor(width * resolution), + Math.floor(height * resolution), + Math.floor(dx * renderer.resolution), + Math.floor(dy * renderer.resolution), + Math.floor(width * renderer.resolution), + Math.floor(height * renderer.resolution) ); } else @@ -176,12 +176,12 @@ source, texture._frame.x * resolution, texture._frame.y * resolution, - width * resolution, - height * resolution, - dx * renderer.resolution, - dy * renderer.resolution, - width * renderer.resolution, - height * renderer.resolution + Math.floor(width * resolution), + Math.floor(height * resolution), + Math.floor(dx * renderer.resolution), + Math.floor(dy * renderer.resolution), + Math.floor(width * renderer.resolution), + Math.floor(height * renderer.resolution) ); } diff --git a/packages/core/src/textures/BaseTexture.js b/packages/core/src/textures/BaseTexture.js index d1167ae..5f2228d 100644 --- a/packages/core/src/textures/BaseTexture.js +++ b/packages/core/src/textures/BaseTexture.js @@ -303,7 +303,7 @@ */ get realWidth() { - return this.width * this.resolution; + return Math.ceil(this.width * this.resolution); } /** @@ -314,7 +314,7 @@ */ get realHeight() { - return this.height * this.resolution; + return Math.ceil(this.height * this.resolution); } /** @@ -378,8 +378,8 @@ setRealSize(realWidth, realHeight, resolution) { this.resolution = resolution || this.resolution; - this.width = realWidth / this.resolution; - this.height = realHeight / this.resolution; + this.width = Math.ceil(realWidth / this.resolution); + this.height = Math.ceil(realHeight / this.resolution); this._refreshPOT(); this.update(); @@ -415,8 +415,8 @@ if (this.valid) { - this.width = this.width * oldResolution / resolution; - this.height = this.height * oldResolution / resolution; + this.width = Math.ceil(this.width * oldResolution / resolution); + this.height = Math.ceil(this.height * oldResolution / resolution); this.emit('update', this); } diff --git a/packages/extract/src/Extract.js b/packages/extract/src/Extract.js index 986d158..d8d4890 100644 --- a/packages/extract/src/Extract.js +++ b/packages/extract/src/Extract.js @@ -113,8 +113,8 @@ renderer.renderTexture.bind(null); } - const width = frame.width * resolution; - const height = frame.height * resolution; + const width = Math.floor(frame.width * resolution); + const height = Math.floor(frame.height * resolution); const canvasBuffer = new CanvasRenderTarget(width, height, 1); diff --git a/packages/text/src/Text.js b/packages/text/src/Text.js index b1625d0..21e1c76 100644 --- a/packages/text/src/Text.js +++ b/packages/text/src/Text.js @@ -311,8 +311,8 @@ const padding = style.trim ? 0 : style.padding; const baseTexture = texture.baseTexture; - texture.trim.width = texture._frame.width = canvas.width / this._resolution; - texture.trim.height = texture._frame.height = canvas.height / this._resolution; + texture.trim.width = texture._frame.width = Math.ceil(canvas.width / this._resolution); + texture.trim.height = texture._frame.height = Math.ceil(canvas.height / this._resolution); texture.trim.x = -padding; texture.trim.y = -padding; @@ -406,8 +406,8 @@ let currentIteration; let stop; - const width = this.canvas.width / this._resolution; - const height = this.canvas.height / this._resolution; + const width = Math.ceil(this.canvas.width / this._resolution); + const height = Math.ceil(this.canvas.height / this._resolution); // make a copy of the style settings, so we can manipulate them later const fill = style.fill.slice();