Fix TileSprite rotation.

The order of operations now no longer produces skew.
Asymmetric scaling now no longer leaves some area untextured.
This commit is contained in:
Ben Richards 2024-07-12 12:19:10 +12:00
parent 8e8b15841a
commit 9c3a1bdebb

View file

@ -558,16 +558,16 @@ var TileSprite = new Class({
ctx.save(); ctx.save();
ctx.scale(scaleX, scaleY);
ctx.rotate(this._tileRotation); ctx.rotate(this._tileRotation);
ctx.scale(scaleX, scaleY);
ctx.translate(-positionX, -positionY); ctx.translate(-positionX, -positionY);
ctx.fillStyle = this.fillPattern; ctx.fillStyle = this.fillPattern;
var scaledWidth = width / scaleX; var scaledWidth = Math.max(width, Math.abs(width / scaleX));
var scaledHeight = height / scaleY; var scaledHeight = Math.max(height, Math.abs(height / scaleY));
var hypotenuse = Math.sqrt(scaledWidth * scaledWidth + scaledHeight * scaledHeight); var hypotenuse = Math.sqrt(scaledWidth * scaledWidth + scaledHeight * scaledHeight);
ctx.fillRect( ctx.fillRect(