Home >Web Front-end >H5 Tutorial >HTML5 uses the drawImage() method to draw images_html5 tutorial tips

HTML5 uses the drawImage() method to draw images_html5 tutorial tips

WBOY
WBOYOriginal
2016-05-16 15:47:341996browse

1. Draw an image

Use the drawImage() method to draw an image. The drawing environment provides three different versions of this method.
drawImage(image,x,y): Draw the image at (x,y) in the canvas.
drawImage(image,x,y,width,height): Draw the image at (x,y) in the canvas and scale it to the specified width and height.
drawImage (image, source And draw it at (x,y) in canvas.

2. tag

Before drawing the image, you need to load the image into the browser. Here we just add an tag after the canvas tag.



3. Draw pictures

Copy the code
The code is as follows:





HTML5

< /head>



Tips: Your browser does not support the tag





4. Drawing effect

5. Attached are the original tank materials
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn