HTML 5 Canvas

Source: Internet
Author: User

Lines:
Context.moveto (40, 40); Move the pen to (Context.lineto) (340, 40); Use stroke line to (340, max) Context.stroke (); Let's paint the lines.

Path: The line can also be ticked out, in addition to drawing a line. What is the path? A coil tool similar to Photoshop. In the canvas, you can use the Beginpath and Closepath two methods to build a path,

1. Draw three lines

Context.moveto (40, 40); Move the pen to (Context.lineto) (340, 40); Use stroke line to (340, Context.lineto) (340, 100); Use stroke line to (340, Context.lineto) (40, 100); Use stroke line to (+) Context.stroke (); Let the lines show up

2. Mark the end of the path before drawing the line. The path will be closed:

Context.beginpath (); Start path Context.moveto (340, 40); Use stroke line to (340, Context.lineto) (340, 100); Use stroke line to (340, Context.lineto) (40, 100); Use stroke line to (+) Context.closepath (); End Path Context.stroke (); Let the lines show up

3. Fill the path to delimit the area.

Context.beginpath (); Start path Context.moveto (340, 40); Use stroke line to (340, Context.lineto) (340, 100); Use stroke line to (340, Context.lineto) (40, 100); Use stroke line to (+) Context.closepath (); End Path Context.fill (); Let the lines show up
Rectangular

The painting rectangle has two methods for sketching rectangles and filling rectangles.

Context.strokerect (x, y, width, height); Just outline the bounding rectangle of the frame context.fillrect (x, y, width, height); Draw a rectangle and fill the rectangular area with color
Circular

The circle is different from the rectangle, and there is no method for sketching and filling. A circular path can be drawn through the arc circle, which is then sketched and filled by the stroke and fill methods mentioned earlier.

Context.arc (x, y, radius, startangle, Endangle, anticlockwise);
Circular

The circle is different from the rectangle, and there is no method for sketching and filling. A circular path can be drawn through the arc circle, which is then sketched and filled by the stroke and fill methods mentioned earlier.

Context.arc (x, y, radius, startangle, Endangle, anticlockwise);
There are a total of 6 parameters. X is the center of the horizontal axis, Y is the center of the ordinate, radius radius, startangle is the angle of the beginning of the circle, Endangle is the angle of the end of the circle, Anticlockwise is the direction of the circle.



HTML 5 Canvas

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.