Home  >  Article  >  Web Front-end  >  How to use html canvas tag

How to use html canvas tag

藏色散人
藏色散人Original
2019-05-26 09:15:252984browse

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>

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!

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