From 9c3a1bdebbbbc70fbc3d63ff23b156340c16a68c Mon Sep 17 00:00:00 2001 From: Ben Richards Date: Fri, 12 Jul 2024 12:19:10 +1200 Subject: [PATCH] Fix TileSprite rotation. The order of operations now no longer produces skew. Asymmetric scaling now no longer leaves some area untextured. --- src/gameobjects/tilesprite/TileSprite.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gameobjects/tilesprite/TileSprite.js b/src/gameobjects/tilesprite/TileSprite.js index a7e2cb63c..62fa39b88 100644 --- a/src/gameobjects/tilesprite/TileSprite.js +++ b/src/gameobjects/tilesprite/TileSprite.js @@ -558,16 +558,16 @@ var TileSprite = new Class({ ctx.save(); - ctx.scale(scaleX, scaleY); - ctx.rotate(this._tileRotation); + ctx.scale(scaleX, scaleY); + ctx.translate(-positionX, -positionY); ctx.fillStyle = this.fillPattern; - var scaledWidth = width / scaleX; - var scaledHeight = height / scaleY; + var scaledWidth = Math.max(width, Math.abs(width / scaleX)); + var scaledHeight = Math.max(height, Math.abs(height / scaleY)); var hypotenuse = Math.sqrt(scaledWidth * scaledWidth + scaledHeight * scaledHeight); ctx.fillRect(