Html5 using canvas to draw hollow circles and solid circles _ html5 tutorial skills-

Source: Internet
Author: User
This article mainly introduces the use of canvas to draw hollow circles and solid circles in html5, if you need it, you can refer to the exercises for drawing hollow circles and solid circles when learning canvas, which is very simple.




The Code is as follows:


Var canvas = document. getElementById ("canvas ");
Var cxt = canvas. getContext ("2d ");
// Draw a hollow circle
Cxt. beginPath ();
Cxt. arc (200,200, 50, 0, 360, false );
Cxt. lineWidth = 5;
Cxt. strokeStyle = "green ";
Cxt. stroke (); // draw a hollow circle
Cxt. closePath ();
// Draw a solid circle
Cxt. beginPath ();
Cxt. arc (200,100, 50, 0, 360, false );
Cxt. fillStyle = "red"; // fill color, black by default
Cxt. fill (); // draw a solid circle
Cxt. closePath ();
// A combination of hollow and solid
Cxt. beginPath ();
Cxt. arc (300,300, 50, 0, 360, false );
Cxt. fillStyle = "red ";
Cxt. fill ();
Cxt. strokeStyle = "green ";
Cxt. stroke ();
Cxt. closePath ();

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.