Home > Web Front-end > H5 Tutorial > body text

HTML5 uses canvas to draw hollow circles and solid circles_html5 tutorial skills

WBOY
Release: 2016-05-16 15:47:15
Original
2234 people have browsed it

What I share with you here is an exercise on drawing hollow circles and solid circles that I did when I was learning canvas. It is very simple.




Copy code
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, the default is black
cxt.fill();// Draw a solid circle
cxt.closePath();
//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();
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!