Skip to content

Commit a7da8dc

Browse files
committed
The Canvas RenderTexture drawImage method incorrectly set the values of the frame, causing them to appear wrongly scaled in the canvas renderer. Fix phaserjs#3710
1 parent 57e3276 commit a7da8dc

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
### Bug Fixes
1010

11-
11+
* The Canvas RenderTexture drawImage method incorrectly set the values of the frame, causing them to appear wrongly scaled in the canvas renderer. Fix #3710 (thanks @saqsun)
1212

1313
## Version 3.9.0 - Yui - 24th May 2018
1414

src/gameobjects/rendertexture/RenderTextureCanvas.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ var RenderTextureCanvas = {
88

99
this.context.fillStyle = 'rgb(' + ur + ',' + ug + ',' + ub + ')';
1010
this.context.fillRect(0, 0, this.canvas.width, this.canvas.height);
11+
1112
return this;
1213
},
1314

@@ -17,17 +18,21 @@ var RenderTextureCanvas = {
1718
this.context.setTransform(1, 0, 0, 1, 0, 0);
1819
this.context.clearRect(0, 0, this.canvas.width, this.canvas.height);
1920
this.context.restore();
21+
2022
return this;
2123
},
2224

2325
draw: function (texture, frame, x, y)
2426
{
27+
var cd = frame.canvasData;
28+
var source = frame.source.image;
29+
2530
var matrix = this.currentMatrix;
2631

2732
this.context.globalAlpha = this.globalAlpha;
2833
this.context.setTransform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
29-
this.context.drawImage(texture.source[frame.sourceIndex].image, frame.cutX, frame.cutY, frame.cutWidth, frame.cutHeight, x, y, frame.cutWidth, frame.cutWidth);
30-
34+
this.context.drawImage(source, cd.sx, cd.sy, cd.sWidth, cd.sHeight, x, y, cd.dWidth, cd.dHeight);
35+
3136
return this;
3237
}
3338

0 commit comments

Comments
 (0)