canvas圆环进度条倒计时效果代码
代码语言:html
所属分类:进度条
代码描述:canvas圆环进度条倒计时效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <style> body{background:#2e3032}canvas{display:block;margin:20px auto} </style> </head> <body> <canvas id="mycanvas" width="250" height="250"></canvas> <script> (function drawCanvas() { var b = document.getElementById("mycanvas"); var f = b.getContext("2d"); var g = b.width; var c = b.height; var e = 90; var j = Math.floor(e / 60); var k = e - (j * 60); var d = 0; var a = 270; var i = 360 / e; function h() { f.fillStyle = "#2e3032"; f.fillRect(0, 0, g, c); f.beginPath(); f.strokeStyle = "#252424"; f.lineWidth = 14; f.arc(g / 2, c / 2, 100, (Math.PI / 180) * 0, (Math.PI / 180) * 360, false); f.stroke(); f.closePath(); f.beginPath(); f.strokeStyle = "#df8209"; f.lineWidth = 14; f.arc(g / 2, c / 2, 100, (Math.PI / 180) * 270, (Math.PI / 180) * a, false); f.stroke(); f.closePath(); grad = f.createRadialGradient(g / 2, c / 2, 80, g / 2, c / 2, 115); grad.addColorStop(0, "rgba(0,0,0,.4)"); grad.addColorStop(0.5, "rgba(0,0,0,0)"); grad.addColorStop(1, "rgba(0,0,0,0.4)"); f.beginPath(); f.strokeStyle = grad; f.lineWidth = 14; f.arc(g / 2, c / 2, 100, (Math.PI / 180) * 0, (Math.PI / 180) * 360, false); f.stroke(); f.closePath(); grad = f.createLinearGradient(g / 2, 0, g / 2, c); grad.addColorStop(0, "#6c6f72"); grad.addColorStop(0.5, "#252424"); f.beginPath(); f.strokeStyle = g.........完整代码请登录后点击上方下载按钮下载查看
网友评论0