Skip to content

Commit 69376bf

Browse files
committed
Working through canvas flip origin bug.
1 parent 8bd0aff commit 69376bf

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

v3/src/renderer/canvas/utils/DrawImage.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,17 @@ var DrawImage = function (src, camera)
3333
var dy = frame.y - src.displayOriginY;
3434

3535
ctx.save();
36-
ctx.translate(src.x - camera.scrollX, src.y - camera.scrollY);
36+
ctx.translate(src.x - camera.scrollX * src.scrollFactorX, src.y - camera.scrollY * src.scrollFactorY);
3737
ctx.rotate(src.rotation);
3838
ctx.scale(src.scaleX, src.scaleY);
3939
ctx.scale(src.flipX ? -1 : 1, src.flipY ? -1 : 1);
40-
ctx.translate(src.dWidth * (src.flipX ? 1 : 0), src.dHeight * (src.flipY ? 1 : 0));
40+
41+
// There is no such property as src.dWidth or src.dHeight, so this call has no effect:
42+
// ctx.translate(src.dWidth * (src.flipX ? 1 : 0), src.dHeight * (src.flipY ? 1 : 0));
43+
44+
// dx -= (src.flipX && src.originX !== 0.5) ? cd.dWidth - (src.originX * cd.dWidth) : 0;
45+
// dy -= (src.flipY && src.originY !== 0.5) ? cd.dHeight - (src.originY * cd.dHeight) : 0;
46+
4147
ctx.drawImage(frame.source.image, cd.sx, cd.sy, cd.sWidth, cd.sHeight, dx, dy, cd.dWidth, cd.dHeight);
4248
ctx.restore();
4349
};

0 commit comments

Comments
 (0)