How to transform the image pattern in JavaScript canvas fillingStyle?
问题 I'm currently developing a 2D graphic library in JavaScript, and now I'm sticking with the background texture transforming problems. I want to set the background texture (property fillStyle ) of a canvas context ( CanvasRenderingContext2D ) to an image ( CanvasPattern ). It's easy to assign an image to the fillStyle . But the only problem is that, the image can't actually be translated, scaled nor skewed. I've looked up MDN, it says there's a prototype called setTransform() . With this API