Getting started explaining HTML5 's canvas features (2)

Source: Internet
Author: User

Before we mentioned the red rectangles drawn in the JS code, we now use the code to see what it means. The code is as follows


Varcontext=c.getcontext ("2d");

Context.fillstyle= "#FF0000";

Context. FillRect (0,0,150,75);
</script>

in fact, a slightly stronger understanding of the small partner should be seen, in the first row is to get the canvas object, and the second row of the GetContext ("2d") object is built-in HTML5 object, with a variety of drawing paths, rectangles, circles, Characters and how to add images. It is obvious that we are using the most primitive 2D method here. The third line is the fill color for the drawing, and the format is no different from the normal CSS style. and the Forth line is the internal parameter of the graph, 4 parameters we use (a,b,c,d) to represent each other. Where A, B is the coordinate of the upper left corner of the rectangle in this example, and the c,d is the rectangle's length and width. Some of the specific things can be asked to consult the brochure, thank you.

Getting started explaining HTML5 's canvas features (2)

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.