Home > Web Front-end > Front-end Q&A > How to use html canvas tag

How to use html canvas tag

藏色散人
Release: 2019-05-26 09:15:25
Original
3016 people have browsed it

html The canvas tag is used to define graphics, such as charts and other images. The tag is just a graphics container, which is done through scripts (usually JavaScript). You can use canvas to draw paths, boxes, circles, characters, and add images. .

How to use html canvas tag

What does canvas mean? How to use html canvas tag?

Function: Define graphics, such as charts and other images.

Description:

The label is just a graphics container, which is done through scripts (usually JavaScript). You can use canvas to draw paths, boxes, circles, and characters. As well as adding images.

Note:

The tag is a new tag in HTML 5. Internet Explorer 8 and earlier does not support the tag.

html canvas tag example

<!DOCTYPE HTML>
<html>
<body>
<canvas id="myCanvas">your browser does not support the canvas tag </canvas>
<script type="text/javascript">
var canvas=document.getElementById(&#39;myCanvas&#39;);
var ctx=canvas.getContext(&#39;2d&#39;);
ctx.fillStyle=&#39;#FF0000&#39;;
ctx.fillRect(0,0,80,100);
</script>
</body>
</html>
Copy after login

Effect:

How to use html canvas tag

The above is the detailed content of How to use html canvas tag. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template