Getting started explaining HTML5 's canvas features (1)

Source: Internet
Author: User

Personally, the canvas function in HTML5 is not practical, of course, the trend is in the case of flash does not decline. Through learning I found that the canvas function can achieve something very emotional, but the front-end staff must have a certain aesthetic and ideas to make interesting things, because the canvas can provide too few things.

Of course, under the premise that Apple resists flash, the foreground of Flash is not bright, which also gives us the front-end personnel more burdens and opportunities. Because in this piece of UI there is no familiarity with our HTML5. Here is a summary of my study after HTML5.

First part

First of all, although the HTML5 of the content, but because the canvas itself is not drawing capabilities, so all our drawing work is done in Java scrip. (Big Liar!!!) Your first step is to create a canvas in the body, with a CSS style that specifies a wide height and, of course, a better view if you can center it. The specific code is as follows

<canvas id= "MyCanvas" width= "height=" ></canvas>
This is the equivalent of you in the current HTML document in a blank sheet of paper, you give the width of how much, this "piece" of how big.
Second part
Secondly, I have said before the canvas this label itself is not drawing ability, need to borrow Java scrip power. So the second step is to write the JS code. Here's a simple red rectangle for you to draw. The code is as follows

</script>
It is important to note that although Var has two objects, it still needs to be written in specification. Can not use a simple ABC to replace, as far as possible to see the name of understanding, convenient for later development and memory.

Getting started explaining HTML5 's canvas features (1)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.