HTML5 Canvas Preparation Knowledge

Source: Internet
Author: User

Use canvas for drawing work. Therefore, it is necessary for us to make some description of the terminology in drawing.

First, the canvas

In daily life, if we want to draw, we can find paper, board, canvas and so on tools. In the Web page element, we just need to define a label.

<id= "C" style= "border:1px solid black;" >< P >your browser isn't support. </ P ></ Canvas >

Where canvas is a canvas, and the p in the tag is used for compatibility with the lower version of the browser. If you visit this page to see the contents of the P tag, it means that the browser you are currently using does not support HTML5, but instead sees the rectangle.

Ways to use the canvas:

var c = document.getElementById ("C");

Second, brush

With the canvas on, if we want to doodle, we need a tool like "brushes".

Ways to get a brush using canvas:

var ctx = C.getcontext ("2d");

One of the GetContext methods is to get a pen, but here's a parameter: 2d. The parameter value passed by default. What does that mean? This can be seen as a kind of brush.

Since there is 2d, then there will be 3d? There will be some later, but not now. So let's start with this 2d pen.

Third, rubber

On the canvas, we can use "eraser" if we find that something needs to be removed in some places.

Use canvas to make an eraser:

Ctx.clearrect (X1,Y1,X2,Y2);

Four, coordinates

2d world, is the plane, in a plane to determine a point, requires two values, x-coordinate and y-coordinate. This is a very important basic concept.

The canvas's origin is the upper-left corner, which is consistent with the location of the Web page.

Five, path

Use coordinate points to line up. From the line into the face

HTML5 Canvas Preparation Knowledge

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.