How to flip images horizontally with HTML5

前端 未结 7 1193
暖寄归人
暖寄归人 2020-11-28 07:14

In IE, I can use:


to implement an image flip horizontally.

7条回答
  •  我在风中等你
    2020-11-28 08:10

    canvas = document.createElement('canvas');
    canvasContext = canvas.getContext('2d');
    
    canvasContext.translate(width, 0);
    canvasContext.scale(-1, 1);
    this.canvasContext.drawImage(image, 0, 0);
    

    Here's a snippet from a sprite object being used for testing and it produces the results you seem to expect.

    Here's another site with more details. http://andrew.hedges.name/widgets/dev/

提交回复
热议问题