This article mainly introduces the usage examples of the drawImage() method in HTML5 Canvas API. The drawImage() method is mainly used to scale the image. Or cropping, the article gives the usage of its coordinates and related parameters, friends in need can refer to it
drawImage() is a very critical method, it can introduce images, canvas, Video and scale or crop it.
There are three forms of expression:
Grammar 1
context.drawImage(img,dx,dy);
Copy after login
Grammar 2
context.drawImage(img,dx,dy,dw,dw);
Copy after login
Grammar 3
##JavaScript CodeCopy content to clipboard
context.drawImage(img,sx,sy,sw,sh,dx,dy,dw,dh);
Copy after login
Let’s take a look at the coordinate sketch:
PS : Do not define the width and height of