canvas圓環百分比載入效果程式碼例項
分享一段程式碼例項,它實現了圓環百分比載入效果。
程式碼例項如下:
[HTML] 純文字檢視 複製程式碼<!doctype html> <html> <head> <meta charset="utf-8"> <meta name="author" content="http://www.softwhy.com/" /> <title>螞蟻部落</title> <style type="text/css"> canvas { border: 3px solid transparent; margin: 0 auto; display: block; } </style> <script type="text/javascript"> window.onload=function(){ var canvas = document.getElementById("myCanvas"); var canvasObj = canvas.getContext("2d"); var deg = 90; function draw() { canvasObj.clearRect(0, 0, canvas.width, canvas.height); deg++; canvasObj.beginPath(); canvasObj.arc(300, 300, 200, 0, Math.PI * 2, false); canvasObj.fillStyle = "#ddd"; canvasObj.fill(); canvasObj.beginPath(); canvasObj.arc(300, 300, 150, 0, Math.PI * 2, false); canvasObj.shadowBlur = 10; canvasObj.shadowColor = "black"; canvasObj.fillStyle = "#eee"; canvasObj.fill(); canvasObj.beginPath(); canvasObj.arc(300, 300, 160, -Math.PI / 180 * 90, (-Math.PI / 180 * deg), true); canvasObj.lineWidth = 20; var linearG = canvasObj.createLinearGradient(300, 120, 300, 470); linearG.addColorStop(0, "deepskyblue"); linearG.addColorStop(1, "purple"); canvasObj.strokeStyle = linearG; canvasObj.stroke(); canvasObj.textAlign = "center"; canvasObj.fillStyle = "greenyellow"; canvasObj.font = "80px serif"; var str = Math.floor((deg - 90) / 360 * 100) + "%"; canvasObj.fillText(str, 300, 320); if (deg == 450) { clearInterval(timer); } } var timer = setInterval(draw, 20); } </script> </head> <body> <canvas id="myCanvas" width="600" height="600"></canvas> </body> </html>
相關文章
- canvas繪製圓環效果程式碼例項Canvas
- js實現圓環百分比載入等待效果程式碼例項JS
- canvas載入效果程式碼例項Canvas
- canvas火焰效果程式碼例項Canvas
- canvas字母雨效果程式碼例項Canvas
- canvas擺動效果程式碼例項Canvas
- canvas水位進度效果程式碼例項Canvas
- canvas原型鐘錶效果程式碼例項Canvas原型
- canvas氣泡上浮效果程式碼例項Canvas
- canvas田字格效果程式碼例項Canvas
- canvas螞蟻線效果程式碼例項Canvas
- canvas模擬彈幕效果程式碼例項Canvas
- canvas繪製箭頭效果程式碼例項Canvas
- canvas繪製夜空小屋效果程式碼例項Canvas
- canvas流星劃過星空效果程式碼例項Canvas
- canvas繪製鐘錶效果程式碼例項Canvas
- canvas繪製橢圓效果程式碼例項Canvas
- canvas實現的驗證碼效果程式碼例項Canvas
- canvas繪製魚吃豆效果程式碼例項Canvas
- canvas實現煙花燃放效果程式碼例項Canvas
- canvas繪製雪花飄落效果程式碼例項Canvas
- canvas實現的鋸齒效果程式碼例項Canvas
- canvas實現的鐘表效果程式碼例項Canvas
- javascript百分比進度條效果程式碼例項JavaScript
- canvas立體效果的圓環Canvas
- 利用canvas實現的驗證碼效果程式碼例項Canvas
- canvas實現的雪花飄落效果程式碼例項Canvas
- canvas實現的藍色雨滴效果程式碼例項Canvas
- canvas實現的彈力小球效果程式碼例項Canvas
- canvas刮刮樂程式碼例項Canvas
- canvas實現的七巧板效果程式碼例項Canvas
- canvas實現的動態心形效果程式碼例項Canvas
- canvas實現的圓形鐘錶效果程式碼例項Canvas
- canvas實現的簡單畫板效果程式碼例項Canvas
- canvas實現文字線性漸變效果程式碼例項Canvas
- 密碼框輸入提示效果程式碼例項密碼
- input密碼輸入提示效果程式碼例項密碼
- canvas畫圖程式碼例項Canvas