Home
Web Front-end
H5 Tutorial
HTML5 uses canvas to draw hollow circles and solid circles_html5 tutorial skills



HTML5 uses canvas to draw hollow circles and solid circles_html5 tutorial skills
May 16, 2016 pm 03:47 PM
canvas
html5
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.
<canvas id="canvas" width="500" height="500" style="background-color: yellow;"></canvas>
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();
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

Hot Article
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD

Hot tools Tags

Hot Article
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)
