Today we are going to learn Canvas, the most eye-catching label in HTML5. I believe many people are learning HTML5 for Canvas. This section describes how to use Canvas labels. Before learning it, let's add a little bit of knowledge, although it's a little theoretical ,...,. Today we are going to learn Canvas, the most eye-catching label in HTML5. I believe many people are learning HTML5 for Canvas. This section describes how to use Canvas labels.
Before learning it, let's add a little bit of knowledge. Although it's a little theoretical, the following things are useful.
Basic knowledge of Canvas labels:
Canvas is a newly added important element in html5. it is used to draw images. Placing a canvas element on a page is equivalent to placing a "canvas" on the page. If you have done Flash, you can understand it as "stage" in Flash ", we can describe it here.
It must be noted that we do not draw on the canvas with the mouse. In fact, the canvas element is only a colorless and transparent area (just like a p with only the width and height without background). You need to use JavaScript to write scripts to draw in it.
Q:Some HTML5 websites are also canvas. Why can I draw images with the mouse over it?
A:This is because the JS script captures the mouse path for painting. It is not really the mouse for painting, but visually it is the mouse for painting. Even from the perspective of programming, we can't say that the mouse is painting, but the mouse path and Action captured, and the program is painting.
Place a canvas label on the page
Generally, a basic canvas consists of the property id, width, and height. The Code is as follows: