您的位置:首页 > Web前端 > JavaScript

JS利用CANVAS 画环形进度条

2016-07-13 12:29 393 查看
<canvas id=”c1″ width=”400″ height=”400″></canvas>

<script>window.onload = function() {
var t = 99;
var oC = document.getElementById('c1');
var oGC = oC.getContext('2d');
var oB = (-90)*Math.PI/180;
var oR = (-25+t)*3.6*Math.PI/180;
function toDraw(){
var x = 200;
var y = 200;
var r = 150;
 
oGC.strokeStyle = '#abcdef';
oGC.lineWidth = '10';
oGC.beginPath();
oGC.arc(x,y,r,oB,oR,false);
oGC.stroke();
oGC.font = "Bold 50px Arial";
oGC.fillStyle = "#ccc"; 
oGC.textAlign = "center";
oGC.fillText(t+'%',x,y+10);
document.getElementById('num').innerHTML=t+'%';
}
toDraw();
}
</script>


效果图:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  javascript