Html5 draws a line using canvas and html5canvas

Source: Internet
Author: User

Html5 draws a line using canvas and html5canvas
This article is a simple application of html5. Using canvas to draw a line is actually an exercise question after you learn canvas. It is very simple to share with you.

The code is too simple.


The Code is as follows:
Var canvas = document. getElementById ("canvas ");
// Set the drawing environment
Var cxt = canvas. getContext ('2d ');
// Enable new approaches
Cxt. beginPath ();
// Set the stroke width
Cxt. lineWidth = 10;
// Set the stroke color
Cxt. strokeStyle = "#00ff00 ";
// Set the stroke position
Cxt. moveTo (20, 20 );
// Set the Moving position
Cxt. lineTo (100,20 );
// Draw a line
Cxt. stroke (); // The line has come out at this time.
// Close the path
Cxt. closePath ();
// The path graph must start with the path and end with the path.

Related Article

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.